file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
tests.rs
use super::mmtree; use super::mixer; use traits::*; use params::*; use synth::Synth; use efx::Efx; use efx::volume::{Volume, VolumeParams}; #[test] fn create_tree() { let mut t = mmtree::MMTree::new(); // always them root mixer assert_eq!(t.mixer_count(), 1); // structure. t.add_mixer("root", "m...
{ nb_samples: usize, tic: usize, } impl Parametrized for ShittyEnvelope {} impl ShittyEnvelope { fn new() -> ShittyEnvelope { ShittyEnvelope { nb_samples: 3, tic: 0, } } } impl Efx for ShittyEnvelope { fn sample(&mut self, sample: SampleValue) -> SoundSamp...
ShittyEnvelope
identifier_name
server.rs
#![allow(unstable)] extern crate hyper; extern crate test; use test::Bencher; use std::old_io::net::ip::Ipv4Addr; use hyper::method::Method::Get; use hyper::server::{Request, Response}; static PHRASE: &'static [u8] = b"Benchmarking hyper vs others!"; fn request(url: hyper::Url) { let req = hyper::client::Reques...
#[bench] fn bench_hyper(b: &mut Bencher) { let server = hyper::Server::http(Ipv4Addr(127, 0, 0, 1), 0); let mut listener = server.listen(hyper_handle).unwrap(); let url = hyper::Url::parse(format!("http://{}", listener.socket).as_slice()).unwrap(); b.iter(|| request(url.clone())); listener.close(...
{ let mut res = res.start().unwrap(); res.write_all(PHRASE).unwrap(); res.end().unwrap(); }
identifier_body
server.rs
#![allow(unstable)] extern crate hyper; extern crate test; use test::Bencher; use std::old_io::net::ip::Ipv4Addr; use hyper::method::Method::Get; use hyper::server::{Request, Response}; static PHRASE: &'static [u8] = b"Benchmarking hyper vs others!"; fn request(url: hyper::Url) { let req = hyper::client::Reques...
(_: Request, res: Response) { let mut res = res.start().unwrap(); res.write_all(PHRASE).unwrap(); res.end().unwrap(); } #[bench] fn bench_hyper(b: &mut Bencher) { let server = hyper::Server::http(Ipv4Addr(127, 0, 0, 1), 0); let mut listener = server.listen(hyper_handle).unwrap(); let url = hyp...
hyper_handle
identifier_name
server.rs
#![allow(unstable)] extern crate hyper; extern crate test; use test::Bencher; use std::old_io::net::ip::Ipv4Addr; use hyper::method::Method::Get; use hyper::server::{Request, Response}; static PHRASE: &'static [u8] = b"Benchmarking hyper vs others!";
fn request(url: hyper::Url) { let req = hyper::client::Request::new(Get, url).unwrap(); req.start().unwrap().send().unwrap().read_to_string().unwrap(); } fn hyper_handle(_: Request, res: Response) { let mut res = res.start().unwrap(); res.write_all(PHRASE).unwrap(); res.end().unwrap(); } #[bench] ...
random_line_split
share.rs
use std::collections::{HashMap, HashSet};
use merkle_sigs::{MerklePublicKey, Proof}; use errors::*; use share::{IsShare, IsSignedShare}; use sss::format::{format_share_for_signing, share_from_string, share_to_string}; /// A share identified by an `id`, a threshold `k`, a number of total shares `n`, /// the `data` held in the share, and the share's `metadata`...
use std::error::Error; use merkle_sigs::verify_data_vec_signature;
random_line_split
share.rs
use std::collections::{HashMap, HashSet}; use std::error::Error; use merkle_sigs::verify_data_vec_signature; use merkle_sigs::{MerklePublicKey, Proof}; use errors::*; use share::{IsShare, IsSignedShare}; use sss::format::{format_share_for_signing, share_from_string, share_to_string}; /// A share identified by an `id...
(raws: &[String], is_signed: bool) -> Result<Vec<Share>> { raws.into_iter() .map(|raw| Self::from_string(raw, is_signed)) .collect() } /// Format the share as a string suitable for being stored in a file. /// The format is the following: /// /// ```text /// 2-1-LiT...
parse_all
identifier_name
share.rs
use std::collections::{HashMap, HashSet}; use std::error::Error; use merkle_sigs::verify_data_vec_signature; use merkle_sigs::{MerklePublicKey, Proof}; use errors::*; use share::{IsShare, IsSignedShare}; use sss::format::{format_share_for_signing, share_from_string, share_to_string}; /// A share identified by an `id...
.entry(root_hash) .or_insert_with(HashSet::new); let rh_set = rh_compatibility_sets.get_mut(&root_hash).unwrap(); rh_set.insert(share.id); } let rh_sets = rh_compatibility_sets.keys().count(); match rh_sets { 0 => bail!(ErrorKi...
{ let mut rh_compatibility_sets = HashMap::new(); for share in shares { if !share.is_signed() { bail!(ErrorKind::MissingSignature(share.get_id())); } let sig_pair = share.signature_pair.as_ref().unwrap(); let signature = &sig_pair.signatu...
identifier_body
share.rs
use std::collections::{HashMap, HashSet}; use std::error::Error; use merkle_sigs::verify_data_vec_signature; use merkle_sigs::{MerklePublicKey, Proof}; use errors::*; use share::{IsShare, IsSignedShare}; use sss::format::{format_share_for_signing, share_from_string, share_to_string}; /// A share identified by an `id...
} Ok(()) } fn is_signed(&self) -> bool { self.signature_pair.is_some() } fn get_signature(&self) -> &Self::Signature { &self.signature_pair } } #[derive(Clone, Debug)] /// Holds the signature along with the proof of inclusion /// in the underlying Merkle tree use...
{ bail! { ErrorKind::IncompatibleSets( rh_compatibility_sets .values() .map(|x| x.to_owned()) .collect(), ) } }
conditional_block
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::CharacterDataBinding::Chara...
}
{ if let Some(ref s) = self.super_type() { s.unbind_from_tree(tree_in_doc); } let node = NodeCast::from_ref(*self); if node.GetParentNode().is_some() { node.check_parent_disabled_state_for_option(); } else { node.check_disabled_attribute(); ...
identifier_body
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::CharacterDataBinding::Chara...
// https://html.spec.whatwg.org/multipage/#attr-option-value fn Value(self) -> DOMString { let element = ElementCast::from_ref(self); let attr = &atom!("value"); if element.has_attribute(attr) { element.get_string_attribute(attr) } else { self.Text() ...
// https://www.whatwg.org/html/#dom-option-text fn SetText(self, value: DOMString) { let node = NodeCast::from_ref(self); node.SetTextContent(Some(value)) }
random_line_split
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::CharacterDataBinding::Chara...
, _ => () } } fn before_remove_attr(&self, attr: &Attr) { if let Some(ref s) = self.super_type() { s.before_remove_attr(attr); } match attr.local_name() { &atom!("disabled") => { let node = NodeCast::from_ref(*self); ...
{ let node = NodeCast::from_ref(*self); node.set_disabled_state(true); node.set_enabled_state(false); }
conditional_block
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::CharacterDataBinding::Chara...
(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> Root<HTMLOptionElement> { let element = HTMLOptionElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLOptionElementBinding::Wrap) } } fn collect_tex...
new
identifier_name
build.rs
use std::env; use std::io::Write; const CFG_KEY: &'static str = "py_sys_config"; #[cfg(feature="python27-sys")] const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON27_PYTHON_FLAGS"; #[cfg(feature="python3-sys")] const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON3_PYTHON_FLAGS"; fn
() { // python{27,3.x}-sys/build.rs passes python interpreter compile flags via // environment variable (using the 'links' mechanism in the cargo.toml). let flags = match env::var(PYTHONSYS_ENV_VAR) { Ok(flags) => flags, Err(_) => { writeln!(std::io::stderr(), "E...
main
identifier_name
build.rs
use std::env; use std::io::Write; const CFG_KEY: &'static str = "py_sys_config"; #[cfg(feature="python27-sys")] const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON27_PYTHON_FLAGS"; #[cfg(feature="python3-sys")] const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON3_PYTHON_FLAGS"; fn main()
let val = key_and_val[1]; if key.starts_with("FLAG") { println!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, &key[5..]) } else { println!("cargo:rustc-cfg={}=\"{}_{}\"", CFG_KEY, &key[4..], val); } } } }
{ // python{27,3.x}-sys/build.rs passes python interpreter compile flags via // environment variable (using the 'links' mechanism in the cargo.toml). let flags = match env::var(PYTHONSYS_ENV_VAR) { Ok(flags) => flags, Err(_) => { writeln!(std::io::stderr(), "Envi...
identifier_body
build.rs
use std::env; use std::io::Write; const CFG_KEY: &'static str = "py_sys_config";
const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON3_PYTHON_FLAGS"; fn main() { // python{27,3.x}-sys/build.rs passes python interpreter compile flags via // environment variable (using the 'links' mechanism in the cargo.toml). let flags = match env::var(PYTHONSYS_ENV_VAR) { Ok(flags) => flags, ...
#[cfg(feature="python27-sys")] const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON27_PYTHON_FLAGS"; #[cfg(feature="python3-sys")]
random_line_split
build.rs
use std::env; use std::io::Write; const CFG_KEY: &'static str = "py_sys_config"; #[cfg(feature="python27-sys")] const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON27_PYTHON_FLAGS"; #[cfg(feature="python3-sys")] const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON3_PYTHON_FLAGS"; fn main() { // python{27,3.x}-sys...
} } }
{ println!("cargo:rustc-cfg={}=\"{}_{}\"", CFG_KEY, &key[4..], val); }
conditional_block
hex.rs
extern crate "rustc-serialize" as serialize; pub fn hex_to_ascii(text_hex: &str) -> Result<String, String> { use self::serialize::hex::{FromHex, ToHex}; use std::string::FromUtf8Error; let utf8 : Vec<u8>; match text_hex.from_hex() { Ok(vec) => utf8 = vec, Err(e) => return Err(format!...
{ use self::serialize::hex::ToHex; use std::iter::repeat; let xor_bytes : Vec<u8> = repeat(byte).take(text_hex.len()/2).collect(); xor(&xor_bytes[..].to_hex()[..], text_hex) }
identifier_body
hex.rs
extern crate "rustc-serialize" as serialize; pub fn hex_to_ascii(text_hex: &str) -> Result<String, String> { use self::serialize::hex::{FromHex, ToHex}; use std::string::FromUtf8Error; let utf8 : Vec<u8>; match text_hex.from_hex() { Ok(vec) => utf8 = vec, Err(e) => return Err(format!...
(a_hex: &str, b_hex: &str) -> Result<String, String> { use self::serialize::hex::{FromHex, ToHex}; if a_hex.len()!=b_hex.len() {return Err("Lengths not equal".to_string());} let a_bytes : Vec<u8>; let b_bytes : Vec<u8>; match a_hex.from_hex() { Ok(bytes) => a_bytes = bytes, Err(_) ...
xor
identifier_name
hex.rs
extern crate "rustc-serialize" as serialize; pub fn hex_to_ascii(text_hex: &str) -> Result<String, String> { use self::serialize::hex::{FromHex, ToHex}; use std::string::FromUtf8Error; let utf8 : Vec<u8>; match text_hex.from_hex() { Ok(vec) => utf8 = vec,
} match String::from_utf8(utf8) { Ok(s) => Ok(s), Err(e) => Err(format!("{}", e.utf8_error())), } } pub fn xor(a_hex: &str, b_hex: &str) -> Result<String, String> { use self::serialize::hex::{FromHex, ToHex}; if a_hex.len()!=b_hex.len() {return Err("Lengths not equal".to_string());...
Err(e) => return Err(format!("{}", e)),
random_line_split
htmltablecaptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding; use dom::bindings::js::Root; use dom::bindin...
{ htmlelement: HTMLElement } impl HTMLTableCaptionElement { fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLTableCaptionElement { HTMLTableCaptionElement { htmlelement: HTMLElement::new_inher...
HTMLTableCaptionElement
identifier_name
htmltablecaptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding; use dom::bindings::js::Root; use dom::bindin...
use dom::node::Node; use string_cache::Atom; #[dom_struct] pub struct HTMLTableCaptionElement { htmlelement: HTMLElement } impl HTMLTableCaptionElement { fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLTableCaptionElement { ...
use dom::document::Document; use dom::htmlelement::HTMLElement;
random_line_split
metrics.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyDirectory, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::inode; use fs::item; use fs::items::project::project_from_inode; use fs::not_implemeted; use helpers; use object; use std::path::Path; fn getattr(fs: &mut GoodDataFS, req: &Request, ino: u6...
info!("Adding inode {:?}, name {:?}", inode, &name); offset += 1; } } reply.ok(); } pub const ITEM: item::ProjectItem = item::ProjectItem { category: constants::Category::MetadataMetrics as u8, reserved: constants::ReservedFile::KeepMe as u8, item_type: FileType::...
{ let inode = inode::Inode::deserialize(ino); let project: &object::Project = &project_from_inode(fs, ino); let report_items = project.metrics(&mut fs.client.connector, true); let mut offset = in_offset; if offset + 1 < report_items.objects.items.len() as u64 { for item in report_items.obje...
identifier_body
metrics.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyDirectory, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::inode; use fs::item; use fs::items::project::project_from_inode; use fs::not_implemeted; use helpers; use object; use std::path::Path; fn getattr(fs: &mut GoodDataFS, req: &Request, ino: u6...
reply.ok(); } pub const ITEM: item::ProjectItem = item::ProjectItem { category: constants::Category::MetadataMetrics as u8, reserved: constants::ReservedFile::KeepMe as u8, item_type: FileType::Directory, path: object::metric::NAME, getattr: getattr, lookup: lookup, read: not_impleme...
{ for item in report_items.objects.items.into_iter().skip(offset as usize) { let name = format!("{}.json", item.metric.meta.identifier.unwrap()); // Reports let inode = inode::Inode { project: inode.project, category: ITEM.category, ...
conditional_block
metrics.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyDirectory, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::inode; use fs::item; use fs::items::project::project_from_inode; use fs::not_implemeted; use helpers; use object; use std::path::Path; fn getattr(fs: &mut GoodDataFS, req: &Request, ino: u6...
getattr: getattr, lookup: lookup, read: not_implemeted::read, };
path: object::metric::NAME,
random_line_split
metrics.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyDirectory, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::inode; use fs::item; use fs::items::project::project_from_inode; use fs::not_implemeted; use helpers; use object; use std::path::Path; fn
(fs: &mut GoodDataFS, req: &Request, ino: u64, reply: ReplyAttr) { super::helpers::getattr(fs, req, ino, reply) } fn lookup(fs: &mut GoodDataFS, req: &Request, parent: u64, name: &Path, reply: ReplyEntry) { super::helpers::lookup(fs, req, parent, name, reply, &ITEM) } pub fn read(fs: &mut GoodDataFS, inode: i...
getattr
identifier_name
location.rs
use header::{Header, HeaderFormat}; use std::fmt::{self, Show}; use header::shared::util::from_one_raw_str; /// The `Location` header. /// /// The Location response-header field is used to redirect the recipient to /// a location other than the Request-URI for completion of the request or identification /// of a new r...
(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let Location(ref value) = *self; value.fmt(fmt) } } bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] });
fmt_header
identifier_name
location.rs
use header::{Header, HeaderFormat}; use std::fmt::{self, Show}; use header::shared::util::from_one_raw_str; /// The `Location` header. /// /// The Location response-header field is used to redirect the recipient to /// a location other than the Request-URI for completion of the request or identification /// of a new r...
} impl HeaderFormat for Location { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let Location(ref value) = *self; value.fmt(fmt) } } bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] });
{ from_one_raw_str(raw).map(|s| Location(s)) }
identifier_body
blockdev.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::cell::RefCell; use std::path::{Path, PathBuf}; use std::rc::Rc; use chrono::{DateTime, TimeZone, Utc}; use ...
{ devnode: PathBuf, rdm: Rc<RefCell<Randomizer>>, user_info: Option<String>, hardware_info: Option<String>, initialization_time: u64, dbus_path: MaybeDbusPath, } impl BlockDev for SimDev { fn devnode(&self) -> PathBuf { self.devnode.clone() } fn user_info(&self) -> Option<...
SimDev
identifier_name
blockdev.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::cell::RefCell; use std::path::{Path, PathBuf}; use std::rc::Rc; use chrono::{DateTime, TimeZone, Utc}; use ...
fn set_dbus_path(&mut self, path: MaybeDbusPath) { self.dbus_path = path } fn get_dbus_path(&self) -> &MaybeDbusPath { &self.dbus_path } } impl SimDev { /// Generates a new device from any devnode. pub fn new(rdm: Rc<RefCell<Randomizer>>, devnode: &Path) -> (Uuid, SimDev) { ...
{ BlockDevState::InUse }
identifier_body
blockdev.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::cell::RefCell; use std::path::{Path, PathBuf}; use std::rc::Rc; use chrono::{DateTime, TimeZone, Utc}; use ...
self.dbus_path = path } fn get_dbus_path(&self) -> &MaybeDbusPath { &self.dbus_path } } impl SimDev { /// Generates a new device from any devnode. pub fn new(rdm: Rc<RefCell<Randomizer>>, devnode: &Path) -> (Uuid, SimDev) { ( Uuid::new_v4(), SimDev {...
fn set_dbus_path(&mut self, path: MaybeDbusPath) {
random_line_split
compositor_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::{self, CompositingReason}; u...
CreatePng(IpcSender<Option<Image>>), /// Informs the compositor that the paint thread for the given pipeline has exited. PaintThreadExited(PipelineId), /// Alerts the compositor that the viewport has been constrained in some manner ViewportConstrained(PipelineId, ViewportConstraints), /// A repl...
TouchEventProcessed(EventResult), /// Changes the cursor. SetCursor(Cursor), /// Composite to a PNG file and return the Image over a passed channel.
random_line_split
compositor_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::{self, CompositingReason}; u...
ScriptToCompositorMsg::Exited => break, } } } pub trait RenderListener { fn recomposite(&mut self, reason: CompositingReason); } impl RenderListener for Box<CompositorProxy +'static> { fn recomposite(&mut self, reason: CompositingReason) { self.send(Msg::Recomposite(reason));...
{ compositor_proxy.send(Msg::GetScrollOffset(pid, lid, send)); }
conditional_block
compositor_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::{self, CompositingReason}; u...
(&mut self, buffer_requests: Vec<BufferRequest>) { let mut native_surfaces = Vec::new(); for request in buffer_requests.into_iter() { if let Some(native_surface) = request.native_surface { native_surfaces.push(native_surface); } } if!native_surface...
ignore_buffer_requests
identifier_name
auth.rs
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or a...
{ access_token: AccessToken, expires: Instant, } impl BoundedToken { /// Tests whether this token will still be valid at the given instant. fn valid_at(&self, when: Instant) -> bool { when < self.expires } } /// Private access token module to prevent accidental leaking of tokens into logs...
BoundedToken
identifier_name
auth.rs
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or a...
/// Attempts to fetch a fresh access token with these credentials. fn fetch(&self, http: &HttpClient) -> Option<BoundedToken> { match self { Credentials::Anonymous => None, Credentials::RefreshToken(RefreshToken(creds)) => match creds.fetch(http) { Ok(t) => Some...
{ matches!(self, Credentials::Anonymous) }
identifier_body
auth.rs
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or a...
pub enum Credentials { Anonymous, RefreshToken(RefreshToken), } // public wrapper struct to hide private implementation details pub struct RefreshToken(RefreshTokenCreds); impl Default for Credentials { fn default() -> Self { Self::Anonymous } } #[derive(Debug, thiserror::Error)] pub enum Cred...
} /// The user's persistent credentials, if any. This represents all the information needed to /// request access tokens. #[derive(Debug)]
random_line_split
stream.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use interfaces::{cef_read_handler_t, cef_stream_reader_t, cef_stream_writer_t}; use interfaces::{cef_write_handler...
fn cef_stream_writer_create_for_handler(_handler: *mut cef_write_handler_t) -> *mut cef_stream_writer_t; }
-> *mut cef_stream_reader_t; fn cef_stream_writer_create_for_file(_file_name: *const cef_string_t) -> *mut cef_stream_writer_t;
random_line_split
main.rs
extern crate atty; extern crate clap; extern crate handlebars; extern crate serde_json; use clap::App; use handlebars::{Context, Handlebars, Helper, RenderContext, RenderError}; use std::collections::BTreeMap; use std::env; use std::fs::File; use std::io; use std::io::{Read, Write}; use std::process::exit; fn handleb...
fn json(input: Option<&str>, inject_env: bool) -> Option<serde_json::Value> { match input { Some("-") => None, None => Some("{}"), value => value } .map(|i| i.to_owned()) .or_else(|| { if atty::is() { let mut raw = String::new(...
{ match_template.map(|t| t.to_owned()).or(match match_file { Some(bars) => { File::open(bars) .and_then(|mut f| { let mut contents = String::new(); f.read_to_string(&mut contents).map(|_| contents) }) .ok() ...
identifier_body
main.rs
extern crate atty; extern crate clap; extern crate handlebars; extern crate serde_json; use clap::App; use handlebars::{Context, Handlebars, Helper, RenderContext, RenderError}; use std::collections::BTreeMap; use std::env; use std::fs::File; use std::io; use std::io::{Read, Write}; use std::process::exit; fn handleb...
} _ => Some("{{json.}}".to_string()), }) } fn json(input: Option<&str>, inject_env: bool) -> Option<serde_json::Value> { match input { Some("-") => None, None => Some("{}"), value => value } .map(|i| i.to_owned()) .or_else(|| { if ...
}) .ok()
random_line_split
main.rs
extern crate atty; extern crate clap; extern crate handlebars; extern crate serde_json; use clap::App; use handlebars::{Context, Handlebars, Helper, RenderContext, RenderError}; use std::collections::BTreeMap; use std::env; use std::fs::File; use std::io; use std::io::{Read, Write}; use std::process::exit; fn
() -> Handlebars { let mut hbs = Handlebars::new(); fn json_helper(c: &Context, h: &Helper, _: &Handlebars, rc: &mut RenderContext) -> Result<(), RenderError> { let param = h.params().get(0).unwrap(); let val = c.navigat...
handlebars
identifier_name
main.rs
use anyhow::Context;
use tokio::{fs::File, io::AsyncReadExt}; use tracing::{event, instrument, Level}; use tracing_subscriber::EnvFilter; #[derive(FromArgs)] /// A simple site generator :) struct Args { #[argh(switch)] /// forces rebuild force: bool, #[argh(positional)] /// path to config file config_filename: std:...
use argh::FromArgs; use engine::{Config, Processor};
random_line_split
main.rs
use anyhow::Context; use argh::FromArgs; use engine::{Config, Processor}; use tokio::{fs::File, io::AsyncReadExt}; use tracing::{event, instrument, Level}; use tracing_subscriber::EnvFilter; #[derive(FromArgs)] /// A simple site generator :) struct Args { #[argh(switch)] /// forces rebuild force: bool, ...
() -> anyhow::Result<()> { let args = argh::from_env::<Args>(); let format = tracing_subscriber::fmt::format().pretty(); tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) .event_format(format) .init(); event!(Level::INFO, input_filename =?args.config_filena...
main
identifier_name
lib.rs
. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustdoc"] #![unstable(feature = "rustdoc")] #![staged_api] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-l...
pub fn opts() -> Vec<getopts::OptGroup> { use getopts::*; vec!( optflag("h", "help", "show this help message"), optflag("V", "version", "print rustdoc's version"), optflag("v", "verbose", "use verbose output"), optopt("r", "input-format", "the input type of the specified file",...
{ const STACK_SIZE: usize = 32000000; // 32MB let res = std::thread::Builder::new().stack_size(STACK_SIZE).scoped(move || { let s = env::args().collect::<Vec<_>>(); main_args(&s) }).unwrap().join(); env::set_exit_status(res as i32); }
identifier_body
lib.rs
. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustdoc"] #![unstable(feature = "rustdoc")] #![staged_api] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-l...
Err(e) => panic!("failed to generate documentation: {}", e), } } Some("json") => { match json_output(krate, json_plugins, output.unwrap_or(PathBuf::new("doc.json"))) { Ok(()) => {} Err(e) => panic!("fa...
{}
conditional_block
lib.rs
bootstrap. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustdoc"] #![unstable(feature = "rustdoc")] #![staged_api] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://...
} /// Interprets the input file as a rust source file, passing it through the /// compiler all the way through the analysis passes. The rustdoc output is then /// generated from the cleaned AST of the crate. /// /// This form of input will run all of the plug/cleaning passes fn rust_input(cratefile: &str, externs: cor...
} Ok(externs)
random_line_split
lib.rs
. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustdoc"] #![unstable(feature = "rustdoc")] #![staged_api] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-l...
() { const STACK_SIZE: usize = 32000000; // 32MB let res = std::thread::Builder::new().stack_size(STACK_SIZE).scoped(move || { let s = env::args().collect::<Vec<_>>(); main_args(&s) }).unwrap().join(); env::set_exit_status(res as i32); } pub fn opts() -> Vec<getopts::OptGroup> { use...
main
identifier_name
memory.rs
use hal::{ device::{AllocationError, MapError, OutOfMemory}, memory::Segment, MemoryTypeId, }; use std::cell::UnsafeCell; use std::convert::TryInto; /// A memory allocation. #[derive(Debug)] pub struct Memory { /// The type of memory this block was allocated from. memory_type: MemoryTypeId, ///...
}; let memory = Memory { memory_type, size, data: UnsafeCell::new(data), }; Ok(memory) } pub fn map(&self, segment: Segment) -> Result<*mut u8, MapError> { if segment.offset >= self.size { return Err(MapError::OutOfBounds)...
.map_err(|_| AllocationError::OutOfMemory(OutOfMemory::Host))?; vec![0u8; size].into_boxed_slice()
random_line_split
memory.rs
use hal::{ device::{AllocationError, MapError, OutOfMemory}, memory::Segment, MemoryTypeId, }; use std::cell::UnsafeCell; use std::convert::TryInto; /// A memory allocation. #[derive(Debug)] pub struct Memory { /// The type of memory this block was allocated from. memory_type: MemoryTypeId, ///...
} pub fn map(&self, segment: Segment) -> Result<*mut u8, MapError> { if segment.offset >= self.size { return Err(MapError::OutOfBounds); } if let Some(size) = segment.size { if segment.offset + size > self.size { return Err(MapError::OutOfBounds)...
{ assert_eq!(memory_type.0, 0, "We only support one memory type"); // Allocate a buffer in RAM let data = { let size = size .try_into() // If we're on 32-bit and the given size is greater than 2^32, // we certainly can't allocate it. ...
identifier_body
memory.rs
use hal::{ device::{AllocationError, MapError, OutOfMemory}, memory::Segment, MemoryTypeId, }; use std::cell::UnsafeCell; use std::convert::TryInto; /// A memory allocation. #[derive(Debug)] pub struct Memory { /// The type of memory this block was allocated from. memory_type: MemoryTypeId, ///...
} let data = unsafe { &mut *self.data.get() }; Ok(data.as_mut_ptr()) } } unsafe impl Sync for Memory {}
{ return Err(MapError::OutOfBounds); }
conditional_block
memory.rs
use hal::{ device::{AllocationError, MapError, OutOfMemory}, memory::Segment, MemoryTypeId, }; use std::cell::UnsafeCell; use std::convert::TryInto; /// A memory allocation. #[derive(Debug)] pub struct Memory { /// The type of memory this block was allocated from. memory_type: MemoryTypeId, ///...
(memory_type: MemoryTypeId, size: u64) -> Result<Self, AllocationError> { assert_eq!(memory_type.0, 0, "We only support one memory type"); // Allocate a buffer in RAM let data = { let size = size .try_into() // If we're on 32-bit and the given size is ...
allocate
identifier_name
region.rs
use cable_math::Vec2; #[derive(Debug, Clone, Copy, Default, PartialEq)] pub struct Region { pub min: Vec2<f32>, pub max: Vec2<f32>, } impl Region { pub fn center(&self) -> Vec2<f32>
pub fn width(&self) -> f32 { self.max.x - self.min.x } pub fn height(&self) -> f32 { self.max.y - self.min.y } pub fn size(&self) -> Vec2<f32> { self.max - self.min } /// Checks if the given point is inside this region. pub fn contains(&self, p: Vec2<f32>) -> bool { p.x >...
{ (self.min + self.max) / 2.0 }
identifier_body
region.rs
use cable_math::Vec2; #[derive(Debug, Clone, Copy, Default, PartialEq)] pub struct Region { pub min: Vec2<f32>, pub max: Vec2<f32>, } impl Region { pub fn
(&self) -> Vec2<f32> { (self.min + self.max) / 2.0 } pub fn width(&self) -> f32 { self.max.x - self.min.x } pub fn height(&self) -> f32 { self.max.y - self.min.y } pub fn size(&self) -> Vec2<f32> { self.max - self.min } /// Checks if the given point is inside this region. pub fn c...
center
identifier_name
region.rs
use cable_math::Vec2; #[derive(Debug, Clone, Copy, Default, PartialEq)] pub struct Region { pub min: Vec2<f32>, pub max: Vec2<f32>, } impl Region { pub fn center(&self) -> Vec2<f32> { (self.min + self.max) / 2.0 } pub fn width(&self) -> f32 { self.max.x - self.min.x } pub fn height(&self...
return pos; } }
{ pos.y = self.max.y; }
conditional_block
region.rs
use cable_math::Vec2; #[derive(Debug, Clone, Copy, Default, PartialEq)] pub struct Region { pub min: Vec2<f32>, pub max: Vec2<f32>, } impl Region { pub fn center(&self) -> Vec2<f32> { (self.min + self.max) / 2.0 } pub fn width(&self) -> f32 { self.max.x - self.min.x } pub fn height(&self)...
/// Creates a new region with all corners offset by the given amount pub fn offset(self, by: Vec2<f32>) -> Region { Region { min: self.min + by, max: self.max + by, } } /// Returns the region in which this region overlaps the given other region. This might produ...
min: Vec2::new(self.max.x, self.min.y), max: Vec2::new(self.min.x, self.max.y), } }
random_line_split
_4_buffered_serial.rs
//! Serial interface buffered loopback //! //! ``` //! //! #![feature(const_fn)] //! #![feature(used)] //! #![no_std] //! //! // version = "0.2.0" //! extern crate cortex_m_rt; //! //! // version = "0.1.0" //! #[macro_use] //! extern crate cortex_m_rtfm as rtfm; //! //! extern crate bluepill; //! extern crate heapl...
//! USART3: Peripheral { //! register_block: Usart3, //! ceiling: C1, //! }, //! }); //! //! // INITIALIZATION PHASE //! fn init(ref priority: P0, threshold: &TMax) { //! let gpiob = GPIOB.access(priority, threshold); //! let rcc = RCC.access(priority, threshold); //! let usart3 = U...
//! RCC: Peripheral { //! register_block: Rcc, //! ceiling: C0, //! },
random_line_split
client_test.rs
extern crate gauc;
//use gauc::couchbase::types::error_type::ErrorType; //use gauc::couchbase::types::operation::Operation; const DEFAULT_CONNECTION_STRING: &'static str = "couchbase://localhost/default"; #[test] fn it_connects() { if let Ok(client) = Client::connect(DEFAULT_CONNECTION_STRING) { assert_eq!(client.opts.versi...
use gauc::client::*;
random_line_split
client_test.rs
extern crate gauc; use gauc::client::*; //use gauc::couchbase::types::error_type::ErrorType; //use gauc::couchbase::types::operation::Operation; const DEFAULT_CONNECTION_STRING: &'static str = "couchbase://localhost/default"; #[test] fn it_connects() { if let Ok(client) = Client::connect(DEFAULT_CONNECTION_STRIN...
} //#[test] //fn it_stores_document() { // if let Ok(mut client) = Client::connect(DEFAULT_CONNECTION_STRING) { // // Store some data // client.store("foo", "{\"msg\": \"This is test!\"}", Operation::Upsert, 0, 0, |res| { // if let Ok(response) = res { // assert_eq!(response...
{ assert_eq!(client.opts.version(), 3); }
conditional_block
client_test.rs
extern crate gauc; use gauc::client::*; //use gauc::couchbase::types::error_type::ErrorType; //use gauc::couchbase::types::operation::Operation; const DEFAULT_CONNECTION_STRING: &'static str = "couchbase://localhost/default"; #[test] fn it_connects()
//#[test] //fn it_stores_document() { // if let Ok(mut client) = Client::connect(DEFAULT_CONNECTION_STRING) { // // Store some data // client.store("foo", "{\"msg\": \"This is test!\"}", Operation::Upsert, 0, 0, |res| { // if let Ok(response) = res { // assert_eq!(response.r...
{ if let Ok(client) = Client::connect(DEFAULT_CONNECTION_STRING) { assert_eq!(client.opts.version(), 3); } }
identifier_body
client_test.rs
extern crate gauc; use gauc::client::*; //use gauc::couchbase::types::error_type::ErrorType; //use gauc::couchbase::types::operation::Operation; const DEFAULT_CONNECTION_STRING: &'static str = "couchbase://localhost/default"; #[test] fn
() { if let Ok(client) = Client::connect(DEFAULT_CONNECTION_STRING) { assert_eq!(client.opts.version(), 3); } } //#[test] //fn it_stores_document() { // if let Ok(mut client) = Client::connect(DEFAULT_CONNECTION_STRING) { // // Store some data // client.store("foo", "{\"msg\": \"This i...
it_connects
identifier_name
underscore.rs
use std::io::{stdout, stderr}; use argparse::{ArgumentParser}; use argparse::{StoreTrue, List, StoreOption, Store}; use unshare::{Command, Namespace}; use options::build_mode::build_mode; use options::version_hash; use container::nsutil::{set_namespace}; use process_util::{run_and_wait, convert_status}; use super::n...
.add_argument("container", Store, "Container to run command in") .required(); ap.refer(&mut command) .add_argument("command", Store, "Command to run inside the container") .required(); ap.refer(&mut cmdargs) .add_argu...
{ let mut cmdargs = Vec::<String>::new(); let mut container = "".to_string(); let mut command = "".to_string(); let mut copy = false; let mut bmode = context.build_mode; { args.insert(0, "vagga _run".to_string()); let mut ap = ArgumentParser::new(); ap.set_description(" ...
identifier_body
underscore.rs
use std::io::{stdout, stderr}; use argparse::{ArgumentParser}; use argparse::{StoreTrue, List, StoreOption, Store}; use unshare::{Command, Namespace}; use options::build_mode::build_mode; use options::version_hash; use container::nsutil::{set_namespace}; use process_util::{run_and_wait, convert_status}; use super::n...
(context: &Context, cname: String, mut args: Vec<String>) -> Result<i32, String> { let mut cmdargs: Vec<String> = vec!(); let mut container = "".to_string(); let mut pid = None; let mut bmode = context.build_mode; { args.insert(0, "vagga ".to_string() + &cname); let mut ap = Argu...
run_in_netns
identifier_name
underscore.rs
use std::io::{stdout, stderr}; use argparse::{ArgumentParser}; use argparse::{StoreTrue, List, StoreOption, Store}; use unshare::{Command, Namespace}; use options::build_mode::build_mode; use options::version_hash; use container::nsutil::{set_namespace}; use process_util::{run_and_wait, convert_status}; use super::n...
args.insert(0, "vagga _version_hash".to_string()); let opt = match version_hash::Options::parse(&args, false) { Ok(x) => x, Err(e) => return Ok(e), }; let mut cmd: Command = Wrapper::new(None, &ctx.settings); cmd.workdir(&ctx.workdir); try!(cmd.map_users_for( &ctx.config....
pub fn version_hash(ctx: &Context, cname: &str, mut args: Vec<String>) -> Result<i32, String> {
random_line_split
event.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codege...
fn IsTrusted(self) -> bool { self.trusted.get() } } pub trait EventHelpers { fn set_trusted(self, trusted: bool); fn fire(self, target: JSRef<EventTarget>) -> bool; } impl<'a> EventHelpers for JSRef<'a, Event> { fn set_trusted(self, trusted: bool) { self.trusted.set(trusted); ...
{ if self.dispatching.get() { return; } self.initialized.set(true); self.stop_propagation.set(false); self.stop_immediate.set(false); self.canceled.set(false); self.trusted.set(false); self.target.clear(); *self.type_.borrow_mut() = ty...
identifier_body
event.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codege...
self.initialized.set(true); self.stop_propagation.set(false); self.stop_immediate.set(false); self.canceled.set(false); self.trusted.set(false); self.target.clear(); *self.type_.borrow_mut() = type_; self.bubbles.set(bubbles); self.cancelable.set...
{ return; }
conditional_block
event.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codege...
(self) -> Option<Temporary<EventTarget>> { self.target.get() } fn GetCurrentTarget(self) -> Option<Temporary<EventTarget>> { self.current_target.get() } fn DefaultPrevented(self) -> bool { self.canceled.get() } fn PreventDefault(self) { if self.cancelable.get()...
GetTarget
identifier_name
event.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codege...
pub fn initialized(&self) -> bool { self.initialized.get() } } impl<'a> EventMethods for JSRef<'a, Event> { fn EventPhase(self) -> u16 { self.phase.get() as u16 } fn Type(self) -> DOMString { // FIXME(https://github.com/rust-lang/rust/issues/23338) let type_ = self....
#[inline]
random_line_split
rlpstream.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
} impl<T> ByteEncodable for T where T: ToBytes, { fn to_bytes<V: VecLike<u8>>(&self, out: &mut V) { ToBytes::to_bytes(self, out) } fn bytes_len(&self) -> usize { ToBytes::to_bytes_len(self) } } struct U8Slice<'a>(&'a [u8]); impl<'a> ByteEncodable for U8Slice<'a> { fn to_bytes<V: VecLike<u8>>(&self, ou...
{ self.bytes.append_slice(bytes); }
identifier_body
rlpstream.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
(&self, s: &mut RlpStream) { Encodable::rlp_append(&self.deref(), s); } } impl<T> RlpEncodable for T where T: Encodable, { fn rlp_append(&self, s: &mut RlpStream) { Encodable::rlp_append(self, s) } }
rlp_append
identifier_name
rlpstream.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
} } impl<T> Encodable for T where T: ByteEncodable, { fn rlp_append(&self, s: &mut RlpStream) { s.append_value(self) } } struct EncodableU8(u8); impl ByteEncodable for EncodableU8 { fn to_bytes<V: VecLike<u8>>(&self, out: &mut V) { out.vec_push(self.0) } fn bytes_len(&self) -> usize { 1 } } impl R...
random_line_split
rlpstream.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
_ => { let position = self.encoder.bytes.len(); self.unfinished_lists.push(ListInfo::new(position, len)); } } // return chainable self self } fn append_empty_data(&mut self) -> &mut RlpStream { // self push raw item self.encoder.bytes.push(0x80); // try to finish and prepend the length ...
{ // we may finish, if the appended list len is equal 0 self.encoder.bytes.push(0xc0u8); self.note_appended(1); self.finished_list = true; }
conditional_block
config.rs
use yaml_rust::{YamlLoader,Yaml}; use yaml_rust::yaml; use std::path::PathBuf; use std::net::SocketAddr; use std::io::Error as IoError; use std::fs::File; use std::io::prelude::*; use std::str::FromStr; #[derive(Debug)] pub struct Config { path:String, uris:Vec<SocketAddr>, fs_name: String } static CONFIG_FILE:&'s...
}, _ => panic!() } }; Ok(Config{path:CONFIG_FILE.to_owned(),uris:uris, fs_name:fs_name}) } pub fn uris(&self) -> Vec<SocketAddr> { self.uris.clone() } }
{ let mut yaml_file = try!(File::open(CONFIG_FILE)); let mut yaml_string = String::new(); try!(yaml_file.read_to_string(&mut yaml_string)); let yaml_config = &YamlLoader::load_from_str(&mut yaml_string).unwrap().clone()[0]; let yaml_config = yaml_config.as_hash().expect("bad config"); let mut uris = vec!(...
identifier_body
config.rs
use yaml_rust::{YamlLoader,Yaml}; use yaml_rust::yaml; use std::path::PathBuf; use std::net::SocketAddr; use std::io::Error as IoError; use std::fs::File; use std::io::prelude::*; use std::str::FromStr; #[derive(Debug)] pub struct Config { path:String, uris:Vec<SocketAddr>, fs_name: String } static CONFIG_FILE:&'s...
let mut yaml_file = try!(File::open(CONFIG_FILE)); let mut yaml_string = String::new(); try!(yaml_file.read_to_string(&mut yaml_string)); let yaml_config = &YamlLoader::load_from_str(&mut yaml_string).unwrap().clone()[0]; let yaml_config = yaml_config.as_hash().expect("bad config"); let mut uris = vec!();...
pub fn build() -> Result<Self,IoError> {
random_line_split
config.rs
use yaml_rust::{YamlLoader,Yaml}; use yaml_rust::yaml; use std::path::PathBuf; use std::net::SocketAddr; use std::io::Error as IoError; use std::fs::File; use std::io::prelude::*; use std::str::FromStr; #[derive(Debug)] pub struct
{ path:String, uris:Vec<SocketAddr>, fs_name: String } static CONFIG_FILE:&'static str = "dsefs-rs.yaml"; impl Config { pub fn build() -> Result<Self,IoError> { let mut yaml_file = try!(File::open(CONFIG_FILE)); let mut yaml_string = String::new(); try!(yaml_file.read_to_string(&mut yaml_string)); let...
Config
identifier_name
util.rs
use parking_lot::Mutex; use std::{ ops::{Deref, DerefMut}, sync::Arc, }; use tokio::task; #[macro_export] macro_rules! try_opt_r { ($x:expr) => { match $x { Some(value) => value, None => return Ok(()), } }; } #[macro_export] macro_rules! try_opt_ret { ($x:ex...
}
{ self.0.abort(); }
identifier_body
util.rs
use parking_lot::Mutex; use std::{ ops::{Deref, DerefMut}, sync::Arc, }; use tokio::task; #[macro_export] macro_rules! try_opt_r { ($x:expr) => { match $x { Some(value) => value, None => return Ok(()), } }; } #[macro_export] macro_rules! try_opt_ret { ($x:ex...
<F>(total_mins: F) -> String where F: Into<f32>, { let total_mins = total_mins.into(); let hours = (total_mins / 60.0).floor() as u8; let minutes = (total_mins % 60.0).floor() as u8; format!("{:02}:{:02}H", hours, minutes) } pub type ArcMutex<T> = Arc<Mutex<T>>; pub fn arc_mutex<T>(value: T) -> ...
hm_from_mins
identifier_name
util.rs
use parking_lot::Mutex; use std::{ ops::{Deref, DerefMut}, sync::Arc, }; use tokio::task; #[macro_export] macro_rules! try_opt_r { ($x:expr) => { match $x { Some(value) => value, None => return Ok(()), } }; } #[macro_export] macro_rules! try_opt_ret { ($x:ex...
}
random_line_split
monitor-instance.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. #[structopt(short, long)] region: Option<String>, /// The ID of the instance to monitor. #[structopt(shor...
* SPDX-License-Identifier: Apache-2.0. */
random_line_split
monitor-instance.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. ...
let shared_config = aws_config::from_env().region(region_provider).load().await; let client = Client::new(&shared_config); enable_monitoring(&client, &instance_id).await }
{ println!("EC2 client version: {}", PKG_VERSION); println!( "Region: {}", region_provider.region().await.unwrap().as_ref() ); println!("Instance ID: {}", instance_id); println!(); }
conditional_block
monitor-instance.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. ...
println!(); } let shared_config = aws_config::from_env().region(region_provider).load().await; let client = Client::new(&shared_config); enable_monitoring(&client, &instance_id).await }
{ tracing_subscriber::fmt::init(); let Opt { region, instance_id, verbose, } = Opt::from_args(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() .or_else(Region::new("us-west-2")); println!(); if verbo...
identifier_body
monitor-instance.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct
{ /// The AWS Region. #[structopt(short, long)] region: Option<String>, /// The ID of the instance to monitor. #[structopt(short, long)] instance_id: String, /// Whether to display additional information. #[structopt(short, long)] verbose: bool, } // Enables monitoring for an ins...
Opt
identifier_name
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject;...
unsafe { NonZero::new_unchecked(extension.reflector().get_jsobject().get()) } } fn is_supported(&self, ext: &WebGLExtensions) -> bool { self.is_enabled() || T::is_supported(ext) } fn is_enabled(&self) -> bool { self.extension.get().is_some() } fn e...
{ self.enable(ext); }
conditional_block
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject;...
impl<T> TypedWebGLExtensionWrapper<T> where T: WebGLExtension + JSTraceable + HeapSizeOf +'static { pub fn dom_object(&self) -> Option<Root<T::Extension>> { self.extension.get() } }
self } }
random_line_split
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject;...
(&self) -> &'static str { T::name() } fn as_any<'a>(&'a self) -> &'a Any { self } } impl<T> TypedWebGLExtensionWrapper<T> where T: WebGLExtension + JSTraceable + HeapSizeOf +'static { pub fn dom_object(&self) -> Option<Root<T::Extension>> { self.extension.get() } }
name
identifier_name
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject;...
}
{ self.extension.get() }
identifier_body
htmlpreelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLPreElementBinding; use dom::bindings::root::DomRoot; use dom::document::...
}
{ Node::reflect_node(Box::new(HTMLPreElement::new_inherited(local_name, prefix, document)), document, HTMLPreElementBinding::Wrap) }
identifier_body
htmlpreelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLPreElementBinding; use dom::bindings::root::DomRoot; use dom::document::...
(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> HTMLPreElement { HTMLPreElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document) } } #[allow(unrooted_must_root)] pub fn new(l...
new_inherited
identifier_name
htmlpreelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLPreElement { htmlelement: HTMLElement, } impl HTMLPreElement { fn new_inherited(local_name: LocalName, prefix: Option<Prefix>, ...
use dom::bindings::codegen::Bindings::HTMLPreElementBinding; use dom::bindings::root::DomRoot; use dom::document::Document;
random_line_split
match-implicit-copy-unique.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} }
{ assert!(**a == 10); *a = box 30; assert!(**a == 30); }
conditional_block
match-implicit-copy-unique.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
#![feature(box_syntax)] struct Pair { a: Box<isize>, b: Box<isize> } pub fn main() { let mut x: Box<_> = box Pair {a: box 10, b: box 20}; let x_internal = &mut *x; match *x_internal { Pair {a: ref mut a, b: ref mut _b} => { assert!(**a == 10); *a = box 30; assert!(**a == 30); } } }
#![allow(unknown_features)]
random_line_split
match-implicit-copy-unique.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ a: Box<isize>, b: Box<isize> } pub fn main() { let mut x: Box<_> = box Pair {a: box 10, b: box 20}; let x_internal = &mut *x; match *x_internal { Pair {a: ref mut a, b: ref mut _b} => { assert!(**a == 10); *a = box 30; assert!(**a == 30); } } }
Pair
identifier_name
match-implicit-copy-unique.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut x: Box<_> = box Pair {a: box 10, b: box 20}; let x_internal = &mut *x; match *x_internal { Pair {a: ref mut a, b: ref mut _b} => { assert!(**a == 10); *a = box 30; assert!(**a == 30); } } }
identifier_body
phys.rs
use core::intrinsics::transmute; extern { static kend: u32; // kernel end } static mut paddress: u32 = 0; // placement address pub fn init() { unsafe { paddress = transmute(&kend); } } pub fn alloc(size: uint) -> u32 { let mut size = size as u32; if size & 0xFFF!= 0
unsafe { let ptr = paddress; paddress += size; ptr } } #[test] fn test_kmalloc() { unsafe { paddress = 0; } let ptr0 = kmalloc(4096); let ptr1 = kmalloc(128); let ptr2 = kmalloc(1); assert_eq!(ptr0, 0); assert_eq!(ptr1, 4096); assert_eq!(ptr1...
{ // align 4096 size &= 0xFFFFF000; size += 0x1000; }
conditional_block
phys.rs
use core::intrinsics::transmute; extern { static kend: u32; // kernel end } static mut paddress: u32 = 0; // placement address pub fn init()
pub fn alloc(size: uint) -> u32 { let mut size = size as u32; if size & 0xFFF!= 0 { // align 4096 size &= 0xFFFFF000; size += 0x1000; } unsafe { let ptr = paddress; paddress += size; ptr } } #[test] fn test_kmalloc() { unsafe { paddress = 0...
{ unsafe { paddress = transmute(&kend); } }
identifier_body
phys.rs
use core::intrinsics::transmute; extern { static kend: u32; // kernel end } static mut paddress: u32 = 0; // placement address pub fn init() { unsafe { paddress = transmute(&kend); } } pub fn alloc(size: uint) -> u32 { let mut size = size as u32; if size & 0xFFF!= 0 { // align 40...
assert_eq!(ptr0, 0); assert_eq!(ptr1, 4096); assert_eq!(ptr1, 8192); }
random_line_split
phys.rs
use core::intrinsics::transmute; extern { static kend: u32; // kernel end } static mut paddress: u32 = 0; // placement address pub fn init() { unsafe { paddress = transmute(&kend); } } pub fn alloc(size: uint) -> u32 { let mut size = size as u32; if size & 0xFFF!= 0 { // align 40...
() { unsafe { paddress = 0; } let ptr0 = kmalloc(4096); let ptr1 = kmalloc(128); let ptr2 = kmalloc(1); assert_eq!(ptr0, 0); assert_eq!(ptr1, 4096); assert_eq!(ptr1, 8192); }
test_kmalloc
identifier_name
fallback.rs
// If SIMD instructions are not available, this file provides a dummy implementation of Teddy that // will compile, but do nothing at runtime. use Match; /// A SIMD accelerated multi substring searcher. #[derive(Clone, Debug)] pub struct Teddy; impl Teddy { /// Create a new `Teddy` multi substring matcher. /...
false } }
pub fn is_accelerated() -> bool {
random_line_split
fallback.rs
// If SIMD instructions are not available, this file provides a dummy implementation of Teddy that // will compile, but do nothing at runtime. use Match; /// A SIMD accelerated multi substring searcher. #[derive(Clone, Debug)] pub struct Teddy; impl Teddy { /// Create a new `Teddy` multi substring matcher. /...
/// Were we compiled with SIMD support? If not, `Teddy::new` will always just return `None`. /// /// See the README for more information on how to compile `teddy` with SIMD support. pub fn is_accelerated() -> bool { false } }
{ unimplemented!(); }
identifier_body
fallback.rs
// If SIMD instructions are not available, this file provides a dummy implementation of Teddy that // will compile, but do nothing at runtime. use Match; /// A SIMD accelerated multi substring searcher. #[derive(Clone, Debug)] pub struct Teddy; impl Teddy { /// Create a new `Teddy` multi substring matcher. /...
<'a, I>(_pats: I) -> Option<Teddy> where I: IntoIterator<Item=&'a [u8]> { None } /// Returns all of the substrings matched by this `Teddy`. pub fn patterns(&self) -> &[Vec<u8>] { unimplemented!(); } /// Returns the approximate size on the heap used by this matcher. pub fn appro...
new
identifier_name
encrypted.rs
// Copyright (c) 2018, Ben Boeckel // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of cond...
/// Use this with `add_key`. New { /// The format of the new key. format: Option<Format>, /// The type of key to use for encrypting the new key. keytype: MasterKeyType, /// The description of the key to use for encrypting the new key. description: Cow<'static, str...
// #[non_exhaustive] pub enum Payload { /// Create a new key. ///
random_line_split
encrypted.rs
// Copyright (c) 2018, Ben Boeckel // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of cond...
; impl KeyType for Encrypted { /// The format of the description depends on the format. /// /// For `ecryptfs`-format keys, the description must be a 16-character hexadecimal string. type Description = str; type Payload = Payload; fn name() -> &'static str { "encrypted" } } /// Th...
Encrypted
identifier_name