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
publisher_to_multiple_subscribers.rs
use crossbeam::channel::unbounded; use std::process::Command; mod util; mod msg { rosrust::rosmsg_include!(std_msgs / String, rosgraph_msgs / Log);
#[test] fn publisher_to_multiple_subscribers() { let _roscore = util::run_roscore_for(util::Language::Multi, util::Feature::Publisher); let _subscriber_cpp = util::ChildProcessTerminator::spawn( Command::new("rosrun") .arg("roscpp_tutorials") .arg("listener") .arg("__nam...
}
random_line_split
path.rs
use std::cmp; use std::fmt::{self, Debug, Formatter}; use std::fs; use std::io::prelude::*; use std::path::{Path, PathBuf}; use filetime::FileTime; use git2; use glob::Pattern; use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry}; use ops; use util::{self, CargoResult, internal, internal_er...
_ => {} } } try!(PathSource::walk(&dir, ret, false, filter)); } return Ok(()) } } impl<'cfg> Debug for PathSource<'cfg> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "the paths source") } } impl<'cfg> Regis...
// Skip cargo artifacts match name { Some("target") | Some("Cargo.lock") => continue,
random_line_split
path.rs
use std::cmp; use std::fmt::{self, Debug, Formatter}; use std::fs; use std::io::prelude::*; use std::path::{Path, PathBuf}; use filetime::FileTime; use git2; use glob::Pattern; use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry}; use ops; use util::{self, CargoResult, internal, internal_er...
(&self, pkg: &Package) -> CargoResult<Vec<PathBuf>> { let root = pkg.root(); let parse = |p: &String| { Pattern::new(p).map_err(|e| { human(format!("could not parse pattern `{}`: {}", p, e)) }) }; let exclude = try!(pkg.manifest().exclude().iter()...
list_files
identifier_name
path.rs
use std::cmp; use std::fmt::{self, Debug, Formatter}; use std::fs; use std::io::prelude::*; use std::path::{Path, PathBuf}; use filetime::FileTime; use git2; use glob::Pattern; use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry}; use ops; use util::{self, CargoResult, internal, internal_er...
fn read_packages(&self) -> CargoResult<Vec<Package>> { if self.updated { Ok(self.packages.clone()) } else if self.id.is_path() && self.id.precise().is_some() { // If our source id is a path and it's listed with a precise // version, then it means that we're not ...
{ trace!("root_package; source={:?}", self); if !self.updated { return Err(internal("source has not been updated")) } match self.packages.iter().find(|p| p.root() == &*self.path) { Some(pkg) => Ok(pkg.clone()), None => Err(internal("no package found ...
identifier_body
selector_parser.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/. */ //! Gecko-specific bits for selector-parsing. use cssparser::ToCss; use element_state::ElementState; use gecko_bi...
; impl ::selectors::SelectorImpl for SelectorImpl { type AttrValue = Atom; type Identifier = Atom; type ClassName = Atom; type LocalName = Atom; type NamespacePrefix = Atom; type NamespaceUrl = Namespace; type BorrowedNamespaceUrl = WeakNamespace; type BorrowedLocalName = WeakAtom; ...
SelectorImpl
identifier_name
selector_parser.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/. */ //! Gecko-specific bits for selector-parsing. use cssparser::ToCss; use element_state::ElementState; use gecko_bi...
PseudoElement(atom, is_anon_box) } #[inline] fn from_atom(atom: &WeakAtom, _in_ua: bool) -> Option<Self> { macro_rules! pseudo_element { ($pseudo_str_with_colon:expr, $atom:expr, $is_anon_box:expr) => {{ if atom == &*$atom { return Some(Pseu...
{ // Do the check on debug regardless. match Self::from_atom(&*atom, true) { Some(pseudo) => { assert_eq!(pseudo.is_anon_box(), is_anon_box); return pseudo; } None => panic!("Unknown pseudo: {:?}", atom), ...
conditional_block
selector_parser.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/. */ //! Gecko-specific bits for selector-parsing. use cssparser::ToCss; use element_state::ElementState; use gecko_bi...
type Impl = SelectorImpl; fn parse_non_ts_pseudo_class(&self, name: Cow<str>) -> Result<NonTSPseudoClass, ()> { macro_rules! pseudo_class_list { ($(($css:expr, $name:ident, $_gecko_type:tt, $_state:tt, $_flags:tt),)*) => { match_ignore_ascii_case! { &name, ...
} impl<'a> ::selectors::Parser for SelectorParser<'a> {
random_line_split
selector_parser.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/. */ //! Gecko-specific bits for selector-parsing. use cssparser::ToCss; use element_state::ElementState; use gecko_bi...
}
{ pc.state_flag() }
identifier_body
error.rs
use std::fmt; use std::error::Error; /// Error when spawning a new state machine pub enum SpawnError<S: Sized> { /// The State Machine Slab capacity is reached /// /// The capacity is configured in the `rotor::Config` and is used /// for creating `rotor::Loop`. /// /// The item in this struct ...
(&self) -> &str { use self::SpawnError::*; match self { &NoSlabSpace(_) => "state machine slab capacity limit is reached", &UserError(ref err) => err.description(), } } pub fn cause(&self) -> Option<&Error> { use self::SpawnError::*; match self { ...
description
identifier_name
error.rs
use std::fmt; use std::error::Error; /// Error when spawning a new state machine pub enum SpawnError<S: Sized> { /// The State Machine Slab capacity is reached /// /// The capacity is configured in the `rotor::Config` and is used /// for creating `rotor::Loop`. /// /// The item in this struct ...
NoSlabSpace(..) => { write!(fmt, "NoSlabSpace(<hidden seed>)") } UserError(ref err) => { write!(fmt, "UserError({:?})", err) } } } }
impl<S> fmt::Debug for SpawnError<S> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { use self::SpawnError::*; match *self {
random_line_split
error.rs
use std::fmt; use std::error::Error; /// Error when spawning a new state machine pub enum SpawnError<S: Sized> { /// The State Machine Slab capacity is reached /// /// The capacity is configured in the `rotor::Config` and is used /// for creating `rotor::Loop`. /// /// The item in this struct ...
} impl<S> SpawnError<S> { pub fn description(&self) -> &str { use self::SpawnError::*; match self { &NoSlabSpace(_) => "state machine slab capacity limit is reached", &UserError(ref err) => err.description(), } } pub fn cause(&self) -> Option<&Error> { ...
{ use self::SpawnError::*; match *self { NoSlabSpace(_) => { write!(fmt, "state machine slab capacity limit is reached") } UserError(ref err) => { write!(fmt, "{}", err) } } }
identifier_body
webglrenderbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLCommand, WebG...
constants::RGB565 => { // RGB565 is not supported on desktop GL. if is_gles() { constants::RGB565 } else { WebGl2Constants::RGB8 } } _ => return Err(WebGLError::InvalidEnum), ...
{ // 16-bit RGBA formats are not supported on desktop GL. if is_gles() { constants::RGB5_A1 } else { WebGl2Constants::RGBA8 } }
conditional_block
webglrenderbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLCommand, WebG...
pub fn ever_bound(&self) -> bool { self.ever_bound.get() } pub fn storage(&self, internal_format: u32, width: i32, height: i32) -> WebGLResult<()> { // Validate the internal_format, and save it for completeness // validation. let actual_format = match internal_format { ...
{ self.is_deleted.get() }
identifier_body
webglrenderbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult, is_gles, webgl_channel}; use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2...
random_line_split
webglrenderbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLCommand, WebG...
(&self) -> u32 { self.internal_format.get().unwrap_or(constants::RGBA4) } pub fn mark_initialized(&self) { self.is_initialized.set(true); } pub fn is_initialized(&self) -> bool { self.is_initialized.get() } pub fn bind(&self, target: u32) { self.ever_bound.set(...
internal_format
identifier_name
build.rs
#![allow(unused)] use std::env; use std::fs::File; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; fn wasi_sdk() -> PathBuf { Path::new(&env::var("WASI_SDK").unwrap_or("/opt/wasi-sdk".to_owned())).to_path_buf() } fn wasi_sysroot() -> PathBuf { match env::var("WASI_SYSROOT") { Ok(w...
() {} #[cfg(feature = "update-bindings")] fn main() { let wasi_sysroot = wasi_sysroot(); let wasm_clang_root = wasm_clang_root(); assert!( wasi_sysroot.exists(), "wasi-sysroot not present at {:?}", wasi_sysroot ); assert!( wasm_clang_root.exists(), "clang-roo...
main
identifier_name
build.rs
#![allow(unused)] use std::env; use std::fs::File; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; fn wasi_sdk() -> PathBuf { Path::new(&env::var("WASI_SDK").unwrap_or("/opt/wasi-sdk".to_owned())).to_path_buf() } fn wasi_sysroot() -> PathBuf { match env::var("WASI_SYSROOT") { Ok(w...
let host_builder = bindgen::Builder::default() .clang_arg("-nostdinc") .clang_arg("-D__wasi__") .clang_arg(format!("-isystem={}/include/", wasi_sysroot.display())) .clang_arg(format!("-I{}/include/", wasm_clang_root.display())) .header(core_h_path.to_str().unwrap()) .white...
random_line_split
build.rs
#![allow(unused)] use std::env; use std::fs::File; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; fn wasi_sdk() -> PathBuf { Path::new(&env::var("WASI_SDK").unwrap_or("/opt/wasi-sdk".to_owned())).to_path_buf() } fn wasi_sysroot() -> PathBuf
fn wasm_clang_root() -> PathBuf { match env::var("CLANG_ROOT") { Ok(clang) => Path::new(&clang).to_path_buf(), Err(_) => { let mut path = wasi_sdk(); path.push("lib"); path.push("clang"); path.push("8.0.1"); path } } } // `sr...
{ match env::var("WASI_SYSROOT") { Ok(wasi_sysroot) => Path::new(&wasi_sysroot).to_path_buf(), Err(_) => { let mut path = wasi_sdk(); path.push("share"); path.push("wasi-sysroot"); path } } }
identifier_body
performancetiming.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/. */ use crate::dom::bindings::codegen::Bindings::PerformanceTimingBinding; use crate::dom::bindings::codegen::Binding...
(&self) -> u64 { self.document.get_load_event_end() } // check-tidy: no specs after this line // Servo-only timing for when top-level content (not iframes) is complete fn TopLevelDomComplete(&self) -> u64 { self.document.get_top_level_dom_complete() } } impl PerformanceTiming { ...
LoadEventEnd
identifier_name
performancetiming.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/. */ use crate::dom::bindings::codegen::Bindings::PerformanceTimingBinding; use crate::dom::bindings::codegen::Binding...
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-loadEventEnd fn LoadEventEnd(&self) -> u64 { self.document.get_load_event_end() } // check-tidy: no specs after this line // Servo-only timing for when top-level content (not iframes) is complete fn TopLevelDomComplete(&...
}
random_line_split
performancetiming.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/. */ use crate::dom::bindings::codegen::Bindings::PerformanceTimingBinding; use crate::dom::bindings::codegen::Binding...
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domContentLoadedEventStart fn DomContentLoadedEventStart(&self) -> u64 { self.document.get_dom_content_loaded_event_start() } // https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domContentLoadedEventEnd fn D...
{ self.document.get_dom_interactive() }
identifier_body
shootout-chameneos-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
() { let all = [Blue, Red, Yellow]; for aa in &all { for bb in &all { println!("{:?} + {:?} -> {:?}", *aa, *bb, transform(*aa, *bb)); } } } #[derive(Copy)] enum Color { Red, Yellow, Blue, } impl fmt::Debug for Color { fn fmt(&self, f: &mut fmt::Formatter) -> fmt...
print_complements
identifier_name
shootout-chameneos-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
1 => {" one"} 2 => {" two"} 3 => {" three"} 4 => {" four"} 5 => {" five"} 6 => {" six"} 7 => {" seven"} 8 => {" eight"} 9 => {" nine"} _ => {panic!("expected digits from 0 to 9...")} } } struct Number(uint); impl fmt::Debug for Number...
{" zero"}
conditional_block
shootout-chameneos-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
{ let nn = if std::env::var_os("RUST_BENCH").is_some() { 200000 } else { std::env::args() .nth(1) .and_then(|arg| arg.parse().ok()) .unwrap_or(600) }; print_complements(); println!(""); rendezvous(nn, vec!(Blu...
identifier_body
shootout-chameneos-redux.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
if other_creature.name == name { evil_clones_met += 1; } } None => break } } // log creatures met and evil clones of self let report = format!("{}{:?}", creatures_met, Number(evil_clones_met)); to_rendezvous_log.send(repo...
color = transform(color, other_creature.color); // track some statistics creatures_met += 1;
random_line_split
imprint_bool.rs
use core::ops::Deref; use super::{Grid as GridTrait,SizeAxis,Pos,RectangularBound}; use ::data::Cell; ///Imprints `b` on `a` #[derive(Copy,Clone,Eq,PartialEq)] pub struct Grid<GA,GB>{ pub a: GA, pub b: GB, } impl<DA,DB,GA,GB> GridTrait for Grid<DA,DB> where DA: Deref<Target = GA>, DB: Deref<Target = GB>, ...
(&self) -> SizeAxis{self.a.height()} }
height
identifier_name
imprint_bool.rs
use core::ops::Deref; use super::{Grid as GridTrait,SizeAxis,Pos,RectangularBound}; use ::data::Cell; ///Imprints `b` on `a` #[derive(Copy,Clone,Eq,PartialEq)] pub struct Grid<GA,GB>{
} impl<DA,DB,GA,GB> GridTrait for Grid<DA,DB> where DA: Deref<Target = GA>, DB: Deref<Target = GB>, GA: GridTrait, GB: GridTrait, <GA as GridTrait>::Cell: Cell + Copy, <GB as GridTrait>::Cell: Cell + Copy, { type Cell = bool; #[inline]fn is_out_of_bounds(&self,pos: Pos) -> bool{ ...
pub a: GA, pub b: GB,
random_line_split
imprint_bool.rs
use core::ops::Deref; use super::{Grid as GridTrait,SizeAxis,Pos,RectangularBound}; use ::data::Cell; ///Imprints `b` on `a` #[derive(Copy,Clone,Eq,PartialEq)] pub struct Grid<GA,GB>{ pub a: GA, pub b: GB, } impl<DA,DB,GA,GB> GridTrait for Grid<DA,DB> where DA: Deref<Target = GA>, DB: Deref<Target = GB>, ...
} } } impl<DA,DB,GA> RectangularBound for Grid<DA,DB> where DA: Deref<Target = GA>, GA: RectangularBound, { #[inline]fn bound_start(&self) -> Pos{self.a.bound_start()} #[inline]fn width(&self) -> SizeAxis{self.a.width()} #[inline]fn height(&self) -> SizeAxis{self.a.height()} }
{ self.b.pos(pos).is_occupied() }
conditional_block
rs_receiver.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
}, Err(e) => { println!("rs_benchmark: unable to receive packet: {}", e); } } } // We received 1_000_000 packets in ((b - a) * 1_000_000) seconds. for (a, b) in timestamps.iter().zip(timestamps.tail().iter()) { println!("{}", *b - *a); ...
{ timestamps.push(time::precise_time_ns() / 1_000); if timestamps.len() == 201 { break; } i = 0; }
conditional_block
rs_receiver.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
() { let iface_name = env::args().nth(1).unwrap(); let interface_names_match = |iface: &NetworkInterface| iface.name == iface_name; // Find the network interface with the provided name let interfaces = get_network_interfaces(); let interface = interfaces.into_iter() .fi...
main
identifier_name
rs_receiver.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
let mut iter = rx.iter(); loop { match iter.next() { Ok(_) => { i += 1; if i == 1_000_000 { timestamps.push(time::precise_time_ns() / 1_000); if timestamps.len() == 201 { break; ...
{ let iface_name = env::args().nth(1).unwrap(); let interface_names_match = |iface: &NetworkInterface| iface.name == iface_name; // Find the network interface with the provided name let interfaces = get_network_interfaces(); let interface = interfaces.into_iter() .filt...
identifier_body
rs_receiver.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
} } } // We received 1_000_000 packets in ((b - a) * 1_000_000) seconds. for (a, b) in timestamps.iter().zip(timestamps.tail().iter()) { println!("{}", *b - *a); } }
random_line_split
core-map.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { let args = os::args(); let n_keys = { if args.len() == 2 { from_str::<uint>(args[1]).unwrap() } else { 1000000 } }; let mut rand = vec::with_capacity(n_keys); { let mut rng: IsaacRng = SeedableRng::from_seed(&[1, 1, 1, 1, 1, 1, ...
{ timed("insert", || { for i in range(0u, n_keys) { map.insert(dist[i], i + 1); } }); timed("search", || { for i in range(0u, n_keys) { assert_eq!(map.find(&dist[i]).unwrap(), &(i + 1)); } }); timed("remove", || { for i in range(0u, n...
identifier_body
core-map.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}; let mut rand = vec::with_capacity(n_keys); { let mut rng: IsaacRng = SeedableRng::from_seed(&[1, 1, 1, 1, 1, 1, 1]); let mut set = HashSet::new(); while set.len()!= n_keys { let next = rng.gen(); if set.insert(next) { rand.push(next); ...
{ 1000000 }
conditional_block
core-map.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(label: &str, f: ||) { let start = time::precise_time_s(); f(); let end = time::precise_time_s(); println!(" {}: {}", label, end - start); } fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) { println!(" Ascending integers:"); timed("insert", || { for i in range(0u, n...
timed
identifier_name
core-map.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
timed("insert", || { for i in range(0u, n_keys) { map.insert(dist[i], i + 1); } }); timed("search", || { for i in range(0u, n_keys) { assert_eq!(map.find(&dist[i]).unwrap(), &(i + 1)); } }); timed("remove", || { for i in range(0u, n_k...
} fn vector<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint, dist: &[uint]) {
random_line_split
fix_ssa_opcalls.rs
//! Fixes the call target for all call sites in the SSA //! For every [`OpCall`] SSA node in every function, try to find that call //! site's corresponding edge in [the callgraph] and replace the "target" //! operand of the SSA node with a constant value for the address of the actual //! call target. //! //! [`OpCall`]...
(&self) -> &dyn Any { self } } impl ModuleAnalyzer for CallSiteFixer { fn analyze<T: FnMut(Box<Change>) -> Action>( &mut self, rmod: &mut RadecoModule, _policy: Option<T>, ) -> Option<Box<AnalyzerResult>> { for rfun in rmod.functions.values_mut() { go_fn(...
as_any
identifier_name
fix_ssa_opcalls.rs
//! Fixes the call target for all call sites in the SSA //! For every [`OpCall`] SSA node in every function, try to find that call //! site's corresponding edge in [the callgraph] and replace the "target" //! operand of the SSA node with a constant value for the address of the actual //! call target. //! //! [`OpCall`]...
} impl Analyzer for CallSiteFixer { fn info(&self) -> &'static AnalyzerInfo { &INFO } fn as_any(&self) -> &dyn Any { self } } impl ModuleAnalyzer for CallSiteFixer { fn analyze<T: FnMut(Box<Change>) -> Action>( &mut self, rmod: &mut RadecoModule, _policy: O...
{ CallSiteFixer }
identifier_body
fix_ssa_opcalls.rs
//! Fixes the call target for all call sites in the SSA //! For every [`OpCall`] SSA node in every function, try to find that call //! site's corresponding edge in [the callgraph] and replace the "target" //! operand of the SSA node with a constant value for the address of the actual //! call target. //! //! [`OpCall`]...
} } fn fix_call_site( ssa: &mut SSAStorage, call_node: <SSAStorage as SSA>::ValueRef, fn_call_map: &HashMap<u64, u64>, ) -> Option<()> { let call_site_addr = ssa.address(call_node)?.address; if let Some(&call_target_addr) = fn_call_map.get(&call_site_addr) { let old_opcall_tgt_node = s...
{ fix_call_site(ssa, node, &call_site_addr_to_target_addr).unwrap_or_else(|| { radeco_err!( "failed to fix call site {:?} in function at {:#X}", node, _fn_addr ) }); }
conditional_block
fix_ssa_opcalls.rs
//! Fixes the call target for all call sites in the SSA //! For every [`OpCall`] SSA node in every function, try to find that call //! site's corresponding edge in [the callgraph] and replace the "target" //! operand of the SSA node with a constant value for the address of the actual //! call target. //! //! [`OpCall`]...
let call_site_addr_to_target_addr: HashMap<u64, u64> = callgraph .callees(rfun.cgid()) .map(|(cs_a, tgt_idx)| (cs_a, callgraph[tgt_idx])) .collect(); let ssa = rfun.ssa_mut(); for node in ssa.inorder_walk() { if let Ok(NodeType::Op(ir::MOpcode::OpCall)) = ssa.node_data(node).map...
} } fn go_fn(rfun: &mut RadecoFunction, callgraph: &CallGraph) -> () { let _fn_addr = rfun.offset;
random_line_split
vector.rs
use crate::{CodePair, DxfError, DxfResult}; /// Represents a simple vector in Cartesian space. #[derive(Clone, Debug, Default, PartialEq)] #[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] pub struct Vector { /// The X component of the vector. pub x: f64, /// The Y component of the vector....
pub(crate) fn set(&mut self, pair: &CodePair) -> DxfResult<()> { match pair.code { 10 => self.x = pair.assert_f64()?, 20 => self.y = pair.assert_f64()?, 30 => self.z = pair.assert_f64()?, _ => { return Err(DxfError::UnexpectedCodePair( ...
Vector::new(0.0, 0.0, 1.0) }
random_line_split
vector.rs
use crate::{CodePair, DxfError, DxfResult}; /// Represents a simple vector in Cartesian space. #[derive(Clone, Debug, Default, PartialEq)] #[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] pub struct Vector { /// The X component of the vector. pub x: f64, /// The Y component of the vector....
}
{ match pair.code { 10 => self.x = pair.assert_f64()?, 20 => self.y = pair.assert_f64()?, 30 => self.z = pair.assert_f64()?, _ => { return Err(DxfError::UnexpectedCodePair( pair.clone(), String::from("expecte...
identifier_body
vector.rs
use crate::{CodePair, DxfError, DxfResult}; /// Represents a simple vector in Cartesian space. #[derive(Clone, Debug, Default, PartialEq)] #[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] pub struct
{ /// The X component of the vector. pub x: f64, /// The Y component of the vector. pub y: f64, /// The Z component of the vector. pub z: f64, } impl Vector { /// Creates a new `Vector` with the specified values. pub fn new(x: f64, y: f64, z: f64) -> Vector { Vector { x, y, z }...
Vector
identifier_name
svh-a-no-change.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 ...
() -> isize { 4 }
an_unused_name
identifier_name
svh-a-no-change.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 ...
pub fn an_unused_name() -> isize { 4 }
{ 3 }
identifier_body
svh-a-no-change.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 ...
pub trait U : MarkerTrait {} pub trait V : MarkerTrait {} impl U for () {} impl V for () {} static A_CONSTANT : isize = 2; pub fn foo<T:U>(_: isize) -> isize { 3 } pub fn an_unused_name() -> isize { 4 }
macro_rules! three { () => { 3 } }
random_line_split
3_09_wave_c.rs
// The Nature of Code // Daniel Shiffman // http://natureofcode.com // // Example 3-9: Wave_C use nannou::prelude::*; fn
() { nannou::app(model).update(update).run(); } struct Model { start_angle: f32, angle_vel: f32, } fn model(app: &App) -> Model { app.new_window().size(200, 200).view(view).build().unwrap(); let start_angle = 0.0; let angle_vel = 0.4; Model { start_angle, angle_vel, } }...
main
identifier_name
3_09_wave_c.rs
// The Nature of Code // Daniel Shiffman // http://natureofcode.com // // Example 3-9: Wave_C use nannou::prelude::*; fn main() { nannou::app(model).update(update).run(); } struct Model { start_angle: f32, angle_vel: f32, } fn model(app: &App) -> Model { app.new_window().size(200, 200).view(view).bui...
fn view(app: &App, model: &Model, frame: Frame) { // Begin drawing let draw = app.draw(); draw.background().color(WHITE); let mut angle = model.start_angle; let rect = app.window_rect(); let mut x = rect.left(); while x <= rect.right() { let y = map_range(angle.sin(), -1.0, 1.0, r...
{ model.start_angle += 0.015; }
identifier_body
3_09_wave_c.rs
// The Nature of Code // Daniel Shiffman // http://natureofcode.com // // Example 3-9: Wave_C use nannou::prelude::*; fn main() { nannou::app(model).update(update).run(); } struct Model { start_angle: f32, angle_vel: f32, } fn model(app: &App) -> Model { app.new_window().size(200, 200).view(view).bui...
}
draw.to_frame(app, &frame).unwrap();
random_line_split
numops.rs
/* * PCG Random Number Generation for Rust * * Copyright 2015 John Brooks <jeb@robojeb.dev> * * 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/LIC...
u128, 128 ); macro_rules! smaller { ( $( $t:ty, $other:ty);*) => { $( impl AsSmaller<$other> for $t { #[inline] fn shrink(self) -> $other { self as $other } } )* } } smaller!( u128, u128; u1...
u32, 32; u64, 64;
random_line_split
lib.rs
// ================================================================= // // * WARNING * // // This file is generated!
// // ================================================================= #![doc( html_logo_url = "https://raw.githubusercontent.com/rusoto/rusoto/master/assets/logo-square.png" )] //! <p><fullname>AWS Shield Advanced</fullname> <p>This is the <i>AWS Shield Advanced API Reference</i>. This guide is for developers who...
// // Changes made to this file will be overwritten. If changes are // required to the generated code, the service_crategen project // must be updated to generate the changes.
random_line_split
callbacks.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
glfw::poll_events(); } } } struct ErrorContext; impl glfw::ErrorCallback for ErrorContext { fn call(&self, _: glfw::Error, description: ~str) { println!("GLFW Error: {:s}", description); } } struct WindowPosContext; impl glfw::WindowPosCallback for WindowPosContext { fn cal...
random_line_split
callbacks.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
; impl glfw::FramebufferSizeCallback for FramebufferSizeContext { fn call(&self, _: &glfw::Window, width: i32, height: i32) { println!("Framebuffer size: {} {}", width, height); } } struct KeyContext; impl glfw::KeyCallback for KeyContext { fn call(&self, window: &glfw::Window, key: glfw::Key, scan...
FramebufferSizeContext
identifier_name
impl_core.rs
#![allow(unused_unsafe)] //! Contains implementations for rust core that have not been stabilized //! //! Functions in this are expected to be properly peer reviewed by the community //! //! Any modifications done are purely to make the code compatible with bincode use core::mem::{self, MaybeUninit}; /// Pulls `N` i...
let mut array = uninit_array::<T, N>(); let mut guard = Guard { array_mut: &mut array, initialized: 0, }; while let Some(item_rslt) = iter.next() { let item = match item_rslt { Err(err) => { return Some(Err(err)); } Ok(elem) =...
)); } } }
random_line_split
impl_core.rs
#![allow(unused_unsafe)] //! Contains implementations for rust core that have not been stabilized //! //! Functions in this are expected to be properly peer reviewed by the community //! //! Any modifications done are purely to make the code compatible with bincode use core::mem::{self, MaybeUninit}; /// Pulls `N` i...
} let mut array = uninit_array::<T, N>(); let mut guard = Guard { array_mut: &mut array, initialized: 0, }; while let Some(item_rslt) = iter.next() { let item = match item_rslt { Err(err) => { return Some(Err(err)); } Ok(...
{ debug_assert!(self.initialized <= N); // SAFETY: this slice will contain only initialized objects. unsafe { core::ptr::drop_in_place(slice_assume_init_mut( self.array_mut.get_unchecked_mut(..self.initialized), )); } ...
identifier_body
impl_core.rs
#![allow(unused_unsafe)] //! Contains implementations for rust core that have not been stabilized //! //! Functions in this are expected to be properly peer reviewed by the community //! //! Any modifications done are purely to make the code compatible with bincode use core::mem::{self, MaybeUninit}; /// Pulls `N` i...
<E, I, T, const N: usize>(iter: &mut I) -> Option<Result<[T; N], E>> where I: Iterator<Item = Result<T, E>>, { if N == 0 { // SAFETY: An empty array is always inhabited and has no validity invariants. return unsafe { Some(Ok(mem::zeroed())) }; } struct Guard<'a, T, const N: usize> { ...
collect_into_array
identifier_name
impl_core.rs
#![allow(unused_unsafe)] //! Contains implementations for rust core that have not been stabilized //! //! Functions in this are expected to be properly peer reviewed by the community //! //! Any modifications done are purely to make the code compatible with bincode use core::mem::{self, MaybeUninit}; /// Pulls `N` i...
} // This is only reached if the iterator is exhausted before // `guard.initialized` reaches `N`. Also note that `guard` is dropped here, // dropping all already initialized elements. None } /// Assuming all the elements are initialized, get a mutable slice to them. /// /// # Safety /// /// It is...
{ mem::forget(guard); // SAFETY: the condition above asserts that all elements are // initialized. let out = unsafe { array_assume_init(array) }; return Some(Ok(out)); }
conditional_block
chain.rs
//! A container for a series of audio devices. //! //! A chain can be used when a single series of audio devices passes its output //! to the input of the next device. It is initialized from a single starting //! device that will receive no input, and ends in a device who's output is //! ignored. //! //! //! # Example ...
let outputs = self.devices[self.devices.len()-1].device.num_outputs(); &self.bus[self.bus.len()-outputs..] } } impl Tick for DeviceChain { fn tick(&mut self) { for device in self.devices.iter_mut() { device.tick(self.time, &mut self.bus); } self.time += 1; ...
} /// Returns a slice to the output of the last device in the chain. pub fn get_output(&self) -> &[Sample] {
random_line_split
chain.rs
//! A container for a series of audio devices. //! //! A chain can be used when a single series of audio devices passes its output //! to the input of the next device. It is initialized from a single starting //! device that will receive no input, and ends in a device who's output is //! ignored. //! //! //! # Example ...
(&self) -> &[Sample] { let outputs = self.devices[self.devices.len()-1].device.num_outputs(); &self.bus[self.bus.len()-outputs..] } } impl Tick for DeviceChain { fn tick(&mut self) { for device in self.devices.iter_mut() { device.tick(self.time, &mut self.bus); } ...
get_output
identifier_name
chain.rs
//! A container for a series of audio devices. //! //! A chain can be used when a single series of audio devices passes its output //! to the input of the next device. It is initialized from a single starting //! device that will receive no input, and ends in a device who's output is //! ignored. //! //! //! # Example ...
}
{ let mock1 = MockAudioDevice::new("mock1", 0, 1); let mock2 = MockAudioDevice::new("mock2", 2, 1); DeviceChain::from(mock1).into(mock2); }
identifier_body
chain.rs
//! A container for a series of audio devices. //! //! A chain can be used when a single series of audio devices passes its output //! to the input of the next device. It is initialized from a single starting //! device that will receive no input, and ends in a device who's output is //! ignored. //! //! //! # Example ...
self.devices.push(AudioNode::new(device, &mut self.bus)); self } /// Return a mutable slice to the input of the first device in the chain. /// /// These inputs never get overwritten, so if you are supplying input you /// must manually zero the buffer again. pub fn get_input(&mu...
{ panic!("DeviceChain: number of outputs must match number of inputs"); }
conditional_block
x11_sockets.rs
use std::{ io::{Read, Write}, os::unix::{io::FromRawFd, net::UnixStream}, }; use slog::{debug, info, warn}; use nix::{errno::Errno, sys::socket, Result as NixResult}; /// Find a free X11 display slot and setup pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [UnixStream; 2]), std::i...
Err(_) => { debug!(log, "Failed to acquire lock"; "D" => display); // we could not open the file, now we try to read it // and if it contains the pid of a process that no longer // exist (so if a previous x server claimed it and did not ...
{ // we got it, write our PID in it and we're good let ret = file.write_fmt(format_args!("{:>10}\n", ::nix::unistd::Pid::this())); if ret.is_err() { // write to the file failed ? we abandon ::std::mem::drop(file); ...
conditional_block
x11_sockets.rs
use std::{ io::{Read, Write}, os::unix::{io::FromRawFd, net::UnixStream}, }; use slog::{debug, info, warn}; use nix::{errno::Errno, sys::socket, Result as NixResult}; /// Find a free X11 display slot and setup pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [UnixStream; 2]), std::i...
}
random_line_split
x11_sockets.rs
use std::{ io::{Read, Write}, os::unix::{io::FromRawFd, net::UnixStream}, }; use slog::{debug, info, warn}; use nix::{errno::Errno, sys::socket, Result as NixResult}; /// Find a free X11 display slot and setup pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [UnixStream; 2]), std::i...
(display: u32) -> NixResult<[UnixStream; 2]> { let path = format!("/tmp/.X11-unix/X{}", display); let _ = ::std::fs::remove_file(&path); // We know this path is not to long, these unwrap cannot fail let fs_addr = socket::UnixAddr::new(path.as_bytes()).unwrap(); let abs_addr = socket::UnixAddr::new_a...
open_x11_sockets_for_display
identifier_name
x11_sockets.rs
use std::{ io::{Read, Write}, os::unix::{io::FromRawFd, net::UnixStream}, }; use slog::{debug, info, warn}; use nix::{errno::Errno, sys::socket, Result as NixResult}; /// Find a free X11 display slot and setup pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [UnixStream; 2]), std::i...
} } Err(_) => { debug!(log, "Failed to acquire lock"; "D" => display); // we could not open the file, now we try to read it // and if it contains the pid of a process that no longer // exist (so if a previous x serve...
{ debug!(log, "Attempting to aquire an X11 display lock"; "D" => display); let filename = format!("/tmp/.X{}-lock", display); let lockfile = ::std::fs::OpenOptions::new() .write(true) .create_new(true) .open(&filename); match lockfile { Ok(...
identifier_body
addrinfo.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ AddrConfig, All, CanonName, NumericHost, NumericServ, Passive, V4Mapped, } /// A transport protocol associated with either a hint or a return value of /// `lookup` pub enum Protocol { TCP, UDP } /// This structure is used to provide hints when fetching addresses for a /// remote hos...
Flag
identifier_name
addrinfo.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// Ignored on android since we cannot give tcp/ip // permission without help of apk #[cfg(all(test, not(target_os = "android")))] mod test { use prelude::*; use super::*; use io::net::ip::*; #[test] fn dns_smoke_test() { let ipaddrs = get_host_addresses("localhost").unwrap(); let ...
{ sys::addrinfo::get_host_addresses(hostname, servname, hint) }
identifier_body
addrinfo.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
Synchronous DNS Resolution Contains the functionality to perform DNS resolution in a style related to getaddrinfo() */ #![allow(missing_docs)] use iter::Iterator; use io::{IoResult}; use io::net::ip::{SocketAddr, IpAddr}; use option::{Option, Some, None}; use sys; use vec::Vec; /// Hints to the types of sockets t...
// except according to those terms. /*!
random_line_split
const-err3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// 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 // except according to those terms. #![feature(rustc_attrs)] #![deny(const_err)] fn black_box<T>(_: T) { unimplemented!...
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
const-err3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { let b = 200u8 + 200u8 + 200u8; //~^ ERROR const_err let c = 200u8 * 4; //~^ ERROR const_err let d = 42u8 - (42u8 + 1); //~^ ERROR const_err let _e = [5u8][1]; //~^ ERROR const_err black_box(b); black_box(c); black_box(d); }
{ unimplemented!() }
identifier_body
const-err3.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>(_: T) { unimplemented!() } fn main() { let b = 200u8 + 200u8 + 200u8; //~^ ERROR const_err let c = 200u8 * 4; //~^ ERROR const_err let d = 42u8 - (42u8 + 1); //~^ ERROR const_err let _e = [5u8][1]; //~^ ERROR const_err black_box(b); black_box(c); black_box(d); }
black_box
identifier_name
char.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...
} else if code < MAX_THREE_B && dst.len() >= 3 { dst[0] = (code >> 12u & 0x0F_u32) as u8 | TAG_THREE_B; dst[1] = (code >> 6u & 0x3F_u32) as u8 | TAG_CONT; dst[2] = (code & 0x3F_u32) as u8 | TAG_CONT; Some(3) } else if dst.len() >= 4 { dst[0] ...
Some(1) } else if code < MAX_TWO_B && dst.len() >= 2 { dst[0] = (code >> 6u & 0x1F_u32) as u8 | TAG_TWO_B; dst[1] = (code & 0x3F_u32) as u8 | TAG_CONT; Some(2)
random_line_split
char.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...
else if dst.len() >= 2 { // Supplementary planes break into surrogates. ch -= 0x1_0000_u32; dst[0] = 0xD800_u16 | ((ch >> 10) as u16); dst[1] = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16); Some(2) } else { None } } }
{ // The BMP falls through (assuming non-surrogate, as it should) dst[0] = ch as u16; Some(1) }
conditional_block
char.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...
(&self) -> uint { len_utf8_bytes(*self) } #[inline] fn encode_utf8<'a>(&self, dst: &'a mut [u8]) -> Option<uint> { // Marked #[inline] to allow llvm optimizing it away let code = *self as u32; if code < MAX_ONE_B && dst.len() >= 1 { dst[0] = code as u8; Some(1) ...
len_utf8_bytes
identifier_name
char.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...
/// /// Returns a 'default' ASCII and C++11-like literal escape of a `char` /// /// The default is chosen with a bias toward producing literals that are /// legal in a variety of languages, including C++11 and similar C-family /// languages. The exact rules are: /// /// - Tab, CR and LF are escaped as '\t', '\r' and ...
{ // avoid calling str::to_str_radix because we don't really need to allocate // here. f('\\'); let pad = match () { _ if c <= '\xff' => { f('x'); 2 } _ if c <= '\uffff' => { f('u'); 4 } _ => { f('U'); 8 } }; for offset in range_step::<i32>(4 * (pad ...
identifier_body
cninetyninehexfloatf.rs
//! formatter for %a %F C99 Hex-floating-point subs use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Formatter}; use super::float_common::{FloatAnalysis, primitive_to_str_common}; use super::base_conv; use super::base_conv::RadixDef; pub struct CninetyNineHexFloatf...
(src: &str, before_decimal: bool) -> String { let rten = base_conv::RadixTen; let rhex = base_conv::RadixHex; if before_decimal { base_conv::base_conv_str(src, &rten, &rhex) } else { let as_arrnum_ten = base_conv::str_to_arrnum(src, &rten); let s = format!("{}", ...
to_hex
identifier_name
cninetyninehexfloatf.rs
//! formatter for %a %F C99 Hex-floating-point subs use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Formatter}; use super::float_common::{FloatAnalysis, primitive_to_str_common}; use super::base_conv; use super::base_conv::RadixDef; pub struct CninetyNineHexFloatf...
// assign 0 let (mut first_segment_raw, second_segment_raw) = match analysis.decimal_pos { Some(pos) => (&str_in[..pos], &str_in[pos + 1..]), None => (&str_in[..], "0"), }; if first_segment_raw.len() == 0 { first_segment_raw = "0"; } // convert to string, hexifying if inp...
})); // assign the digits before and after the decimal points // to separate slices. If no digits after decimal point,
random_line_split
cninetyninehexfloatf.rs
//! formatter for %a %F C99 Hex-floating-point subs use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Formatter}; use super::float_common::{FloatAnalysis, primitive_to_str_common}; use super::base_conv; use super::base_conv::RadixDef; pub struct CninetyNineHexFloatf...
{ let rten = base_conv::RadixTen; let rhex = base_conv::RadixHex; if before_decimal { base_conv::base_conv_str(src, &rten, &rhex) } else { let as_arrnum_ten = base_conv::str_to_arrnum(src, &rten); let s = format!("{}", base_conv::base_conv_float(&as_arrnum...
identifier_body
cninetyninehexfloatf.rs
//! formatter for %a %F C99 Hex-floating-point subs use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Formatter}; use super::float_common::{FloatAnalysis, primitive_to_str_common}; use super::base_conv; use super::base_conv::RadixDef; pub struct CninetyNineHexFloatf...
else { "p" }; if mantissa >= 0 { format!("{}+{}", ind, mantissa) } else { format!("{}{}", ind, mantissa) } }); f } fn to_hex(src: &str, before_decimal: bool) -> String { let rten = base_conv::RadixTen; let rhex = base_conv::RadixHex; ...
{ "P" }
conditional_block
synonyms.rs
use fnv::FnvHashMap; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::io::Error; use std::path::Path; #[inline] pub fn parse_line(line: &str) -> Result<(String, String), Error>
pub fn load(path: &Path) -> Option<FnvHashMap<String, String>> { if path.is_file() { Some(parse_file(&path).unwrap()) } else { None } } fn parse_file(path: &Path) -> Result<FnvHashMap<String, String>, Error> { let mut synonyms = FnvHashMap::default(); let f = File::open(path)?; ...
{ let v: Vec<&str> = line.split(" ").map(|t| t.trim()).collect(); let (word, synonym) = match v.len() { 2 => (v[0].to_string(), v[1].to_string()), _ => panic!("Unknown format: {:?}!", &line), }; Ok((word, synonym)) }
identifier_body
synonyms.rs
use fnv::FnvHashMap; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::io::Error; use std::path::Path; #[inline] pub fn parse_line(line: &str) -> Result<(String, String), Error> { let v: Vec<&str> = line.split(" ").map(|t| t.trim()).collect(); let (word, synonym) = match v.len() { ...
Ok(synonyms) }
let (word, synonym) = parse_line(&line).unwrap(); synonyms.insert(word, synonym); }
random_line_split
synonyms.rs
use fnv::FnvHashMap; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::io::Error; use std::path::Path; #[inline] pub fn parse_line(line: &str) -> Result<(String, String), Error> { let v: Vec<&str> = line.split(" ").map(|t| t.trim()).collect(); let (word, synonym) = match v.len() { ...
(path: &Path) -> Result<FnvHashMap<String, String>, Error> { let mut synonyms = FnvHashMap::default(); let f = File::open(path)?; let file = BufReader::new(&f); for line in file.lines() { let line = line.unwrap(); let (word, synonym) = parse_line(&line).unwrap(); synonyms.inser...
parse_file
identifier_name
guard.rs
/*! This module defines request guards for accessing the current game state. You can use these types in the parameters of the request handler, like so: ```rust,ignore #[route("/whatever/<foo>")] fn (foo: usize, game: Game) -> &'static str { let j = game.jamnum(); ... } ``` These request guards guarantee the exist...
(&self) -> &gamestate::GameState { self.game.as_ref().unwrap() } } impl<'a, 'r> FromRequest<'a, 'r> for Game<'r> { type Error = (); fn from_request(_: &'a Request<'r>) -> rocket::request::Outcome<Game<'r>, ()> { // TODO: authentication goes here let game = get_game(); if game.is_none() ...
deref
identifier_name
guard.rs
/*! This module defines request guards for accessing the current game state. You can use these types in the parameters of the request handler, like so: ```rust,ignore #[route("/whatever/<foo>")] fn (foo: usize, game: Game) -> &'static str { let j = game.jamnum(); ...
is no current game, the request will fail. Both of the guard types `Game` and `MutGame` implement `Deref` and the latter implements `DerefMut` to `GameState`, so you can use them just like you would a regular `GameState`. */ use std::ops::{Deref, DerefMut}; use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; ...
} ``` These request guards guarantee the existence of a current game: if there
random_line_split
guard.rs
/*! This module defines request guards for accessing the current game state. You can use these types in the parameters of the request handler, like so: ```rust,ignore #[route("/whatever/<foo>")] fn (foo: usize, game: Game) -> &'static str { let j = game.jamnum(); ... } ``` These request guards guarantee the exist...
rocket::Outcome::Success(MutGame { game: game }) } } /// Start a new game, with the given rosters and time to derby pub fn start_game(team1: roster::Team, team2: roster::Team, time_to_derby: Duration) -> () { *CUR_GAME.write().unwrap() = Some(gamestate::GameState::new(team1, team2, time_to_derby)); ...
{ return rocket::Outcome::Failure((Status::BadRequest, ())) }
conditional_block
svggraphicselement.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::SVGGraphicsElementBinding; use dom::bindings::inheritance::Castable; use dom...
}
Some(self.upcast::<SVGElement>() as &VirtualMethods) }
random_line_split
svggraphicselement.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::SVGGraphicsElementBinding; use dom::bindings::inheritance::Castable; use dom...
{ svgelement: SVGElement, } impl SVGGraphicsElement { pub fn new_inherited(tag_name: Atom, prefix: Option<DOMString>, document: &Document) -> SVGGraphicsElement { SVGGraphicsElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document) } pub fn ...
SVGGraphicsElement
identifier_name
svggraphicselement.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::SVGGraphicsElementBinding; use dom::bindings::inheritance::Castable; use dom...
pub fn new_inherited_with_state(state: ElementState, tag_name: Atom, prefix: Option<DOMString>, document: &Document) -> SVGGraphicsElement { SVGGraphicsElement { svgelement: SVGElement::new_inherited_with_s...
{ SVGGraphicsElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document) }
identifier_body
lib.rs
// Copyright (c) 2017 FaultyRAM // // 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 except according to t...
} impl Default for TestEngine<OsString, OsString> { fn default() -> TestEngine<OsString, OsString> { Self::from_args() } } impl InputReader { /// Reads a line of text from the input file, consuming the end-of-line marker if one is /// present. pub fn read_next_line(&mut self) -> &str { ...
{ let mut args = env::args_os(); let input_file_path = args.nth(1).expect("input file path not specified"); let output_file_path = args.next().expect("output file path not specified"); Self::new(input_file_path, output_file_path) }
identifier_body
lib.rs
// Copyright (c) 2017 FaultyRAM // // 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 except according to t...
fn default() -> TestEngine<OsString, OsString> { Self::from_args() } } impl InputReader { /// Reads a line of text from the input file, consuming the end-of-line marker if one is /// present. pub fn read_next_line(&mut self) -> &str { if self.offset >= self.input.len() { ...
impl Default for TestEngine<OsString, OsString> {
random_line_split
lib.rs
// Copyright (c) 2017 FaultyRAM // // 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 except according to t...
(&mut self, buf: &[u8]) -> io::Result<()> { self.0.write_all(buf) } fn write_fmt(&mut self, fmt: Arguments) -> io::Result<()> { self.0.write_fmt(fmt) } }
write_all
identifier_name
spawn.rs
use engine::components::Spawned; use engine::resources::{SpawnBuffer, UnitTypeMap}; use specs::prelude::*; #[derive(Default)] pub struct SpawnSystem { spawn_buf_bak: SpawnBuffer, spawn_buf_tmp: SpawnBuffer, } impl SpawnSystem { pub fn
(&mut self, world: &mut World) { use std::mem; self.spawn_buf_tmp.0.clear(); // Need this for borrow checking or we're just borrowing world while we try to pass it // mutably mem::swap( &mut self.spawn_buf_tmp, &mut *world.write_resource::<SpawnBuffer>()...
update
identifier_name
spawn.rs
use engine::components::Spawned; use engine::resources::{SpawnBuffer, UnitTypeMap}; use specs::prelude::*; #[derive(Default)] pub struct SpawnSystem { spawn_buf_bak: SpawnBuffer, spawn_buf_tmp: SpawnBuffer, } impl SpawnSystem { pub fn update(&mut self, world: &mut World) { use std::mem; s...
})); mem::swap( &mut *world.write_resource::<SpawnBuffer>(), &mut self.spawn_buf_bak, ); } }
{ spawn.delay -= 1; Some(spawn) }
conditional_block
spawn.rs
use engine::components::Spawned; use engine::resources::{SpawnBuffer, UnitTypeMap}; use specs::prelude::*; #[derive(Default)] pub struct SpawnSystem { spawn_buf_bak: SpawnBuffer, spawn_buf_tmp: SpawnBuffer, }
use std::mem; self.spawn_buf_tmp.0.clear(); // Need this for borrow checking or we're just borrowing world while we try to pass it // mutably mem::swap( &mut self.spawn_buf_tmp, &mut *world.write_resource::<SpawnBuffer>(), ); // We're ba...
impl SpawnSystem { pub fn update(&mut self, world: &mut World) {
random_line_split
debug.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::rt::io; use std::rt::io::Writer; use std::vec::raw::buf_as_slice; use std::cast::transmute; use std::mem:...
(buf: &[u8]) { let mut stderr = io::stderr(); stderr.write(bytes!(" ")); for (i, &v) in buf.iter().enumerate() { let output = format!("{:02X} ", v as uint); stderr.write(output.as_bytes()); match i % 16 { 15 => stderr.write(bytes!("\n ")), 7 => stderr.w...
hexdump_slice
identifier_name
debug.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::rt::io; use std::rt::io::Writer; use std::vec::raw::buf_as_slice; use std::cast::transmute; use std::mem:...
pub fn hexdump<T>(obj: &T) { unsafe { let buf: *u8 = transmute(obj); debug!("dumping at {:p}", buf); buf_as_slice(buf, size_of::<T>(), hexdump_slice); } }
{ let mut stderr = io::stderr(); stderr.write(bytes!(" ")); for (i, &v) in buf.iter().enumerate() { let output = format!("{:02X} ", v as uint); stderr.write(output.as_bytes()); match i % 16 { 15 => stderr.write(bytes!("\n ")), 7 => stderr.write(bytes!("...
identifier_body
debug.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::rt::io;
use std::rt::io::Writer; use std::vec::raw::buf_as_slice; use std::cast::transmute; use std::mem::size_of; fn hexdump_slice(buf: &[u8]) { let mut stderr = io::stderr(); stderr.write(bytes!(" ")); for (i, &v) in buf.iter().enumerate() { let output = format!("{:02X} ", v as uint); stderr.w...
random_line_split
lib.rs
extern crate banko_lib; use banko_lib::Bankoplade; use std::u64; #[no_mangle] pub extern "C" fn rust_encoder_init() -> *mut banko_lib::Encoder { let result: Box<banko_lib::Encoder> = Default::default(); Box::into_raw(result) } #[no_mangle] pub unsafe extern "C" fn rust_encoder_free(ptr: *mut banko_lib::Encod...
#[no_mangle] pub extern "C" fn rust_decoder_run( decoder: *mut banko_lib::Decoder, in_u64: u64, out_plade: *mut Bankoplade, ) -> bool { match unsafe { (decoder.as_ref(), out_plade.as_mut()) } { (Some(decoder), Some(out_plade)) => { let plade = decoder.decode(in_u64); le...
{ Box::from_raw(ptr); }
identifier_body
lib.rs
extern crate banko_lib; use banko_lib::Bankoplade; use std::u64; #[no_mangle] pub extern "C" fn rust_encoder_init() -> *mut banko_lib::Encoder { let result: Box<banko_lib::Encoder> = Default::default(); Box::into_raw(result) } #[no_mangle] pub unsafe extern "C" fn rust_encoder_free(ptr: *mut banko_lib::Encod...
( encoder: *const banko_lib::Encoder, in_plade: *const Bankoplade, out_u64: *mut u64, ) -> bool { match unsafe { (encoder.as_ref(), in_plade.as_ref(), out_u64.as_mut()) } { (Some(encoder), Some(in_plade), Some(out_u64)) => { if let Some(out) = encoder.encode(in_plade) { ...
rust_encoder_run
identifier_name
lib.rs
extern crate banko_lib; use banko_lib::Bankoplade; use std::u64; #[no_mangle] pub extern "C" fn rust_encoder_init() -> *mut banko_lib::Encoder { let result: Box<banko_lib::Encoder> = Default::default(); Box::into_raw(result) } #[no_mangle] pub unsafe extern "C" fn rust_encoder_free(ptr: *mut banko_lib::Encod...
pub unsafe extern "C" fn rust_decoder_free(ptr: *mut banko_lib::Decoder) { Box::from_raw(ptr); } #[no_mangle] pub extern "C" fn rust_decoder_run( decoder: *mut banko_lib::Decoder, in_u64: u64, out_plade: *mut Bankoplade, ) -> bool { match unsafe { (decoder.as_ref(), out_plade.as_mut()) } { ...
let result: Box<banko_lib::Decoder> = Default::default(); Box::into_raw(result) } #[no_mangle]
random_line_split