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
htmlstyleelement.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::HTMLStyleElementBinding; use dom::bindings::codegen::Bindings::NodeBinding::...
(&self) -> bool { *self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLStyleElement))) } } impl HTMLStyleElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLStyleElement { HTMLS...
is_htmlstyleelement
identifier_name
htmlstyleelement.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::HTMLStyleElementBinding; use dom::bindings::codegen::Bindings::NodeBinding::...
} }
{ self.parse_own_css(); }
conditional_block
utils.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 rustc::lint::Context; use rustc::middle::{ty, def}; use syntax::ptr::P; use syntax::{ast, ast_map}; use synta...
}, _ => false, } } _ => false, } }) } // Determines if a block is in an unsafe context so that an unhelpful // lint can be aborted. pub fn unsafe_context(map: &ast_map::Map, id: ast::NodeId) -> bool { match map.find(map.get...
random_line_split
utils.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 rustc::lint::Context; use rustc::middle::{ty, def}; use syntax::ptr::P; use syntax::{ast, ast_map}; use synta...
<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> { match ty.node { TyPath(Path {segments: ref seg,..}, _) => { // So ast::Path isn't the full path, just the tokens that were provided. // I could muck around with the maps and find the full path // however the mor...
match_ty_unwrap
identifier_name
utils.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 rustc::lint::Context; use rustc::middle::{ty, def}; use syntax::ptr::P; use syntax::{ast, ast_map}; use synta...
_ => false, } } _ => false // There are probably a couple of other unsafe cases we don't care to lint, those will need to be added. } }
{ match map.find(map.get_parent(id)) { Some(ast_map::NodeImplItem(itm)) => { match *itm { ast::MethodImplItem(ref meth) => match meth.node { ast::MethDecl(_, _, _, _, style, _, _, _) => match style { ast::Unsafety::Unsafe => true, ...
identifier_body
rust_string.rs
use std::ffi::CString; use std::mem::forget; use libc; /// Compatibility wrapper for strings allocated in Rust and passed to C. /// /// Rust doesn't ensure the safety of freeing memory across an FFI boundary, so /// we need to take special care to ensure we're not accidentally calling /// `tor_free`() on any string al...
}
{ assert_eq!(mem::size_of::<*mut libc::c_char>(), mem::size_of::<RustString>()) }
identifier_body
rust_string.rs
use std::ffi::CString; use std::mem::forget; use libc; /// Compatibility wrapper for strings allocated in Rust and passed to C. /// /// Rust doesn't ensure the safety of freeing memory across an FFI boundary, so /// we need to take special care to ensure we're not accidentally calling /// `tor_free`() on any string al...
#[test] fn size_of() { assert_eq!(mem::size_of::<*mut libc::c_char>(), mem::size_of::<RustString>()) } }
random_line_split
rust_string.rs
use std::ffi::CString; use std::mem::forget; use libc; /// Compatibility wrapper for strings allocated in Rust and passed to C. /// /// Rust doesn't ensure the safety of freeing memory across an FFI boundary, so /// we need to take special care to ensure we're not accidentally calling /// `tor_free`() on any string al...
(&self) -> *const libc::c_char { self.0 as *const libc::c_char } } impl From<CString> for RustString { /// Constructs a new `RustString` /// /// # Examples /// ``` /// # use tor_util::RustString; /// use std::ffi::CString; /// /// let r = RustString::from(CString::new("asdf"...
as_ptr
identifier_name
storage.rs
use std::borrow::Cow; use std::ffi::CStr; /// Structure containing information about a camera's storage. /// /// ## Example /// /// A `Storage` object can be used to retrieve information about a camera's storage: /// /// ```no_run /// let mut context = gphoto::Context::new().unwrap(); /// let mut camera = gphoto::Came...
::gphoto2::GP_STORAGEINFO_FST_DCF => FilesystemType::DCF, ::gphoto2::GP_STORAGEINFO_FST_UNDEFINED => FilesystemType::Unknown, }) } else { None } } /// The storage's access permissions. pub fn access_ty...
pub fn filesystem_type(&self) -> Option<FilesystemType> { if self.inner.fields & ::gphoto2::GP_STORAGEINFO_FILESYSTEMTYPE != 0 { Some(match self.inner.fstype { ::gphoto2::GP_STORAGEINFO_FST_GENERICFLAT => FilesystemType::Flat, ::gphoto2::GP_STORAGEINFO_FST...
random_line_split
storage.rs
use std::borrow::Cow; use std::ffi::CStr; /// Structure containing information about a camera's storage. /// /// ## Example /// /// A `Storage` object can be used to retrieve information about a camera's storage: /// /// ```no_run /// let mut context = gphoto::Context::new().unwrap(); /// let mut camera = gphoto::Came...
(&self) -> Option<Cow<str>> { if self.inner.fields & ::gphoto2::GP_STORAGEINFO_BASE!= 0 { Some(unsafe { String::from_utf8_lossy(CStr::from_ptr(self.inner.basedir.as_ptr()).to_bytes()) }) } else { None } } /// The storage's labe...
base_dir
identifier_name
ast.rs
use clingo::*; use std::env; pub struct OnStatementData<'a, 'b> { atom: &'b ast::Term<'b>, control: &'a mut Control, } impl<'a, 'b> StatementHandler for OnStatementData<'a, 'b> { // adds atom enable to all rule bodies fn on_statement(&mut self, stm: &ast::Statement) -> bool { // pass through a...
() { // collect clingo options from the command line let options = env::args().skip(1).collect(); let mut ctl = Control::new(options).expect("Failed creating Control."); let sym = Symbol::create_id("enable", true).unwrap(); { // initilize atom to add and the program builder let mu...
main
identifier_name
ast.rs
use clingo::*; use std::env; pub struct OnStatementData<'a, 'b> { atom: &'b ast::Term<'b>, control: &'a mut Control, } impl<'a, 'b> StatementHandler for OnStatementData<'a, 'b> { // adds atom enable to all rule bodies fn on_statement(&mut self, stm: &ast::Statement) -> bool { // pass through a...
let rule = ast::Rule::new(*head, &extended_body); // initialize the statement let stm2 = rule.ast_statement(); // add the rewritten statement to the program builder .add(&stm2) .expect("Failed to add ...
random_line_split
ast.rs
use clingo::*; use std::env; pub struct OnStatementData<'a, 'b> { atom: &'b ast::Term<'b>, control: &'a mut Control, } impl<'a, 'b> StatementHandler for OnStatementData<'a, 'b> { // adds atom enable to all rule bodies fn on_statement(&mut self, stm: &ast::Statement) -> bool { // pass through a...
let ext = ast::External::new(ast::Term::from(sym), &[]); let mut builder = ast::ProgramBuilder::from(&mut ctl).unwrap(); let stm = ext.ast_statement(); builder .add(&stm) .expect("Failed to add statement to ProgramBuilder."); // finish building a program ...
{ // collect clingo options from the command line let options = env::args().skip(1).collect(); let mut ctl = Control::new(options).expect("Failed creating Control."); let sym = Symbol::create_id("enable", true).unwrap(); { // initilize atom to add and the program builder let mut d...
identifier_body
main.rs
use std::io::Write; use std::str::FromStr; fn main()
fn gcd(mut n: u64, mut m: u64) -> u64 { assert!(n!= 0 && m!= 0); while m!= 0 { if m < n { let t = m; m = n; n = t; } m = m % n; } n } #[test] fn test_gcd() { assert_eq!(gcd(14, 15), 1); assert_eq!(gcd(2 * 3 * 5 * 11 * 17, ...
{ let mut numbers = Vec::new(); for arg in std::env::args().skip(1) { numbers.push(u64::from_str(&arg) .expect("error parsing argument")); } if numbers.len() == 0 { writeln!(std::io::stderr(), "Usage: gcd NUMBER ...").unwrap(); std::process::exit(1); } ...
identifier_body
main.rs
use std::io::Write; use std::str::FromStr; fn main() { let mut numbers = Vec::new(); for arg in std::env::args().skip(1) { numbers.push(u64::from_str(&arg) .expect("error parsing argument"));
std::process::exit(1); } let mut d = numbers[0]; for m in &numbers[1..] { d = gcd(d, *m); } println!("The greatest common divisor of {:?} is {}", numbers, d); } fn gcd(mut n: u64, mut m: u64) -> u64 { assert!(n!= 0 && m!= 0); while m!= 0 { if m < n { le...
} if numbers.len() == 0 { writeln!(std::io::stderr(), "Usage: gcd NUMBER ...").unwrap();
random_line_split
main.rs
use std::io::Write; use std::str::FromStr; fn main() { let mut numbers = Vec::new(); for arg in std::env::args().skip(1) { numbers.push(u64::from_str(&arg) .expect("error parsing argument")); } if numbers.len() == 0 { writeln!(std::io::stderr(), "Usage: gcd NUMBER....
(mut n: u64, mut m: u64) -> u64 { assert!(n!= 0 && m!= 0); while m!= 0 { if m < n { let t = m; m = n; n = t; } m = m % n; } n } #[test] fn test_gcd() { assert_eq!(gcd(14, 15), 1); assert_eq!(gcd(2 * 3 * 5 * 11 * 17, ...
gcd
identifier_name
main.rs
use std::io::Write; use std::str::FromStr; fn main() { let mut numbers = Vec::new(); for arg in std::env::args().skip(1) { numbers.push(u64::from_str(&arg) .expect("error parsing argument")); } if numbers.len() == 0
let mut d = numbers[0]; for m in &numbers[1..] { d = gcd(d, *m); } println!("The greatest common divisor of {:?} is {}", numbers, d); } fn gcd(mut n: u64, mut m: u64) -> u64 { assert!(n!= 0 && m!= 0); while m!= 0 { if m < n { let t = m; m = n; ...
{ writeln!(std::io::stderr(), "Usage: gcd NUMBER ...").unwrap(); std::process::exit(1); }
conditional_block
tempfile.rs
// Copyright 2013 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 ...
(tmpdir: &Path, suffix: &str) -> Option<Path> { let mut r = rand::rng(); for 1000.times { let p = tmpdir.push(r.gen_str(16) + suffix); if os::make_dir(&p, 0x1c0) { // 700 return Some(p); } } None } #[cfg(test)] mod tests { use tempfile::mkdtemp; use std::os...
mkdtemp
identifier_name
tempfile.rs
// Copyright 2013 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 root = mkdtemp(&os::tmpdir(), "recursive_mkdir_rel"). expect("recursive_mkdir_rel"); assert!(do os::change_dir_locked(&root) { let path = Path("frob"); debug!("recursive_mkdir_rel: Making: %s in cwd %s [%?]", path.to_str(), os::getcwd().to_str(...
random_line_split
tempfile.rs
// Copyright 2013 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 p = mkdtemp(&Path("."), "foobar").unwrap(); os::remove_dir(&p); assert!(p.to_str().ends_with("foobar")); } // Ideally these would be in std::os but then core would need // to depend on std #[test] fn recursive_mkdir_rel() { use std::libc::consts::os::posix88::{S_...
{ let mut r = rand::rng(); for 1000.times { let p = tmpdir.push(r.gen_str(16) + suffix); if os::make_dir(&p, 0x1c0) { // 700 return Some(p); } } None } #[cfg(test)] mod tests { use tempfile::mkdtemp; use std::os; #[test] fn test_mkdtemp() {
identifier_body
dns_resolver.rs
//! Asynchronous DNS resolver use std::{ io::{self, ErrorKind}, net::SocketAddr, }; use futures::Future; use tokio; use trust_dns_resolver::{config::ResolverConfig, AsyncResolver}; use crate::context::SharedContext; pub fn
(dns: Option<ResolverConfig>) -> AsyncResolver { let (resolver, bg) = { // To make this independent, if targeting macOS, BSD, Linux, or Windows, we can use the system's configuration: #[cfg(any(unix, windows))] { if let Some(conf) = dns { use trust_dns_resolver::c...
create_resolver
identifier_name
dns_resolver.rs
//! Asynchronous DNS resolver use std::{ io::{self, ErrorKind}, net::SocketAddr, }; use futures::Future; use tokio; use trust_dns_resolver::{config::ResolverConfig, AsyncResolver}; use crate::context::SharedContext; pub fn create_resolver(dns: Option<ResolverConfig>) -> AsyncResolver { let (resolver, bg...
}
random_line_split
dns_resolver.rs
//! Asynchronous DNS resolver use std::{ io::{self, ErrorKind}, net::SocketAddr, }; use futures::Future; use tokio; use trust_dns_resolver::{config::ResolverConfig, AsyncResolver}; use crate::context::SharedContext; pub fn create_resolver(dns: Option<ResolverConfig>) -> AsyncResolver { let (resolver, bg...
} // For other operating systems, we can use one of the preconfigured definitions #[cfg(not(any(unix, windows)))] { // Directly reference the config types use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; if let Some(conf) = dns { ...
{ use trust_dns_resolver::system_conf::read_system_conf; // use the system resolver configuration let (config, opts) = read_system_conf().expect("Failed to read global dns sysconf"); AsyncResolver::new(config, opts) }
conditional_block
dns_resolver.rs
//! Asynchronous DNS resolver use std::{ io::{self, ErrorKind}, net::SocketAddr, }; use futures::Future; use tokio; use trust_dns_resolver::{config::ResolverConfig, AsyncResolver}; use crate::context::SharedContext; pub fn create_resolver(dns: Option<ResolverConfig>) -> AsyncResolver
use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; if let Some(conf) = dns { AsyncResolver::new(conf, ResolverOpts::default()) } else { // Get a new resolver with the google nameservers as the upstream recursive resolvers ...
{ let (resolver, bg) = { // To make this independent, if targeting macOS, BSD, Linux, or Windows, we can use the system's configuration: #[cfg(any(unix, windows))] { if let Some(conf) = dns { use trust_dns_resolver::config::ResolverOpts; AsyncResol...
identifier_body
dom_html_heading_element.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::DOMElement; use crate::DOMEventTarget; use crate::DOMHTMLElement; use crate::DOMNode; use crate::DOMObject; use glib::object::Cast; use glib::object::IsA; use glib::si...
}
{ f.write_str("DOMHTMLHeadingElement") }
identifier_body
dom_html_heading_element.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::DOMElement; use crate::DOMEventTarget; use crate::DOMHTMLElement; use crate::DOMNode; use crate::DOMObject; use glib::object::Cast; use glib::object::IsA; use glib::si...
<P, F: Fn(&P) +'static>( this: *mut ffi::WebKitDOMHTMLHeadingElement, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) where P: IsA<DOMHTMLHeadingElement>, { let f: &F = &*(f as *const F); f(&DOMHTMLHeadingElement::from_g...
notify_align_trampoline
identifier_name
dom_html_heading_element.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::DOMElement; use crate::DOMEventTarget; use crate::DOMHTMLElement; use crate::DOMNode; use crate::DOMObject; use glib::object::Cast; use glib::object::IsA; use glib::si...
} } fn set_align(&self, value: &str) { unsafe { ffi::webkit_dom_html_heading_element_set_align( self.as_ref().to_glib_none().0, value.to_glib_none().0, ); } } fn connect_property_align_notify<F: Fn(&Self) +'static>(&self, ...
))
random_line_split
rsa.rs
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this f...
(sha: usize,z: &[u8],olen: usize,k: &mut [u8]) { let hlen=sha; let mut j=0; for i in 0..k.len() {k[i]=0} let mut cthreshold=olen/hlen; if olen%hlen!=0 {cthreshold+=1} for counter in 0..cthreshold { let mut b:[u8;64]=[0;64]; hashit(sha,Some(z),counter as isize,&mut b); if j+hlen>olen { for i in 0..(...
mgf1
identifier_name
rsa.rs
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this f...
/* SHAXXX identifier strings */ const SHA256ID:[u8;19]= [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20]; const SHA384ID:[u8;19]= [0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30]; const SHA512ID:[u8;19]= [0x30,0x51,0x30,0x...
{ let hlen=sha; let mut j=0; for i in 0..k.len() {k[i]=0} let mut cthreshold=olen/hlen; if olen%hlen!=0 {cthreshold+=1} for counter in 0..cthreshold { let mut b:[u8;64]=[0;64]; hashit(sha,Some(z),counter as isize,&mut b); if j+hlen>olen { for i in 0..(olen%hlen) {k[j]=b[i]; j+=1} } else { for ...
identifier_body
rsa.rs
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this f...
r.dscopy(&jp); jp.rmod(&prv.q); if FF::comp(&jp,&jq)>0 {jq.add(&prv.q)} jq.sub(&jp); jq.norm(); let mut t=FF::mul(&prv.c,&jq); jq=t.dmod(&prv.q); t=FF::mul(&jq,&prv.p); r.add(&t); r.norm(); r.tobytes(f); }
r.zero();
random_line_split
rsa.rs
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this f...
let hs=h.hash(); for i in 0..sha {w[i]=hs[i]} } } pub fn key_pair(rng: &mut RAND,e: isize,prv: &mut RsaPrivateKey,pbc: &mut RsaPublicKey) { /* IEEE1363 A16.11/A16.12 more or less */ let n=pbc.n.getlen()/2; let mut t=FF::new_int(n); let mut p1=FF::new_int(n); let mut q1=FF::new_int(n); loop { ...
{h.process_num(n as i32)}
conditional_block
attr.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 app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::Zero; use num::ToPrimitive; use std::ascii...
/// Assumes the `AttrValue` is a `Dimension` and returns its value /// /// ## Panics /// /// Panics if the `AttrValue` is not a `Dimension` pub fn as_dimension(&self) -> &LengthOrPercentageOrAuto { match *self { AttrValue::Dimension(_, ref l) => l, _ => panic!("...
{ match *self { AttrValue::Length(_, ref length) => length.as_ref(), _ => panic!("Length not found"), } }
identifier_body
attr.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 app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::Zero; use num::ToPrimitive; use std::ascii...
match *self { AttrValue::String(ref value) | AttrValue::TokenList(ref value, _) | AttrValue::UInt(ref value, _) | AttrValue::Length(ref value, _) | AttrValue::Color(ref value, _) | AttrValue::Int(ref value, _) | ...
random_line_split
attr.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 app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::Zero; use num::ToPrimitive; use std::ascii...
{ String(DOMString), TokenList(DOMString, Vec<Atom>), UInt(DOMString, u32), Int(DOMString, i32), Atom(Atom), Length(DOMString, Option<Length>), Color(DOMString, Option<RGBA>), Dimension(DOMString, LengthOrPercentageOrAuto), Url(DOMString, Option<Url>), } /// Shared implementation t...
AttrValue
identifier_name
deriving-eq-ord-boxed-slice.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 ...
println!("{}", a >= b); }
random_line_split
deriving-eq-ord-boxed-slice.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 ...
(Box<[u8]>); pub fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let a = Foo(Box::new([0, 1, 2])); let b = Foo(Box::new([0, 1, 2])); assert!(a == b); println!("{}", a!= b); println!("{}", a < b); println!("{}", a <= b); println!("{}", a == b); pri...
Foo
identifier_name
qsearch.rs
//! Defines the `Qsearch` trait. use uci::SetOption; use value::*; use depth::*; use move_generator::MoveGenerator; /// Parameters describing a quiescence search. /// /// **Important note:** `lower_bound` and `upper_bound` fields /// together give the interval within which an as precise as possible /// evaluation is...
<'a, T: MoveGenerator + 'a> { /// A mutable reference to the root position for the search. /// /// **Important note:** The search routine may use this reference /// to do and undo moves, but when the search is finished, all /// played moves must be taken back so that the board is restored /// to...
QsearchParams
identifier_name
qsearch.rs
//! Defines the `Qsearch` trait. use uci::SetOption; use value::*; use depth::*; use move_generator::MoveGenerator; /// Parameters describing a quiescence search. /// /// **Important note:** `lower_bound` and `upper_bound` fields /// together give the interval within which an as precise as possible /// evaluation is...
/// Will always be between `VALUE_EVAL_MIN` and `VALUE_EVAL_MAX`. fn value(&self) -> Value; /// Retruns the number of positions searched to calculate the evaluation. fn searched_nodes(&self) -> u64; } /// A trait for performing quiescence searches. /// /// Quiescence search is a restricted search whi...
/// Returns the calculated evaluation for the position. ///
random_line_split
dynamics.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 https://mozilla.org/MPL/2.0/. extern crate core; use self::core::slice; use self::core::fmt::{ Debug, Error, Formatter, }; use contex...
} impl HpackEncodable for DynamicHeader { #[inline(always)] fn name(&self) -> &[u8] { &self.buf[0..self.seg] } #[inline(always)] fn value(&self) -> &[u8] { &self.buf[self.seg..self.buf.len()] } #[inline] fn size(&self) -> u32 { self.buf.len() as u32 + 32 ...
{ let mut buf = Vec::with_capacity(name.len() + value.len()); buf.extend(name); buf.extend(value); DynamicHeader { seg: name.len(), buf: buf, } }
identifier_body
dynamics.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 https://mozilla.org/MPL/2.0/. extern crate core; use self::core::slice; use self::core::fmt::{ Debug, Error, Formatter, }; use contex...
/// Header is a decoded header of &[u8] backed by a Headers buffer. #[repr(C)] pub struct Header { name: (*const u8, usize), value: (*const u8, usize), compressable: bool, } impl Header { #[inline(always)] pub fn new( name: &[u8], value: &[u8], compressable: ...
HpackEncodable, };
random_line_split
dynamics.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 https://mozilla.org/MPL/2.0/. extern crate core; use self::core::slice; use self::core::fmt::{ Debug, Error, Formatter, }; use contex...
{ name: (*const u8, usize), value: (*const u8, usize), compressable: bool, } impl Header { #[inline(always)] pub fn new( name: &[u8], value: &[u8], compressable: bool, ) -> Header { Header { name: (name.as_ptr(), name.len()), ...
Header
identifier_name
security_checker.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::repo_handlers::RepoHandler; use anyhow::{bail, Context, Error, Result}; use borrowed::borrowed; use fbinit::FacebookInit; use fu...
} } let futures = repo_handlers.iter().map(|(reponame, repohandler)| { borrowed!(allowlisted_identities); async move { if let Some(acl_name) = repohandler.repo.hipster_acl() { let permchecker = PermissionCheckerBuilder::acl_for_re...
{ if tier_permchecker.is_some() { bail!("invalid config: only one PermissionChecker for tier is allowed"); } tier_permchecker = Some(PermissionCheckerBuilder::acl_for_tier(fb, &tier).await?); }
conditional_block
security_checker.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::repo_handlers::RepoHandler; use anyhow::{bail, Context, Error, Result};
BoxMembershipChecker, BoxPermissionChecker, MembershipCheckerBuilder, MononokeIdentity, MononokeIdentitySet, PermissionCheckerBuilder, }; use slog::{warn, Logger}; use std::collections::HashMap; pub struct ConnectionsSecurityChecker { tier_permchecker: BoxPermissionChecker, allowlisted_checker: BoxMemb...
use borrowed::borrowed; use fbinit::FacebookInit; use futures::future::try_join_all; use metaconfig_types::{AllowlistEntry, CommonConfig}; use permission_checker::{
random_line_split
security_checker.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::repo_handlers::RepoHandler; use anyhow::{bail, Context, Error, Result}; use borrowed::borrowed; use fbinit::FacebookInit; use fu...
pub async fn check_if_repo_access_allowed( &self, reponame: &str, identities: &MononokeIdentitySet, ) -> Result<bool> { match self.repo_permcheckers.get(reponame) { Some(permchecker) => Ok(permchecker.check_set(&identities, &["read"]).await?), None => Ok(f...
let action = "trusted_parties"; Ok(self.allowlisted_checker.is_member(&identities).await? || self .tier_permchecker .check_set(&identities, &[action]) .await?) }
identifier_body
security_checker.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::repo_handlers::RepoHandler; use anyhow::{bail, Context, Error, Result}; use borrowed::borrowed; use fbinit::FacebookInit; use fu...
( fb: FacebookInit, common_config: CommonConfig, repo_handlers: &HashMap<String, RepoHandler>, logger: &Logger, ) -> Result<Self> { let mut allowlisted_identities = MononokeIdentitySet::new(); let mut tier_permchecker = None; for allowlist_entry in common_con...
new
identifier_name
idle.rs
use crate::{Event, Loop}; /// Idle arguments, such as expected idle time in seconds. #[derive(Copy, Clone, PartialEq, PartialOrd, Debug, Deserialize, Serialize)] pub struct IdleArgs { /// Expected idle time in seconds. pub dt: f64, } /// When background tasks should be performed. pub trait IdleEvent: Sized { ...
/// Calls closure if this is an idle event. fn idle<U, F>(&self, f: F) -> Option<U> where F: FnMut(&IdleArgs) -> U; /// Returns idle arguments. fn idle_args(&self) -> Option<IdleArgs> { self.idle(|args| *args) } } impl IdleEvent for Event { fn from_idle_args(args: &IdleArgs...
{ IdleEvent::from_idle_args(&IdleArgs { dt }, old_event) }
identifier_body
idle.rs
use crate::{Event, Loop}; /// Idle arguments, such as expected idle time in seconds. #[derive(Copy, Clone, PartialEq, PartialOrd, Debug, Deserialize, Serialize)] pub struct IdleArgs { /// Expected idle time in seconds. pub dt: f64, } /// When background tasks should be performed. pub trait IdleEvent: Sized { ...
where F: FnMut(&IdleArgs) -> U, { match *self { Event::Loop(Loop::Idle(ref args)) => Some(f(args)), _ => None, } } } #[cfg(test)] mod tests { use super::*; #[test] fn test_input_idle() { use IdleArgs; let e: Event = IdleArgs { dt...
fn idle<U, F>(&self, mut f: F) -> Option<U>
random_line_split
idle.rs
use crate::{Event, Loop}; /// Idle arguments, such as expected idle time in seconds. #[derive(Copy, Clone, PartialEq, PartialOrd, Debug, Deserialize, Serialize)] pub struct IdleArgs { /// Expected idle time in seconds. pub dt: f64, } /// When background tasks should be performed. pub trait IdleEvent: Sized { ...
(&self) -> Option<IdleArgs> { self.idle(|args| *args) } } impl IdleEvent for Event { fn from_idle_args(args: &IdleArgs, _old_event: &Self) -> Option<Self> { Some(Event::Loop(Loop::Idle(*args))) } fn idle<U, F>(&self, mut f: F) -> Option<U> where F: FnMut(&IdleArgs) -> U, ...
idle_args
identifier_name
main.rs
// Copyright 2018 Google Inc. // // 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 agreed to in...
() { let out = indoc! { b" Hello fellow Rustaceans! " }; let width = 24; let mut writer = BufWriter::new(stdout()); ferris_says::say(out, width, &mut writer).unwrap(); } }
test_dev_dependencies
identifier_name
main.rs
// Copyright 2018 Google Inc. // // 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 agreed to in...
#[cfg(test)] mod tests { use super::*; use indoc::indoc; #[test] fn test_dev_dependencies() { let out = indoc! { b" Hello fellow Rustaceans! " }; let width = 24; let mut writer = BufWriter::new(stdout()); ferris_says::say(out, width, &mut writer).unwrap(); } }
{ let out = b"Hello fellow Rustaceans!"; let width = 24; let mut writer = BufWriter::new(stdout()); ferris_says::say(out, width, &mut writer).unwrap(); }
identifier_body
main.rs
// Copyright 2018 Google Inc. // // 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 //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use std::io::{stdout, BufWriter}; fn main() { let out = b"Hello fellow Rustaceans!"; let width = 24; let mut writer = BufWriter::n...
// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS,
random_line_split
serde_types.rs
use hybrid_clocks::{Timestamp, WallT}; use potboiler_common::{enum_str, types::CRDT}; use serde_derive::{Deserialize, Serialize}; use std::{collections::HashMap, fmt}; enum_str!(Operation { Set("set"), Add("add"), Remove("remove"), Create("create"), }); #[derive(Serialize, Deserialize, Debug, Clone)] ...
pub struct LWWConfigOp { pub crdt: CRDT, } #[derive(Serialize, Deserialize, Debug)] pub struct LWW { pub when: Timestamp<WallT>, pub data: serde_json::Value, } #[derive(Serialize, Deserialize, Debug)] pub struct ORCreateOp {} #[derive(Serialize, Deserialize, Debug)] pub struct ORSetOp { pub item: Str...
#[derive(Serialize, Deserialize, Debug)]
random_line_split
serde_types.rs
use hybrid_clocks::{Timestamp, WallT}; use potboiler_common::{enum_str, types::CRDT}; use serde_derive::{Deserialize, Serialize}; use std::{collections::HashMap, fmt}; enum_str!(Operation { Set("set"), Add("add"), Remove("remove"), Create("create"), }); #[derive(Serialize, Deserialize, Debug, Clone)] ...
{ pub adds: HashMap<String, String>, pub removes: HashMap<String, String>, }
ORSet
identifier_name
ecs_pos_vel_spread.rs
#![feature(test)] extern crate test; extern crate froggy; use test::Bencher; use froggy::{Pointer, Storage};
// it has a custom Velocity component struct Velocity { pub dx: f32, pub dy: f32, } struct Entity { pos: Pointer<Position>, vel: Option<Pointer<Velocity>>, } struct World { pos: Storage<Position>, vel: Storage<Velocity>, entities: Vec<Entity>, } fn build() -> World { let mut world = W...
mod bench_setup; use bench_setup::{Position, N_POS_VEL, N_POS}; // Since component linking is not used in this bench,
random_line_split
ecs_pos_vel_spread.rs
#![feature(test)] extern crate test; extern crate froggy; use test::Bencher; use froggy::{Pointer, Storage}; mod bench_setup; use bench_setup::{Position, N_POS_VEL, N_POS}; // Since component linking is not used in this bench, // it has a custom Velocity component struct Velocity { pub dx: f32, pub dy: f32,...
vel: Some(world.vel.create(Velocity { dx: 0.0, dy: 0.0 })), }); } } } world } #[bench] fn bench_build(b: &mut Bencher) { b.iter(build); } #[bench] fn bench_update(b: &mut Bencher) { let mut world = build(); b.iter(|| { for e in &world...
{ let mut world = World { pos: Storage::with_capacity(N_POS_VEL + N_POS), vel: Storage::with_capacity(N_POS_VEL), entities: Vec::with_capacity(N_POS_VEL + N_POS), }; // setup entities { let pos_spread = (N_POS + N_POS_VEL) / N_POS_VEL; for fx in 1 .. (N_POS_VEL ...
identifier_body
ecs_pos_vel_spread.rs
#![feature(test)] extern crate test; extern crate froggy; use test::Bencher; use froggy::{Pointer, Storage}; mod bench_setup; use bench_setup::{Position, N_POS_VEL, N_POS}; // Since component linking is not used in this bench, // it has a custom Velocity component struct Velocity { pub dx: f32, pub dy: f32,...
(b: &mut Bencher) { b.iter(build); } #[bench] fn bench_update(b: &mut Bencher) { let mut world = build(); b.iter(|| { for e in &world.entities { if let Some(ref vel) = e.vel { let mut p = &mut world.pos[&e.pos]; let v = &world.vel[vel]; p...
bench_build
identifier_name
ecs_pos_vel_spread.rs
#![feature(test)] extern crate test; extern crate froggy; use test::Bencher; use froggy::{Pointer, Storage}; mod bench_setup; use bench_setup::{Position, N_POS_VEL, N_POS}; // Since component linking is not used in this bench, // it has a custom Velocity component struct Velocity { pub dx: f32, pub dy: f32,...
} } world } #[bench] fn bench_build(b: &mut Bencher) { b.iter(build); } #[bench] fn bench_update(b: &mut Bencher) { let mut world = build(); b.iter(|| { for e in &world.entities { if let Some(ref vel) = e.vel { let mut p = &mut world.pos[&e.pos]; ...
{ world.entities.push(Entity { pos: world.pos.create(Position { x: 0.0, y: 0.0 }), vel: Some(world.vel.create(Velocity { dx: 0.0, dy: 0.0 })), }); }
conditional_block
detect_format_change.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use generate_format::Corpus; use serde_reflection::Registry; use std::collections::{btree_map::Entry, BTreeMap}; #[test] fn analyze_serde_formats() { let mut all_corpuses = BTreeMap::new(); for corpus in Corpus::values() { ...
for key in registry.keys() { assert!( expected.contains_key(key), r#" ---- Type `{}` was added and has no recorded format in {} yet.{} ---- "#, key, path, message(name), ); } } #[test] fn test_we_can_detect_changes_in_yaml() { let...
random_line_split
detect_format_change.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use generate_format::Corpus; use serde_reflection::Registry; use std::collections::{btree_map::Entry, BTreeMap}; #[test] fn analyze_serde_formats() { let mut all_corpuses = BTreeMap::new(); for corpus in Corpus::values() { ...
() { let yaml1 = r#"--- Person: ENUM: 0: NickName: NEWTYPE: STR "#; let yaml2 = r#"--- Person: ENUM: 0: NickName: NEWTYPE: STR 1: FullName: UNIT "#; let value1 = serde_yaml::from_str::<Registry>(yaml1).unwrap(); let value2 = serde_y...
test_we_can_detect_changes_in_yaml
identifier_name
detect_format_change.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use generate_format::Corpus; use serde_reflection::Registry; use std::collections::{btree_map::Entry, BTreeMap}; #[test] fn analyze_serde_formats() { let mut all_corpuses = BTreeMap::new(); for corpus in Corpus::values() { ...
fn assert_registry_has_not_changed(name: &str, path: &str, registry: Registry, expected: Registry) { for (key, value) in expected.iter() { assert_eq!( Some(value), registry.get(key), r#" ---- The recorded format for type `{}` was removed or does not match the recorded v...
{ format!( r#" You may run `cargo run -p generate-format -- --corpus {} --record` to refresh the records. Please verify the changes to the recorded file(s) and consider tagging your pull-request as `breaking`."#, name ) }
identifier_body
build.rs
// // Copyright 2021 The Project Oak Authors // // 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 o...
// limitations under the License. // extern crate prost_build; fn main() { let file_paths = [ "oak_functions/proto/abi.proto", "oak_functions/proto/lookup_data.proto", "oak_functions/proto/invocation.proto", ]; prost_build::compile_protos(&file_paths, &["../.."]).expect("Proto comp...
// See the License for the specific language governing permissions and
random_line_split
build.rs
// // Copyright 2021 The Project Oak Authors // // 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 o...
{ let file_paths = [ "oak_functions/proto/abi.proto", "oak_functions/proto/lookup_data.proto", "oak_functions/proto/invocation.proto", ]; prost_build::compile_protos(&file_paths, &["../.."]).expect("Proto compilation failed"); // Tell cargo to rerun this build script if the prot...
identifier_body
build.rs
// // Copyright 2021 The Project Oak Authors // // 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 o...
() { let file_paths = [ "oak_functions/proto/abi.proto", "oak_functions/proto/lookup_data.proto", "oak_functions/proto/invocation.proto", ]; prost_build::compile_protos(&file_paths, &["../.."]).expect("Proto compilation failed"); // Tell cargo to rerun this build script if the p...
main
identifier_name
client.rs
#![deny(warnings)] #![allow(non_snake_case)] #[allow(unused_imports)] use std::vec::Vec; use object; use rest::url; use super::connector::Connector; pub struct GoodDataClient { pub connector: Connector, pub token: Option<String>, pub environment: Option<String>, pub driver: Option<String>, pub u...
(&mut self) { self.disconnect(); } } #[allow(dead_code)] #[allow(unused_variables)] #[allow(unreachable_code)] impl GoodDataClient { /// Create Instance of GoodData Client pub fn new(connector: Connector, token: Option<String>, environment: Option<String>, ...
drop
identifier_name
client.rs
#![deny(warnings)] #![allow(non_snake_case)] #[allow(unused_imports)] use std::vec::Vec; use object; use rest::url; use super::connector::Connector; pub struct GoodDataClient { pub connector: Connector, pub token: Option<String>, pub environment: Option<String>, pub driver: Option<String>, pub u...
let res = self.user.as_ref().unwrap().project_delete(&mut self.connector, project_delete); } pub fn projects_fetch(&mut self) { let projects = self.user.as_ref().unwrap().projects(&mut self.connector); self.projects = match projects { Some(p) => Some(p.projects), ...
None => {} } } pub fn delete_project(&mut self, project_delete: object::Project) {
random_line_split
client.rs
#![deny(warnings)] #![allow(non_snake_case)] #[allow(unused_imports)] use std::vec::Vec; use object; use rest::url; use super::connector::Connector; pub struct GoodDataClient { pub connector: Connector, pub token: Option<String>, pub environment: Option<String>, pub driver: Option<String>, pub u...
pub fn projects_fetch_if_none(&mut self) -> &Vec<object::Project> { match self.projects { Some(ref projects) => projects, None => { self.projects_fetch(); self.projects().as_ref().unwrap() } } } pub fn create_project(&mut...
{ &self.user }
identifier_body
packed-struct-size-xc.rs
// Copyright 2014 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 ...
() { check!(packed::P1S5, 1, 5); check!(packed::P2S6, 2, 6); check!(packed::P2CS8, 2, 8); }
main
identifier_name
packed-struct-size-xc.rs
// Copyright 2014 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 ...
check!(packed::P2S6, 2, 6); check!(packed::P2CS8, 2, 8); }
random_line_split
packed-struct-size-xc.rs
// Copyright 2014 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 ...
{ check!(packed::P1S5, 1, 5); check!(packed::P2S6, 2, 6); check!(packed::P2CS8, 2, 8); }
identifier_body
props.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 dbus::arg::IterAppend; use dbus_tree::{MTSync, MethodErr, PropInfo}; use crate::{ dbus_api::{ api::s...
<E>( i: &mut IterAppend<'_>, _: &PropInfo<'_, MTSync<TData<E>>, TData<E>>, ) -> Result<(), MethodErr> where E: Engine, { i.append(VERSION); Ok(()) } pub fn get_locked_pools<E>( i: &mut IterAppend<'_>, p: &PropInfo<'_, MTSync<TData<E>>, TData<E>>, ) -> Result<(), MethodErr> where E: Engi...
get_version
identifier_name
props.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 dbus::arg::IterAppend; use dbus_tree::{MTSync, MethodErr, PropInfo}; use crate::{ dbus_api::{ api::s...
pub fn get_locked_pools<E>( i: &mut IterAppend<'_>, p: &PropInfo<'_, MTSync<TData<E>>, TData<E>>, ) -> Result<(), MethodErr> where E: Engine, { get_manager_property(i, p, |e| Ok(shared::locked_pools_prop(e))) }
{ i.append(VERSION); Ok(()) }
identifier_body
props.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 dbus::arg::IterAppend;
use crate::{ dbus_api::{ api::shared::{self, get_manager_property}, types::TData, }, engine::Engine, stratis::VERSION, }; pub fn get_version<E>( i: &mut IterAppend<'_>, _: &PropInfo<'_, MTSync<TData<E>>, TData<E>>, ) -> Result<(), MethodErr> where E: Engine, { i.append(V...
use dbus_tree::{MTSync, MethodErr, PropInfo};
random_line_split
sgx.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
} impl Drop for SystemLibModule { fn drop(&mut self) { shutdown() } }
{ sgx_join_threads() }
conditional_block
sgx.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
impl Drop for SystemLibModule { fn drop(&mut self) { shutdown() } }
{ if env!("TVM_NUM_THREADS") != "0" { sgx_join_threads() } }
identifier_body
sgx.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
(&mut self) { shutdown() } }
drop
identifier_name
sgx.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information
* "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 agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS,...
* regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the
random_line_split
cstool.rs
//! Disassembles machine code use std::fmt::Display; use std::fs::File; use std::io; use std::io::prelude::*; use std::process::exit; use std::str::FromStr; use capstone::{self, prelude::*, Arch, Endian, EnumList, ExtraMode, Mode}; use clap::{App, Arg, ArgGroup}; use log::{debug, info}; use stderrlog; const DEFAULT_...
let is_hex = matches.is_present(HEX_ARG) || matches.is_present(CODE_ARG); info!("is_hex = {:?}", is_hex); let show_detail = matches.is_present(DETAIL_ARG); info!("show_detail = {:?}", show_detail); let arch: Arch = Arch::from_str(matches.value_of(ARCH_ARG).unwrap()) .unwrap() .into(...
.unwrap();
random_line_split
cstool.rs
//! Disassembles machine code use std::fmt::Display; use std::fs::File; use std::io; use std::io::prelude::*; use std::process::exit; use std::str::FromStr; use capstone::{self, prelude::*, Arch, Endian, EnumList, ExtraMode, Mode}; use clap::{App, Arg, ArgGroup}; use log::{debug, info}; use stderrlog; const DEFAULT_...
} /// Print register names fn reg_names<T, I>(cs: &Capstone, regs: T) -> String where T: Iterator<Item = I>, I: Into<RegId>, { let names: Vec<String> = regs.map(|x| cs.reg_name(x.into()).unwrap()).collect(); names.join(", ") } /// Print instruction group names fn group_names<T, I>(cs: &Capstone, regs...
{ match self { Ok(t) => t, Err(e) => { eprintln!("error: {}", e); exit(1); } } }
identifier_body
cstool.rs
//! Disassembles machine code use std::fmt::Display; use std::fs::File; use std::io; use std::io::prelude::*; use std::process::exit; use std::str::FromStr; use capstone::{self, prelude::*, Arch, Endian, EnumList, ExtraMode, Mode}; use clap::{App, Arg, ArgGroup}; use log::{debug, info}; use stderrlog; const DEFAULT_...
(self) -> T { match self { Ok(t) => t, Err(e) => { eprintln!("error: {}", e); exit(1); } } } } /// Print register names fn reg_names<T, I>(cs: &Capstone, regs: T) -> String where T: Iterator<Item = I>, I: Into<RegId>, { ...
expect_exit
identifier_name
attribute-spans-preserved.rs
// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] extern crate proc_macro; use proc_macro::*; #[proc_macro_attribute] pub fn
(attr: TokenStream, f: TokenStream) -> TokenStream { let mut tokens = f.into_iter(); assert_eq!(tokens.next().unwrap().to_string(), "#"); let next_attr = match tokens.next().unwrap() { TokenTree::Group(g) => g, _ => panic!(), }; let fn_tok = tokens.next().unwrap(); let ident_tok...
foo
identifier_name
attribute-spans-preserved.rs
// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] extern crate proc_macro; use proc_macro::*; #[proc_macro_attribute] pub fn foo(attr: TokenStream, f: TokenStream) -> TokenStream
Group::new(Delimiter::Brace, new_body.collect()).into(), ].into_iter().collect::<TokenStream>(); println!("{}", tokens); return tokens }
{ let mut tokens = f.into_iter(); assert_eq!(tokens.next().unwrap().to_string(), "#"); let next_attr = match tokens.next().unwrap() { TokenTree::Group(g) => g, _ => panic!(), }; let fn_tok = tokens.next().unwrap(); let ident_tok = tokens.next().unwrap(); let args_tok = token...
identifier_body
attribute-spans-preserved.rs
// force-host // no-prefer-dynamic
#![crate_type = "proc-macro"] extern crate proc_macro; use proc_macro::*; #[proc_macro_attribute] pub fn foo(attr: TokenStream, f: TokenStream) -> TokenStream { let mut tokens = f.into_iter(); assert_eq!(tokens.next().unwrap().to_string(), "#"); let next_attr = match tokens.next().unwrap() { Toke...
random_line_split
cargo.rs
extern crate cargo; extern crate env_logger; extern crate git2_curl; extern crate rustc_serialize; extern crate toml; #[macro_use] extern crate log; use std::collections::BTreeSet; use std::env; use std::fs; use std::io; use std::path::{PathBuf, Path}; use std::process::Command; use cargo::{execute_main_without_stdin...
macro_rules! each_subcommand{ ($mac:ident) => ({ $mac!(bench); $mac!(build); $mac!(clean); $mac!(doc); $mac!(fetch); $mac!(generate_lockfile); $mac!(git_checkout); $mac!(help); $mac!(install); $mac!(locate_project); $mac!(login); $mac!(new); $mac!(owner); $mac!(...
{ env_logger::init().unwrap(); execute_main_without_stdin(execute, true, USAGE) }
identifier_body
cargo.rs
extern crate cargo; extern crate env_logger; extern crate git2_curl; extern crate rustc_serialize; extern crate toml; #[macro_use] extern crate log; use std::collections::BTreeSet; use std::env; use std::fs; use std::io; use std::path::{PathBuf, Path}; use std::process::Command; use cargo::{execute_main_without_stdin...
(path: &Path) -> bool { use std::os::unix::prelude::*; fs::metadata(path).map(|m| { m.permissions().mode() & 0o001 == 0o001 }).unwrap_or(false) } #[cfg(windows)] fn is_executable(path: &Path) -> bool { fs::metadata(path).map(|m| m.is_file()).unwrap_or(false) } /// Get `Command` to run given com...
is_executable
identifier_name
cargo.rs
extern crate cargo; extern crate env_logger; extern crate git2_curl; extern crate rustc_serialize; extern crate toml; #[macro_use] extern crate log; use std::collections::BTreeSet; use std::env; use std::fs; use std::io; use std::path::{PathBuf, Path}; use std::process::Command; use cargo::{execute_main_without_stdin...
let entry = entry.path(); let filename = match entry.file_name().and_then(|s| s.to_str()) { Some(filename) => filename, _ => continue }; if filename.starts_with(command_prefix) && filename.ends_with(env::consts::EXE_SUFFIX) &...
}; for entry in entries { let entry = match entry { Ok(e) => e, Err(..) => continue };
random_line_split
decode.rs
const GREEK_FROM_BETA: [char; 26] = [ '\u{03b1}', // A => alpha '\u{03b2}', // B => beta '\u{03be}', // C => xi '\u{03b4}', // D => delta '\u{03b5}', // E => epsilon '\u{03c6}', // F => phi '\u{03b3}', // G => gamma '\u{03b7}', // H => eta '\u{03b9}', // I => iota '\u{03c2}', // ...
(&mut self) -> Option<char> { self.next_helper() } }
next
identifier_name
decode.rs
const GREEK_FROM_BETA: [char; 26] = [ '\u{03b1}', // A => alpha '\u{03b2}', // B => beta '\u{03be}', // C => xi '\u{03b4}', // D => delta '\u{03b5}', // E => epsilon '\u{03c6}', // F => phi '\u{03b3}', // G => gamma '\u{03b7}', // H => eta '\u{03b9}', // I => iota '\u{03c2}', // ...
'\''=> APOSTROPHE, '-' => HYPHEN, '_' => DASH, ':' => MIDDLE_DOT, '#' => NUMERAL_SIGN, _ => c, } } pub struct BetaDecoding<I: Iterator<Item=char>> { betacode: I, lookahead: Option<char>, breathing: Option<char>, accent: Option<char>, awaiting_upp...
{ match c { 'a' ... 'z' => { const LITTLE_A: usize = 'a' as usize; let index = (c as usize) - LITTLE_A; GREEK_FROM_BETA[index] }, 'A' ... 'Z' => { const BIG_A: usize = 'A' as usize; let index = (c as usize) - BIG_A; GREE...
identifier_body
decode.rs
const GREEK_FROM_BETA: [char; 26] = [ '\u{03b1}', // A => alpha '\u{03b2}', // B => beta '\u{03be}', // C => xi '\u{03b4}', // D => delta '\u{03b5}', // E => epsilon '\u{03c6}', // F => phi '\u{03b3}', // G => gamma '\u{03b7}', // H => eta '\u{03b9}', // I => iota '\u{03c2}', // ...
const MEDIAL_SIGMA: char = '\u{03c3}'; const FINAL_SIGMA: char = '\u{03c2}'; const QUESTION_MARK: char = ';'; // normal semicolon is prefered const APOSTROPHE: char = '\u{2019}'; // right single quotation mark const HYPHEN: char = '\u{2010}'; // TLG says to use this instead of '-' const DASH: char = '\u{2014}'; // em ...
];
random_line_split
opt_vec.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 ...
Vec(ref v1) => { v0.push_all(*v1); } } return Vec(v0); } fn push_all<I: BaseIter<T>>(&mut self, from: &I) { for from.each |e| { self.push(copy *e); } } } impl<A:Eq> Eq for OptVec<A> { fn eq(&self, other: &OptVec<A>) -> bool { // Note: ca...
{}
conditional_block
opt_vec.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 ...
fn ne(&self, other: &OptVec<A>) -> bool { !self.eq(other) } } impl<A> BaseIter<A> for OptVec<A> { fn each(&self, blk: &fn(v: &A) -> bool) { match *self { Empty => {} Vec(ref v) => v.each(blk) } } fn size_hint(&self) -> Option<uint> { Some(se...
{ // Note: cannot use #[deriving(Eq)] here because // (Empty, Vec(~[])) ought to be equal. match (self, other) { (&Empty, &Empty) => true, (&Empty, &Vec(ref v)) => v.is_empty(), (&Vec(ref v), &Empty) => v.is_empty(), (&Vec(ref v1), &Vec(ref v2)) =>...
identifier_body
opt_vec.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 ...
<I: BaseIter<T>>(&mut self, from: &I) { for from.each |e| { self.push(copy *e); } } } impl<A:Eq> Eq for OptVec<A> { fn eq(&self, other: &OptVec<A>) -> bool { // Note: cannot use #[deriving(Eq)] here because // (Empty, Vec(~[])) ought to be equal. match (self,...
push_all
identifier_name
opt_vec.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 ...
impl<T:Copy> OptVec<T> { fn prepend(&self, +t: T) -> OptVec<T> { let mut v0 = ~[t]; match *self { Empty => {} Vec(ref v1) => { v0.push_all(*v1); } } return Vec(v0); } fn push_all<I: BaseIter<T>>(&mut self, from: &I) { for from.each |e| { ...
}
random_line_split
font_context.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 app_units::Au; use fnv::FnvHasher; use font::{Font, FontGroup, FontHandleMethods}; use font_cache_thread::Font...
}; let handle = FontHandle::new_from_template(&self.platform_handle, template, Some(actual_pt_size))?; Ok(Font::new(handle, variant, descriptor, pt_size, actual_pt_size, font_key)) ...
// painting. We should also support true small-caps (where the // font supports it) in the future. let actual_pt_size = match variant { font_variant_caps::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), font_variant_caps::T::normal => pt_size,
random_line_split
font_context.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 app_units::Au; use fnv::FnvHasher; use font::{Font, FontGroup, FontHandleMethods}; use font_cache_thread::Font...
} #[derive(Debug)] struct LayoutFontGroupCacheKey { pointer: ServoArc<style_structs::Font>, size: Au, } impl PartialEq for LayoutFontGroupCacheKey { fn eq(&self, other: &LayoutFontGroupCacheKey) -> bool { self.pointer == other.pointer && self.size == other.size } } impl Eq for LayoutFontGrou...
{ // FIXME(njn): Measure other fields eventually. self.platform_handle.heap_size_of_children() }
identifier_body
font_context.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 app_units::Au; use fnv::FnvHasher; use font::{Font, FontGroup, FontHandleMethods}; use font_cache_thread::Font...
(&self, other: &LayoutFontGroupCacheKey) -> bool { self.pointer == other.pointer && self.size == other.size } } impl Eq for LayoutFontGroupCacheKey {} impl Hash for LayoutFontGroupCacheKey { fn hash<H>(&self, hasher: &mut H) where H: Hasher { self.pointer.hash.hash(hasher) } } #[inline] p...
eq
identifier_name
mem.rs
use core::intrinsics; use core::mem; use core::ptr; /// This replaces the value behind the `v` unique reference by calling the /// relevant function. /// /// If a panic occurs in the `change` closure, the entire process will be aborted. #[allow(dead_code)] // keep as illustration and for future use #[inline] pub fn ta...
} let guard = PanicGuard; let value = unsafe { ptr::read(v) }; let (new_value, ret) = change(value); unsafe { ptr::write(v, new_value); } mem::forget(guard); ret }
{ intrinsics::abort() }
identifier_body
mem.rs
use core::intrinsics; use core::mem; use core::ptr; /// This replaces the value behind the `v` unique reference by calling the /// relevant function. /// /// If a panic occurs in the `change` closure, the entire process will be aborted. #[allow(dead_code)] // keep as illustration and for future use #[inline] pub fn ta...
}
random_line_split
mem.rs
use core::intrinsics; use core::mem; use core::ptr; /// This replaces the value behind the `v` unique reference by calling the /// relevant function. /// /// If a panic occurs in the `change` closure, the entire process will be aborted. #[allow(dead_code)] // keep as illustration and for future use #[inline] pub fn ta...
(&mut self) { intrinsics::abort() } } let guard = PanicGuard; let value = unsafe { ptr::read(v) }; let (new_value, ret) = change(value); unsafe { ptr::write(v, new_value); } mem::forget(guard); ret }
drop
identifier_name
MoTSA.rs
// pub fn find_median_sorted_arrays(nums1: Vec<i32>, nums2: Vec<i32>) -> f64 { // let (l1, l2) = (nums1.len() as f32, nums2.len() as f32); // let l = ((l1 + l2) / 2_f32).floor() as usize; // dbg!(l); // if l == 0 { // if l1 > l2 { // return nums1[0] as f64; // } else { // ...
{ assert_eq!(find_median_sorted_arrays(vec![1, 3], vec![2]), 2.0); assert_eq!(find_median_sorted_arrays(vec![1, 2], vec![3, 4]), 2.5); assert_eq!(find_median_sorted_arrays(vec![0, 0], vec![0, 0]), 0.0); assert_eq!(find_median_sorted_arrays(vec![], vec![1]), 1.0); assert_eq!(find_median_sorted_arrays...
identifier_body
MoTSA.rs
// pub fn find_median_sorted_arrays(nums1: Vec<i32>, nums2: Vec<i32>) -> f64 { // let (l1, l2) = (nums1.len() as f32, nums2.len() as f32); // let l = ((l1 + l2) / 2_f32).floor() as usize; // dbg!(l); // if l == 0 { // if l1 > l2 { // return nums1[0] as f64; // } else { // ...
else { *n.nth(l).unwrap() as f64 } } fn main() { assert_eq!(find_median_sorted_arrays(vec![1, 3], vec![2]), 2.0); assert_eq!(find_median_sorted_arrays(vec![1, 2], vec![3, 4]), 2.5); assert_eq!(find_median_sorted_arrays(vec![0, 0], vec![0, 0]), 0.0); assert_eq!(find_median_sorted_arrays(vec...
{ (*n.nth(l - 1).unwrap() as f64 + *n.next().unwrap() as f64) / 2_f64 }
conditional_block