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
mod.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
mod fetch; mod miner_service; mod snapshot_service; mod sync_provider; mod update_service; pub use self::dapps::TestDappsService; pub use self::fetch::TestFetch; pub use self::miner_service::TestMinerService; pub use self::snapshot_service::TestSnapshotService; pub use self::sync_provider::{Config, TestSyncProvider}; ...
// along with Parity. If not, see <http://www.gnu.org/licenses/>. //! Test rpc services. mod dapps;
random_line_split
data.rs
indirect_function", name = "indirect-function")] pub fn indirect_function_lisp(object: LispObject, _noerror: LispObject) -> LispObject { match object.as_symbol() { None => object, Some(symbol) => symbol.get_indirect_function(), } } /// Return a symbol representing the type of OBJECT. /// The sy...
symbol_redirect::SYMBOL_FORWARDED => unsafe { let valcontents = symbol.get_fwd(); // For a built-in buffer-local variable, get the default value // rather than letting do_symval_forwarding get the current value. if let Some(buffer_objfwd) = as_buffer_objfwd(valco...
{ while symbol.get_redirect() == symbol_redirect::SYMBOL_VARALIAS { symbol = symbol.get_indirect_variable(); } match symbol.get_redirect() { symbol_redirect::SYMBOL_PLAINVAL => unsafe { symbol.get_value() }, symbol_redirect::SYMBOL_LOCALIZED => { // If var is set up for a...
identifier_body
data.rs
indirect_function", name = "indirect-function")] pub fn indirect_function_lisp(object: LispObject, _noerror: LispObject) -> LispObject { match object.as_symbol() { None => object, Some(symbol) => symbol.get_indirect_function(), } } /// Return a symbol representing the type of OBJECT. /// The sy...
(valcontents: *const Lisp_Fwd) -> LispObject { match (*valcontents).u_intfwd.ty { Lisp_Fwd_Int => LispObject::from(*(*valcontents).u_intfwd.intvar), Lisp_Fwd_Bool => LispObject::from(*(*valcontents).u_boolfwd.boolvar), Lisp_Fwd_Obj => (*(*valcontents).u_objfwd.objvar), Lisp_Fwd_Buffe...
do_symval_forwarding
identifier_name
data.rs
"indirect_function", name = "indirect-function")] pub fn indirect_function_lisp(object: LispObject, _noerror: LispObject) -> LispObject { match object.as_symbol() { None => object, Some(symbol) => symbol.get_indirect_function(), } } /// Return a symbol representing the type of OBJECT. /// The ...
} else if let Some(v) = array.as_vector() { if idx_u >= v.len() { args_out_of_range!(array, idx); } unsafe { v.get_unchecked(idx_u) } } else if array.is_byte_code_function() || array.is_record() { let vl = array.as_vectorlike().unwrap(); if idx >= vl.pseudovec...
} else if let Some(ct) = array.as_char_table() { ct.get(idx as isize)
random_line_split
data.rs
indirect_function", name = "indirect-function")] pub fn indirect_function_lisp(object: LispObject, _noerror: LispObject) -> LispObject { match object.as_symbol() { None => object, Some(symbol) => symbol.get_indirect_function(), } } /// Return a symbol representing the type of OBJECT. /// The sy...
else { let (_, d) = blv.defcell.into(); d } } symbol_redirect::SYMBOL_FORWARDED => unsafe { let valcontents = symbol.get_fwd(); // For a built-in buffer-local variable, get the default value // rather than letting do_symva...
{ unsafe { do_symval_forwarding(fwd) } }
conditional_block
mod.rs
mod configuration; mod transition; pub mod automaton; pub mod from_str; #[macro_use] pub mod coarse_to_fine; use crate::util::push_down::Pushdown; use search::agenda::weighted::Weighted; use std::vec::Vec; pub use self::configuration::Configuration; pub use self::transition::Transition; /// Something we can `apply`...
} } /// Something that recognises words and output corresponding parses. pub trait Recognisable<T, W> { // TODO rename to Recogniser type Parse; fn recognise<'a>(&'a self, word: Vec<T>) -> Box<dyn Iterator<Item = Self::Parse> + 'a>; fn recognise_beam_search<'a>( &'a self, beam: us...
impl<S, I: Instruction<Storage = S>, T, W: Clone> Weighted for Item<S, I, T, W> { type Weight = W; fn get_weight(&self) -> W { self.0.weight.clone()
random_line_split
mod.rs
mod configuration; mod transition; pub mod automaton; pub mod from_str; #[macro_use] pub mod coarse_to_fine; use crate::util::push_down::Pushdown; use search::agenda::weighted::Weighted; use std::vec::Vec; pub use self::configuration::Configuration; pub use self::transition::Transition; /// Something we can `apply`...
(&self) -> W { self.0.weight.clone() } } /// Something that recognises words and output corresponding parses. pub trait Recognisable<T, W> { // TODO rename to Recogniser type Parse; fn recognise<'a>(&'a self, word: Vec<T>) -> Box<dyn Iterator<Item = Self::Parse> + 'a>; fn recognise_beam_s...
get_weight
identifier_name
parser.rs
extern crate thunderdome; #[cfg(test)] mod parser_tests { use thunderdome::parser::*; fn
(q: &str) -> Option<ParsedGraphQuery> { let result = pre_parse(q); assert!(result.is_ok()); result.ok() } #[test] fn global_graph_query() { validate("g.V()"); } #[test] fn vertex_query() { validate("g.v(1)"); validate("g.v(1,2)"); validat...
validate
identifier_name
parser.rs
extern crate thunderdome; #[cfg(test)]
mod parser_tests { use thunderdome::parser::*; fn validate(q: &str) -> Option<ParsedGraphQuery> { let result = pre_parse(q); assert!(result.is_ok()); result.ok() } #[test] fn global_graph_query() { validate("g.V()"); } #[test] fn vertex_query() { ...
random_line_split
parser.rs
extern crate thunderdome; #[cfg(test)] mod parser_tests { use thunderdome::parser::*; fn validate(q: &str) -> Option<ParsedGraphQuery> { let result = pre_parse(q); assert!(result.is_ok()); result.ok() } #[test] fn global_graph_query() { validate("g.V()"); } ...
, _ => { panic!("OH NOES")} } } }
{ }
conditional_block
parser.rs
extern crate thunderdome; #[cfg(test)] mod parser_tests { use thunderdome::parser::*; fn validate(q: &str) -> Option<ParsedGraphQuery> { let result = pre_parse(q); assert!(result.is_ok()); result.ok() } #[test] fn global_graph_query() { validate("g.V()"); } ...
}
{ // maybe a weird offset command? validate("g.V().limit(10, 20)"); let result = validate("g.V().limit(10.0)").unwrap(); match result.steps.get(1).unwrap().args.get(0).unwrap() { &Arg::Float(ref x) if *x == 10.0 => { }, _ => { panic!("OH NOES")} } }
identifier_body
imports.rs
// Copyright 2015 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 ...
else { format!("{} as {}", path_str, ident_str) }) } } } } impl<'a> FmtVisitor<'a> { pub fn format_imports(&mut self, use_items: &[ptr::P<ast::Item>]) { // Find the location immediately before the first use item in the run. This must not lie ...
{ path_str }
conditional_block
imports.rs
// Copyright 2015 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_items: &Vec<ast::PathListItem>, b_items: &Vec<ast::PathListItem>) -> Ordering { let mut a = a_items.clone(); let mut b = b_items.clone(); a.sort_by(|a, b| compare_path_list_items(a, b)); b.sort_by(|a, b| compare_path_list_items(a, b)); ...
compare_path_list_item_lists
identifier_name
imports.rs
// Copyright 2015 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 append_alias(path_item_str: String, vpi: &ast::PathListItem) -> String { match vpi.node { ast::PathListItemKind::Ident { rename: Some(rename),.. } | ast::PathListItemKind::Mod { rename: Some(rename),.. } => { format!("{} as {}", path_item_str, rename) } _ => path_ite...
{ let path_item_str = match vpi.node { ast::PathListItemKind::Ident { name, .. } => name.to_string(), ast::PathListItemKind::Mod { .. } => "self".to_owned(), }; Some(append_alias(path_item_str, vpi)) }
identifier_body
imports.rs
// Copyright 2015 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 ...
}
random_line_split
mat33.rs
use super::Vec2; use super::Vec3; /// A 3-by-3 matrix. Stored in column-major order. pub struct Mat33 { pub ex: Vec3, pub ey: Vec3, pub ez: Vec3 } impl Mat33 { pub fn new() -> Mat33 { Mat33 { ex: Vec3::new(0.0, 0.0, 0.0), ey: Vec3::new(0.0, 0.0, 0.0), ez: Ve...
(c1: Vec3, c2: Vec3, c3: Vec3) -> Mat33 { Mat33 { ex: c1, ey: c2, ez: c3 } } /// Set this matrix to all zeros. pub fn set_zero(&mut self) { self.ex.set_zero(); self.ey.set_zero(); self.ez.set_zero(); } /// Solve A * x = b,...
new_columns
identifier_name
mat33.rs
use super::Vec2; use super::Vec3; /// A 3-by-3 matrix. Stored in column-major order. pub struct Mat33 { pub ex: Vec3, pub ey: Vec3, pub ez: Vec3 } impl Mat33 { pub fn new() -> Mat33 { Mat33 { ex: Vec3::new(0.0, 0.0, 0.0), ey: Vec3::new(0.0, 0.0, 0.0), ez: Ve...
let b = self.ey.x; let c = self.ex.y; let d = self.eu.y; let mut det = a * d - b * c; if det!= 0.0 { det = 1.0 / det; } let m = Mat33::new(); m.ex.x = det * d; m.ey.x = -det * b; m.ex.z = 0.0; m.ex.y = -det * c; m.ey.y = det * a; m.ey...
/// pub fn get_inverse22(&self) -> Mat33 { let a = self.ex.x;
random_line_split
mat33.rs
use super::Vec2; use super::Vec3; /// A 3-by-3 matrix. Stored in column-major order. pub struct Mat33 { pub ex: Vec3, pub ey: Vec3, pub ez: Vec3 } impl Mat33 { pub fn new() -> Mat33 { Mat33 { ex: Vec3::new(0.0, 0.0, 0.0), ey: Vec3::new(0.0, 0.0, 0.0), ez: Ve...
/// Solve A * x = b, where b is a column vector. This is more efficient /// than computing the inverse in one-shot cases. pub fn solve33(&self, b: Vec3) -> Vec3 { let mut det = Vec3::dot(self.ex, Vec3::cross(self.ey, self.ez)); if det!= 0.0 { det = 1.0 / det; } ...
{ self.ex.set_zero(); self.ey.set_zero(); self.ez.set_zero(); }
identifier_body
mat33.rs
use super::Vec2; use super::Vec3; /// A 3-by-3 matrix. Stored in column-major order. pub struct Mat33 { pub ex: Vec3, pub ey: Vec3, pub ez: Vec3 } impl Mat33 { pub fn new() -> Mat33 { Mat33 { ex: Vec3::new(0.0, 0.0, 0.0), ey: Vec3::new(0.0, 0.0, 0.0), ez: Ve...
let x = det * (a22 * b.x - a12 * b.y); let y = det * (a11 * b.y - a21 * b.x); Vec2::new(x, y) } /// pub fn get_inverse22(&self) -> Mat33 { let a = self.ex.x; let b = self.ey.x; let c = self.ex.y; let d = self.eu.y; let mut det = a * d - b * c...
{ det = 1.0 / det; }
conditional_block
reader.rs
//! Read points from an.sdc file. use std::fs::File; use std::iter::IntoIterator; use std::io::{BufReader, Read}; use std::path::Path; use std::str; use byteorder; use byteorder::{LittleEndian, ReadBytesExt}; use error::Error; use point::{Point, TargetType}; use result::Result; /// An object for readings.sdc points...
Ok(Reader { reader: reader, version: Version { major: major, minor: minor, }, header_information: header_information, }) } /// Reads the next point from the underlying `Read`. /// /// # Examples /// /// ``` /// use sdc::reader::Reader; ...
{ return Err(Error::InvalidHeaderInformation); }
conditional_block
reader.rs
//! Read points from an.sdc file. use std::fs::File; use std::iter::IntoIterator; use std::io::{BufReader, Read}; use std::path::Path; use std::str; use byteorder; use byteorder::{LittleEndian, ReadBytesExt}; use error::Error; use point::{Point, TargetType}; use result::Result; /// An object for readings.sdc points...
(&mut self) -> Result<Option<Point>> { // Technically we should just check the first byte instead of the first four, but the work // required to do that doesn't seem worth it at the moment. let time = match self.reader.read_f64::<LittleEndian>() { Ok(time) => time, Err(by...
next_point
identifier_name
reader.rs
//! Read points from an.sdc file. use std::fs::File; use std::iter::IntoIterator; use std::io::{BufReader, Read}; use std::path::Path; use std::str; use byteorder; use byteorder::{LittleEndian, ReadBytesExt}; use error::Error; use point::{Point, TargetType}; use result::Result; /// An object for readings.sdc points...
/// Reads the next point from the underlying `Read`. /// /// # Examples /// /// ``` /// use sdc::reader::Reader; /// let mut reader = Reader::from_path("data/4-points-5.0.sdc").unwrap(); /// let point = reader.next_point(); /// ``` pub fn next_point(&mut self) -> Result<Option<P...
}
random_line_split
reader.rs
//! Read points from an.sdc file. use std::fs::File; use std::iter::IntoIterator; use std::io::{BufReader, Read}; use std::path::Path; use std::str; use byteorder; use byteorder::{LittleEndian, ReadBytesExt}; use error::Error; use point::{Point, TargetType}; use result::Result; /// An object for readings.sdc points...
let mut class_id = None; let mut rho = None; let mut reflectance = None; if self.version.major >= 5 && self.version.minor >= 2 { class_id = Some(try!(self.reader.read_u8())); } // These 5.3 and 5.4 reads are untested, since I don't have a real-world sample fil...
{ // Technically we should just check the first byte instead of the first four, but the work // required to do that doesn't seem worth it at the moment. let time = match self.reader.read_f64::<LittleEndian>() { Ok(time) => time, Err(byteorder::Error::UnexpectedEOF) => ret...
identifier_body
moves-based-on-type-block-bad.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 ...
{ Foo(Box<S>), Bar(Box<isize>), Baz } fn f<G>(s: &S, g: G) where G: FnOnce(&S) { g(s) } fn main() { let s = S { x: box E::Bar(box 42) }; loop { f(&s, |hellothere| { match hellothere.x { //~ ERROR cannot move out box E::Foo(_) => {} box E::Ba...
E
identifier_name
moves-based-on-type-block-bad.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 ...
} }) } }
{}
conditional_block
moves-based-on-type-block-bad.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 ...
{ let s = S { x: box E::Bar(box 42) }; loop { f(&s, |hellothere| { match hellothere.x { //~ ERROR cannot move out box E::Foo(_) => {} box E::Bar(x) => println!("{}", x.to_string()), //~ NOTE attempting to move value to here box E::Baz => {} ...
identifier_body
moves-based-on-type-block-bad.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// option. This file may not be copied, modified, or distributed // except according to those terms. // ignore-tidy-linelength #![feature(box_syntax)] struct S { x: Box<E> } enum E { Foo(Box<S>), Bar(Box<isize>), Baz } fn f<G>(s: &S, g: G) where G: FnOnce(&S) { g(s) } fn main() { let s = S...
// 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 http://opensource.org/licenses/MIT>, at your
random_line_split
frontend.rs
use std::io::{Read, Write, Stdin, stdin, Stdout, stdout}; use std::ops::Drop; use termion; use termion::{clear, color}; use termion::raw::IntoRawMode; use left_pad::leftpad; use cursor::Cursor; // The Frontend is responsible for rendering the state of the editor // to the screen and interacting with the user. pub stru...
(&mut self, x: u16, y: u16) { write!(self.stdout, "{}", termion::cursor::Goto(x+1, y+1)).unwrap(); } /// Moves the cursor to the position specified by the Cursor pub fn move_cursor(&mut self, cursor: &Cursor) { let (_, height) = self.terminal_size(); let x = (cursor.column + 4) as u1...
goto_term
identifier_name
frontend.rs
use std::io::{Read, Write, Stdin, stdin, Stdout, stdout}; use std::ops::Drop; use termion; use termion::{clear, color}; use termion::raw::IntoRawMode; use left_pad::leftpad; use cursor::Cursor; // The Frontend is responsible for rendering the state of the editor // to the screen and interacting with the user. pub stru...
} } /// Flushes stdout to make the changes show pub fn flush(&mut self) { self.stdout.flush().unwrap(); } /// Hides the cursor pub fn hide_cursor(&mut self) { write!(self.stdout, "{}", termion::cursor::Hide{}).unwrap(); } /// Shows the cursor pub fn show_curs...
{ // Draw a ~ to show that there is no line. write!(self.stdout, "{} ~{}", color::Fg(color::Cyan), color::Fg(color::Reset), ).unwrap(); }
conditional_block
frontend.rs
use std::io::{Read, Write, Stdin, stdin, Stdout, stdout}; use std::ops::Drop; use termion; use termion::{clear, color}; use termion::raw::IntoRawMode; use left_pad::leftpad; use cursor::Cursor; // The Frontend is responsible for rendering the state of the editor // to the screen and interacting with the user. pub stru...
// Get one byte of input let mut b = [0; 1]; self.stdin.read_exact(&mut b[..]).unwrap(); match b[0] { 0 | 3 | 4 => return None, // 0x7f is backspace 0x7f if!buf.is_empty() => { // Delete the last characte...
fn read_line(&mut self) -> Option<String> { // Start with a buffer of size 40 so that small inputs don't require // reallocating the buffer. let mut buf = Vec::with_capacity(30); loop {
random_line_split
error.rs
//! rzw specific error types //! //! These error type is compatible with the rust standard io `ErrorKind`. pub type Result<T> = std::result::Result<T, Error>; /// Categories of errors that can occur when interacting with z-Wave. /// /// This list is intended to grow over time and it is not recommended to exhaustively...
} impl std::fmt::Display for Error { /// How to print the error fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> { fmt.write_str(&self.description) } } impl std::error::Error for Error { /// Get the error description fn description(&self) -> &str { ...
{ self.kind }
identifier_body
error.rs
//! rzw specific error types //! //! These error type is compatible with the rust standard io `ErrorKind`. pub type Result<T> = std::result::Result<T, Error>; /// Categories of errors that can occur when interacting with z-Wave. /// /// This list is intended to grow over time and it is not recommended to exhaustively...
{ kind: ErrorKind, description: String, } impl Error { /// Create a new error with a given type and description pub fn new<T: Into<String>>(kind: ErrorKind, description: T) -> Self { Error { kind: kind, description: description.into(), } } /// Returns t...
Error
identifier_name
error.rs
//! rzw specific error types //! //! These error type is compatible with the rust standard io `ErrorKind`. pub type Result<T> = std::result::Result<T, Error>; /// Categories of errors that can occur when interacting with z-Wave. /// /// This list is intended to grow over time and it is not recommended to exhaustively...
} impl std::fmt::Display for Error { /// How to print the error fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> { fmt.write_str(&self.description) } } impl std::error::Error for Error { /// Get the error description fn description(&self) -> &str { ...
/// Returns the corresponding `ErrorKind` for this error. pub fn kind(&self) -> ErrorKind { self.kind }
random_line_split
encryption.rs
use std::fs::{File, remove_file}; use std::io::{ErrorKind, Read, Write}; use hyper::Client as HyperClient; use rusoto_core::{ ChainProvider, DispatchSignedRequest, ProvideAwsCredentials, Region, default_tls_client, }; use rusoto_kms::{ DecryptError, DecryptRequest, DecryptResponse, ...
( provider: ChainProvider, region: Region, kms_master_key_id: Option<&'a str>, ) -> Encryptor<'a, ChainProvider, HyperClient> { Encryptor { client: KmsClient::new( default_tls_client().expect("failed to create HTTP client with TLS"), provid...
new
identifier_name
encryption.rs
use std::fs::{File, remove_file}; use std::io::{ErrorKind, Read, Write}; use hyper::Client as HyperClient; use rusoto_core::{ ChainProvider, DispatchSignedRequest, ProvideAwsCredentials, Region, default_tls_client, }; use rusoto_kms::{ DecryptError, DecryptRequest, DecryptResponse, ...
pub fn decrypt_file(&mut self, source: &str) -> Result<Vec<u8>, KawsError> { let mut src = File::open(source)?; let mut encoded_data = String::new(); src.read_to_string(&mut encoded_data)?; let encrypted_data = encoded_data.from_base64()?; let decrypted_data = self.decry...
{ Encryptor { client: KmsClient::new( default_tls_client().expect("failed to create HTTP client with TLS"), provider, region, ), decrypted_files: vec![], kms_master_key_id: kms_master_key_id, } }
identifier_body
encryption.rs
use std::fs::{File, remove_file}; use std::io::{ErrorKind, Read, Write}; use hyper::Client as HyperClient; use rusoto_core::{ ChainProvider, DispatchSignedRequest, ProvideAwsCredentials, Region, default_tls_client, }; use rusoto_kms::{ DecryptError, DecryptRequest, DecryptResponse, ...
impl<'a, P, D> Drop for Encryptor<'a, P, D> where P: ProvideAwsCredentials, D: DispatchSignedRequest { fn drop(&mut self) { let mut failures = vec![]; for file in self.decrypted_files.iter() { log_wrap!(&format!("Removing unencrypted file {:?}", file), { if let Err(error...
} }
random_line_split
digest_ext_table_test.rs
extern crate veye_checker; use veye_checker::digest_ext_table::{DigestExtTable, DigestAlgo}; #[test] fn test_digest_ext_table_init_with_default_values(){ let ext_tbl = DigestExtTable::default(); assert!(ext_tbl.is_md5("whl".to_string())); assert!(ext_tbl.is_sha1("jar".to_string())); assert!(ext_tbl.i...
let mut ext_tbl = DigestExtTable::default(); let file_ext = "tjar".to_string(); assert!(ext_tbl.add(DigestAlgo::Md5, file_ext.clone())); assert!(ext_tbl.is_md5(file_ext)) } #[test] fn test_digest_ext_table_adding_new_extension_into_sha1(){ let mut ext_tbl = DigestExtTable::default(); let file_...
#[test] fn test_digest_ext_table_adding_new_extension_into_md5(){
random_line_split
digest_ext_table_test.rs
extern crate veye_checker; use veye_checker::digest_ext_table::{DigestExtTable, DigestAlgo}; #[test] fn test_digest_ext_table_init_with_default_values(){ let ext_tbl = DigestExtTable::default(); assert!(ext_tbl.is_md5("whl".to_string())); assert!(ext_tbl.is_sha1("jar".to_string())); assert!(ext_tbl.i...
#[test] fn test_digest_ext_table_swipes_default_table(){ let mut ext_tbl = DigestExtTable::default(); assert!(ext_tbl.swipe()) }
{ let mut ext_tbl = DigestExtTable::default(); let file_ext = "tnupkg".to_string(); assert!(ext_tbl.add(DigestAlgo::Sha512, file_ext.clone())); assert!(ext_tbl.is_sha512(file_ext)) }
identifier_body
digest_ext_table_test.rs
extern crate veye_checker; use veye_checker::digest_ext_table::{DigestExtTable, DigestAlgo}; #[test] fn test_digest_ext_table_init_with_default_values(){ let ext_tbl = DigestExtTable::default(); assert!(ext_tbl.is_md5("whl".to_string())); assert!(ext_tbl.is_sha1("jar".to_string())); assert!(ext_tbl.i...
(){ let mut ext_tbl = DigestExtTable::default(); let file_ext = "tjar".to_string(); assert!(ext_tbl.add(DigestAlgo::Md5, file_ext.clone())); assert!(ext_tbl.is_md5(file_ext)) } #[test] fn test_digest_ext_table_adding_new_extension_into_sha1(){ let mut ext_tbl = DigestExtTable::default(); let f...
test_digest_ext_table_adding_new_extension_into_md5
identifier_name
material_query_resolvers.rs
// use eyre::{ // // eyre, // Result, // // Context as _, // }; use async_graphql::{ ID, Context, FieldResult, }; use printspool_json_store::Record as _; use crate::{ Material, }; #[derive(async_graphql::InputObject, Default)] pub struct MaterialsInput { #[graphql(name = "materialID")]...
else { Material::get_all(db, false).await? }; Ok(materials) } }
{ let material = Material::get(db, &id, false).await?; vec![material] }
conditional_block
material_query_resolvers.rs
// // Context as _, // }; use async_graphql::{ ID, Context, FieldResult, }; use printspool_json_store::Record as _; use crate::{ Material, }; #[derive(async_graphql::InputObject, Default)] pub struct MaterialsInput { #[graphql(name = "materialID")] material_id: Option<ID>, } #[derive(Defa...
// use eyre::{ // // eyre, // Result,
random_line_split
material_query_resolvers.rs
// use eyre::{ // // eyre, // Result, // // Context as _, // }; use async_graphql::{ ID, Context, FieldResult, }; use printspool_json_store::Record as _; use crate::{ Material, }; #[derive(async_graphql::InputObject, Default)] pub struct
{ #[graphql(name = "materialID")] material_id: Option<ID>, } #[derive(Default)] pub struct MaterialQuery; #[async_graphql::Object] impl MaterialQuery { async fn materials<'ctx>( &self, ctx: &'ctx Context<'_>, #[graphql(default)] input: MaterialsInput, ) -> FieldResult...
MaterialsInput
identifier_name
lib.rs
//! `primal` puts raw power into prime numbers. //! //! This crates includes //! //! - optimised prime sieves //! - checking for primality //! - enumerating primes //! - factorising numbers //! - estimating upper and lower bounds for π(*n*) (the number of primes //! below *n*) and *p<sub>k</sub>* (the <i>k</i>th prim...
b.iter(|| { let sieve = Sieve::new(1_000_000); (1..N).step_by(STEP) .filter(|&n| sieve.is_prime(n)).count() }) } }
identifier_body
lib.rs
//! `primal` puts raw power into prime numbers. //! //! This crates includes //! //! - optimised prime sieves //! - checking for primality //! - enumerating primes //! - factorising numbers //! - estimating upper and lower bounds for π(*n*) (the number of primes //! below *n*) and *p<sub>k</sub>* (the <i>k</i>th prim...
&mut Bencher) { b.iter(|| { let sieve = Sieve::new(1_000_000); (1..N).step_by(STEP) .filter(|&n| sieve.is_prime(n)).count() }) } }
ch_sieve_tests(b:
identifier_name
lib.rs
//! `primal` puts raw power into prime numbers. //! //! This crates includes //! //! - optimised prime sieves //! - checking for primality //! - enumerating primes //! - factorising numbers //! - estimating upper and lower bounds for π(*n*) (the number of primes //! below *n*) and *p<sub>k</sub>* (the <i>k</i>th prim...
let sieve = Sieve::new(1_000_000); (1..N).step_by(STEP) .filter(|&n| sieve.is_prime(n)).count() }) } }
#[bench] fn bench_sieve_tests(b: &mut Bencher) { b.iter(|| {
random_line_split
backtrace.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 ...
// `size_of::<SYMBOL_INFO>() - MAX_SYM_NAME + 1` (== 81) // due to struct alignment. info.SizeOfStruct = 88; let mut displacement = 0u64; let ret = SymFromAddr(process, addr as u64, &mut displacement, &mut info); if ret == libc::TRUE { ...
random_line_split
backtrace.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 ...
{ ContextFlags: libc::DWORD, Dr0: libc::DWORD, Dr1: libc::DWORD, Dr2: libc::DWORD, Dr3: libc::DWORD, Dr6: libc::DWORD, Dr7: libc::DWORD, FloatSave: FLOATING_SAVE_AREA, SegGs: libc::DWORD, SegFs: libc::DWORD, SegEs: libc::DWORD, ...
CONTEXT
identifier_name
backtrace.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 ...
// Fetch the symbols necessary from dbghelp.dll let SymFromAddr = sym!("SymFromAddr", SymFromAddrFn); let SymInitialize = sym!("SymInitialize", SymInitializeFn); let SymCleanup = sym!("SymCleanup", SymCleanupFn); let StackWalk64 = sym!("StackWalk64", StackWalk64Fn); // Allocate necessary struc...
{ // According to windows documentation, all dbghelp functions are // single-threaded. static LOCK: StaticMutex = StaticMutex::new(); let _g = LOCK.lock(); // Open up dbghelp.dll, we don't link to it explicitly because it can't // always be found. Additionally, it's nice having fewer dependenci...
identifier_body
linkage1.rs
// run-pass // ignore-windows // ignore-macos // ignore-emscripten doesn't support this linkage // ignore-sgx weak linkage not permitted // aux-build:linkage1.rs #![feature(linkage)] extern crate linkage1 as other; extern "C" { #[linkage = "extern_weak"] static foo: *const isize; #[linkage = "extern_weak...
// library unless it satisfies a non weak undefined symbol. The 'other' crate // is compiled as a dynamic library where it would only be used for a // weak-symbol as part of an executable, so the dynamic library would be // discarded. By adding and calling `other::bar`, we get around this problem. o...
fn main() { // It appears that the --as-needed flag to linkers will not pull in a dynamic
random_line_split
linkage1.rs
// run-pass // ignore-windows // ignore-macos // ignore-emscripten doesn't support this linkage // ignore-sgx weak linkage not permitted // aux-build:linkage1.rs #![feature(linkage)] extern crate linkage1 as other; extern "C" { #[linkage = "extern_weak"] static foo: *const isize; #[linkage = "extern_weak...
() { // It appears that the --as-needed flag to linkers will not pull in a dynamic // library unless it satisfies a non weak undefined symbol. The 'other' crate // is compiled as a dynamic library where it would only be used for a // weak-symbol as part of an executable, so the dynamic library would be ...
main
identifier_name
linkage1.rs
// run-pass // ignore-windows // ignore-macos // ignore-emscripten doesn't support this linkage // ignore-sgx weak linkage not permitted // aux-build:linkage1.rs #![feature(linkage)] extern crate linkage1 as other; extern "C" { #[linkage = "extern_weak"] static foo: *const isize; #[linkage = "extern_weak...
{ // It appears that the --as-needed flag to linkers will not pull in a dynamic // library unless it satisfies a non weak undefined symbol. The 'other' crate // is compiled as a dynamic library where it would only be used for a // weak-symbol as part of an executable, so the dynamic library would be ...
identifier_body
pixel.rs
/* * Copyright 2016 Mattis Marjak * * 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 t...
}
{ self.fmt_w_prefix(f, "") }
identifier_body
pixel.rs
/* * Copyright 2016 Mattis Marjak * * 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 t...
use std::fmt; #[cfg(target_os = "freebsd")] use libc::size_t; #[cfg(not(target_os = "freebsd"))] use size_t; use bindings; use result::MagickError; use crate::result::Result; #[derive(Default, Debug)] pub struct HSL { pub hue: f64, pub saturation: f64, pub lightness: f64, } wand_common!( PixelWand,...
* See the License for the specific language governing permissions and * limitations under the License. */ use std::ffi::{CStr, CString};
random_line_split
pixel.rs
/* * Copyright 2016 Mattis Marjak * * 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 t...
(&self, other: &PixelWand, fuzz: f64) -> Result<()> { match unsafe { bindings::IsPixelWandSimilar(self.wand, other.wand, fuzz) } { bindings::MagickBooleanType_MagickTrue => Ok(()), _ => Err(MagickError("not similar")), } } pub fn get_hsl(&self) -> HSL { let mut h...
is_similar
identifier_name
dom_apis.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/. */ //! Generic implementations of some DOM APIs so they can be shared between Servo //! and Gecko. use context::Quir...
; for selector in self.selector_list.0.iter() { target_vector.push(Invalidation::new(selector, 0)) } false } fn matching_context(&mut self) -> &mut MatchingContext<'a, E::Impl> { &mut self.matching_context } fn should_process_descendants(&mut self, _: E) -...
{ self_invalidations }
conditional_block
dom_apis.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/. */ //! Generic implementations of some DOM APIs so they can be shared between Servo //! and Gecko. use context::Quir...
fn is_empty(output: &Self::Output) -> bool { output.is_empty() } } /// A query for the first in-tree match of all the elements in a subtree. pub struct QueryFirst; impl<E: TElement> SelectorQuery<E> for QueryFirst { type Output = Option<E>; fn should_stop_after_first_match() -> bool { true ...
{ output.push(element); }
identifier_body
dom_apis.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/. */ //! Generic implementations of some DOM APIs so they can be shared between Servo //! and Gecko. use context::Quir...
(&mut self, _: E) -> bool { if Q::should_stop_after_first_match() { return Q::is_empty(&self.results) } true } fn invalidated_self(&mut self, e: E) { Q::append_element(self.results, e); } fn recursion_limit_exceeded(&mut self, _e: E) {} fn invalidated_d...
should_process_descendants
identifier_name
dom_apis.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/. */ //! Generic implementations of some DOM APIs so they can be shared between Servo //! and Gecko. use context::Quir...
selector_list: &SelectorList<E::Impl>, results: &mut Q::Output, quirks_mode: QuirksMode, ) -> Result<(), ()> where E: TElement, Q: SelectorQuery<E>, { use selectors::parser::{Component, LocalName}; use std::borrow::Borrow; // We need to return elements in document order, and reordering ...
/// FIXME(emilio, nbp): This may very well be a good candidate for code to be /// replaced by HolyJit :) fn query_selector_fast<E, Q>( root: E::ConcreteNode,
random_line_split
util.rs
// Copyright 2015 Michael 'ExpHP' Lamparski // // Licensed under the terms of the MIT License, available at: // http://opensource.org/licenses/MIT // and also included in the file COPYING at the root of this distribution. // This file may not be copied, modified, or distributed except according // to those terms. use...
use num::{Zero,One,Integer}; use num::{ToPrimitive,FromPrimitive}; use rand::FromEntropy; /// Services more types than NumCast does, such as BigInt. pub trait MoreNumCast: ToPrimitive + FromPrimitive {} impl<T: ToPrimitive + FromPrimitive> MoreNumCast for T {} #[cfg(test)] use test::Bencher; /// Computes the greate...
random_line_split
util.rs
// Copyright 2015 Michael 'ExpHP' Lamparski // // Licensed under the terms of the MIT License, available at: // http://opensource.org/licenses/MIT // and also included in the file COPYING at the root of this distribution. // This file may not be copied, modified, or distributed except according // to those terms. use...
let mut x = n.clone(); let mut y = (x.clone() + n.clone() / x.clone()) >> literal(1); while y < x { x = y.clone(); y = (x.clone() + n.clone() / x.clone()) >> literal(1); } return x; } #[bench] fn bench_fast(b: &mut Bencher) { b.iter(|| { (0usize..1000) .map(|...
{ return Zero::zero(); }
conditional_block
util.rs
// Copyright 2015 Michael 'ExpHP' Lamparski // // Licensed under the terms of the MIT License, available at: // http://opensource.org/licenses/MIT // and also included in the file COPYING at the root of this distribution. // This file may not be copied, modified, or distributed except according // to those terms. use...
fn isqrt_safe<T>(n: T) -> T where T: Clone + Zero + Integer + Shr<usize, Output = T>, { // NOTE: while I'd like to remove the Shr bound, replacing '>> 1' with '/ 2' makes this // algorithm take twice as long for BigInts :/ if n.is_zero() { return Zero::zero(); } let mut x = n.clo...
{ x.to_f64().and_then(|f| { // Mantissa is 52 bits, and the square root takes half as many bits, so this // may be a bit conservative. The main concern is to avoid handling very // large BigInts which may lose more than half of their precision. if f > 20f64.exp2() { No...
identifier_body
util.rs
// Copyright 2015 Michael 'ExpHP' Lamparski // // Licensed under the terms of the MIT License, available at: // http://opensource.org/licenses/MIT // and also included in the file COPYING at the root of this distribution. // This file may not be copied, modified, or distributed except according // to those terms. use...
<T>(a: T, b: T) -> T where T: Clone + Zero + Integer, { let mut cur_a = a; let mut cur_b = b; while (!cur_a.is_zero()) { let old_b = cur_b; cur_b = cur_a.clone(); cur_a = old_b % cur_a; } cur_b } #[bench] fn bench_gcd(b: &mut Bencher) { use rand::Rng; let mut rng...
gcd
identifier_name
ui.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import Method %> // CSS Basic User Interface M...
(pub bool); } pub use self::computed_value::T as SpecifiedValue; impl ToCss for computed_value::T { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { dest.write_str(if self.0 { "1" } else { "0" }) } } #[inline] pub fn get_initial_value() -> com...
T
identifier_name
ui.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import Method %> // CSS Basic User Interface M...
${helpers.single_keyword("-moz-window-shadow", "none default menu tooltip sheet", products="gecko", gecko_ffi_name="mWindowShadow", gecko_constant_prefix="NS_STYLE_WINDOW_SHADOW", animation_value_type="discrete", interna...
gecko_enum_prefix="StyleWindowDragging", animation_value_type="discrete", spec="None (Nonstandard Firefox-only property)")}
random_line_split
block_limits.rs
extern crate blockstack_lib; extern crate serde_json; use blockstack_lib::{ chainstate::stacks::index::storage::{TrieFileStorage}, chainstate::burn::BlockHeaderHash, vm::types::{QualifiedContractIdentifier}, vm::database::{MarfedKV, NULL_HEADER_DB}, vm::clarity::ClarityInstance, vm::costs::Ex...
fn main() { let argv: Vec<_> = env::args().collect(); if argv.len() < 3 { eprintln!("Usage: {} [test-name] [scalar]", argv[0]); process::exit(1); } let scalar = argv[2].parse().expect("Invalid scalar"); let result = match argv[1].as_str() { "runtime" => { run...
{ let other_decl = ""; let inner_loop = "(define-private (inner-loop (x int)) (begin (map sha512 list-10) 0))"; test_via_tx(scaling, inner_loop, other_decl) }
identifier_body
block_limits.rs
extern crate blockstack_lib; extern crate serde_json; use blockstack_lib::{ chainstate::stacks::index::storage::{TrieFileStorage}, chainstate::burn::BlockHeaderHash, vm::types::{QualifiedContractIdentifier}, vm::database::{MarfedKV, NULL_HEADER_DB}, vm::clarity::ClarityInstance, vm::costs::Ex...
(scaling: u32, inner_loop: &str, other_decl: &str) -> ExecutionCost { let marf = MarfedKV::temporary(); let mut clarity_instance = ClarityInstance::new(marf, ExecutionCost::max_value()); let contract_identifier = QualifiedContractIdentifier::local("foo").unwrap(); let blocks = [TrieFileStorage::block_...
test_via_tx
identifier_name
block_limits.rs
extern crate blockstack_lib; extern crate serde_json; use blockstack_lib::{ chainstate::stacks::index::storage::{TrieFileStorage}, chainstate::burn::BlockHeaderHash, vm::types::{QualifiedContractIdentifier}, vm::database::{MarfedKV, NULL_HEADER_DB}, vm::clarity::ClarityInstance, vm::costs::Ex...
test_via_tx(scaling, inner_loop, other_decl) } // on a fairly underpowered laptop: // write-count of ~50k corresponds to 10 seconds. (scaling => 50) fn write_count_test(scaling: u32) -> ExecutionCost { let other_decl = "(define-data-var var-to-read int 0)"; let inner_loop = "(define-private (inner-loop (x ...
let other_decl = "(define-data-var var-to-read (list 1024 int) list-10)"; let inner_loop = "(define-private (inner-loop (x int)) (var-set var-to-read list-10))";
random_line_split
block_limits.rs
extern crate blockstack_lib; extern crate serde_json; use blockstack_lib::{ chainstate::stacks::index::storage::{TrieFileStorage}, chainstate::burn::BlockHeaderHash, vm::types::{QualifiedContractIdentifier}, vm::database::{MarfedKV, NULL_HEADER_DB}, vm::clarity::ClarityInstance, vm::costs::Ex...
, }; println!("{}", serde_json::to_string(&result).unwrap()); }
{ eprintln!("bad test name"); process::exit(1); }
conditional_block
lu.rs
#[macro_use] extern crate linxal; extern crate ndarray; extern crate num_traits; use ndarray::{Array, ArrayBase, Data, Ix2}; use linxal::factorization::{LUError, LUFactors}; use linxal::types::{LinxalMatrix}; use std::cmp; /// Check that all the properties of the lu factorization are /// reasonable. fn check_lu<D1: ...
{ let mut m = Array::zeros((4, 4)); m[(0, 0)] = 1.0; m[(1, 2)] = 2.0; m[(2, 1)] = 3.0; m[(3, 3)] = 4.0; let lu = m.lu(); println!("{:?}", lu); assert!(lu.is_ok()); check_lu(&m, &lu.unwrap(), true); }
identifier_body
lu.rs
#[macro_use] extern crate linxal; extern crate ndarray; extern crate num_traits; use ndarray::{Array, ArrayBase, Data, Ix2}; use linxal::factorization::{LUError, LUFactors}; use linxal::types::{LinxalMatrix}; use std::cmp; /// Check that all the properties of the lu factorization are /// reasonable. fn check_lu<D1: ...
} #[test] fn lu_diag() { let mut m = Array::zeros((4, 4)); m.diag_mut().assign(&Array::linspace(1.0, 4.0, 4)); let lu = m.lu(); assert!(lu.is_ok()); check_lu(&m, &lu.unwrap(), true); } #[test] fn lu_rectanglular() { let v: Vec<f32> = (0..12).map(|x| (x * x) as f32).collect(); let m = Ar...
{ assert!(inverse.is_err()); assert_eq!(inverse.err().unwrap(), LUError::NotSquare); }
conditional_block
lu.rs
#[macro_use] extern crate linxal; extern crate ndarray; extern crate num_traits; use ndarray::{Array, ArrayBase, Data, Ix2}; use linxal::factorization::{LUError, LUFactors}; use linxal::types::{LinxalMatrix}; use std::cmp; /// Check that all the properties of the lu factorization are /// reasonable. fn check_lu<D1: ...
() { let mut m = Array::zeros((4, 4)); m.diag_mut().assign(&Array::linspace(1.0, 4.0, 4)); let lu = m.lu(); assert!(lu.is_ok()); check_lu(&m, &lu.unwrap(), true); } #[test] fn lu_rectanglular() { let v: Vec<f32> = (0..12).map(|x| (x * x) as f32).collect(); let m = Array::from_vec(v).into_...
lu_diag
identifier_name
lu.rs
#[macro_use] extern crate linxal; extern crate ndarray; extern crate num_traits;
use linxal::factorization::{LUError, LUFactors}; use linxal::types::{LinxalMatrix}; use std::cmp; /// Check that all the properties of the lu factorization are /// reasonable. fn check_lu<D1: Data<Elem=f32>>( m: &ArrayBase<D1, Ix2>, lu: &LUFactors<f32>, invertible: bool) { let l: Array<f32, Ix2> = lu.l(); ...
use ndarray::{Array, ArrayBase, Data, Ix2};
random_line_split
recorder.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
], vec![ 248, 99, 128, 128, 128, 128, 200, 131, 32, 111, 103, 131, 99, 97, 116, 128, 128, 128, 206, 134, 32, 111, 116, 100, 111, 103, 134, 104, 111, 116, 99, 97, 116, 206, 134, 32, 110, 115, 101, 114, 116, 134, 114, 101, 109, 111, 118, 101, 128, 128, 160, 202, 250, 252, 153, 229, 63, 255, 13, 100,...
92, 119, 88, 96, 80, 126, 59, 11, 160, 142, 98, 229, 237, 200, 231, 224, 79, 118, 215, 93, 144, 246, 179, 176, 160, 118, 211, 171, 199, 172, 136, 136, 240, 221, 59, 110, 82, 86, 54, 23, 95, 48, 108, 71, 125, 59, 51, 253, 210, 18, 116, 79, 0, 236, 102, 142, 48, 128, 128, 128, 128, 128, 128, 128, 128, 128
random_line_split
recorder.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
() -> Self { Recorder::new() } } impl Recorder { /// Create a new `Recorder` which records all given nodes. #[inline] pub fn new() -> Self { Recorder::with_depth(0) } /// Create a `Recorder` which only records nodes beyond a given depth. pub fn with_depth(depth: u32) -> Self { Recorder { nodes: Vec::n...
default
identifier_name
recorder.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
} /// Drain all visited records. pub fn drain(&mut self) -> Vec<Record> { ::std::mem::replace(&mut self.nodes, Vec::new()) } } #[cfg(test)] mod tests { use super::*; use bigint::hash::H256; #[test] fn basic_recorder() { let mut basic = Recorder::new(); let node1 = vec![1, 2, 3, 4]; let node2 = vec!...
{ self.nodes.push(Record { depth: depth, data: data.into(), hash: *hash, }) }
conditional_block
recorder.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
} #[cfg(test)] mod tests { use super::*; use bigint::hash::H256; #[test] fn basic_recorder() { let mut basic = Recorder::new(); let node1 = vec![1, 2, 3, 4]; let node2 = vec![4, 5, 6, 7, 8, 9, 10]; let (hash1, hash2) = (keccak(&node1), keccak(&node2)); basic.record(&hash1, &node1, 0); basic.record(...
{ ::std::mem::replace(&mut self.nodes, Vec::new()) }
identifier_body
theme.rs
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError};
pub fn theme_option( h: &Helper<'_, '_>, _r: &Handlebars<'_>, ctx: &Context, rc: &mut RenderContext<'_, '_>, out: &mut dyn Output, ) -> Result<(), RenderError> { trace!("theme_option (handlebars helper)"); let param = h.param(0).and_then(|v| v.value().as_str()).ok_or_else(|| { Rende...
random_line_split
theme.rs
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError}; pub fn
( h: &Helper<'_, '_>, _r: &Handlebars<'_>, ctx: &Context, rc: &mut RenderContext<'_, '_>, out: &mut dyn Output, ) -> Result<(), RenderError> { trace!("theme_option (handlebars helper)"); let param = h.param(0).and_then(|v| v.value().as_str()).ok_or_else(|| { RenderError::new("Param ...
theme_option
identifier_name
theme.rs
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError}; pub fn theme_option( h: &Helper<'_, '_>, _r: &Handlebars<'_>, ctx: &Context, rc: &mut RenderContext<'_, '_>, out: &mut dyn Output, ) -> Result<(), RenderError>
{ trace!("theme_option (handlebars helper)"); let param = h.param(0).and_then(|v| v.value().as_str()).ok_or_else(|| { RenderError::new("Param 0 with String type is required for theme_option helper.") })?; let default_theme = rc.evaluate(ctx, "@root/default_theme")?; let default_theme_name ...
identifier_body
theme.rs
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError}; pub fn theme_option( h: &Helper<'_, '_>, _r: &Handlebars<'_>, ctx: &Context, rc: &mut RenderContext<'_, '_>, out: &mut dyn Output, ) -> Result<(), RenderError> { trace!("theme_option (handlebars helper)"); l...
Ok(()) }
{ out.write(" (default)")?; }
conditional_block
shootout-fasta-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2013-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
n -= bytes; } Ok(()) } } fn make_lookup(a: &[AminoAcid]) -> [AminoAcid;LOOKUP_SIZE] { let mut lookup = [ NULL_AMINO_ACID;LOOKUP_SIZE ]; let mut j = 0; for (i, slot) in lookup.iter_mut().enumerate() { while a[j].p < (i as f32) { j += 1; } ...
{ pos -= alu_len; }
conditional_block
shootout-fasta-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2013-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
(a: &[AminoAcid]) -> [AminoAcid;LOOKUP_SIZE] { let mut lookup = [ NULL_AMINO_ACID;LOOKUP_SIZE ]; let mut j = 0; for (i, slot) in lookup.iter_mut().enumerate() { while a[j].p < (i as f32) { j += 1; } *slot = a[j]; } lookup } struct RandomFasta<'a, W:'a> { seed...
make_lookup
identifier_name
shootout-fasta-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2013-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
fn nextc(&mut self) -> u8 { let r = self.rng(1.0); for a in &self.lookup[..] { if a.p >= r { return a.c; } } 0 } fn make(&mut self, n: usize) -> IoResult<()> { let lines = n / LINE_LEN; let chars_left = n % LINE_LEN; ...
{ self.seed = (self.seed * IA + IC) % IM; max * (self.seed as f32) / (IM as f32) }
identifier_body
shootout-fasta-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2013-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
} *slot = a[j]; } lookup } struct RandomFasta<'a, W:'a> { seed: u32, lookup: [AminoAcid;LOOKUP_SIZE], out: &'a mut W, } impl<'a, W: Writer> RandomFasta<'a, W> { fn new(w: &'a mut W, a: &[AminoAcid]) -> RandomFasta<'a, W> { RandomFasta { seed: 42, ...
let mut j = 0; for (i, slot) in lookup.iter_mut().enumerate() { while a[j].p < (i as f32) { j += 1;
random_line_split
task-perf-linked-failure.rs
// xfail-pretty // xfail-test linked failure // 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/LICEN...
; let num_tasks = from_str::<uint>(args[1]).unwrap(); // Main group #0 waits for unsupervised group #1. // Grandparent group #1 waits for middle group #2, then fails, killing #3. // Middle group #2 creates grandchild_group #3, waits for it to be ready, exits. let x: result::Result<(), ~Any> = do t...
{ args.clone() }
conditional_block
task-perf-linked-failure.rs
// xfail-pretty // xfail-test linked failure // 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/LICEN...
// Grandparent group #1 waits for middle group #2, then fails, killing #3. // Middle group #2 creates grandchild_group #3, waits for it to be ready, exits. let x: result::Result<(), ~Any> = do task::try { // unlinked do spawn_supervised_blocking("grandparent") { do spawn_supervised_block...
}; let num_tasks = from_str::<uint>(args[1]).unwrap(); // Main group #0 waits for unsupervised group #1.
random_line_split
task-perf-linked-failure.rs
// xfail-pretty // xfail-test linked failure // 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/LICEN...
// When grandchild group is ready to go, make the middle group exit. error!("Middle group wakes up and exits"); } // Grandparent group waits for middle group to be gone, then fails error!("Grandparent group wakes up and fails"); fail!(); } ; assert!(x.is_e...
{ let args = os::args(); let args = if os::getenv("RUST_BENCH").is_some() { ~[~"", ~"100000"] } else if args.len() <= 1u { ~[~"", ~"100"] } else { args.clone() }; let num_tasks = from_str::<uint>(args[1]).unwrap(); // Main group #0 waits for unsupervised group #1. ...
identifier_body
task-perf-linked-failure.rs
// xfail-pretty // xfail-test linked failure // 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/LICEN...
(num_tasks: uint) { let (po, ch) = stream(); let ch = SharedChan::new(ch); for _ in range(0, num_tasks) { let ch = ch.clone(); let mut t = task::task(); do t.spawn { // linked ch.send(()); let (p, _c) = stream::<()>(); p.recv(); // block forever ...
grandchild_group
identifier_name
domtokenlist.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::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
let token = try!(self.check_token_exceptions(&token)); match atoms.iter().position(|atom| *atom == token) { Some(index) => match force { Some(true) => Ok(true), _ => { atoms.remove(index); self.element.set_atomic_tokenli...
random_line_split
domtokenlist.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::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
// check-tidy: no specs after this line fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<DOMString> { let item = self.Item(index); *found = item.is_some(); item } }
{ self.element.get_string_attribute(&self.local_name) }
identifier_body
domtokenlist.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::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
(&self) -> Option<Root<Attr>> { self.element.get_attribute(&ns!(), &self.local_name) } fn check_token_exceptions(&self, token: &str) -> Fallible<Atom> { match token { "" => Err(Error::Syntax), slice if slice.find(HTML_SPACE_CHARACTERS).is_some() => Err(Error::InvalidChar...
attribute
identifier_name
domtokenlist.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::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
}, } } // https://dom.spec.whatwg.org/#dom-domtokenlist-value fn Value(&self) -> DOMString { self.element.get_string_attribute(&self.local_name) } // https://dom.spec.whatwg.org/#dom-domtokenlist-value fn SetValue(&self, value: DOMString) { self.element.set...
{ atoms.push(token); self.element.set_atomic_tokenlist_attribute(&self.local_name, atoms); Ok(true) }
conditional_block
shlobj.rs
// Copyright © 2015, Peter Atashian, skdltmxn // Licensed under the MIT License <LICENSE.md> pub const INVALID_HANDLE_VALUE: ::HANDLE = -1isize as ::HANDLE; pub type GPFIDL_FLAGS = ::c_int; ENUM!{enum KNOWN_FOLDER_FLAG { KF_FLAG_DEFAULT = 0x00000000, KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000, ...
pub const CSIDL_COMMON_PROGRAMS: ::c_int = 0x0017; pub const CSIDL_COMMON_STARTUP: ::c_int = 0x0018; pub const CSIDL_COMMON_DESKTOPDIRECTORY: ::c_int = 0x0019; pub const CSIDL_APPDATA: ::c_int = 0x001a; pub const CSIDL_PRINTHOOD: ::c_int = 0x001b; pub const CSIDL_LOCAL_APPDATA: ::c_int = 0x001c; pub const CSIDL_A...
random_line_split
datetime_expressions.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...
atetime: &NaiveDateTime) -> i64 { // Note: Use chrono APIs that are different than // naive_datetime_to_timestamp to compute the utc offset to // try and double check the logic let utc_offset_secs = match Local.offset_from_local_datetime(&naive_datetime) { LocalResult::Single...
tetime_to_timestamp(naive_d
identifier_name
datetime_expressions.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...
naive_datetime_to_timestamp(&naive_datetime_whole_secs), parse_timestamp("2020-09-08T13:42:29")? ); assert_eq!( naive_datetime_to_timestamp(&naive_datetime_whole_secs), parse_timestamp("2020-09-08 13:42:29")? ); Ok(()) } #[test] ...
// Ensure both T and ' ' variants work assert_eq!(
random_line_split
datetime_expressions.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...
test] fn string_to_timestamp_no_timezone() -> Result<()> { // This test is designed to succeed in regardless of the local // timezone the test machine is running. Thus it is still // somewhat suceptable to bugs in the use of chrono let naive_datetime = NaiveDateTime::new( ...
// Note: Use chrono APIs that are different than // naive_datetime_to_timestamp to compute the utc offset to // try and double check the logic let utc_offset_secs = match Local.offset_from_local_datetime(&naive_datetime) { LocalResult::Single(local_offset) => { loca...
identifier_body
expand.rs
/* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * (c) kwantam <kwantam@gmail.com> * 20150428 created `expand` module to eliminate most allocs during setup * * For the full copyright and license information, please view the LICENSE * file that was distributed wit...
#[inline] fn next(&mut self) -> Option<Self::Item> { if self.string.len() == 0 { return None; } // is the next character an escape? let (ret, idx) = match self.string.chars().next().unwrap() { '\\' if self.string.len() > 1 => { // yes---...
{ let slen = self.string.len(); (min(slen, 1), None) }
identifier_body
expand.rs
/* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * (c) kwantam <kwantam@gmail.com> * 20150428 created `expand` module to eliminate most allocs during setup * * For the full copyright and license information, please view the LICENSE * file that was distributed wit...
'v' => 0x0bu8 as char, 'n' => '\n', 'r' => '\r', 't' => '\t', _ => c, } } struct Unescape<'a> { string: &'a str, } impl<'a> Iterator for Unescape<'a> { type Item = char; #[inline] fn size_hint(&self) -> (usize, Option<usize>) { let slen = self.strin...
'a' => 0x07u8 as char, 'b' => 0x08u8 as char, 'f' => 0x0cu8 as char,
random_line_split
expand.rs
/* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * (c) kwantam <kwantam@gmail.com> * 20150428 created `expand` module to eliminate most allocs during setup * * For the full copyright and license information, please view the LICENSE * file that was distributed wit...
(&self) -> (usize, Option<usize>) { let slen = self.string.len(); (min(slen, 1), None) } #[inline] fn next(&mut self) -> Option<Self::Item> { if self.string.len() == 0 { return None; } // is the next character an escape? let (ret, idx) = match se...
size_hint
identifier_name
htmlolistelement.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::HTMLOListElementBinding; use dom::bindings::codegen::InheritTypes::HTMLOList...
} impl HTMLOListElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOListElement { HTMLOListElement { htmlelement: HTMLElement::new_inherited(HTMLOListElementTypeId, localName, document) } } pub fn new(localName: DOMString, document: &JSRef<D...
random_line_split