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
issue-16272.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 ...
} fn test() { let status = Command::new(&env::current_exe().unwrap()) .arg("foo").arg("") .status().unwrap(); assert!(status.success()); }
{ assert_eq!(len, 3); }
conditional_block
issue-16272.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 status = Command::new(&env::current_exe().unwrap()) .arg("foo").arg("") .status().unwrap(); assert!(status.success()); }
} fn test() {
random_line_split
issue-16272.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 status = Command::new(&env::current_exe().unwrap()) .arg("foo").arg("") .status().unwrap(); assert!(status.success()); }
identifier_body
lexer.rs
use lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to analyze given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] impl<'a>...
(code: String) -> Lexer<'a> { Lexer { index: 0, errors: 0, code: code, whitespaces: String::from(" \t"), terminals: vec![ "let","for","while","do_while","if", "else_if","else","continue","break","return", ...
new
identifier_name
lexer.rs
use lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to analyze given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] impl<'a>...
}
{ let mut s = String::new(); self.index += 1; while self.getc() != '\"' { s.push(self.getc()); self.index += 1; } self.index += 1; Lexeme::StringLiteral(s) }
identifier_body
lexer.rs
use lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to analyze given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] impl<'a>...
} if!construct { if self.getc().is_numeric() { lexemes.push(self.number()); } else if self.getc() == '\"' { lexemes.push(self.string()); } else if self.getc().is_alphabetic() { lexemes.pu...
{ lexemes.push(self.lexemes[i].clone()); self.index += self.terminals[i].len(); construct = true; break; }
conditional_block
lexer.rs
use lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to analyze given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] impl<'a>...
if self.errors > 0 { println!("Total Errors : {}", self.errors); } else { println!("Build Successful!"); println!("_________________"); } lexemes } // returns number of errors pub fn count_errors(&mut self) -> u32 { self.errors ...
} } }
random_line_split
sphere.rs
use material::Material; use vector::Vector4; use ray::Ray; use renderable::{ IntersectionRecord, Renderable }; use std::rc::Rc; pub struct Sphere { center: Vector4, radius: f32, material: Rc<Box<Material>>, } impl Sphere { pub fn new<TMaterial: Material +'static>(center: Vector4, radius: f32, material...
(intersection_point - self.center) / self.radius, self.material.clone(), )); } let distance = (-b + sqrt_discriminant) / a; if distance < distance_max && distance > distance_min { let intersection_po...
{ let o_minus_c = ray.origin() - self.center; let a = ray.direction().dot3(ray.direction()); let b = o_minus_c.dot3(ray.direction()); let c = (o_minus_c).dot3(o_minus_c) - self.radius * self.radius; let discriminant = b * b - a * c; // Get the distance (d) value if a ...
identifier_body
sphere.rs
use material::Material; use vector::Vector4; use ray::Ray; use renderable::{ IntersectionRecord, Renderable }; use std::rc::Rc; pub struct Sphere { center: Vector4, radius: f32, material: Rc<Box<Material>>, } impl Sphere { pub fn new<TMaterial: Material +'static>(center: Vector4, radius: f32, material...
} None } }
{ let intersection_point = ray.point_at_distance(distance); return Some(IntersectionRecord::new( distance, intersection_point, (intersection_point - self.center) / self.radius, self.material.c...
conditional_block
sphere.rs
use material::Material; use vector::Vector4; use ray::Ray; use renderable::{ IntersectionRecord, Renderable }; use std::rc::Rc; pub struct Sphere { center: Vector4, radius: f32, material: Rc<Box<Material>>, } impl Sphere { pub fn new<TMaterial: Material +'static>(center: Vector4, radius: f32, material...
(&self, ray: &Ray, distance_min: f32, distance_max: f32) -> Option<IntersectionRecord> { let o_minus_c = ray.origin() - self.center; let a = ray.direction().dot3(ray.direction()); let b = o_minus_c.dot3(ray.direction()); let c = (o_minus_c).dot3(o_minus_c) - self.radius * self....
intersects
identifier_name
sphere.rs
use material::Material; use vector::Vector4; use ray::Ray; use renderable::{ IntersectionRecord, Renderable }; use std::rc::Rc; pub struct Sphere { center: Vector4, radius: f32, material: Rc<Box<Material>>, } impl Sphere { pub fn new<TMaterial: Material +'static>(center: Vector4, radius: f32, material...
}
}
random_line_split
message_builder.rs
//! Builder for constructing Asynchronous message interactions use std::collections::HashMap; use bytes::Bytes; use log::*; use maplit::hashmap; use pact_models::content_types::ContentType; use pact_models::json_utils::json_to_string; use pact_models::matchingrules::MatchingRuleCategory; use pact_models::path_exp::Do...
<G: Into<String>>(&mut self, given: G) -> &mut Self { self.provider_states.push(ProviderState::default(&given.into())); self } /// Adds a text comment to this interaction. This allows to specify just a bit more information /// about the interaction. It has no functional impact, but can be displayed in th...
given
identifier_name
message_builder.rs
//! Builder for constructing Asynchronous message interactions use std::collections::HashMap; use bytes::Bytes; use log::*; use maplit::hashmap; use pact_models::content_types::ContentType; use pact_models::json_utils::json_to_string; use pact_models::matchingrules::MatchingRuleCategory; use pact_models::path_exp::Do...
self.message_contents = InteractionContents { body : OptionalBody::from(Value::Object(contents_map.clone())), .. InteractionContents::default() }; } self } fn setup_core_matcher( &mut self, content_type: &ContentType, config: &HashMap<String, Value>, content_matc...
debug!("No content matcher found, will use the internal implementation"); self.setup_core_matcher(&ct, &contents_hashmap, None); } } else {
random_line_split
message_builder.rs
//! Builder for constructing Asynchronous message interactions use std::collections::HashMap; use bytes::Bytes; use log::*; use maplit::hashmap; use pact_models::content_types::ContentType; use pact_models::json_utils::json_to_string; use pact_models::matchingrules::MatchingRuleCategory; use pact_models::path_exp::Do...
/// Specify the body as `JsonPattern`, possibly including special matching /// rules. /// /// ``` /// use pact_consumer::prelude::*; /// use pact_consumer::*; /// use pact_consumer::builders::MessageInteractionBuilder; /// /// MessageInteractionBuilder::new("hello message", "core/interaction/message...
{ self.contents_plugin.as_ref().map(|plugin| { let config = if let Some(config) = self.plugin_config.get(plugin.name.as_str()) { config.pact_configuration.clone() } else { hashmap!{} }; PluginData { name: plugin.name.clone(), version: plugin.version.clone(), ...
identifier_body
pp.rs
i += 1us; i %= n; } s.push(']'); s } #[derive(Copy)] pub enum PrintStackBreak { Fits, Broken(Breaks), } #[derive(Copy)] pub struct PrintStackElem { offset: isize, pbreak: PrintStackBreak } static SIZE_INFINITY: isize = 0xffff; pub fn mk_printer(out: Box<io::Writer+'stati...
{ rbox(p, indent, Breaks::Consistent) }
identifier_body
pp.rs
Printer { out: out, buf_len: n, margin: linewidth as isize, space: linewidth as isize, left: 0, right: 0, token: token, size: size, left_total: 0, right_total: 0, scan_stack: scan_stack, scan_stack_empty: true, t...
zero_word
identifier_name
pp.rs
(or before each) and the breaking algorithm decides to break //! there anyways (because the functions themselves are long) you wind up with //! extra blank lines. If you don't put hardbreaks you can wind up with the //! "thing which should be on its own line" not getting its own line in the //! rare case of "really sm...
top: 0, bottom: 0, print_stack: Vec::new(), pending_indentation: 0 } } /// In case you do not have the paper, here is an explanation of what's going /// on. /// /// There is a stream of input tokens flowing through this printer. /// /// The printer buffers up to 3N tokens inside it...
random_line_split
pp.rs
or before each) and the breaking algorithm decides to break //! there anyways (because the functions themselves are long) you wind up with //! extra blank lines. If you don't put hardbreaks you can wind up with the //! "thing which should be on its own line" not getting its own line in the //! rare case of "really smal...
Ok(()) } Token::End => { debug!("print End -> pop End"); let print_stack = &mut self.print_stack; assert!((print_stack.len()!= 0us)); print_stack.pop().unwrap(); Ok(()) } Token::Break(b) => { let...
{ debug!("print Begin -> push fitting block"); self.print_stack.push(PrintStackElem { offset: 0, pbreak: PrintStackBreak::Fits }); }
conditional_block
owned.rs
use super::*; use std::borrow::Cow; #[cfg(feature = "lazy")] include!("lazy.rs"); #[allow(non_snake_case)] #[derive(Debug, Default, Clone, PartialEq)] pub struct OwnedIpInfo { pub city_id: u32, pub country: String, pub region: String, pub province: String, pub city: String, pub ISP: String, } ...
if data_ptr == 0 { Err(Error::NotFound)?; } let data_len = (data_ptr >> 24) & 0xff; data_ptr = data_ptr & 0x00FFFFFF; get_ip_info( get_u32(&self.db_bin_bytes[..], data_ptr), &self.db_bin_bytes[(data_ptr + 4) as usize..(data_ptr + data_len) as...
}
random_line_split
owned.rs
use super::*; use std::borrow::Cow; #[cfg(feature = "lazy")] include!("lazy.rs"); #[allow(non_snake_case)] #[derive(Debug, Default, Clone, PartialEq)] pub struct OwnedIpInfo { pub city_id: u32, pub country: String, pub region: String, pub province: String, pub city: String, pub ISP: String, } ...
} if data_ptr == 0 { Err(Error::NotFound)?; } let data_len = (data_ptr >> 24) & 0xff; data_ptr = data_ptr & 0x00FFFFFF; get_ip_info( get_u32(&self.db_bin_bytes[..], data_ptr), &self.db_bin_bytes[(data_ptr + 4) as usize..(data_ptr + d...
{ let eip = get_u32(&self.db_bin_bytes[..], p + 4); if ip > eip { l = m + 1; } else { data_ptr = get_u32(&self.db_bin_bytes[..], p + 8); break; } }
conditional_block
owned.rs
use super::*; use std::borrow::Cow; #[cfg(feature = "lazy")] include!("lazy.rs"); #[allow(non_snake_case)] #[derive(Debug, Default, Clone, PartialEq)] pub struct OwnedIpInfo { pub city_id: u32, pub country: String, pub region: String, pub province: String, pub city: String, pub ISP: String, } ...
} pub struct OwnedIp2Region { // super block index info first_index_ptr: u32, // last_index_ptr: u32, total_blocks: u32, db_bin_bytes: Cow<'static, [u8]>, } impl OwnedIp2Region { pub fn new(path: &str) -> io::Result<Self> { let mut file = File::open(path)?; Self::new2(&mut fil...
{ write!(f, "{}", self.as_ref()) }
identifier_body
owned.rs
use super::*; use std::borrow::Cow; #[cfg(feature = "lazy")] include!("lazy.rs"); #[allow(non_snake_case)] #[derive(Debug, Default, Clone, PartialEq)] pub struct OwnedIpInfo { pub city_id: u32, pub country: String, pub region: String, pub province: String, pub city: String, pub ISP: String, } ...
(file: &mut File) -> io::Result<Self> { let file_size = file.metadata()?.len(); let mut bytes = Vec::with_capacity(file_size as usize); file.read_to_end(&mut bytes)?; let first_index_ptr = get_u32(&bytes[..], 0); let last_index_ptr = get_u32(&bytes[..], 4); let total_blo...
new2
identifier_name
task-comm-10.rs
// Copyright 2012-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-MI...
(tx: &Sender<Sender<String>>) { let (tx2, rx) = channel(); tx.send(tx2).unwrap(); let mut a; let mut b; a = rx.recv().unwrap(); assert!(a == "A".to_string()); println!("{}", a); b = rx.recv().unwrap(); assert!(b == "B".to_string()); println!("{}", b); } pub fn main() { let ...
start
identifier_name
task-comm-10.rs
// Copyright 2012-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-MI...
let (tx, rx) = channel(); let _child = thread::scoped(move|| { start(&tx) }); let mut c = rx.recv().unwrap(); c.send("A".to_string()).unwrap(); c.send("B".to_string()).unwrap(); thread::yield_now(); }
assert!(b == "B".to_string()); println!("{}", b); } pub fn main() {
random_line_split
task-comm-10.rs
// Copyright 2012-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-MI...
{ let (tx, rx) = channel(); let _child = thread::scoped(move|| { start(&tx) }); let mut c = rx.recv().unwrap(); c.send("A".to_string()).unwrap(); c.send("B".to_string()).unwrap(); thread::yield_now(); }
identifier_body
main.rs
fn is_prime(number: i32) -> bool { if number % 2 == 0 && number!= 2 || number == 1 { return false; } let limit = (number as f32).sqrt() as i32 + 1; // We test if the number is divisible by any odd number up to the limit (3..limit).step_by(2).all(|x| number % x!= 0) } fn main() { print...
() { assert!(is_prime(2)); } #[test] fn test_many() { let primes = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]; assert!(primes.iter().all(|&x| is_prime(x))); }
test_two
identifier_name
main.rs
fn is_prime(number: i32) -> bool { if number % 2 == 0 && number!= 2 || number == 1 { return false; } let limit = (number as f32).sqrt() as i32 + 1; // We test if the number is divisible by any odd number up to the limit (3..limit).step_by(2).all(|x| number % x!= 0) } fn main() { print...
}
random_line_split
main.rs
fn is_prime(number: i32) -> bool { if number % 2 == 0 && number!= 2 || number == 1
let limit = (number as f32).sqrt() as i32 + 1; // We test if the number is divisible by any odd number up to the limit (3..limit).step_by(2).all(|x| number % x!= 0) } fn main() { println!("{}", is_prime(15_485_863)); // The 1 000 000th prime. println!("{}", is_prime(62_773_913)); // The product ...
{ return false; }
conditional_block
main.rs
fn is_prime(number: i32) -> bool { if number % 2 == 0 && number!= 2 || number == 1 { return false; } let limit = (number as f32).sqrt() as i32 + 1; // We test if the number is divisible by any odd number up to the limit (3..limit).step_by(2).all(|x| number % x!= 0) } fn main() { print...
#[test] fn test_two() { assert!(is_prime(2)); } #[test] fn test_many() { let primes = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]; assert!(primes.iter().all(|&x| is_prime(x))); }
{ // https://primes.utm.edu/notes/faq/one.html assert!(!is_prime(1)); }
identifier_body
build_insert_query.rs
extern crate rustorm; extern crate uuid; extern crate chrono; extern crate rustc_serialize; use uuid::Uuid; use rustorm::query::Query; use rustorm::dao::{Dao, IsDao}; use rustorm::pool::ManagedPool; #[derive(Debug, Clone)] pub struct Photo { pub photo_id: Uuid, pub url: Option<String>, } impl IsDao for Phot...
(dao: &Dao) -> Self { Photo { photo_id: dao.get("photo_id"), url: dao.get_opt("url"), } } fn to_dao(&self) -> Dao { let mut dao = Dao::new(); dao.set("photo_id", &self.photo_id); match self.url { Some(ref _value) => dao.set("url", _val...
from_dao
identifier_name
build_insert_query.rs
extern crate rustorm; extern crate uuid; extern crate chrono; extern crate rustc_serialize; use uuid::Uuid; use rustorm::query::Query; use rustorm::dao::{Dao, IsDao}; use rustorm::pool::ManagedPool;
#[derive(Debug, Clone)] pub struct Photo { pub photo_id: Uuid, pub url: Option<String>, } impl IsDao for Photo{ fn from_dao(dao: &Dao) -> Self { Photo { photo_id: dao.get("photo_id"), url: dao.get_opt("url"), } } fn to_dao(&self) -> Dao { let mut dao...
random_line_split
build_insert_query.rs
extern crate rustorm; extern crate uuid; extern crate chrono; extern crate rustc_serialize; use uuid::Uuid; use rustorm::query::Query; use rustorm::dao::{Dao, IsDao}; use rustorm::pool::ManagedPool; #[derive(Debug, Clone)] pub struct Photo { pub photo_id: Uuid, pub url: Option<String>, } impl IsDao for Phot...
} #[test] fn test_insert_query() { let url = "postgres://postgres:p0stgr3s@localhost/bazaar_v6"; let pool = ManagedPool::init(&url, 1).unwrap(); let db = pool.connect().unwrap(); let mut query = Query::insert(); query.into_table("bazaar.product") .set("name", &"product1") .retur...
{ let mut dao = Dao::new(); dao.set("photo_id", &self.photo_id); match self.url { Some(ref _value) => dao.set("url", _value), None => dao.set_null("url"), } dao }
identifier_body
type-params-in-for-each.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 ...
pub fn main() { }
random_line_split
type-params-in-for-each.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 ...
<F>(lo: usize, hi: usize, mut it: F) where F: FnMut(usize) { let mut lo_ = lo; while lo_ < hi { it(lo_); lo_ += 1; } } fn create_index<T>(_index: Vec<S<T>>, _hash_fn: extern fn(T) -> usize) { range_(0, 256, |_i| { let _bucket: Vec<T> = Vec::new(); }) } pub fn main() { }
range_
identifier_name
mod.rs
use std::fmt; use std::error::Error; use std::sync::Mutex; use CapabilitiesSource; use gl; use version::Api; use version::Version; pub use self::compute::{ComputeShader, ComputeCommand}; pub use self::program::Program; pub use self::reflection::{Uniform, UniformBlock, BlockLayout, OutputPrimitives}; pub use self::ref...
<'a> { /// Use GLSL source code. SourceCode { /// Source code of the vertex shader. vertex_shader: &'a str, /// Source code of the optional tessellation control shader. tessellation_control_shader: Option<&'a str>, /// Source code of the optional tessellation evaluation...
ProgramCreationInput
identifier_name
mod.rs
use std::fmt; use std::error::Error; use std::sync::Mutex; use CapabilitiesSource; use gl; use version::Api; use version::Version; pub use self::compute::{ComputeShader, ComputeCommand}; pub use self::program::Program; pub use self::reflection::{Uniform, UniformBlock, BlockLayout, OutputPrimitives}; pub use self::ref...
/// Source code of the optional tessellation evaluation shader. pub tessellation_evaluation_shader: Option<&'a str>, /// Source code of the optional geometry shader. pub geometry_shader: Option<&'a str>, /// Source code of the fragment shader. pub fragment_shader: &'a str, } impl<'a> From<So...
pub tessellation_control_shader: Option<&'a str>,
random_line_split
mod.rs
use std::fmt; use std::error::Error; use std::sync::Mutex; use CapabilitiesSource; use gl; use version::Api; use version::Version; pub use self::compute::{ComputeShader, ComputeCommand}; pub use self::program::Program; pub use self::reflection::{Uniform, UniformBlock, BlockLayout, OutputPrimitives}; pub use self::ref...
/// Some shader compilers have race-condition issues, so we lock this mutex /// in the GL thread every time we compile a shader or link a program. // TODO: replace by a StaticMutex lazy_static! { static ref COMPILER_GLOBAL_LOCK: Mutex<()> = Mutex::new(()); } /// Error that can be triggered when creating a `Progr...
{ ctxt.get_version() >= &Version(Api::Gl, 4, 1) || ctxt.get_version() >= &Version(Api::GlEs, 2, 0) || ctxt.get_extensions().gl_arb_get_programy_binary }
identifier_body
move-1.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.
// except according to those terms. struct Triple { x: int, y: int, z: int } fn test(x: bool, foo: @Triple) -> int { let bar = foo; let mut y: @Triple; if x { y = bar; } else { y = @Triple{x: 4, y: 5, z: 6}; } return y.y; } pub fn main() { let x = @Triple {x: 1, y: 2, z: 3}; assert!((test(tru...
// // 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 // option. This file may not be copied, modified, or distributed
random_line_split
move-1.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 ...
pub fn main() { let x = @Triple {x: 1, y: 2, z: 3}; assert!((test(true, x) == 2)); assert!((test(true, x) == 2)); assert!((test(true, x) == 2)); assert!((test(false, x) == 5)); }
{ let bar = foo; let mut y: @Triple; if x { y = bar; } else { y = @Triple{x: 4, y: 5, z: 6}; } return y.y; }
identifier_body
move-1.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x = @Triple {x: 1, y: 2, z: 3}; assert!((test(true, x) == 2)); assert!((test(true, x) == 2)); assert!((test(true, x) == 2)); assert!((test(false, x) == 5)); }
main
identifier_name
move-1.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 ...
else { y = @Triple{x: 4, y: 5, z: 6}; } return y.y; } pub fn main() { let x = @Triple {x: 1, y: 2, z: 3}; assert!((test(true, x) == 2)); assert!((test(true, x) == 2)); assert!((test(true, x) == 2)); assert!((test(false, x) == 5)); }
{ y = bar; }
conditional_block
event.rs
use collections::borrow::Cow; use ::data::grid; use ::data::shapes::tetromino::{Shape,RotatedShape,Rotation}; use ::game::data::Input; //TODO: Document when the events triggers. If one triggers before or after mutation of the structure ///Events which can occur ingame. ///These should get signaled by the game state ...
player: P, current: Rotation, target: Rotation, cause: RotationCause, }, PlayerCollidedOnMovement{//TODO: Implement player: P, current: grid::PosAxis, target: grid::PosAxis, cause: RotationCause, }, PlayerRotated{//TODO: Implement player: P, old: Rotation, new: Rotation, cause: RotationCause...
random_line_split
event.rs
use collections::borrow::Cow; use ::data::grid; use ::data::shapes::tetromino::{Shape,RotatedShape,Rotation}; use ::game::data::Input; //TODO: Document when the events triggers. If one triggers before or after mutation of the structure ///Events which can occur ingame. ///These should get signaled by the game state ...
{ NewAfterImprint, Desync, Other(Option<Cow<'static,str>>) } #[derive(Clone,Debug,Serialize,Deserialize)] pub enum ShapeImprintCause<P>{ PlayerInflicted(P), Desync, Other(Option<Cow<'static,str>>) }
ShapeChangeCause
identifier_name
workforce3.rs
// Copyright (c) 2016 Yusuke Sasaki // // This software is released under the MIT License.
// See http://opensource.org/licenses/mit-license.php or <LICENSE>. extern crate gurobi; extern crate itertools; use gurobi::*; use itertools::*; mod workforce; use workforce::make_model; fn main() { let mut env = Env::new("workforce3.log").unwrap(); env.set(param::LogToConsole, 0).unwrap(); let mut model = m...
random_line_split
workforce3.rs
// Copyright (c) 2016 Yusuke Sasaki // // This software is released under the MIT License. // See http://opensource.org/licenses/mit-license.php or <LICENSE>. extern crate gurobi; extern crate itertools; use gurobi::*; use itertools::*; mod workforce; use workforce::make_model; fn main()
&constrs[..], RepeatN::new(1.0, constrs.len()).collect_vec().as_slice()) .unwrap(); svars.cloned().collect_vec() }; model.optimize().unwrap(); println!("slack variables: "); for slack in slacks { let value = slack.get(&model, ...
{ let mut env = Env::new("workforce3.log").unwrap(); env.set(param::LogToConsole, 0).unwrap(); let mut model = make_model(&env).unwrap(); model.optimize().unwrap(); match model.status().unwrap() { Status::Infeasible => { let mut model = model.copy().unwrap(); model.set(attr::ModelName, "assi...
identifier_body
workforce3.rs
// Copyright (c) 2016 Yusuke Sasaki // // This software is released under the MIT License. // See http://opensource.org/licenses/mit-license.php or <LICENSE>. extern crate gurobi; extern crate itertools; use gurobi::*; use itertools::*; mod workforce; use workforce::make_model; fn main() { let mut env = Env::new("...
} }
{ println!("Optimization is stopped with status {:?}", status); }
conditional_block
workforce3.rs
// Copyright (c) 2016 Yusuke Sasaki // // This software is released under the MIT License. // See http://opensource.org/licenses/mit-license.php or <LICENSE>. extern crate gurobi; extern crate itertools; use gurobi::*; use itertools::*; mod workforce; use workforce::make_model; fn
() { let mut env = Env::new("workforce3.log").unwrap(); env.set(param::LogToConsole, 0).unwrap(); let mut model = make_model(&env).unwrap(); model.optimize().unwrap(); match model.status().unwrap() { Status::Infeasible => { let mut model = model.copy().unwrap(); model.set(attr::ModelName, "a...
main
identifier_name
json.rs
extern crate serde_json; use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader, Lines}; use data::{Data, Number}; use expr::Expr; use row::Row; use source::{Source, SourceError}; pub struct JsonSource { lines: Lines<BufReader<File>>, } impl JsonSource { pub fn new(filename: &str)...
} serde_json::Value::String(s) => Data::String(s), _ => continue, }; row.fields.insert(Expr::Column(key), val); } return Some(Ok(row)); } } #[cfg(test)] mod tests { use super::*; use row::make_rows; use source::ope...
Data::Number(Number::Float(n.as_f64().unwrap())) }
random_line_split
json.rs
extern crate serde_json; use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader, Lines}; use data::{Data, Number}; use expr::Expr; use row::Row; use source::{Source, SourceError}; pub struct JsonSource { lines: Lines<BufReader<File>>, } impl JsonSource { pub fn
(filename: &str) -> Result<Source, SourceError> { let file = File::open(filename)?; let reader = BufReader::new(file); Ok(Box::new(JsonSource { lines: reader.lines() })) } } impl Iterator for JsonSource { type Item = Result<Row, SourceError>; fn next(&mut self) -> Option<Self::Item>...
new
identifier_name
TestAsinpi.rs
/* * Copyright (C) 2014 The Android Open Source Project * * 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 app...
#pragma version(1) #pragma rs java_package_name(android.renderscript.cts) // Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime. float __attribute__((kernel)) testAsinpiFloatFloat(float inV) { return asinpi(inV); } float2 __attribute__((kernel)) testAsinpiFloat2Float2(float2 inV) { ...
* 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. */
random_line_split
method-missing-call.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 ...
fn get_x(&self) -> isize { self.x } } fn main() { let point: Point = Point::new(); let px: isize = point .get_x;//~ ERROR attempted to take value of method `get_x` on type `Point` //~^ HELP maybe a `()` to call it is missing // Ensure the sp...
{ Point{x:0, y:0} }
identifier_body
method-missing-call.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 ys = &[1,2,3,4,5,6,7]; let a = ys.iter() .map(|x| x) .filter(|&&x| x == 1) .filter_map; //~ ERROR attempted to take value of method `filter_map` on type //~^ HELP maybe a `()` to call it is missing }
let px: isize = point .get_x;//~ ERROR attempted to take value of method `get_x` on type `Point` //~^ HELP maybe a `()` to call it is missing // Ensure the span is useful
random_line_split
method-missing-call.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 ...
() -> Point { Point{x:0, y:0} } fn get_x(&self) -> isize { self.x } } fn main() { let point: Point = Point::new(); let px: isize = point .get_x;//~ ERROR attempted to take value of method `get_x` on type `Point` //~^ HELP maybe a `()` ...
new
identifier_name
alternate_formats_country_code_set.rs
// Copyright (C) 2015 Guillaume Gomez // // 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...
_countryCodeSet.insert(66); _countryCodeSet.insert(81); _countryCodeSet.insert(84); _countryCodeSet.insert(90); _countryCodeSet.insert(91); _countryCodeSet.insert(94); _countryCodeSet.insert(95); _countryCodeSet.insert(255); _countryCodeSet.insert(350); _countryCodeSet.insert(351...
{ // The capacity is set to 57 as there are 43 different entries, // and this offers a load factor of roughly 0.75. let mut _countryCodeSet = HashSet::with_capacity(57); _countryCodeSet.insert(7); _countryCodeSet.insert(27); _countryCodeSet.insert(30); _countryCodeSet.insert(31); _countryCode...
identifier_body
alternate_formats_country_code_set.rs
// Copyright (C) 2015 Guillaume Gomez // // 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...
// and this offers a load factor of roughly 0.75. let mut _countryCodeSet = HashSet::with_capacity(57); _countryCodeSet.insert(7); _countryCodeSet.insert(27); _countryCodeSet.insert(30); _countryCodeSet.insert(31); _countryCodeSet.insert(34); _countryCodeSet.insert(36); _countryCodeSet.in...
// The capacity is set to 57 as there are 43 different entries,
random_line_split
alternate_formats_country_code_set.rs
// Copyright (C) 2015 Guillaume Gomez // // 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...
() -> HashSet<u32> { // The capacity is set to 57 as there are 43 different entries, // and this offers a load factor of roughly 0.75. let mut _countryCodeSet = HashSet::with_capacity(57); _countryCodeSet.insert(7); _countryCodeSet.insert(27); _countryCodeSet.insert(30); _countryCodeSet.insert(31...
get_country_code_set
identifier_name
enter.rs
use crate::errors::Result; use crate::kernel::execve; use crate::kernel::groups::syscall_group_from_sysnum; use crate::kernel::groups::SyscallGroup::*; use crate::kernel::heap::*; use crate::kernel::ptrace::*; use crate::kernel::socket::*; use crate::kernel::standard::*; use crate::process::proot::InfoBag; use crate::p...
(info_bag: &InfoBag, tracee: &mut Tracee) -> Result<()> { let sys_num = tracee.regs.get_sys_num(Original); let sys_type = syscall_group_from_sysnum(sys_num); match sys_type { Accept => accept::enter(), BindConnect => bind_connect::enter(), Brk => brk::enter(), Chdir => chdir...
translate
identifier_name
enter.rs
use crate::errors::Result; use crate::kernel::execve; use crate::kernel::groups::syscall_group_from_sysnum; use crate::kernel::groups::SyscallGroup::*; use crate::kernel::heap::*; use crate::kernel::ptrace::*; use crate::kernel::socket::*; use crate::kernel::standard::*; use crate::process::proot::InfoBag; use crate::p...
PivotRoot => pivot_root::enter(), Ptrace => ptrace::enter(), ReadLink => dir_link_attr::enter(tracee), ReadLinkAt => unlink_mkdir_at::enter(tracee), Rename => link_rename::enter(tracee), RenameAt => rename_at::enter(tracee), SocketCall => socketcall::enter(), ...
{ let sys_num = tracee.regs.get_sys_num(Original); let sys_type = syscall_group_from_sysnum(sys_num); match sys_type { Accept => accept::enter(), BindConnect => bind_connect::enter(), Brk => brk::enter(), Chdir => chdir::enter(tracee), ChmodAccessMkNodAt => chmod_acc...
identifier_body
enter.rs
use crate::errors::Result; use crate::kernel::execve; use crate::kernel::groups::syscall_group_from_sysnum; use crate::kernel::groups::SyscallGroup::*; use crate::kernel::heap::*; use crate::kernel::ptrace::*; use crate::kernel::socket::*; use crate::kernel::standard::*; use crate::process::proot::InfoBag; use crate::p...
RenameAt => rename_at::enter(tracee), SocketCall => socketcall::enter(), StandardSyscall => standard_syscall::enter(tracee), StatAt => stat_at::enter(tracee), SymLink => sym_link::enter(tracee), SymLinkAt => sym_link_at::enter(tracee), Wait => wait::enter(), ...
Rename => link_rename::enter(tracee),
random_line_split
ufcs-explicit-self-bad.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 ...
} struct Bar<T> { f: T, } impl<T> Bar<T> { fn foo(self: Bar<int>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } fn bar(self: &Bar<uint>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } } fn ...
{ //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` self.f + x }
identifier_body
ufcs-explicit-self-bad.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> Bar<T> { fn foo(self: Bar<int>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } fn bar(self: &Bar<uint>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } } fn main() { let foo = box Foo { ...
struct Bar<T> { f: T, }
random_line_split
ufcs-explicit-self-bad.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 ...
<T> { f: T, } impl<T> Bar<T> { fn foo(self: Bar<int>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } fn bar(self: &Bar<uint>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } } fn main() { l...
Bar
identifier_name
parallel.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/. */ //! Implements parallel traversals over the DOM and flow trees. //! //! This code is highly unsafe. Keep this file...
}); }, shared_layout_context); }
random_line_split
parallel.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/. */ //! Implements parallel traversals over the DOM and flow trees. //! //! This code is highly unsafe. Keep this file...
} } } /// A parallel top-down flow traversal. trait ParallelPreorderFlowTraversal : PreorderFlowTraversal { fn run_parallel(&self, unsafe_flows: UnsafeFlowList, proxy: &mut WorkerProxy<SharedLayoutContext, UnsafeFlowList>); fn should_record_thread_ids(&self...
{ // Stop. break }
conditional_block
parallel.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/. */ //! Implements parallel traversals over the DOM and flow trees. //! //! This code is highly unsafe. Keep this file...
pub type UnsafeFlowList = (Box<Vec<UnsafeNode>>, usize); pub type ChunkedFlowTraversalFunction = extern "Rust" fn(UnsafeFlowList, &mut WorkerProxy<SharedLayoutContext, UnsafeFlowList>); pub type FlowTraversalFunction = extern "Rust" fn(UnsafeFlow, &SharedLayoutContext); /// Information that we need stored in e...
{ unsafe { mem::transmute::<&Flow, UnsafeFlow>(flow) } }
identifier_body
parallel.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/. */ //! Implements parallel traversals over the DOM and flow trees. //! //! This code is highly unsafe. Keep this file...
{ /// The number of children that still need work done. pub children_count: AtomicIsize, /// The address of the parent flow. pub parent: UnsafeFlow, } impl FlowParallelInfo { pub fn new() -> FlowParallelInfo { FlowParallelInfo { children_count: AtomicIsize::new(0), ...
FlowParallelInfo
identifier_name
logger.rs
/* Copyright (C) 2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
// Authentication js.open_object("authentication")?; if let Some(chosen_security_type) = tx.chosen_security_type { js.set_uint("security_type", chosen_security_type as u64)?; } match tx.chosen_security_type { Some(2) => { js.open_object("vnc")?; if let Some(re...
random_line_split
logger.rs
/* Copyright (C) 2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
js.close()?; } _ => () } if let Some(security_result) = &tx.tc_security_result { let _ = match security_result.status { 0 => js.set_string("security_result", "OK")?, 1 => js.set_string("security-result", "FAIL")?, 2 => js.set_string("secur...
{ let mut s = String::new(); for &byte in &sr.secret[..] { write!(&mut s, "{:02x}", byte).expect("Unable to write"); } js.set_string("response", &s)?; }
conditional_block
logger.rs
/* Copyright (C) 2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
js.set_uint("security_type", chosen_security_type as u64)?; } match tx.chosen_security_type { Some(2) => { js.open_object("vnc")?; if let Some(ref sc) = tx.tc_vnc_challenge { let mut s = String::new(); for &byte in &sc.secret[..] { ...
{ js.open_object("rfb")?; // Protocol version if let Some(tx_spv) = &tx.tc_server_protocol_version { js.open_object("server_protocol_version")?; js.set_string("major", &tx_spv.major)?; js.set_string("minor", &tx_spv.minor)?; js.close()?; } if let Some(tx_cpv) = &tx.t...
identifier_body
logger.rs
/* Copyright (C) 2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
(_state: &mut RFBState, tx: *mut std::os::raw::c_void, js: &mut JsonBuilder) -> bool { let tx = cast_pointer!(tx, RFBTransaction); log_rfb(tx, js).is_ok() }
rs_rfb_logger_log
identifier_name
tree_sortable.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use TreeModel; use ffi; use glib; use glib::object::Downcast; use glib::object::IsA; use glib::signal::connect; use glib::translate::*; use glib_ffi; use std::boxed::Box as Box_; use std::mem::transmute;
glib_wrapper! { pub struct TreeSortable(Object<ffi::GtkTreeSortable>): TreeModel; match fn { get_type => || ffi::gtk_tree_sortable_get_type(), } } pub trait TreeSortableExt { fn has_default_sort_func(&self) -> bool; //fn set_default_sort_func<'a, P: Into<Option</*Unimplemented*/Fundamenta...
random_line_split
tree_sortable.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use TreeModel; use ffi; use glib; use glib::object::Downcast; use glib::object::IsA; use glib::signal::connect; use glib::translate::*; use glib_ffi; use std::boxed::Box as Box_; use std::mem::transmute; glib_wrapper! { pub struct...
{ callback_guard!(); let f: &Box_<Fn(&P) + 'static> = transmute(f); f(&TreeSortable::from_glib_none(this).downcast_unchecked()) }
identifier_body
tree_sortable.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use TreeModel; use ffi; use glib; use glib::object::Downcast; use glib::object::IsA; use glib::signal::connect; use glib::translate::*; use glib_ffi; use std::boxed::Box as Box_; use std::mem::transmute; glib_wrapper! { pub struct...
<F: Fn(&Self) +'static>(&self, f: F) -> u64 { unsafe { let f: Box_<Box_<Fn(&Self) +'static>> = Box_::new(Box_::new(f)); connect(self.to_glib_none().0, "sort-column-changed", transmute(sort_column_changed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _) }...
connect_sort_column_changed
identifier_name
tx.rs
use std::collections::HashMap; use protobuf::Message; use crypto::{PublicKey, SecretKey, Signature, sign, verify_signature}; use ironcoin_pb::{Commitment, DetachedSignature, Transaction, Transfer}; use error::{IroncError, IroncResult}; pub trait TransactionExt { fn verify_signatures(&self) -> IroncResult<()>; } ...
, None => return Err(IroncError::new("Missing key.")) } } Ok(()) } } #[derive(Default)] pub struct TransactionBuilder { transfer_secret_keys: Vec<SecretKey>, bounty_secret_key: Option<SecretKey>, commit: Commitment } impl TransactionBuilder { pub fn new(...
{ let public_key = try!(PublicKey::from_slice(transfer.get_source_pk())); let signature = try!(Signature::from_slice(sign_bytes)); try!(verify_signature(&public_key, commit_bytes, &signature)); }
conditional_block
tx.rs
use std::collections::HashMap; use protobuf::Message; use crypto::{PublicKey, SecretKey, Signature, sign, verify_signature}; use ironcoin_pb::{Commitment, DetachedSignature, Transaction, Transfer}; use error::{IroncError, IroncResult}; pub trait TransactionExt { fn verify_signatures(&self) -> IroncResult<()>; } ...
( &mut self, sk: &SecretKey, source: &PublicKey, destination: &PublicKey, tokens: u64, op_index:u32) -> &mut Self { let mut transfer = Transfer::new(); transfer.set_op_index(op_index); transfer.set_tokens(tokens); transfer.mut_source_pk().push_all(&source.0); tran...
add_transfer
identifier_name
tx.rs
use std::collections::HashMap; use protobuf::Message; use crypto::{PublicKey, SecretKey, Signature, sign, verify_signature}; use ironcoin_pb::{Commitment, DetachedSignature, Transaction, Transfer}; use error::{IroncError, IroncResult}; pub trait TransactionExt { fn verify_signatures(&self) -> IroncResult<()>; } ...
pub fn add_transfer( &mut self, sk: &SecretKey, source: &PublicKey, destination: &PublicKey, tokens: u64, op_index:u32) -> &mut Self { let mut transfer = Transfer::new(); transfer.set_op_index(op_index); transfer.set_tokens(tokens); transfer.mut_source_pk().push_all...
{ TransactionBuilder { transfer_secret_keys: Vec::<SecretKey>::new(), bounty_secret_key: None, commit: Commitment::new() } }
identifier_body
tx.rs
use std::collections::HashMap; use protobuf::Message; use crypto::{PublicKey, SecretKey, Signature, sign, verify_signature}; use ironcoin_pb::{Commitment, DetachedSignature, Transaction, Transfer}; use error::{IroncError, IroncResult}; pub trait TransactionExt { fn verify_signatures(&self) -> IroncResult<()>; } ...
commit: Commitment } impl TransactionBuilder { pub fn new() -> TransactionBuilder { TransactionBuilder { transfer_secret_keys: Vec::<SecretKey>::new(), bounty_secret_key: None, commit: Commitment::new() } } pub fn add_transfer( &mut self, sk:...
#[derive(Default)] pub struct TransactionBuilder { transfer_secret_keys: Vec<SecretKey>, bounty_secret_key: Option<SecretKey>,
random_line_split
mod.rs
mod asset; mod combat_screen; mod input; mod start_screen; mod teams_screen; mod text; mod types; use sdl2::render::Texture; pub use asset::*; pub use input::*; pub use text::*; pub use types::*; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::WindowCanvas; use std::time::Instant; use crate::core::{...
fn update_scrolling(ui: UI, g: &Game, i: &Option<UserInput>) -> UI { let scrolling = ui.scrolling; let (_, _, w, h) = ui.viewport; UI { scrolling: match (scrolling, g, i) { (Some(sd), Game::Combat(..), None) => Some(sd), (None, Game::Combat(combat_data), _) => Some(Scroll...
{ if ui.frames == 50 { let time_for_50_frames = ui.last_check.elapsed().as_nanos(); UI { frames: 0, fps: 50_000_000_000 / time_for_50_frames, last_check: std::time::Instant::now(), ..ui } } else { UI { frames: ui.frames...
identifier_body
mod.rs
mod asset; mod combat_screen; mod input; mod start_screen; mod teams_screen; mod text; mod types; use sdl2::render::Texture; pub use asset::*; pub use input::*; pub use text::*; pub use types::*; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::WindowCanvas; use std::time::Instant; use crate::core::{...
( cvs: &mut WindowCanvas, assets: &mut AssetRepo, scene: Scene, ) -> Result<(), String> { let (r, g, b) = scene.background; cvs.set_draw_color(Color::RGB(r, g, b)); cvs.clear(); for (tex_name, ScreenSprite(pos, align, sprite)) in scene.images { if let Some(ref mut t) = assets.textu...
draw_scene
identifier_name
mod.rs
mod asset; mod combat_screen; mod input; mod start_screen; mod teams_screen; mod text; mod types; use sdl2::render::Texture; pub use asset::*; pub use input::*; pub use text::*; pub use types::*; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::WindowCanvas; use std::time::Instant; use crate::core::{...
); // let time_create_scene = Instant::now() - now; // let now = Instant::now(); draw_scene(cvs, assets, scene)?; // let time_draw_scene = Instant::now() - now; // cvs.present(); // println!("create scene: {}ms, draw scene {}ms", time_create_scene.as_millis(), time_draw_scene.as_millis());...
random_line_split
label.rs
use std::fmt::{Write, self}; use std::iter; use std::str; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Label { bits: u8, // amount of bits in tail (last element of vec). always between 0 and 7 buffer: Vec<u8> // backing buffer } impl Label { /** * Small layout intermezzo * A lab...
(&mut self) -> Option<bool> { if self.bits == 0 { if self.buffer.len() > 1 { self.buffer.pop(); self.bits = 8; } else { return None; } } let len = self.buffer.len(); let tail = &mut self.buffer[len - 1];...
pop
identifier_name
label.rs
use std::fmt::{Write, self}; use std::iter; use std::str; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Label { bits: u8, // amount of bits in tail (last element of vec). always between 0 and 7 buffer: Vec<u8> // backing buffer } impl Label { /** * Small layout intermezzo * A lab...
pub fn len(&self) -> usize { let len = self.buffer.len(); if len == 0 { return 0; } return len * 8 - 8 + self.bits as usize } pub fn push(&mut self, val: bool) { if self.buffer.len() == 0 { self.buffer.push(0) } self.bits +=...
{ Label {bits: 0, buffer: Vec::new()} }
identifier_body
label.rs
use std::fmt::{Write, self}; use std::iter; use std::str; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Label { bits: u8, // amount of bits in tail (last element of vec). always between 0 and 7 buffer: Vec<u8> // backing buffer } impl Label { /** * Small layout intermezzo * A lab...
*tail ^= val; self.bits -= 1; return Some(val!= 0); } } impl fmt::Display for Label { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let len = self.buffer.len(); if self.bits == 0 && len > 0 { if self.buffer[..len - 1].iter().all(|c| match *c { ...
let val: u8 = *tail & (1 << (8 - self.bits));
random_line_split
label.rs
use std::fmt::{Write, self}; use std::iter; use std::str; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Label { bits: u8, // amount of bits in tail (last element of vec). always between 0 and 7 buffer: Vec<u8> // backing buffer } impl Label { /** * Small layout intermezzo * A lab...
} pub fn pop(&mut self) -> Option<bool> { if self.bits == 0 { if self.buffer.len() > 1 { self.buffer.pop(); self.bits = 8; } else { return None; } } let len = self.buffer.len(); let tail = &mut...
{ self.buffer.push(0); self.bits = 0; }
conditional_block
main.rs
extern crate stopwatch; use stopwatch::{Stopwatch}; fn main() { let timer = Stopwatch::start_new(); //digits are stored in reverse order (least significant first) as an optimization match expand(196, 100000) { Ok(iter) => println!("converged after {} iterations", iter), Err(max_iters) => pr...
if is_palindrome(&digits) { return Ok(iter); } } //return iteration count as error value Err(max_iters) } fn to_digits(n:u64) -> Vec<u8> { let mut rem = n; let mut digits:Vec<u8> = Vec::new(); while rem > 0 { let digit = (rem % 10) as u8; rem /= 10; ...
{ println!("{} {}", iter, digits.len()); }
conditional_block
main.rs
extern crate stopwatch; use stopwatch::{Stopwatch}; fn main() { let timer = Stopwatch::start_new(); //digits are stored in reverse order (least significant first) as an optimization match expand(196, 100000) { Ok(iter) => println!("converged after {} iterations", iter), Err(max_iters) => pr...
(digits: &mut Vec<u8>) { //first fold in half and sum, to cut down on additions let digits_len = digits.len(); for i in 0.. (digits_len + 1) / 2 { let j = digits_len - 1 - i; let sum = digits[i] + digits[j]; digits[i] = sum; digits[j] = sum; } //now propagate overflow...
reverse_add
identifier_name
main.rs
extern crate stopwatch; use stopwatch::{Stopwatch}; fn main() { let timer = Stopwatch::start_new(); //digits are stored in reverse order (least significant first) as an optimization match expand(196, 100000) { Ok(iter) => println!("converged after {} iterations", iter), Err(max_iters) => pr...
/* note that digits here are in reverse order (least significant digit first) e.g. the number 349 should be represented as vec![9,4,3] this lets us easily grow the array when a new digit is created by overflow, as we can simply append it. Otherwise we'd have to prepend, which is slower. */ fn reverse_add(digits: &mu...
{ let mut rem = n; let mut digits:Vec<u8> = Vec::new(); while rem > 0 { let digit = (rem % 10) as u8; rem /= 10; digits.push(digit); } return digits; }
identifier_body
main.rs
extern crate stopwatch; use stopwatch::{Stopwatch}; fn main() { let timer = Stopwatch::start_new(); //digits are stored in reverse order (least significant first) as an optimization match expand(196, 100000) { Ok(iter) => println!("converged after {} iterations", iter), Err(max_iters) => pr...
}
} } return true;
random_line_split
unbind_3pid.rs
//! [POST /_matrix/client/r0/account/3pid/unbind](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-unbind) use ruma_api::ruma_api; use super::ThirdPartyIdRemovalStatus; use crate::r0::thirdparty::Medium; ruma_api! { metadata { description: "Unbind a 3PID from a user's ...
error: crate::Error }
random_line_split
motion.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/. */ //! Specified types for CSS values that are related to motion path. use crate::parser::{Parse, ParserContext}; u...
(computed: &Self::ComputedValue) -> Self { OffsetRotate { direction: if computed.auto { OffsetRotateDirection::Auto } else { OffsetRotateDirection::None }, angle: ToComputedValue::from_computed_value(&computed.angle), } ...
from_computed_value
identifier_name
motion.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/. */ //! Specified types for CSS values that are related to motion path. use crate::parser::{Parse, ParserContext}; u...
#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)] #[repr(u8)] pub enum OffsetRotateDirection { /// Unspecified direction keyword. #[css(skip)] None, /// 0deg offset (face forward). Auto, /// 180deg offset (face backward). Reverse, } impl Offse...
/// The direction of offset-rotate.
random_line_split
motion.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/. */ //! Specified types for CSS values that are related to motion path. use crate::parser::{Parse, ParserContext}; u...
}
{ OffsetRotate { direction: if computed.auto { OffsetRotateDirection::Auto } else { OffsetRotateDirection::None }, angle: ToComputedValue::from_computed_value(&computed.angle), } }
identifier_body
motion.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/. */ //! Specified types for CSS values that are related to motion path. use crate::parser::{Parse, ParserContext}; u...
if!contain { contain = input.try(|i| i.expect_ident_matching("contain")).is_ok(); if contain { continue; } } break; } if angle.is_none() || size.is_none() { return Err(input.new_custom_...
{ size = input.try(RaySize::parse).ok(); if size.is_some() { continue; } }
conditional_block
main.rs
// Powerlink Analyzer - Analyze Ethernet POWERLINK Network Traffic // Copyright (C) 2016, Thomas Keh // // This program 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, version 3 of the License. // // This pr...
eval.print_errors::<StdoutPrinter>(); eval.print_state_changes::<StdoutPrinter>(); eval.print_stats::<StdoutPrinter>(); } } }
eval.print_stats::<CsvPrinter>(); } else if matches.opt_present("r") { eval.print_raw(&filter, matches.opt_present("s")); } else { eval.print_metadata::<StdoutPrinter>();
random_line_split
main.rs
// Powerlink Analyzer - Analyze Ethernet POWERLINK Network Traffic // Copyright (C) 2016, Thomas Keh // // This program 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, version 3 of the License. // // This pr...
() { let _ = SimpleLogger::init(LogLevelFilter::Info); let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); opts.optflag("p", "pgftable", "prints master metrics as pgf table"); opts.optflag("c", "csv", "...
main
identifier_name
main.rs
// Powerlink Analyzer - Analyze Ethernet POWERLINK Network Traffic // Copyright (C) 2016, Thomas Keh // // This program 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, version 3 of the License. // // This pr...
fn main() { let _ = SimpleLogger::init(LogLevelFilter::Info); let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); opts.optflag("p", "pgftable", "prints master metrics as pgf table"); opts.optflag("c",...
{ let brief = format!("Usage: {} [options] PCAPNG_FILE", program); print!("{}", opts.usage(&brief)); }
identifier_body
main.rs
// Powerlink Analyzer - Analyze Ethernet POWERLINK Network Traffic // Copyright (C) 2016, Thomas Keh // // This program 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, version 3 of the License. // // This pr...
else { "type=='pres'".to_string() }; for file_path in &matches.free { //info!("Loading PCAP file {}.",file_path); let file_path = Path::new(&file_path); let mut cap = Capture::from_file_with_precision(file_path,Precision::Nano).expect("Loading PCAP file failed"); let mut db = Database::new(); { ...
{ matches.opt_str("f").unwrap() }
conditional_block
recursive-struct.rs
// Copyright 2013-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-MI...
}; // It's important that LongCycleWithAnonymousTypes is encountered only at the end of the // `box` chain. let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes { next: Val { val: box box box box box LongCycleWithAnonymousTypes { next: E...
next: None, value: 29.5,
random_line_split
recursive-struct.rs
// Copyright 2013-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-MI...
<T> { next: Box<LongCycle3<T>>, value: T, } struct LongCycle3<T> { next: Box<LongCycle4<T>>, value: T, } struct LongCycle4<T> { next: Option<Box<LongCycle1<T>>>, value: T, } struct LongCycleWithAnonymousTypes { next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>, value: ui...
LongCycle2
identifier_name
nist-spce.rs
// Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 G. Fraux — BSD license //! Testing energy computation for SPC/E water using data from //! https://www.nist.gov/mml/csd/chemical-informatics-research-group/spce-water-reference-calculations-9%C3%A5-cutoff //! https://www.nist.gov/mml/csd/che...
{ let system = get_system("spce-1.xyz", 10.0); let energy = system.potential_energy() / K_BOLTZMANN; let expected = -4.88604e5; assert!(f64::abs((energy - expected)/expected) < 1e-3); } #[test] fn nist2() { let system = get_system("spce-2.xyz", 10.0); let e...
t1()
identifier_name