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
system_info.rs
use minidump::system_info::{Cpu, Os}; /// Information about the system that produced a `Minidump`. pub struct SystemInfo { /// The operating system that produced the minidump pub os: Os, /// A string identifying the version of the operating system /// /// This may look like "5.1.2600 Service Pack 2...
/// Will be greater than one for multi-core systems. pub cpu_count: usize, }
///
random_line_split
astconv_util.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...
span_err!(tcx.sess, typ.span, E0109, "type parameters are not allowed on this type"); break; } } if (flags & NO_REGIONS)!= 0 { for lifetime in segment.parameters.lifetimes() { span_err!(tcx.sess, lifetime....
if (flags & NO_TPS) != 0 { for typ in segment.parameters.types() {
random_line_split
astconv_util.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...
<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty) -> Option<Ty<'tcx>> { if let ast::TyPath(None, ref path) = ast_ty.node { let def = match tcx.def_map.borrow().get(&ast_ty.id) { None => { tcx.sess.span_bug(ast_ty.span, ...
ast_ty_to_prim_ty
identifier_name
astconv_util.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...
{ if let ast::TyPath(None, ref path) = ast_ty.node { let def = match tcx.def_map.borrow().get(&ast_ty.id) { None => { tcx.sess.span_bug(ast_ty.span, &format!("unbound path {:?}", path)) } Some(d) => d.full_def() };...
identifier_body
rush.rs
extern crate libc; ///! Rush main /// Rush module mod rush { use std::ptr; use std::io::stdio; use libc::funcs::posix88::unistd::execvp; use libc::funcs::posix88::unistd::fork; use libc::types::os::arch::posix88::pid_t; /// Wait. #[link(name = "c")] extern { fn wait (statu...
} } } } /// Main fn main () { rush::prompt (); }
unsafe { wait (&mut status);
random_line_split
rush.rs
extern crate libc; ///! Rush main /// Rush module mod rush { use std::ptr; use std::io::stdio; use libc::funcs::posix88::unistd::execvp; use libc::funcs::posix88::unistd::fork; use libc::types::os::arch::posix88::pid_t; /// Wait. #[link(name = "c")] extern { fn wait (statu...
(buffer: & mut [u8]) -> uint { let mut stdin = stdio::stdin (); let n = match stdin.read (buffer) { Ok (n) => n, Err (..) => 0, }; n } /// Tokenize a buffer (split at spaces). fn buffer_to_tokens (n: uint, buffer: & mut [u8]) -> Vec<Strin...
read_input
identifier_name
rush.rs
extern crate libc; ///! Rush main /// Rush module mod rush { use std::ptr; use std::io::stdio; use libc::funcs::posix88::unistd::execvp; use libc::funcs::posix88::unistd::fork; use libc::types::os::arch::posix88::pid_t; /// Wait. #[link(name = "c")] extern { fn wait (statu...
/// Tokenize a buffer (split at spaces). fn buffer_to_tokens (n: uint, buffer: & mut [u8]) -> Vec<String> { let input_string = match String::from_utf8 (Vec::from_slice (buffer)) { Ok (s) => s, Err (e) => fail! ("{}", e), }; let tokens: Vec<&str> = in...
{ let mut stdin = stdio::stdin (); let n = match stdin.read (buffer) { Ok (n) => n, Err (..) => 0, }; n }
identifier_body
env.rs
use std::collections::{HashMap}; use std::rc::{Rc}; use spine; #[derive(Debug)] pub struct Env<V, C>(Rc<Env_<V, C>>); #[derive(Debug)] enum
<V, C> { Empty, BindVars(HashMap<spine::Var, V>, Env<V, C>), BindConts(HashMap<spine::ContName, C>, Env<V, C>), } impl<V, C> Clone for Env<V, C> { fn clone(&self) -> Self { Env(self.0.clone()) } } impl<V, C> Env<V, C> { pub fn new() -> Env<V, C> { Env(Rc::new(Env_::Empty)) } pub fn bind_vars(...
Env_
identifier_name
env.rs
use std::collections::{HashMap}; use std::rc::{Rc}; use spine; #[derive(Debug)] pub struct Env<V, C>(Rc<Env_<V, C>>); #[derive(Debug)] enum Env_<V, C> { Empty, BindVars(HashMap<spine::Var, V>, Env<V, C>), BindConts(HashMap<spine::ContName, C>, Env<V, C>), } impl<V, C> Clone for Env<V, C> { fn clone(&self) ->...
}
{ match *self.0 { Env_::Empty => None, Env_::BindConts(ref binds, ref parent) => binds.get(cont).or_else(|| parent.lookup_cont(cont)), Env_::BindVars(_, ref parent) => parent.lookup_cont(cont), } }
identifier_body
env.rs
use std::collections::{HashMap}; use std::rc::{Rc}; use spine; #[derive(Debug)] pub struct Env<V, C>(Rc<Env_<V, C>>); #[derive(Debug)] enum Env_<V, C> { Empty, BindVars(HashMap<spine::Var, V>, Env<V, C>), BindConts(HashMap<spine::ContName, C>, Env<V, C>), } impl<V, C> Clone for Env<V, C> { fn clone(&self) ->...
pub fn lookup_cont<'r>(&'r self, cont: &spine::ContName) -> Option<&'r C> { match *self.0 { Env_::Empty => None, Env_::BindConts(ref binds, ref parent) => binds.get(cont).or_else(|| parent.lookup_cont(cont)), Env_::BindVars(_, ref parent) => parent.lookup_cont(cont), } } }
Env_::BindConts(_, ref parent) => parent.lookup_var(var), } }
random_line_split
morestack3.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 ...
} getbig(100); } } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(400); }; }
{ getbig(i - 1); }
conditional_block
morestack3.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
// except according to those terms. // error-pattern:explicit failure // Just testing unwinding extern mod std; fn getbig_and_fail(&&i: int) { let _r = and_then_get_big_again(5); if i!= 0 { getbig_and_fail(i - 1); } else { fail!(); } } struct and_then_get_big_again { x:int, } imp...
// 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
morestack3.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 and_then_get_big_again { x:int, } impl Drop for and_then_get_big_again { fn finalize(&self) { fn getbig(i: int) { if i!= 0 { getbig(i - 1); } } getbig(100); } } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_...
{ let _r = and_then_get_big_again(5); if i != 0 { getbig_and_fail(i - 1); } else { fail!(); } }
identifier_body
morestack3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(i: int) { if i!= 0 { getbig(i - 1); } } getbig(100); } } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(400); }; }
getbig
identifier_name
cell-does-not-clone.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 main() { let x = Cell::new(Foo { x: 22 }); let _y = x.get(); let _z = x.clone(); }
{ // Using Cell in any way should never cause clone() to be // invoked -- after all, that would permit evil user code to // abuse `Cell` and trigger crashes. panic!(); }
identifier_body
cell-does-not-clone.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 x = Cell::new(Foo { x: 22 }); let _y = x.get(); let _z = x.clone(); }
pub fn main() {
random_line_split
cell-does-not-clone.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 ...
{ x: int } impl Clone for Foo { fn clone(&self) -> Foo { // Using Cell in any way should never cause clone() to be // invoked -- after all, that would permit evil user code to // abuse `Cell` and trigger crashes. panic!(); } } pub fn main() { let x = Cell::new(Foo { x...
Foo
identifier_name
executed.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
() { use rlp; let original = CallType::Call; let encoded = rlp::encode(&original); let decoded = rlp::decode(&encoded); assert_eq!(original, decoded); }
should_encode_and_decode_call_type
identifier_name
executed.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
format!("Invalid transaction nonce: expected {}, found {}", expected, got), NotEnoughCash { required, got } => format!("Cost of transaction exceeds sender balance. {} is required \ but the sender only has {}", required, got), Internal => "Internal evm error".into(), TransactionMalformed(ref err) =...
BlockGasLimitReached { gas_limit, gas_used, gas } => format!("Block gas limit reached. The limit is {}, {} has \ already been used, and {} more is required", gas_limit, gas_used, gas), InvalidNonce { expected, got } =>
random_line_split
executed.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} /// Result of executing the transaction. #[derive(PartialEq, Debug, Clone, Binary)] pub enum CallError { /// Couldn't find the transaction in the chain. TransactionNotFound, /// Couldn't find requested block's state in the chain. StatePruned, /// Error executing. Execution(ExecutionError), } impl From<Execut...
{ use self::ExecutionError::*; let msg = match *self { NotEnoughBaseGas { required, got } => format!("Not enough base gas. {} is required, but only {} paid", required, got), BlockGasLimitReached { gas_limit, gas_used, gas } => format!("Block gas limit reached. The limit is {}, {} has \ already b...
identifier_body
text.rs
/// for correct painting order. Since we compress several leaf fragments here, the mapping must /// be adjusted. fn flush_clump_to_list(&mut self, font_context: &mut FontContext, out_fragments: &mut Vec<Fragment>, paragraph_byte...
ly_style_transform_if_necessary(st
identifier_name
text.rs
debug_assert!(!fragments.is_empty()); // Calculate bidi embedding levels, so we can split bidirectional fragments for reordering. let text = text(&fragments); let para_level = fragments.front().unwrap().style.writing_mode.to_bidi_level(); let bidi_info = process_text(&text, Some...
let new_fragment = { let mut first_fragment = fragments.front_mut().unwrap(); let string_before; { let unscanned_text_fragment_info = match first_fragment.specific { SpecificFragmentInfo::UnscannedText(ref mut unscanned_text_fragment_info) => { ...
return }
conditional_block
text.rs
debug_assert!(!fragments.is_empty()); // Calculate bidi embedding levels, so we can split bidirectional fragments for reordering. let text = text(&fragments); let para_level = fragments.front().unwrap().style.writing_mode.to_bidi_level(); let bidi_info = process_text(&text, Some(...
Some(position) if position < unscanned_text_fragment_info.text.len() - 1 => { position } Some(_) | None => return, }; string_before = unscanned_text_fragment_info.text[..(position + 1)].to_owned().into_boxed_sli...
if fragments.len() < 1 { return } let new_fragment = { let mut first_fragment = fragments.front_mut().unwrap(); let string_before; { let unscanned_text_fragment_info = match first_fragment.specific { SpecificFragmentInfo::UnscannedText(ref mut unsc...
identifier_body
text.rs
lump" is a range of inline flow leaves that can be merged together into a single /// fragment. Adjacent text with the same style can be merged, and nothing else can. /// /// The flow keeps track of the fragments contained by all non-leaf DOM nodes. This is necessary /// for correct painting order. Since...
} }
random_line_split
mod.rs
use num::traits::ToPrimitive; use focus::FocusNode; use util::F32Ord; use util::ref_eq; pub use self::up::focus_up; pub use self::down::focus_down; pub use self::left::focus_left; pub use self::right::focus_right; #[derive(Copy, Clone, Default)] pub struct Cursor { x: f32, y: f32 } pub enum Axis { X, ...
Some(parent) => { let mut factor = 0f32; let res = parent.children() .filter(|n| n.line_number == (current_node.line_number as isize + offset) as usize) .map(|n| { factor += 1f32; (n.bounds.intersects_x(&from.bounds) ...
{ match current_node.parent() {
random_line_split
mod.rs
use num::traits::ToPrimitive; use focus::FocusNode; use util::F32Ord; use util::ref_eq; pub use self::up::focus_up; pub use self::down::focus_down; pub use self::left::focus_left; pub use self::right::focus_right; #[derive(Copy, Clone, Default)] pub struct Cursor { x: f32, y: f32 } pub enum
{ X, Y } impl Cursor { pub fn new(node: &FocusNode) -> Cursor { Cursor { x: node.bounds.x + node.bounds.width / 2.0, y: node.bounds.y + node.bounds.height / 2.0, } } pub fn from(previous: Cursor, node: &FocusNode, axis: Axis) -> Cursor { match axis...
Axis
identifier_name
mod.rs
use num::traits::ToPrimitive; use focus::FocusNode; use util::F32Ord; use util::ref_eq; pub use self::up::focus_up; pub use self::down::focus_down; pub use self::left::focus_left; pub use self::right::focus_right; #[derive(Copy, Clone, Default)] pub struct Cursor { x: f32, y: f32 } pub enum Axis { X, ...
} fn distance(a: &Cursor, b:&Cursor) -> f32 { (a.x - b.x).abs() + (a.y - b.y).abs() } mod down; mod up; mod right; mod left; // ======================================== // // Left/Right Logic // // ======================================== // fn find_matching_child_x<'a>( from: &'a...
{ match axis { Axis::X => Cursor { x: node.bounds.x + node.bounds.width / 2.0, y: previous.y, }, Axis::Y => Cursor { x: previous.x, y: node.bounds.y + node.bounds.height / 2.0, }, } }
identifier_body
error.rs
use std::io; use std::str::Utf8Error; use sdl2::IntegerOrSdlError; use sdl2::video::WindowBuildError; use core_compat; #[derive(Debug)] pub enum Error { SpriteLoad, MapLoad, Rm(core_compat::error::Error), Io(io::Error), Utf8(Utf8Error), Str(String), WindowBuildError, ...
} impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::Io(err) } } impl From<Utf8Error> for Error { fn from(err: Utf8Error) -> Error { Error::Utf8(err) } } impl From<WindowBuildError> for Error { fn from(_: WindowBuildError) -> Error { ...
{ Error::Str(err) }
identifier_body
error.rs
use std::io; use std::str::Utf8Error; use sdl2::IntegerOrSdlError; use sdl2::video::WindowBuildError; use core_compat; #[derive(Debug)]
Rm(core_compat::error::Error), Io(io::Error), Utf8(Utf8Error), Str(String), WindowBuildError, IntegerOrSdlError, } impl From<core_compat::error::Error> for Error { fn from(err: core_compat::error::Error) -> Error { Error::Rm(err) } } impl From<String> for Error { ...
pub enum Error { SpriteLoad, MapLoad,
random_line_split
error.rs
use std::io; use std::str::Utf8Error; use sdl2::IntegerOrSdlError; use sdl2::video::WindowBuildError; use core_compat; #[derive(Debug)] pub enum
{ SpriteLoad, MapLoad, Rm(core_compat::error::Error), Io(io::Error), Utf8(Utf8Error), Str(String), WindowBuildError, IntegerOrSdlError, } impl From<core_compat::error::Error> for Error { fn from(err: core_compat::error::Error) -> Error { Error::Rm(err) } ...
Error
identifier_name
important_paths.rs
use crate::util::errors::CargoResult; use crate::util::paths; use std::fs; use std::path::{Path, PathBuf}; /// Finds the root `Cargo.toml`. pub fn find_root_manifest_for_wd(cwd: &Path) -> CargoResult<PathBuf> { let file = "Cargo.toml"; for current in paths::ancestors(cwd) { let manifest = current.join(...
else { anyhow::bail!("Could not find `{}` in `{}`", file, pwd.display()) } }
{ Ok(manifest) }
conditional_block
important_paths.rs
use crate::util::errors::CargoResult; use crate::util::paths; use std::fs; use std::path::{Path, PathBuf}; /// Finds the root `Cargo.toml`. pub fn find_root_manifest_for_wd(cwd: &Path) -> CargoResult<PathBuf> { let file = "Cargo.toml"; for current in paths::ancestors(cwd) { let manifest = current.join(...
(pwd: &Path, file: &str) -> CargoResult<PathBuf> { let manifest = pwd.join(file); if manifest.exists() { Ok(manifest) } else { anyhow::bail!("Could not find `{}` in `{}`", file, pwd.display()) } }
find_project_manifest_exact
identifier_name
important_paths.rs
use crate::util::errors::CargoResult; use crate::util::paths; use std::fs; use std::path::{Path, PathBuf}; /// Finds the root `Cargo.toml`. pub fn find_root_manifest_for_wd(cwd: &Path) -> CargoResult<PathBuf>
/// Returns the path to the `file` in `pwd`, if it exists. pub fn find_project_manifest_exact(pwd: &Path, file: &str) -> CargoResult<PathBuf> { let manifest = pwd.join(file); if manifest.exists() { Ok(manifest) } else { anyhow::bail!("Could not find `{}` in `{}`", file, pwd.display()) ...
{ let file = "Cargo.toml"; for current in paths::ancestors(cwd) { let manifest = current.join(file); if fs::metadata(&manifest).is_ok() { return Ok(manifest); } } anyhow::bail!( "could not find `{}` in `{}` or any parent directory", file, cwd....
identifier_body
important_paths.rs
use crate::util::errors::CargoResult; use crate::util::paths;
pub fn find_root_manifest_for_wd(cwd: &Path) -> CargoResult<PathBuf> { let file = "Cargo.toml"; for current in paths::ancestors(cwd) { let manifest = current.join(file); if fs::metadata(&manifest).is_ok() { return Ok(manifest); } } anyhow::bail!( "could not f...
use std::fs; use std::path::{Path, PathBuf}; /// Finds the root `Cargo.toml`.
random_line_split
config.rs
extern crate toml; use {Args}; use toml::Table; use std::env; use std::fs::File; use std::io::{Read, BufReader, ErrorKind}; static DEFAULT_TAG: &'static str = "tags"; static DEFAULT_CMD: &'static str = "ctags"; pub fn read_config(args: &mut Args) { if let Some(config) = get_config() { read_setting(&c...
if args.flag_tag_cmd == "" { args.flag_tag_cmd = DEFAULT_CMD.to_string(); } } fn read_setting(config: &Table, setting: &mut String, key: &str) { if *setting == "" { if let Some(tagfile_config) = config.get(key) { if let Some(tagfile_path) = tagfile_config.as_str() { ...
} if args.arg_TAGFILE == "" { args.arg_TAGFILE = DEFAULT_TAG.to_string(); }
random_line_split
config.rs
extern crate toml; use {Args}; use toml::Table; use std::env; use std::fs::File; use std::io::{Read, BufReader, ErrorKind}; static DEFAULT_TAG: &'static str = "tags"; static DEFAULT_CMD: &'static str = "ctags"; pub fn read_config(args: &mut Args)
fn read_setting(config: &Table, setting: &mut String, key: &str) { if *setting == "" { if let Some(tagfile_config) = config.get(key) { if let Some(tagfile_path) = tagfile_config.as_str() { *setting = tagfile_path.to_string(); } else { println!("Inval...
{ if let Some(config) = get_config() { read_setting(&config, &mut args.arg_TAGFILE, "tagfile"); read_setting(&config, &mut args.flag_tag_cmd, "cmd"); } if args.arg_TAGFILE == "" { args.arg_TAGFILE = DEFAULT_TAG.to_string(); } if args.flag_tag_cmd == "" { args.flag_tag...
identifier_body
config.rs
extern crate toml; use {Args}; use toml::Table; use std::env; use std::fs::File; use std::io::{Read, BufReader, ErrorKind}; static DEFAULT_TAG: &'static str = "tags"; static DEFAULT_CMD: &'static str = "ctags"; pub fn
(args: &mut Args) { if let Some(config) = get_config() { read_setting(&config, &mut args.arg_TAGFILE, "tagfile"); read_setting(&config, &mut args.flag_tag_cmd, "cmd"); } if args.arg_TAGFILE == "" { args.arg_TAGFILE = DEFAULT_TAG.to_string(); } if args.flag_tag_cmd == "" { ...
read_config
identifier_name
config.rs
extern crate toml; use {Args}; use toml::Table; use std::env; use std::fs::File; use std::io::{Read, BufReader, ErrorKind}; static DEFAULT_TAG: &'static str = "tags"; static DEFAULT_CMD: &'static str = "ctags"; pub fn read_config(args: &mut Args) { if let Some(config) = get_config() { read_setting(&c...
} } } // TODO: Use more appropriate directory on Windows fn get_config() -> Option<Table> { if let Some(home) = env::home_dir() { let option_path = home.join(".config").join("retag.toml"); match File::open(&option_path) { Ok(file) => { let mut toml_contents...
{ println!("Invalid setting for option: {}", key); }
conditional_block
uniform.rs
use crate::*; #[derive(Clone, Debug, Default)] pub struct UniformCrossover; impl CrossoverMethod for UniformCrossover { fn crossover( &self, rng: &mut dyn RngCore, parent_a: &Chromosome, parent_b: &Chromosome, ) -> Chromosome
} #[cfg(test)] mod tests { use super::*; use rand::SeedableRng; use rand_chacha::ChaCha8Rng; #[allow(clippy::float_cmp)] // it's safe, because we're comparing hard-coded floats only #[test] fn test() { let mut rng = ChaCha8Rng::from_seed(Default::default()); let parent_a: Chro...
{ assert_eq!(parent_a.len(), parent_b.len()); let parent_a = parent_a.iter(); let parent_b = parent_b.iter(); parent_a .zip(parent_b) .map(|(&a, &b)| if rng.gen_bool(0.5) { a } else { b }) .collect() }
identifier_body
uniform.rs
use crate::*; #[derive(Clone, Debug, Default)] pub struct UniformCrossover; impl CrossoverMethod for UniformCrossover { fn crossover( &self, rng: &mut dyn RngCore, parent_a: &Chromosome, parent_b: &Chromosome, ) -> Chromosome { assert_eq!(parent_a.len(), parent_b.len())...
let diff_b = child.iter().zip(parent_b).filter(|(c, p)| *c!= p).count(); // Roughly looks like 50%, which proves that chance for picking either // gene is 50% assert_eq!(diff_a, 49); assert_eq!(diff_b, 51); } }
random_line_split
uniform.rs
use crate::*; #[derive(Clone, Debug, Default)] pub struct UniformCrossover; impl CrossoverMethod for UniformCrossover { fn crossover( &self, rng: &mut dyn RngCore, parent_a: &Chromosome, parent_b: &Chromosome, ) -> Chromosome { assert_eq!(parent_a.len(), parent_b.len())...
() { let mut rng = ChaCha8Rng::from_seed(Default::default()); let parent_a: Chromosome = (1..=100).map(|n| n as f32).collect(); let parent_b: Chromosome = (1..=100).map(|n| -n as f32).collect(); let child = UniformCrossover::default().crossover(&mut rng, &parent_a, &parent_b); ...
test
identifier_name
uniform.rs
use crate::*; #[derive(Clone, Debug, Default)] pub struct UniformCrossover; impl CrossoverMethod for UniformCrossover { fn crossover( &self, rng: &mut dyn RngCore, parent_a: &Chromosome, parent_b: &Chromosome, ) -> Chromosome { assert_eq!(parent_a.len(), parent_b.len())...
else { b }) .collect() } } #[cfg(test)] mod tests { use super::*; use rand::SeedableRng; use rand_chacha::ChaCha8Rng; #[allow(clippy::float_cmp)] // it's safe, because we're comparing hard-coded floats only #[test] fn test() { let mut rng = ChaCha8Rng::from_seed(Default...
{ a }
conditional_block
nameck.rs
an analysis pass and should not be invoked directly; it is intended //! to be instantiated through `Database`. It is not considered a stable API, //! although a stable wrapper may be added in `Database`. //! //! Scope check needs the ability to look up math symbols and statement labels //! to ensure that they are dec...
(&mut self, id: SegmentId, seg: Arc<Segment>) { if self.segments.contains_key(&id) { return; } // for each entity in the segment that we're adding: find the slot, bump // the generation, add it self.segments.insert(id, seg.clone()); let sref = SegmentRef { ...
add_segment
identifier_name
nameck.rs
an analysis pass and should not be invoked directly; it is intended //! to be instantiated through `Database`. It is not considered a stable API, //! although a stable wrapper may be added in `Database`. //! //! Scope check needs the ability to look up math symbols and statement labels //! to ensure that they are dec...
deviv(&mut self.labels, label, |slot| { slot.generation = gen; slot_remove(&mut slot.labels, StatementAddress::new(id, labdef.index)); }); } for &ref floatdef in &seg.floats { deviv(&mut self.symbols, &float...
{ // the reverse of add_segment, except we still bump the generation, // don't roll it back if let Some(seg) = self.segments.remove(&id) { let sref = SegmentRef { segment: &seg, id: id, }; let gen = self.generation; ...
identifier_body
nameck.rs
is an analysis pass and should not be invoked directly; it is intended //! to be instantiated through `Database`. It is not considered a stable API, //! although a stable wrapper may be added in `Database`. //! //! Scope check needs the ability to look up math symbols and statement labels //! to ensure that they are ...
fn remove_segment(&mut self, id: SegmentId) { // the reverse of add_segment, except we still bump the generation, // don't roll it back if let Some(seg) = self.segments.remove(&id) { let sref = SegmentRef { segment: &seg, id: id, }; ...
} }
random_line_split
content_type.rs
use mime::Mime; header! { /// `Content-Type` header, defined in /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-3.1.1.5) /// /// The `Content-Type` header field indicates the media type of the /// associated representation: either the representation enclosed in the
/// format and how that data is intended to be processed by a recipient, /// within the scope of the received message semantics, after any content /// codings indicated by Content-Encoding are decoded. /// /// Although the `mime` crate allows the mime options to be any slice, this crate /// forc...
/// message payload or the selected representation, as determined by the /// message semantics. The indicated media type defines both the data
random_line_split
content_type.rs
use mime::Mime; header! { /// `Content-Type` header, defined in /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-3.1.1.5) /// /// The `Content-Type` header field indicates the media type of the /// associated representation: either the representation enclosed in the /// message payload ...
() -> ContentType { ContentType(mime!(Text/Plain; Charset=Utf8)) } /// A constructor to easily create a `Content-Type: text/html; charset=utf-8` header. #[inline] pub fn html() -> ContentType { ContentType(mime!(Text/Html; Charset=Utf8)) } /// A constructor to easily create a...
plaintext
identifier_name
content_type.rs
use mime::Mime; header! { /// `Content-Type` header, defined in /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-3.1.1.5) /// /// The `Content-Type` header field indicates the media type of the /// associated representation: either the representation enclosed in the /// message payload ...
/// A constructor to easily create a `Content-Type: image/png` header. #[inline] pub fn png() -> ContentType { ContentType(mime!(Image/Png)) } } impl Eq for ContentType {} bench_header!(bench, ContentType, { vec![b"application/json; charset=utf-8".to_vec()] });
{ ContentType(mime!(Image/Jpeg)) }
identifier_body
camera.rs
use corange::*; #[derive(Clone)] pub enum CameraType { Manual, Orbit, Free, } #[derive(Clone)] pub struct Camera { pub position: vec3, pub target: vec3, pub fov: f32, pub near_clip: f32, pub far_clip: f32, pub movement: CameraType, pub frame: u64
fn default() -> Camera { unsafe { Camera { movement: CameraType::Free, position: vec3_new(10.0, 10.0, 10.0), target: vec3_zero(), far_clip: 512.0, near_clip: 0.10, fov: 0.78, frame: 0...
} impl Default for Camera {
random_line_split
camera.rs
use corange::*; #[derive(Clone)] pub enum CameraType { Manual, Orbit, Free, } #[derive(Clone)] pub struct Camera { pub position: vec3, pub target: vec3, pub fov: f32, pub near_clip: f32, pub far_clip: f32, pub movement: CameraType, pub frame: u64 } impl Default for Camera { ...
() -> Camera { unsafe { Camera { movement: CameraType::Free, position: vec3_new(10.0, 10.0, 10.0), target: vec3_zero(), far_clip: 512.0, near_clip: 0.10, fov: 0.78, frame: 0 }...
default
identifier_name
position.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%! from data import to_rust_ident %> <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import AL...
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { Auto, Number(i32), } impl ToCss for T { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { T::Auto => dest.write_str(...
#[derive(PartialEq, Clone, Eq, Copy, Debug)]
random_line_split
position.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%! from data import to_rust_ident %> <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import AL...
(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { if input.try(|input| input.expect_ident_matching("auto")).is_ok() { Ok(computed_value::T::Auto) } else { specified::parse_integer(input).map(computed_value::T::Number) } } </%helpers:longha...
parse
identifier_name
position.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%! from data import to_rust_ident %> <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import AL...
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { if input.try(|input| input.expect_ident_matching("auto")).is_ok() { Ok(computed_value::T::Auto) } else { specified::parse_integer(input).map(computed_value::T::Number) } } </%h...
{ computed_value::T::Auto }
identifier_body
main.rs
fn find() -> usize { let limit = 4_000_000usize; let mut fibonachi: Vec<usize> = Vec::new(); fibonachi.push(1); fibonachi.push(2); let mut i = 2usize; loop { let k = fibonachi[i - 2] + fibonachi[i - 1]; println!("{} - {}", i, k); if k < limit { fibonachi.push(...
} let sum = fibonachi.iter().map(|&x| {if x % 2 == 0 {x} else {0} }).sum(); sum } fn main() { let sum = find(); println!("sum of even = {}", sum); } #[test] fn it_works() { assert!(find()==4613732usize); }
{ break; }
conditional_block
main.rs
fn find() -> usize { let limit = 4_000_000usize; let mut fibonachi: Vec<usize> = Vec::new(); fibonachi.push(1); fibonachi.push(2); let mut i = 2usize; loop { let k = fibonachi[i - 2] + fibonachi[i - 1]; println!("{} - {}", i, k); if k < limit { fibonachi.push(...
() { assert!(find()==4613732usize); }
it_works
identifier_name
main.rs
fn find() -> usize { let limit = 4_000_000usize; let mut fibonachi: Vec<usize> = Vec::new(); fibonachi.push(1); fibonachi.push(2); let mut i = 2usize; loop { let k = fibonachi[i - 2] + fibonachi[i - 1]; println!("{} - {}", i, k); if k < limit { fibonachi.push(...
}
random_line_split
main.rs
fn find() -> usize { let limit = 4_000_000usize; let mut fibonachi: Vec<usize> = Vec::new(); fibonachi.push(1); fibonachi.push(2); let mut i = 2usize; loop { let k = fibonachi[i - 2] + fibonachi[i - 1]; println!("{} - {}", i, k); if k < limit { fibonachi.push(...
#[test] fn it_works() { assert!(find()==4613732usize); }
{ let sum = find(); println!("sum of even = {}", sum); }
identifier_body
activation.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::EventBinding::EventMethods; use dom::bindings::codegen::InheritTypes::{Event...
event.fire(target); // Step 5 if event.DefaultPrevented() { self.canceled_activation(); } else { // post click activation self.activation_behavior(event, target); } // Step 6 element.r().set_click_in_progress(false); } }
{ let element = self.as_element().root(); // Step 1 if element.r().click_in_progress() { return; } // Step 2 element.r().set_click_in_progress(true); // Step 3 self.pre_click_activation(); // Step 4 // https://html.spec.whatwg....
identifier_body
activation.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::EventBinding::EventMethods; use dom::bindings::codegen::InheritTypes::{EventCast, EventTargetCast}; use dom::bindings::js::{JSRef, Temporary, OptionalRootable, Rootable}; use dom::element::{Element, ActivationElementHelpers}; use dom::event::{Event, EventHelpers, EventBubbles, Eve...
random_line_split
activation.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::EventBinding::EventMethods; use dom::bindings::codegen::InheritTypes::{Event...
(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) { let element = self.as_element().root(); // Step 1 if element.r().click_in_progress() { return; } // Step 2 element.r().set_click_in_progress(true); // Step 3 self.pre_click_a...
synthetic_click_activation
identifier_name
activation.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::EventBinding::EventMethods; use dom::bindings::codegen::InheritTypes::{Event...
// Step 2 element.r().set_click_in_progress(true); // Step 3 self.pre_click_activation(); // Step 4 // https://html.spec.whatwg.org/multipage/#fire-a-synthetic-mouse-event let win = window_from_node(element.r()).root(); let target: JSRef<EventTarget> = E...
{ return; }
conditional_block
regions-dependent-autoslice.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 subslice1<'r>(v: &'r [uint]) -> &'r [uint] { v } fn both<'r>(v: &'r [uint]) -> &'r [uint] { subslice1(subslice1(v)) } pub fn main() { let v = vec!(1,2,3); both(&v); }
random_line_split
regions-dependent-autoslice.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 v = vec!(1,2,3); both(&v); }
main
identifier_name
regions-dependent-autoslice.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 v = vec!(1,2,3); both(&v); }
{ subslice1(subslice1(v)) }
identifier_body
regions-outlives-projection-container-wc.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { }
{ // For this type to be valid, the rules require that all // associated types of traits that appear in `WithAssoc` must // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if ...
identifier_body
regions-outlives-projection-container-wc.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'b> { m: [fn(&'b()); 0] } impl<'b> TheTrait for TheType<'b> { type TheAssocType = &'b (); } /////////////////////////////////////////////////////////////////////////// pub struct WithAssoc<T> where T : TheTrait { m: [T; 0] } fn with_assoc<'a,'b>() { // For this type to be valid, the rules require t...
TheType
identifier_name
regions-outlives-projection-container-wc.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
impl<'b> TheTrait for TheType<'b> { type TheAssocType = &'b (); } /////////////////////////////////////////////////////////////////////////// pub struct WithAssoc<T> where T : TheTrait { m: [T; 0] } fn with_assoc<'a,'b>() { // For this type to be valid, the rules require that all // associated types ...
pub struct TheType<'b> { m: [fn(&'b()); 0] }
random_line_split
log.rs
use std::cell::RefCell; use std::rc::Rc; use jsrs_common::backend::Backend; use jsrs_common::types::coerce::AsString; use jsrs_common::types::js_var::{JsType, JsPtrEnum, JsVar}; use jsrs_common::js_error::{self, JsError}; pub fn log(_scope: Rc<RefCell<Backend>>, _this: Option<(JsVar, JsPtrEnum)>, args: Vec<(J...
(_scope: Rc<RefCell<Backend>>, _this: Option<(JsVar, JsPtrEnum)>, args: Vec<(JsVar, Option<JsPtrEnum>)>) -> js_error::Result<(JsVar, Option<JsPtrEnum>)> { let s = match args.first() { Some(&(_, Some(ref var))) => var.as_string(), Some(&(ref var, _)) => var.t.as_string(), ...
error
identifier_name
log.rs
use std::cell::RefCell; use std::rc::Rc; use jsrs_common::backend::Backend; use jsrs_common::types::coerce::AsString; use jsrs_common::types::js_var::{JsType, JsPtrEnum, JsVar}; use jsrs_common::js_error::{self, JsError}; pub fn log(_scope: Rc<RefCell<Backend>>, _this: Option<(JsVar, JsPtrEnum)>, args: Vec<(J...
Some(&(ref var, _)) => var.t.as_string(), None => String::from(""), }; println!("{}", s); //let (var, ptr) = try!(eval_exp(exp, state)); Err(JsError::TestError(s)) //(JsVar::new(JsType::JsNull), None) }
pub fn error(_scope: Rc<RefCell<Backend>>, _this: Option<(JsVar, JsPtrEnum)>, args: Vec<(JsVar, Option<JsPtrEnum>)>) -> js_error::Result<(JsVar, Option<JsPtrEnum>)> { let s = match args.first() { Some(&(_, Some(ref var))) => var.as_string(),
random_line_split
log.rs
use std::cell::RefCell; use std::rc::Rc; use jsrs_common::backend::Backend; use jsrs_common::types::coerce::AsString; use jsrs_common::types::js_var::{JsType, JsPtrEnum, JsVar}; use jsrs_common::js_error::{self, JsError}; pub fn log(_scope: Rc<RefCell<Backend>>, _this: Option<(JsVar, JsPtrEnum)>, args: Vec<(J...
pub fn error(_scope: Rc<RefCell<Backend>>, _this: Option<(JsVar, JsPtrEnum)>, args: Vec<(JsVar, Option<JsPtrEnum>)>) -> js_error::Result<(JsVar, Option<JsPtrEnum>)> { let s = match args.first() { Some(&(_, Some(ref var))) => var.as_string(), Some(&(ref var, _)) => var.t.as...
{ match args.first() { Some(&(_, Some(ref var))) => println!("{}", var.as_string()), Some(&(ref var, _)) => println!("{}", var.t.as_string()), None => println!("") }; Ok((JsVar::new(JsType::JsNull), None)) }
identifier_body
create.rs
use num::Num; #[inline] pub fn new<T: Copy + Num>(m11: T, m12: T, m13: T, m21: T, m22: T, m23: T) -> [T; 6] { [ m11, m21, m12, m22, m13, m23 ] } #[inline] pub fn create<T: Copy + Num>(m11: T, m12: T, m13: T, m21: T, m22: T, m23: T) -> [T; 6] {
} #[test] fn test_new() { let m = new( 1, 0, 0, 0, 1, 0 ); assert!(m == [ 1, 0, 0, 1, 0, 0 ]); } #[inline] pub fn new_identity<T: Copy + Num>() -> [T; 6] { new( T::one(), T::zero(), T::zero(), T::zero(), T::one(), T::zero() ) } #[inline] p...
new(m11, m12, m13, m21, m22, m23)
random_line_split
create.rs
use num::Num; #[inline] pub fn new<T: Copy + Num>(m11: T, m12: T, m13: T, m21: T, m22: T, m23: T) -> [T; 6] { [ m11, m21, m12, m22, m13, m23 ] } #[inline] pub fn create<T: Copy + Num>(m11: T, m12: T, m13: T, m21: T, m22: T, m23: T) -> [T; 6] { new(m11, m12, m13, m21, m22, m23) } #[...
<'a, 'b, T: Copy + Num>(out: &'a mut [T; 6], a: &'b [T; 6]) -> &'a mut [T; 6] { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; out[4] = a[4]; out[5] = a[5]; out } #[test] fn test_copy() { let mut v = [0, 0, 0, 0, 0, 0]; copy(&mut v, &[1, 2, 3, 4, 5, 6]); assert!(v ==...
copy
identifier_name
create.rs
use num::Num; #[inline] pub fn new<T: Copy + Num>(m11: T, m12: T, m13: T, m21: T, m22: T, m23: T) -> [T; 6] { [ m11, m21, m12, m22, m13, m23 ] } #[inline] pub fn create<T: Copy + Num>(m11: T, m12: T, m13: T, m21: T, m22: T, m23: T) -> [T; 6] { new(m11, m12, m13, m21, m22, m23) } #[...
#[inline] pub fn new_identity<T: Copy + Num>() -> [T; 6] { new( T::one(), T::zero(), T::zero(), T::zero(), T::one(), T::zero() ) } #[inline] pub fn new_zero<T: Copy + Num>() -> [T; 6] { new( T::zero(), T::zero(), T::zero(), T::zero(), T::zero(), T::zero() ) } #[inline]...
{ let m = new( 1, 0, 0, 0, 1, 0 ); assert!(m == [ 1, 0, 0, 1, 0, 0 ]); }
identifier_body
features.rs
//! Feature tests for OS functionality pub use self::os::*; #[cfg(any(target_os = "linux", target_os = "android"))] mod os { use sys::utsname::uname; // Features: // * atomic cloexec on socket: 2.6.27 // * pipe2: 2.6.27 // * accept4: 2.6.28 static VERS_UNKNOWN: usize = 1; static VERS_2_6_...
#[test] pub fn test_parsing_kernel_version() { assert!(kernel_version() > 0); } } #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] mod os { /// Check if the OS supports atomic close-on-exec for soc...
{ kernel_version() >= VERS_2_6_27 }
identifier_body
features.rs
//! Feature tests for OS functionality pub use self::os::*; #[cfg(any(target_os = "linux", target_os = "android"))] mod os { use sys::utsname::uname; // Features: // * atomic cloexec on socket: 2.6.27 // * pipe2: 2.6.27 // * accept4: 2.6.28 static VERS_UNKNOWN: usize = 1; static VERS_2_6_...
b'.' | b'-' => { curr += 1; } b'0'...b'9' => { match curr { 0 => digit(&mut major, b), 1 => digit(&mut minor, b), _ => digit(&mut patch, b), ...
break; } match b {
random_line_split
features.rs
//! Feature tests for OS functionality pub use self::os::*; #[cfg(any(target_os = "linux", target_os = "android"))] mod os { use sys::utsname::uname; // Features: // * atomic cloexec on socket: 2.6.27 // * pipe2: 2.6.27 // * accept4: 2.6.28 static VERS_UNKNOWN: usize = 1; static VERS_2_6_...
() -> bool { false } }
socket_atomic_cloexec
identifier_name
features.rs
//! Feature tests for OS functionality pub use self::os::*; #[cfg(any(target_os = "linux", target_os = "android"))] mod os { use sys::utsname::uname; // Features: // * atomic cloexec on socket: 2.6.27 // * pipe2: 2.6.27 // * accept4: 2.6.28 static VERS_UNKNOWN: usize = 1; static VERS_2_6_...
KERNEL_VERS } } /// Check if the OS supports atomic close-on-exec for sockets pub fn socket_atomic_cloexec() -> bool { kernel_version() >= VERS_2_6_27 } #[test] pub fn test_parsing_kernel_version() { assert!(kernel_version() > 0); } } #[cfg(any(target...
{ KERNEL_VERS = parse_kernel_version(); }
conditional_block
values.rs
// Copyright (C) 2017 Jesse Jones // // 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; either version 3, or (at your option) // any later version. // // This program is distributed in the hope ...
} impl StringValue { /// This is normally called via the set_value! macro. pub fn set_value(&self, effector: &mut Effector, name: &str, value: &str) { effector.set_string(name, value); } } /// Type safe way to update the simulation [`Store`]. /// /// # Examples /// /// ``` /// use score::*; /// /// struct Inte...
{ effector.set_float(name, value); }
identifier_body
values.rs
// Copyright (C) 2017 Jesse Jones // // 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; either version 3, or (at your option) // any later version. // // This program is distributed in the hope ...
(&self, effector: &mut Effector, name: &str, value: f64) { effector.set_float(name, value); } } impl StringValue { /// This is normally called via the set_value! macro. pub fn set_value(&self, effector: &mut Effector, name: &str, value: &str) { effector.set_string(name, value); } } /// Type safe way to upda...
set_value
identifier_name
values.rs
// Copyright (C) 2017 Jesse Jones // // 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; either version 3, or (at your option) // any later version. // // This program is distributed in the hope ...
/// ``` /// use score::*; /// /// struct InterfaceComponent /// { /// tx_packets: IntValue, /// } /// /// fn reset(iface: InterfaceComponent, mut effector: Effector) /// { /// // The effector is actually the object that is updated. /// // When the component finishes processing the current event /// // the simulatio...
/// Type safe way to update the simulation [`Store`]. /// /// # Examples ///
random_line_split
common.rs
// Copyright 2018 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
{ /// Generic errors that haven't been updated to use a more specific code yet. Unknown = 1, /// An argument passed is not (and never is) valid for this particular call. InvalidArgument = 2, /// An argument passed or operation attempted is not valid for the current state of the object. InvalidS...
SyscallError
identifier_name
common.rs
// Copyright 2018 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
/// The requested operation is unknown or unsupported. NotImplemented = 5, /// The resource is currently busy. ResourceBusy = 6, /// Internal error in the kernel. This indicates a bug and that the kernel might be unstable. InternalError = 7, } impl From<SyscallError> for isize { fn from(e: ...
random_line_split
common.rs
// Copyright 2018 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
}
{ -(e as isize) }
identifier_body
fix_code_tags.rs
// http://rosettacode.org/wiki/Rosetta_Code/Fix_code_tags extern crate regex; use std::io; use std::io::prelude::*; use regex::Regex; const LANGUAGES: &'static str = "_div abap actionscript actionscript3 ada apache applescript \ apt_sources asm asp autoit avisynth bash basic4gl bf bl...
lotusscript lscript lua m68k make matlab mirc modula3 mpasm mxml \ mysql nsis objc ocaml ocaml-brief oobas oracle11 oracle8 pascal \ per perl php php-brief pic16 pixelbender plsql povray powershell \ ...
html4strict idl ini inno intercal io java java5 javascript \ kixtart klonec klonecpp latex lisp lolcode lotusformulas \
random_line_split
fix_code_tags.rs
// http://rosettacode.org/wiki/Rosetta_Code/Fix_code_tags extern crate regex; use std::io; use std::io::prelude::*; use regex::Regex; const LANGUAGES: &'static str = "_div abap actionscript actionscript3 ada apache applescript \ apt_sources asm asp autoit avisynth bash basic4gl bf bl...
() { let input = "Lorem ipsum <code foo>saepe audire</code> elaboraret ne quo, id equidem atomorum \ inciderint usu. <foo>In sit inermis deleniti percipit</foo>, ius ex tale civibus \ omittam. <barf>Vix ut doctus cetero invenire</barf>, his eu altera electram. \ To...
test_replace
identifier_name
fix_code_tags.rs
// http://rosettacode.org/wiki/Rosetta_Code/Fix_code_tags extern crate regex; use std::io; use std::io::prelude::*; use regex::Regex; const LANGUAGES: &'static str = "_div abap actionscript actionscript3 ada apache applescript \ apt_sources asm asp autoit avisynth bash basic4gl bf bl...
#[test] fn test_replace() { let input = "Lorem ipsum <code foo>saepe audire</code> elaboraret ne quo, id equidem atomorum \ inciderint usu. <foo>In sit inermis deleniti percipit</foo>, ius ex tale civibus \ omittam. <barf>Vix ut doctus cetero invenire</barf>, his eu altera electr...
{ let stdin = io::stdin(); let mut buf = String::new(); stdin.lock().read_to_string(&mut buf).unwrap(); println!("{}", fix_tags(LANGUAGES.split_whitespace().collect(), &buf)); }
identifier_body
lib.rs
extern crate byteorder; extern crate rand; extern crate mio; use std::io; use std::fmt; pub mod dnsresolv; pub mod dnsparser; pub mod httpclient; #[derive(Debug)] pub enum DnsError { Io(io::Error), InvalidFormat(String), InvalidResource(), } impl From<io::Error> for DnsError { fn from(err: io::Error)...
(err: String) -> DnsError { DnsError::InvalidFormat(err) } } impl fmt::Display for DnsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { DnsError::Io(ref err) => write!(f, "error: {}", err), DnsError::InvalidFormat(ref err) => write!(f, "Invalid...
from
identifier_name
lib.rs
extern crate byteorder; extern crate rand; extern crate mio; use std::io; use std::fmt; pub mod dnsresolv; pub mod dnsparser; pub mod httpclient; #[derive(Debug)] pub enum DnsError { Io(io::Error), InvalidFormat(String), InvalidResource(), } impl From<io::Error> for DnsError { fn from(err: io::Error)...
}
random_line_split
lib.rs
extern crate byteorder; extern crate rand; extern crate mio; use std::io; use std::fmt; pub mod dnsresolv; pub mod dnsparser; pub mod httpclient; #[derive(Debug)] pub enum DnsError { Io(io::Error), InvalidFormat(String), InvalidResource(), } impl From<io::Error> for DnsError { fn from(err: io::Error)...
} impl fmt::Display for DnsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { DnsError::Io(ref err) => write!(f, "error: {}", err), DnsError::InvalidFormat(ref err) => write!(f, "Invalid format: {}", err), DnsError::InvalidResource() => write!(...
{ DnsError::InvalidFormat(err) }
identifier_body
hermit.rs
use std::io; use config::Config; use file_operations::FileOperations; use shell::Shell; #[derive(Copy,Clone)] #[derive(PartialEq,Eq)] #[derive(Debug)] pub enum Error { ShellDoesNotExist, } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::ShellDoesNotExist } } pub struct ...
.map(|shell_name| Shell::new(shell_name, self.config.root_path())) } pub fn set_current_shell(&mut self, name: &str) -> Result<(), Error> { if self.config.does_shell_exist(name) { self.config.set_current_shell_name(name).map_err(From::from) } else { Err(Error:...
self.config .current_shell_name()
random_line_split
hermit.rs
use std::io; use config::Config; use file_operations::FileOperations; use shell::Shell; #[derive(Copy,Clone)] #[derive(PartialEq,Eq)] #[derive(Debug)] pub enum Error { ShellDoesNotExist, } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::ShellDoesNotExist } } pub struct ...
fn mock_config() -> MockConfig { MockConfig { root_path: PathBuf::from("/"), allowed_shell_names: vec!["default".to_owned()], current_shell: "default".to_owned(), } } #[test] fn returns_the_current_shell() { let config = mock_config(); ...
{ Hermit { config: config.clone() } }
identifier_body
hermit.rs
use std::io; use config::Config; use file_operations::FileOperations; use shell::Shell; #[derive(Copy,Clone)] #[derive(PartialEq,Eq)] #[derive(Debug)] pub enum Error { ShellDoesNotExist, } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::ShellDoesNotExist } } pub struct ...
else { Err(Error::ShellDoesNotExist) } } pub fn init_shell(&self, file_ops: &mut FileOperations, name: &str) { let path = self.config.shell_root_path().join(name); file_ops.create_git_repo(path); } } #[cfg(test)] mod tests { use std::path::PathBuf; use config:...
{ self.config.set_current_shell_name(name).map_err(From::from) }
conditional_block
hermit.rs
use std::io; use config::Config; use file_operations::FileOperations; use shell::Shell; #[derive(Copy,Clone)] #[derive(PartialEq,Eq)] #[derive(Debug)] pub enum Error { ShellDoesNotExist, } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::ShellDoesNotExist } } pub struct ...
(&self) -> Option<Shell> { self.config .current_shell_name() .map(|shell_name| Shell::new(shell_name, self.config.root_path())) } pub fn set_current_shell(&mut self, name: &str) -> Result<(), Error> { if self.config.does_shell_exist(name) { self.config.set_curr...
current_shell
identifier_name
docfile.rs
//! Extract Rust docstrings from source files for Emacs' DOC file. #![allow(dead_code)] use libc::{c_char, c_int}; use std::collections::HashMap; use std::ffi::{CStr, CString}; use std::fs::File; use std::io::{stdout, BufRead, BufReader, Write}; use std::mem; use std::ptr; const LISP_OBJECT: c_int = 1; const EMACS_I...
( filename: *const c_char, generate_globals: c_int, add_global: AddGlobalFn, ) { let filename = unsafe { CStr::from_ptr(filename) }.to_str().unwrap(); let fp = BufReader::new(File::open(&*filename).unwrap()); let mut in_docstring = false; let mut docstring = String::new(); let mut docst...
scan_rust_file
identifier_name
docfile.rs
//! Extract Rust docstrings from source files for Emacs' DOC file. #![allow(dead_code)] use libc::{c_char, c_int}; use std::collections::HashMap; use std::ffi::{CStr, CString}; use std::fs::File; use std::io::{stdout, BufRead, BufReader, Write}; use std::mem; use std::ptr; const LISP_OBJECT: c_int = 1; const EMACS_I...
if chunk[1].contains("&mut") { docstring_usage.push_str("&rest "); } let argname = chunk[0] .trim() .trim_left_matches("mut ") .trim() ...
random_line_split
docfile.rs
//! Extract Rust docstrings from source files for Emacs' DOC file. #![allow(dead_code)] use libc::{c_char, c_int}; use std::collections::HashMap; use std::ffi::{CStr, CString}; use std::fs::File; use std::io::{stdout, BufRead, BufReader, Write}; use std::mem; use std::ptr; const LISP_OBJECT: c_int = 1; const EMACS_I...
} else { in_docstring = false; } if line.starts_with("#[lisp_fn") { attribute = line.to_owned(); } if line.starts_with("pub fn ") || line.starts_with("fn ") { if attribute.is_empty() { // Not a #[lisp_fn] cont...
{ docstring.push_str(line[3..].trim_left()); docstring.push('\n'); }
conditional_block
docfile.rs
//! Extract Rust docstrings from source files for Emacs' DOC file. #![allow(dead_code)] use libc::{c_char, c_int}; use std::collections::HashMap; use std::ffi::{CStr, CString}; use std::fs::File; use std::io::{stdout, BufRead, BufReader, Write}; use std::mem; use std::ptr; const LISP_OBJECT: c_int = 1; const EMACS_I...
docstring.clear(); } in_docstring = true; if line.starts_with("/// usage: (") { docstring_usage.push_str(&line[11..]); } else { docstring.push_str(line[3..].trim_left()); docstring.push('\n'); } ...
{ let filename = unsafe { CStr::from_ptr(filename) }.to_str().unwrap(); let fp = BufReader::new(File::open(&*filename).unwrap()); let mut in_docstring = false; let mut docstring = String::new(); let mut docstring_usage = String::new(); let mut attribute = String::new(); let mut line_iter =...
identifier_body
var-captured-in-sendable-closure.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// <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. // compile-flags:-Z extra-debug-info // debugger:rbreak zzz // debugger:run // debugger:finish // debugger:print constant // check:$1 = 1 // debugger:pri...
// 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
random_line_split
var-captured-in-sendable-closure.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 ...
(_: &int, _:&int, _:&int) { } fn zzz() {()}
do_something
identifier_name
test.rs
//! //! test.rs.rs //! //! Created by Mitchell Nordine at 05:57PM on December 19, 2014. //! //! Always remember to run high performance Rust code with the --release flag. `Synth` //! extern crate dsp; extern crate pitch_calc as pitch; extern crate portaudio; extern crate synth; extern crate time_calc as time; use...
() -> Result<(), pa::Error> { // Construct our fancy Synth! let mut synth = { use synth::{Point, Oscillator, mode, oscillator, Envelope}; // The following envelopes should create a downward pitching sine wave that gradually quietens. // Try messing around with the points and adding som...
run
identifier_name