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
run.rs
use std::process::{Command, Child}; use env::EnvList; use super::Result; use error::BenvError; pub fn run(program_with_args: &str, env_list: EnvList) -> Result<Child> { let (program, args) = try!(split_program_and_args(program_with_args)); let mut command = Command::new(&program); command.args(&args); ...
// #[cfg(test)] // mod test { // use super::*; // use env::{Env, EnvList}; // #[test] // fn test_simple_command() { // // TODO // // // // With latest nightly, it seems impossible to write a proper test case // // where stdout of the child process is captured. // ...
{ // Life would have been good... // match program_with_args.split_whitespace() { // [program, .. args] => (program.to_string(), args.to_string()) // } let mut vec: Vec<&str> = program_with_args.split_whitespace().collect(); if vec.len() == 0 { return Err(BenvError::MissingProgram); ...
identifier_body
winvers.rs
/*! Defines the `WinVersions` feature set component. */ use std::fmt; use std::cmp::{Ord, Ordering, PartialOrd}; use std::ops::{Range, RangeFrom, RangeFull, RangeTo}; use itertools::Itertools; use WinVersion; /** This represents a set of Windows versions. It's a vector of ranges because these things *can* be kinda fr...
// Here we go! try!(write!(fmt, "#[cfg(any(")); for (i, Range { start: a, end: b }) in self.0.iter().cloned().enumerate() { try!(write!(fmt, "{}", if i == 0 { "" } else { ", " })); match (a, b) { (0, b) => try!(write!(fmt, "not(feature=\"{}{:08x}\")", PR...
{ return Ok(()); }
conditional_block
winvers.rs
/*! Defines the `WinVersions` feature set component. */ use std::fmt; use std::cmp::{Ord, Ordering, PartialOrd}; use std::ops::{Range, RangeFrom, RangeFull, RangeTo}; use itertools::Itertools; use WinVersion; /** This represents a set of Windows versions. It's a vector of ranges because these things *can* be kinda fr...
(Vec<Range<u32>>); impl WinVersions { /// Returns `true` if this set contains *any* versions. pub fn is_any(&self) -> bool { &*self.0!= [0..0] } /** Returns `true` if this set can be represented by a single `>=` conditional. */ pub fn is_simple(&self) -> bool { !self.is_any(...
WinVersions
identifier_name
winvers.rs
/*! Defines the `WinVersions` feature set component. */ use std::fmt; use std::cmp::{Ord, Ordering, PartialOrd}; use std::ops::{Range, RangeFrom, RangeFull, RangeTo}; use itertools::Itertools; use WinVersion; /** This represents a set of Windows versions. It's a vector of ranges because these things *can* be kinda fr...
fn from(v: WinVersion) -> WinVersions { match v.next_version() { Some(n) => WinVersions(vec![(v as u32)..(n as u32)]), None => WinVersions(vec![(v as u32)..!0]) } } } impl From<Range<Option<WinVersion>>> for WinVersions { fn from(v: Range<Option<WinVersion>>) -> WinV...
impl From<WinVersion> for WinVersions {
random_line_split
winvers.rs
/*! Defines the `WinVersions` feature set component. */ use std::fmt; use std::cmp::{Ord, Ordering, PartialOrd}; use std::ops::{Range, RangeFrom, RangeFull, RangeTo}; use itertools::Itertools; use WinVersion; /** This represents a set of Windows versions. It's a vector of ranges because these things *can* be kinda fr...
} impl From<Range<WinVersion>> for WinVersions { fn from(v: Range<WinVersion>) -> WinVersions { assert!(v.start < v.end); WinVersions(vec![(v.start as u32)..(v.end as u32)]) } } impl From<RangeFrom<WinVersion>> for WinVersions { fn from(v: RangeFrom<WinVersion>) -> WinVersions { W...
{ match (v.start, v.end) { (None, None) => (..).into(), (Some(a), None) => (a..).into(), (None, Some(b)) => (..b).into(), (Some(a), Some(b)) => (a..b).into() } }
identifier_body
extern-return-TwoU64s.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...
}
random_line_split
extern-return-TwoU64s.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...
{ one: u64, two: u64 } #[link(name = "rustrt")] extern { pub fn rust_dbg_extern_return_TwoU64s() -> TwoU64s; } pub fn main() { unsafe { let y = rust_dbg_extern_return_TwoU64s(); assert_eq!(y.one, 10); assert_eq!(y.two, 20); } }
TwoU64s
identifier_name
af_sample.rs
// Arrayfire sample // Aftype -> DType [compilation errors with sample code](https://github.com/arrayfire/arrayfire-rust/issues/75) extern crate arrayfire as af; use af::*; // low dimension linear algebra type aliases pub fn new_vec3<T: af::HasAfEnum>(values: &[T]) -> Array { Array::new(&values, Dim4::new(&[3, ...
test_backend(); } println!("Create a 5-by-3 matrix of random floats on the GPU"); let a = randu::<f32>(dims); print(&a); }
if available.contains(&Backend::OPENCL) { println!("Evaluating OpenCL Backend..."); set_backend(Backend::OPENCL); println!("There are {} OpenCL compute devices", device_count());
random_line_split
af_sample.rs
// Arrayfire sample // Aftype -> DType [compilation errors with sample code](https://github.com/arrayfire/arrayfire-rust/issues/75) extern crate arrayfire as af; use af::*; // low dimension linear algebra type aliases pub fn new_vec3<T: af::HasAfEnum>(values: &[T]) -> Array { Array::new(&values, Dim4::new(&[3, ...
() { let a: [f32; 3] = [1.0, 2.0, 3.0]; let va = new_vec3(&a); println!("a : {:?}", &a); print(&va); let b: [f32; 9] = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]; let mb = new_mat3x3(&b); let mc = new_mat3x3(&b); println!("a : {:?}", &b); print(&mb); let dc = mb * mc; pr...
test_backend
identifier_name
af_sample.rs
// Arrayfire sample // Aftype -> DType [compilation errors with sample code](https://github.com/arrayfire/arrayfire-rust/issues/75) extern crate arrayfire as af; use af::*; // low dimension linear algebra type aliases pub fn new_vec3<T: af::HasAfEnum>(values: &[T]) -> Array { Array::new(&values, Dim4::new(&[3, ...
if available.contains(&Backend::OPENCL) { println!("Evaluating OpenCL Backend..."); set_backend(Backend::OPENCL); println!("There are {} OpenCL compute devices", device_count()); test_backend(); } println!("Create a 5-by-3 matrix of random floats on the GPU"); let a = ...
{ let num_rows: u64 = 5; let num_cols: u64 = 3; let dims = Dim4::new(&[num_rows, num_cols, 1, 1]); let available = get_available_backends(); if available.contains(&Backend::CPU) { println!("Evaluating CPU Backend..."); set_backend(Backend::CPU); println!("There are {} CPU com...
identifier_body
af_sample.rs
// Arrayfire sample // Aftype -> DType [compilation errors with sample code](https://github.com/arrayfire/arrayfire-rust/issues/75) extern crate arrayfire as af; use af::*; // low dimension linear algebra type aliases pub fn new_vec3<T: af::HasAfEnum>(values: &[T]) -> Array { Array::new(&values, Dim4::new(&[3, ...
println!("Create a 5-by-3 matrix of random floats on the GPU"); let a = randu::<f32>(dims); print(&a); }
{ println!("Evaluating OpenCL Backend..."); set_backend(Backend::OPENCL); println!("There are {} OpenCL compute devices", device_count()); test_backend(); }
conditional_block
nested.rs
// edition:2018 // compile-flags: --crate-version 1.0.0 // @is nested.json "$.crate_version" \"1.0.0\" // @is - "$.index[*][?(@.name=='nested')].kind" \"module\" // @is - "$.index[*][?(@.name=='nested')].inner.is_crate" true // @count - "$.index[*][?(@.name=='nested')].inner.items[*]" 1 // @is nested.json "$.index[*]...
// @is nested.json "$.index[*][?(@.name=='L4')].kind" \"struct\" // @is - "$.index[*][?(@.name=='L4')].inner.struct_type" \"unit\" // @set l4_id = - "$.index[*][?(@.name=='L4')].id" // @has - "$.index[*][?(@.name=='l3')].inner.items[*]" $l4_id pub struct L4; } // @is nest...
pub mod l3 {
random_line_split
nested.rs
// edition:2018 // compile-flags: --crate-version 1.0.0 // @is nested.json "$.crate_version" \"1.0.0\" // @is - "$.index[*][?(@.name=='nested')].kind" \"module\" // @is - "$.index[*][?(@.name=='nested')].inner.is_crate" true // @count - "$.index[*][?(@.name=='nested')].inner.items[*]" 1 // @is nested.json "$.index[*]...
; } // @is nested.json "$.index[*][?(@.inner.source=='l3::L4')].kind" \"import\" // @is - "$.index[*][?(@.inner.source=='l3::L4')].inner.glob" false pub use l3::L4; }
L4
identifier_name
task_local.rs
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro w...
/// Accesses the current task-local and runs the provided closure. /// /// If the task-local with the associated key is not present, this /// method will return an `AccessError`. For a panicking variant, /// see `with`. pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError> w...
{ self.try_with(f).expect( "cannot access a Task Local Storage value \ without setting it via `LocalKey::set`", ) }
identifier_body
task_local.rs
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro w...
}) } } impl<T: Copy +'static> LocalKey<T> { /// Returns a copy of the task-local value /// if the task-local value implements `Copy`. pub fn get(&'static self) -> T { self.with(|v| *v) } } impl<T:'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -...
{ Err(AccessError { _private: () }) }
conditional_block
task_local.rs
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro w...
/// if the task-local value implements `Copy`. pub fn get(&'static self) -> T { self.with(|v| *v) } } impl<T:'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey {.. }") } } pin_project! { /// A future that sets a valu...
} impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local value
random_line_split
task_local.rs
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro w...
(&'static self) -> T { self.with(|v| *v) } } impl<T:'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey {.. }") } } pin_project! { /// A future that sets a value `T` of a task local for the future `F` during /// its execu...
get
identifier_name
keyboard.rs
use crate::backend::input::KeyState; use crate::wayland::Serial; use slog::{debug, info, o, trace, warn}; use std::{ cell::RefCell, default::Default, fmt, io::{Error as IoError, Write}, ops::Deref as _, os::unix::io::AsRawFd, rc::Rc, }; use tempfile::tempfile; use thiserror::Error; use wayla...
; let wl_state = match state { KeyState::Pressed => WlKeyState::Pressed, KeyState::Released => WlKeyState::Released, }; guard.with_focused_kbds(|kbd, _| { // key event must be sent before modifers event for libxkbcommon // to process them correctly...
{ None }
conditional_block
keyboard.rs
use crate::backend::input::KeyState; use crate::wayland::Serial; use slog::{debug, info, o, trace, warn}; use std::{ cell::RefCell, default::Default, fmt, io::{Error as IoError, Write}, ops::Deref as _, os::unix::io::AsRawFd, rc::Rc, }; use tempfile::tempfile; use thiserror::Error; use wayla...
let sym = guard.state.key_get_one_sym(keycode + 8); let mods_changed = guard.key_input(keycode, state); trace!(self.arc.logger, "Calling input filter"; "mods_state" => format_args!("{:?}", guard.mods_state), "sym" => xkb::keysym_get_name(sym) ); if!filter(&guard.mo...
random_line_split
keyboard.rs
use crate::backend::input::KeyState; use crate::wayland::Serial; use slog::{debug, info, o, trace, warn}; use std::{ cell::RefCell, default::Default, fmt, io::{Error as IoError, Write}, ops::Deref as _, os::unix::io::AsRawFd, rc::Rc, }; use tempfile::tempfile; use thiserror::Error; use wayla...
{ /// The "control" key pub ctrl: bool, /// The "alt" key pub alt: bool, /// The "shift" key pub shift: bool, /// The "Caps lock" key pub caps_lock: bool, /// The "logo" key /// /// Also known as the "windows" key on most keyboards pub logo: bool, /// The "Num lock" ...
ModifiersState
identifier_name
mod.rs
// TODO: Remove #![allow(dead_code)] // TODO: make this private again, once #18241 is fixed // https://github.com/rust-lang/rust/issues/18241 pub mod item; pub mod block; pub use self::item::{ ItemExt, TypeDef, Interface, Class, ClassMember, Field, Method, TypeItem, FormalParameter...
self.segments.push(rhs); self } } impl ops::Add<Path> for Ident { type Output = Path; fn add(self, mut rhs: Path) -> Self::Output { rhs.segments.insert(0, self); rhs } } impl ops::Add for Ident { type Output = Path; fn add(self, rhs: Ident) -> Self::Output { ...
random_line_split
mod.rs
// TODO: Remove #![allow(dead_code)] // TODO: make this private again, once #18241 is fixed // https://github.com/rust-lang/rust/issues/18241 pub mod item; pub mod block; pub use self::item::{ ItemExt, TypeDef, Interface, Class, ClassMember, Field, Method, TypeItem, FormalParameter...
{ pub package: Option<Path>, pub imports: Vec<Import>, pub types: Vec<TypeDef>, } impl Default for Ident { fn default() -> Self { Ident { name: "".into(), span: Span::dummy(), } } } /// A import declaration #[derive(Debug, Clone)] pub enum Import { /// ...
CompilationUnit
identifier_name
router.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
(Some(EndpointPath { app_id, app_params: app_params.into_iter().map(Into::into).collect(), query, host: host.to_owned(), port, using_dapps_domains: true, }), special) }, Some(host) if path_segments.len() > 1 => { let special = special_endpoint(&path_segments); let id = path_segme...
};
random_line_split
router.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
} impl Router { pub fn new( content_fetcher: Arc<Fetcher>, endpoints: Option<Endpoints>, special: HashMap<SpecialEndpoint, Option<Box<Endpoint>>>, embeddable_on: Embeddable, dapps_domain: String, ) -> Self { Router { endpoints: endpoints, fetch: content_fetcher, special: special, embeddable_...
{ let is_origin_set = req.headers().get::<header::Origin>().is_some(); let (is_utils, response) = self.resolve_request(req, self.endpoints.is_some()); match response { Response::Some(response) => http::RequestMiddlewareAction::Respond { should_validate_hosts: !is_utils, response, }, Response::Non...
identifier_body
router.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
{ Rpc, Api, Utils, Home, None, } enum Response { Some(endpoint::Response), None(hyper::Request), } /// An endpoint router. /// Dispatches the request to particular Endpoint by requested uri/path. pub struct Router { endpoints: Option<Endpoints>, fetch: Arc<Fetcher>, special: HashMap<SpecialEndpoint, Option...
SpecialEndpoint
identifier_name
lib.rs
//! Find discrete returns in full waveform LiDAR data. //! //! # Why is this library called `peakbag`? //! //! [Peak bagging](https://en.wikipedia.org/wiki/Peak_bagging) is when you try to summit a bunch of //! mountains, just to say you summited a bunch of mountains. While the practice of peak bagging //! can correlat...
} impl<T> PeakDetector<T> where T: Copy + fmt::Display + PartialOrd + ToPrimitive + Unsigned { /// Detects peaks in full waveform data. /// /// # Panics /// /// Panics if a sample value cannot be converted to an `i64` and `f64`. /// /// # Examples /// /// ``` /// use peakbag::P...
{ self.max_kurtosis = max_kurtosis; self }
identifier_body
lib.rs
//! Find discrete returns in full waveform LiDAR data. //! //! # Why is this library called `peakbag`? //! //! [Peak bagging](https://en.wikipedia.org/wiki/Peak_bagging) is when you try to summit a bunch of //! mountains, just to say you summited a bunch of mountains. While the practice of peak bagging //! can correlat...
(mut self, max_kurtosis: f64) -> PeakDetector<T> { self.max_kurtosis = max_kurtosis; self } } impl<T> PeakDetector<T> where T: Copy + fmt::Display + PartialOrd + ToPrimitive + Unsigned { /// Detects peaks in full waveform data. /// /// # Panics /// /// Panics if a sample value c...
max_kurtosis
identifier_name
lib.rs
//! Find discrete returns in full waveform LiDAR data. //! //! # Why is this library called `peakbag`? //! //! [Peak bagging](https://en.wikipedia.org/wiki/Peak_bagging) is when you try to summit a bunch of //! mountains, just to say you summited a bunch of mountains. While the practice of peak bagging //! can correlat...
match state { State::Ascending(n) => { if slope < 0 { state = State::Ascending(0); } else if n == self.width { state = State::Descending(0, i); } else { state ...
{ if sample == s { state = State::Saturated; } }
conditional_block
lib.rs
//! Find discrete returns in full waveform LiDAR data. //! //! # Why is this library called `peakbag`? //! //! [Peak bagging](https://en.wikipedia.org/wiki/Peak_bagging) is when you try to summit a bunch of //! mountains, just to say you summited a bunch of mountains. While the practice of peak bagging //! can correlat...
{ let detector = PeakDetector::new(width, floor, ceiling); detector.detect_peaks(data) } /// Configurable struct for detecting peaks. /// /// This structure allow for fine-grained adjustment of the peak detection procedures. #[derive(Clone, Copy, Debug)] pub struct PeakDetector<T: Copy> { width: usize, ...
where T: Copy + fmt::Display + PartialOrd + ToPrimitive + Unsigned
random_line_split
configpaths_08.rs
use libnewsboat::{cliargsparser::CliArgsParser, configpaths::ConfigPaths}; use section_testing::{enable_sections, section}; use std::env; use tempfile::TempDir; mod configpaths_helpers; enable_sections! { #[test] fn t_configpaths_try_migrate_from_newsbeuter_does_not_migrate_if_config_paths_were_specified_via_cli( ) {...
// ConfigPaths rely on these variables, so let's sanitize them to ensure // that the tests aren't affected env::remove_var("XDG_CONFIG_HOME"); env::remove_var("XDG_DATA_HOME"); if section!("Newsbeuter dotdir exists") { configpaths_helpers::mock_newsbeuter_dotdir(&tmp); } if sec...
env::set_var("HOME", tmp.path());
random_line_split
utils.rs
extern crate num_cpus; use self::num_cpus::get; use gitignore::*; use regex::RegexSet; use std::fs::File; use std::fs::Metadata; use std::io::prelude::*; use std::path::PathBuf; #[cfg(target_os = "linux")] use std::os::linux::fs::MetadataExt; #[cfg(any( target_os = "macos", target_os = "freebsd", target_...
(in_paths: &PathBuf, maybe_ignore: &Option<RegexSet>) -> Option<RegexSet> { if let Some(ref ignore) = *maybe_ignore { Some(ignore.to_owned()) } else if let (ignore_path, Ok(mut file)) = { let mut ignore_path = in_paths.clone(); ignore_path.push(".ignore"); (ignore_path.clone(), F...
mk_ignores
identifier_name
utils.rs
extern crate num_cpus; use self::num_cpus::get; use gitignore::*; use regex::RegexSet; use std::fs::File; use std::fs::Metadata; use std::io::prelude::*;
#[cfg(any( target_os = "macos", target_os = "freebsd", target_os = "netbsd", target_os = "dragonfly", target_os = "solaris" ))] use std::os::unix::fs::MetadataExt; #[cfg(target_os = "linux")] pub fn size(m: &Metadata, blocks: bool) -> u64 { if blocks { m.st_blocks() * 512 } else { ...
use std::path::PathBuf; #[cfg(target_os = "linux")] use std::os::linux::fs::MetadataExt;
random_line_split
utils.rs
extern crate num_cpus; use self::num_cpus::get; use gitignore::*; use regex::RegexSet; use std::fs::File; use std::fs::Metadata; use std::io::prelude::*; use std::path::PathBuf; #[cfg(target_os = "linux")] use std::os::linux::fs::MetadataExt; #[cfg(any( target_os = "macos", target_os = "freebsd", target_...
}
{ n }
conditional_block
utils.rs
extern crate num_cpus; use self::num_cpus::get; use gitignore::*; use regex::RegexSet; use std::fs::File; use std::fs::Metadata; use std::io::prelude::*; use std::path::PathBuf; #[cfg(target_os = "linux")] use std::os::linux::fs::MetadataExt; #[cfg(any( target_os = "macos", target_os = "freebsd", target_...
#[cfg(any( target_os = "macos", target_os = "freebsd", target_os = "netbsd", target_os = "dragonfly", target_os = "solaris" ))] pub fn size(m: &Metadata, blocks: bool) -> u64 { if blocks { m.blocks() * 512 // idk if this is correct on bsd } else { m.len() } } /// Gathe...
{ m.len() }
identifier_body
regions-mock-tcx.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...
} impl<'tcx> TotalEq for TypeStructure<'tcx> {} struct TypeContext<'tcx, 'ast> { ty_arena: &'tcx Arena, types: Vec<Type<'tcx>>, type_table: HashMap<NodeId, Type<'tcx>>, ast_arena: &'ast Arena, ast_counter: uint, } impl<'tcx,'ast> TypeContext<'tcx, 'ast> { fn new(ty_arena: &'tcx Arena, ast_a...
{ match (*self, *other) { (TypeInt, TypeInt) => true, (TypeFunction(s_a, s_b), TypeFunction(o_a, o_b)) => *s_a == *o_a && *s_b == *o_b, _ => false } }
identifier_body
regions-mock-tcx.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...
(&mut self, a: AstKind<'ast>) -> Ast<'ast> { let id = self.ast_counter; self.ast_counter += 1; self.ast_arena.alloc(|| AstStructure { id: NodeId {id:id}, kind: a }) } } #[deriving(Eq, TotalEq, Hash)] struct NodeId { id: uint } type Ast<'ast> = &'ast AstStructure<'ast>; struct AstStruc...
ast
identifier_name
regions-mock-tcx.rs
// Copyright 2012-2014 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. // ignore-fast `use` standards don't resolve // Test a sample usage pattern for regions. Makes use of the // following features: // // - Multiple lifetim...
// 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
io.rs
use core::cmp::PartialEq; use core::ops::{BitAnd, BitOr, Not}; pub trait Io { type Value: Copy + PartialEq + BitAnd<Output = Self::Value> + BitOr<Output = Self::Value> + Not<Output = Self::Value>; fn read(&self) -> Self::Value; fn write(&mut self, value: Self::Value); #[inline(always)] fn readf(&...
#[inline(always)] pub fn readf(&self, flags: I::Value) -> bool { self.inner.readf(flags) } } pub struct WriteOnly<I: Io> { inner: I } impl<I: Io> WriteOnly<I> { pub const fn new(inner: I) -> WriteOnly<I> { WriteOnly { inner: inner } } #[inline(always)...
{ self.inner.read() }
identifier_body
io.rs
use core::cmp::PartialEq; use core::ops::{BitAnd, BitOr, Not}; pub trait Io { type Value: Copy + PartialEq + BitAnd<Output = Self::Value> + BitOr<Output = Self::Value> + Not<Output = Self::Value>; fn read(&self) -> Self::Value; fn write(&mut self, value: Self::Value); #[inline(always)] fn readf(&...
(&mut self, flags: Self::Value, value: bool) { let tmp: Self::Value = match value { true => self.read() | flags, false => self.read() &!flags, }; self.write(tmp); } } pub struct ReadOnly<I: Io> { inner: I } impl<I: Io> ReadOnly<I> { pub const fn new(inner: I...
writef
identifier_name
io.rs
use core::cmp::PartialEq; use core::ops::{BitAnd, BitOr, Not}; pub trait Io { type Value: Copy + PartialEq + BitAnd<Output = Self::Value> + BitOr<Output = Self::Value> + Not<Output = Self::Value>; fn read(&self) -> Self::Value; fn write(&mut self, value: Self::Value); #[inline(always)] fn readf(&...
impl<I: Io> ReadOnly<I> { pub const fn new(inner: I) -> ReadOnly<I> { ReadOnly { inner: inner } } #[inline(always)] pub fn read(&self) -> I::Value { self.inner.read() } #[inline(always)] pub fn readf(&self, flags: I::Value) -> bool { self.inner....
pub struct ReadOnly<I: Io> { inner: I }
random_line_split
lib.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // 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 ...
#[cfg(target_os="linux")] extern crate x11; #[cfg(target_os="linux")] extern crate glx; #[cfg(target_os="android")] extern crate egl; pub mod color; pub mod geometry; pub mod layers; pub mod rendergl; pub mod scene; pub mod texturegl; pub mod tiling; pub mod util; pub mod platform { #[cfg(target_os="linux")] ...
#[cfg(target_os="macos")] extern crate cgl;
random_line_split
work_multiplexer.rs
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicab...
/// If true, then the thread should break out of its processing loop. pub fn should_i_stop(&self) -> bool { Err(TryRecvError::Disconnected) == self.receiver.try_recv() } } /// Builds up the configuration for a set of worker threads. pub struct ThreadedWorkMultiplexerBuilder { pub thread_count...
{ ThreadNotifier { receiver } }
identifier_body
work_multiplexer.rs
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicab...
(&mut self) { for thread_info in &mut self.thread_sync { if let Some((tx, handle)) = thread_info.take() { drop(tx); let thread_name = handle.thread().name().unwrap_or("UNKNOWN").to_string(); match handle.join() { Ok(_) => { ...
stop
identifier_name
work_multiplexer.rs
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicab...
} // pub fn live_thread_count(&self) -> u32 { // self.thread_sync // .iter() // .map(|maybe_x| { // if let Some(tuple) = maybe_x.as_ref() { // if let Ok(_) = tuple.0.send(()) { // 1 // } else { // ...
} } } }
random_line_split
work_multiplexer.rs
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicab...
} } /// Signals each thread to stop, then blocks until they have stopped. /// /// Threads have to check to see if they have been signaled using their notifier. pub fn stop(&mut self) { for thread_info in &mut self.thread_sync { if let Some((tx, handle)) = thread_info.ta...
{ let thread_name = handle.thread().name().unwrap_or("UNKNOWN").to_string(); match handle.join() { Ok(_) => { log::trace!("Joined {}", thread_name); } Err(_) => { log::error!("{} p...
conditional_block
clipboard_provider.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 ipc_channel::ipc::{self, IpcSender}; use script_traits::ScriptMsg as ConstellationMsg; use std::borrow::ToOwne...
(&mut self, s: String) { self.send(ConstellationMsg::SetClipboardContents(s)).unwrap(); } } pub struct DummyClipboardContext { content: String, } impl DummyClipboardContext { pub fn new(s: &str) -> DummyClipboardContext { DummyClipboardContext { content: s.to_owned(), }...
set_clipboard_contents
identifier_name
clipboard_provider.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 ipc_channel::ipc::{self, IpcSender}; use script_traits::ScriptMsg as ConstellationMsg;
// blocking method to set the clipboard contents fn set_clipboard_contents(&mut self, String); } impl ClipboardProvider for IpcSender<ConstellationMsg> { fn clipboard_contents(&mut self) -> String { let (tx, rx) = ipc::channel().unwrap(); self.send(ConstellationMsg::GetClipboardContents(tx)...
use std::borrow::ToOwned; pub trait ClipboardProvider { // blocking method to get the clipboard contents fn clipboard_contents(&mut self) -> String;
random_line_split
tcp-connect-timeouts.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 addr = next_test_ip4(); assert!(TcpStream::connect_timeout(addr, Duration::milliseconds(-1)).is_err()); }
identifier_body
tcp-connect-timeouts.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 addr = next_test_ip4(); let (tx1, rx1) = channel(); let (_tx2, rx2) = channel::<()>(); let _t = Thread::spawn(move|| { let _l = TcpListener::bind(addr).unwrap().listen(); tx1.send(()).unwrap(); let _ = rx2.recv(); }); rx1.recv().unwrap(); let mut v = Vec::n...
eventual_timeout
identifier_name
tcp-connect-timeouts.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 (tx1, rx1) = channel(); let (_tx2, rx2) = channel::<()>(); let _t = Thread::spawn(move|| { let _l = TcpListener::bind(addr).unwrap().listen(); tx1.send(()).unwrap(); let _ = rx2.recv(); }); rx1.recv().unwrap(); let mut v = Vec::new(); for _ in range(0u, 10000) { ...
random_line_split
mod.rs
//! Mega naive LALR(1) generation algorithm. use collections::{map, Map, Multimap}; use grammar::repr::*; use itertools::Itertools; use lr1::build; use lr1::core::*; use lr1::lookahead::*; use std::mem; use std::rc::Rc; use tls::Tls; #[cfg(test)] mod test; // Intermediate LALR(1) state. Identical to an LR(1) state, ...
pub reductions: Multimap<&'grammar Production, TokenSet>, pub gotos: Map<NonterminalString, StateIndex>, } pub fn build_lalr_states<'grammar>( grammar: &'grammar Grammar, start: NonterminalString, ) -> LR1Result<'grammar> { // First build the LR(1) states let lr_states = try!(build::build_lr1_s...
struct LALR1State<'grammar> { pub index: StateIndex, pub items: Vec<LR1Item<'grammar>>, pub shifts: Map<TerminalString, StateIndex>,
random_line_split
mod.rs
//! Mega naive LALR(1) generation algorithm. use collections::{map, Map, Multimap}; use grammar::repr::*; use itertools::Itertools; use lr1::build; use lr1::core::*; use lr1::lookahead::*; use std::mem; use std::rc::Rc; use tls::Tls; #[cfg(test)] mod test; // Intermediate LALR(1) state. Identical to an LR(1) state, ...
else { Ok(lr1_states) } }
{ Err(TableConstructionError { states: lr1_states, conflicts: conflicts, }) }
conditional_block
mod.rs
//! Mega naive LALR(1) generation algorithm. use collections::{map, Map, Multimap}; use grammar::repr::*; use itertools::Itertools; use lr1::build; use lr1::core::*; use lr1::lookahead::*; use std::mem; use std::rc::Rc; use tls::Tls; #[cfg(test)] mod test; // Intermediate LALR(1) state. Identical to an LR(1) state, ...
items: vec![], shifts: map(), reductions: Multimap::new(), gotos: map(), }); index }); lalr1_states[lalr1_index.0] .items .extend(lr1_state.items.vec.iter().cloned()); remap[lr1_index]...
{ // Now compress them. This vector stores, for each state, the // LALR(1) state to which we will remap it. let mut remap: Vec<_> = (0..lr_states.len()).map(|_| StateIndex(0)).collect(); let mut lalr1_map: Map<Vec<LR0Item>, StateIndex> = map(); let mut lalr1_states: Vec<LALR1State> = vec![]; fo...
identifier_body
mod.rs
//! Mega naive LALR(1) generation algorithm. use collections::{map, Map, Multimap}; use grammar::repr::*; use itertools::Itertools; use lr1::build; use lr1::core::*; use lr1::lookahead::*; use std::mem; use std::rc::Rc; use tls::Tls; #[cfg(test)] mod test; // Intermediate LALR(1) state. Identical to an LR(1) state, ...
<'grammar> { pub index: StateIndex, pub items: Vec<LR1Item<'grammar>>, pub shifts: Map<TerminalString, StateIndex>, pub reductions: Multimap<&'grammar Production, TokenSet>, pub gotos: Map<NonterminalString, StateIndex>, } pub fn build_lalr_states<'grammar>( grammar: &'grammar Grammar, star...
LALR1State
identifier_name
lib.rs
extern crate byteorder;
pub v1: [f32; 3], pub v2: [f32; 3], pub v3: [f32; 3], pub attr_byte_count: u16, } fn point_eq(lhs: [f32; 3], rhs: [f32; 3]) -> bool { lhs[0] == rhs[0] && lhs[1] == rhs[1] && lhs[2] == rhs[2] } impl PartialEq for Triangle { fn eq(&self, rhs: &Triangle) -> bool { point_eq(self.normal, rh...
use std::io::{Result, Write, ErrorKind, Error}; use byteorder::{ReadBytesExt, LittleEndian, WriteBytesExt}; pub struct Triangle { pub normal: [f32; 3],
random_line_split
lib.rs
extern crate byteorder; use std::io::{Result, Write, ErrorKind, Error}; use byteorder::{ReadBytesExt, LittleEndian, WriteBytesExt}; pub struct Triangle { pub normal: [f32; 3], pub v1: [f32; 3], pub v2: [f32; 3], pub v3: [f32; 3], pub attr_byte_count: u16, } fn point_eq(lhs: [f32; 3], rhs: [f32; 3...
<T: ReadBytesExt>(input: &mut T) -> Result<BinaryStlFile> { // read the header let header = try!(read_header(input)); let mut triangles = Vec::new(); for _ in 0..header.num_triangles { triangles.push(try!(read_triangle(input))); } Ok(BinaryStlFile { header: header, ...
read_stl
identifier_name
lib.rs
extern crate byteorder; use std::io::{Result, Write, ErrorKind, Error}; use byteorder::{ReadBytesExt, LittleEndian, WriteBytesExt}; pub struct Triangle { pub normal: [f32; 3], pub v1: [f32; 3], pub v2: [f32; 3], pub v3: [f32; 3], pub attr_byte_count: u16, } fn point_eq(lhs: [f32; 3], rhs: [f32; 3...
fn write_point<T: WriteBytesExt>(out: &mut T, p: [f32; 3]) -> Result<()> { for x in &p { try!(out.write_f32::<LittleEndian>(*x)); } Ok(()) } pub fn write_stl<T: WriteBytesExt>(out: &mut T, stl: &BinaryStlFile) -> Result<()> { assert_eq!(stl.header.num_triangles as usize, stl.triangles.len());...
{ // read the header let header = try!(read_header(input)); let mut triangles = Vec::new(); for _ in 0..header.num_triangles { triangles.push(try!(read_triangle(input))); } Ok(BinaryStlFile { header: header, triangles: triangles, }) }
identifier_body
try_concat.rs
use core::pin::Pin; use futures_core::future::Future; use futures_core::ready; use futures_core::stream::TryStream; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_concat`](super::TryStreamExt::try_concat) method. #[derive(Debug)] #[must_u...
a.extend(x) } else { *this.accum = Some(x) } } else { break this.accum.take().unwrap_or_default(); } })) } }
if let Some(a) = this.accum {
random_line_split
try_concat.rs
use core::pin::Pin; use futures_core::future::Future; use futures_core::ready; use futures_core::stream::TryStream; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_concat`](super::TryStreamExt::try_concat) method. #[derive(Debug)] #[must_u...
else { break this.accum.take().unwrap_or_default(); } })) } }
{ if let Some(a) = this.accum { a.extend(x) } else { *this.accum = Some(x) } }
conditional_block
try_concat.rs
use core::pin::Pin; use futures_core::future::Future; use futures_core::ready; use futures_core::stream::TryStream; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_concat`](super::TryStreamExt::try_concat) method. #[derive(Debug)] #[must_u...
} impl<St> Future for TryConcat<St> where St: TryStream, St::Ok: Extend<<St::Ok as IntoIterator>::Item> + IntoIterator + Default, { type Output = Result<St::Ok, St::Error>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let mut this = self.project(); Poll...
{ Self { stream, accum: None } }
identifier_body
try_concat.rs
use core::pin::Pin; use futures_core::future::Future; use futures_core::ready; use futures_core::stream::TryStream; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_concat`](super::TryStreamExt::try_concat) method. #[derive(Debug)] #[must_u...
(stream: St) -> Self { Self { stream, accum: None } } } impl<St> Future for TryConcat<St> where St: TryStream, St::Ok: Extend<<St::Ok as IntoIterator>::Item> + IntoIterator + Default, { type Output = Result<St::Ok, St::Error>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Sel...
new
identifier_name
tuple.rs
// Compiler: // // Run-time: // status: 0
#![feature(auto_traits, lang_items, no_core, start, intrinsics)] #![no_std] #![no_core] /* * Core */ // Because we don't have core yet. #[lang = "sized"] pub trait Sized {} #[lang = "copy"] trait Copy { } impl Copy for isize {} #[lang = "receiver"] trait Receiver { } #[lang = "freeze"] pub(crate) unsafe auto ...
// stdout: 3
random_line_split
tuple.rs
// Compiler: // // Run-time: // status: 0 // stdout: 3 #![feature(auto_traits, lang_items, no_core, start, intrinsics)] #![no_std] #![no_core] /* * Core */ // Because we don't have core yet. #[lang = "sized"] pub trait Sized {} #[lang = "copy"] trait Copy { } impl Copy for isize {} #[lang = "receiver"] tra...
{ let test: (isize, isize, isize) = (3, 1, 4); unsafe { libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.0); } 0 }
identifier_body
tuple.rs
// Compiler: // // Run-time: // status: 0 // stdout: 3 #![feature(auto_traits, lang_items, no_core, start, intrinsics)] #![no_std] #![no_core] /* * Core */ // Because we don't have core yet. #[lang = "sized"] pub trait Sized {} #[lang = "copy"] trait Copy { } impl Copy for isize {} #[lang = "receiver"] tra...
(mut argc: isize, _argv: *const *const u8) -> isize { let test: (isize, isize, isize) = (3, 1, 4); unsafe { libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.0); } 0 }
main
identifier_name
mulpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn mulpd_1() { run_test(&Instruction { mnemonic: Mnemonic::MULPD, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM7...
run_test(&Instruction { mnemonic: Mnemonic::MULPD, operand1: Some(Direct(XMM5)), operand2: Some(IndirectScaledDisplaced(RSI, Two, 1406090988, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, ...
fn mulpd_3() { run_test(&Instruction { mnemonic: Mnemonic::MULPD, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM5)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 89, 245], OperandSize::Qword) } fn mulpd_4() {
random_line_split
mulpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn mulpd_1() { run_test(&Instruction { mnemonic: Mnemonic::MULPD, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM7...
() { run_test(&Instruction { mnemonic: Mnemonic::MULPD, operand1: Some(Direct(XMM5)), operand2: Some(IndirectScaledDisplaced(RSI, Two, 1406090988, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102,...
mulpd_4
identifier_name
mulpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn mulpd_1() { run_test(&Instruction { mnemonic: Mnemonic::MULPD, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM7...
{ run_test(&Instruction { mnemonic: Mnemonic::MULPD, operand1: Some(Direct(XMM5)), operand2: Some(IndirectScaledDisplaced(RSI, Two, 1406090988, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15...
identifier_body
hba.rs
use arch::memory; use core::mem::size_of; use core::u32; use disk::Disk; use drivers::io::{Io, Mmio}; use system::error::{Error, Result, EIO}; use super::fis::{FIS_TYPE_REG_H2D, FisRegH2D}; const ATA_CMD_READ_DMA_EXT: u8 = 0x25; const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35; const ATA_DEV_BUSY: u8 = 0x80; const ATA_DEV_...
cmdheader.prdtl.write(entries); let ctba = cmdheader.ctba.read() as usize; unsafe { ::memset(ctba as *mut u8, 0, size_of::<HbaCmdTable>()) }; let cmdtbl = unsafe { &mut *(ctba as *mut HbaCmdTable) }; let prdt_entry = &mut cmdtbl.prdt_entr...
{ if buf >= 0x80000000 { buf -= 0x80000000; } // TODO: PRDTL for files larger than 4MB let entries = 1; if buf > 0 && sectors > 0 { self.is.write(u32::MAX); if let Some(slot) = self.slot() { // debugln!("Slot {}", slot); ...
identifier_body
hba.rs
use arch::memory; use core::mem::size_of; use core::u32; use disk::Disk; use drivers::io::{Io, Mmio}; use system::error::{Error, Result, EIO}; use super::fis::{FIS_TYPE_REG_H2D, FisRegH2D}; const ATA_CMD_READ_DMA_EXT: u8 = 0x25; const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35; const ATA_DEV_BUSY: u8 = 0x80; const ATA_DEV_...
pub vs: Mmio<u32>, // 0x10, Version pub ccc_ctl: Mmio<u32>, // 0x14, Command completion coalescing control pub ccc_pts: Mmio<u32>, // 0x18, Command completion coalescing ports pub em_loc: Mmio<u32>, // 0x1C, Enclosure management location pub em_ctl: Mmio<u32>, // 0x20, Enclosure management control ...
pub pi: Mmio<u32>, // 0x0C, Port implemented
random_line_split
hba.rs
use arch::memory; use core::mem::size_of; use core::u32; use disk::Disk; use drivers::io::{Io, Mmio}; use system::error::{Error, Result, EIO}; use super::fis::{FIS_TYPE_REG_H2D, FisRegH2D}; const ATA_CMD_READ_DMA_EXT: u8 = 0x25; const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35; const ATA_DEV_BUSY: u8 = 0x80; const ATA_DEV_...
(&mut self) { // debugln!("Starting port"); while self.cmd.readf(HBA_PORT_CMD_CR) {} self.cmd.writef(HBA_PORT_CMD_FRE, true); self.cmd.writef(HBA_PORT_CMD_ST, true); } pub fn stop(&mut self) { // debugln!("Stopping port"); self.cmd.writef(HBA_PORT_CMD_ST, fals...
start
identifier_name
hba.rs
use arch::memory; use core::mem::size_of; use core::u32; use disk::Disk; use drivers::io::{Io, Mmio}; use system::error::{Error, Result, EIO}; use super::fis::{FIS_TYPE_REG_H2D, FisRegH2D}; const ATA_CMD_READ_DMA_EXT: u8 = 0x25; const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35; const ATA_DEV_BUSY: u8 = 0x80; const ATA_DEV_...
} } #[repr(packed)] pub struct HbaMem { pub cap: Mmio<u32>, // 0x00, Host capability pub ghc: Mmio<u32>, // 0x04, Global host control pub is: Mmio<u32>, // 0x08, Interrupt status pub pi: Mmio<u32>, // 0x0C, Port implemented pub vs: Mmio<u32>, // 0x10, Version pub ccc_ctl: Mmio<u32>, // 0x1...
{ debugln!("Invalid request"); Err(Error::new(EIO)) }
conditional_block
task-comm-3.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 ...
(ch: &SharedChan<int>, message: int, count: int) { info!("Starting test00_start"); let mut i: int = 0; while i < count { info!("Sending Message"); ch.send(message + 0); i = i + 1; } info!("Ending test00_start"); } fn test00() { let number_of_tasks: int = 16; let numb...
test00_start
identifier_name
task-comm-3.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
// xfail-fast extern mod extra; use std::comm::SharedChan; use std::comm; use std::task; pub fn main() { info!("===== WITHOUT THREADS ====="); test00(); } fn test00_start(ch: &SharedChan<int>, message: int, count: int) { info!("Starting test00_start"); let mut i: int = 0; while i < count { info...
// <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.
random_line_split
task-comm-3.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 = i + 1; } // Read from spawned tasks... let mut sum = 0; for _r in results.iter() { i = 0; while i < number_of_messages { let value = po.recv(); sum += value; i = i + 1; } } // Join spawned tasks... for r in...
{ let number_of_tasks: int = 16; let number_of_messages: int = 4; info!("Creating tasks"); let (po, ch) = comm::stream(); let ch = comm::SharedChan::new(ch); let mut i: int = 0; // Create and spawn tasks... let mut results = ~[]; while i < number_of_tasks { let ch = ch.cl...
identifier_body
extern-fail.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 count(n: uint) -> uint { unsafe { task::deschedule(); rustrt::rust_dbg_call(cb, n) } } fn main() { do 10u.times { do task::spawn { let result = count(5u); info!("result = %?", result); fail!(); }; } }
count(data - 1u) + count(data - 1u) } }
random_line_split
extern-fail.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 count(n: uint) -> uint { unsafe { task::deschedule(); rustrt::rust_dbg_call(cb, n) } } fn main() { do 10u.times { do task::spawn { let result = count(5u); info!("result = %?", result); fail!(); }; } }
{ count(data - 1u) + count(data - 1u) }
conditional_block
extern-fail.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() { do 10u.times { do task::spawn { let result = count(5u); info!("result = %?", result); fail!(); }; } }
{ unsafe { task::deschedule(); rustrt::rust_dbg_call(cb, n) } }
identifier_body
extern-fail.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 ...
() { do 10u.times { do task::spawn { let result = count(5u); info!("result = %?", result); fail!(); }; } }
main
identifier_name
main.rs
#[cfg(test)] #[macro_use] extern crate meta; #[allow(clippy::needless_range_loop)] fn shell_sort<T: Ord + Copy>(v: &mut [T])
fn main() { let mut numbers = [4i32, 65, 2, -31, 0, 99, 2, 83, 782, 1]; println!("Before: {:?}", numbers); shell_sort(&mut numbers); println!("After: {:?}", numbers); } #[cfg(test)] mod tests { test_sort!(super::shell_sort); }
{ let mut gap = v.len() / 2; let len = v.len(); while gap > 0 { for i in gap..len { let temp = v[i]; let mut j = i; while j >= gap && v[j - gap] > temp { v[j] = v[j - gap]; j -= gap; } v[j] = temp; } ...
identifier_body
main.rs
#[cfg(test)] #[macro_use] extern crate meta; #[allow(clippy::needless_range_loop)] fn
<T: Ord + Copy>(v: &mut [T]) { let mut gap = v.len() / 2; let len = v.len(); while gap > 0 { for i in gap..len { let temp = v[i]; let mut j = i; while j >= gap && v[j - gap] > temp { v[j] = v[j - gap]; j -= gap; } ...
shell_sort
identifier_name
main.rs
#[cfg(test)] #[macro_use] extern crate meta; #[allow(clippy::needless_range_loop)] fn shell_sort<T: Ord + Copy>(v: &mut [T]) { let mut gap = v.len() / 2; let len = v.len(); while gap > 0 { for i in gap..len { let temp = v[i]; let mut j = i; while j >= gap && v[j ...
} gap /= 2; } } fn main() { let mut numbers = [4i32, 65, 2, -31, 0, 99, 2, 83, 782, 1]; println!("Before: {:?}", numbers); shell_sort(&mut numbers); println!("After: {:?}", numbers); } #[cfg(test)] mod tests { test_sort!(super::shell_sort); }
j -= gap; } v[j] = temp;
random_line_split
lib.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/. */ #![feature(box_syntax)] #![feature(custom_derive)] #![feature(plugin)] #![feature(plugin)] #![plugin(plugins)] #!...
{ pub pipeline: CompositionPipeline, pub size: Option<TypedSize2D<PagePx, f32>>, pub children: Vec<SendableFrameTree>, } /// The subset of the pipeline that is needed for layer composition. #[derive(Clone)] pub struct CompositionPipeline { pub id: PipelineId, pub script_chan: IpcSender<Constellati...
SendableFrameTree
identifier_name
lib.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/. */ #![feature(box_syntax)] #![feature(custom_derive)] #![feature(plugin)] #![feature(plugin)] #![plugin(plugins)] #!...
extern crate msg; extern crate net_traits; #[macro_use] extern crate profile_traits; extern crate script_traits; extern crate style_traits; extern crate time; extern crate url; #[macro_use] extern crate util; extern crate webrender; extern crate webrender_traits; pub use compositor_thread::CompositorProxy; pub use com...
extern crate image; extern crate ipc_channel; extern crate layers; #[macro_use] extern crate log;
random_line_split
tty_painter.rs
use std::io::prelude::*; use std::io::BufWriter; use term::terminfo::{parm, TermInfo}; use vterm_sys::{Size, Pos}; use super::pen::*; use ::cell_buffer::*; // TODO: // * [ ] clean up error handling and all the expects on write_all pub struct TtyPainter<F: Write + Send> { // the physical state of the tty that is b...
self.pen.visible = old_visible; let bytes = self.pen.flush(&self.terminfo, &mut self.vars); self.io.write_all(&bytes).ok().expect("failed to write"); self.io.flush().unwrap(); trace!("draw_screen finish"); } pub fn move_cursor(&mut self, pos: Pos, is_visible: bool) { ...
self.write_cap("rc", &vec![]);
random_line_split
tty_painter.rs
use std::io::prelude::*; use std::io::BufWriter; use term::terminfo::{parm, TermInfo}; use vterm_sys::{Size, Pos}; use super::pen::*; use ::cell_buffer::*; // TODO: // * [ ] clean up error handling and all the expects on write_all pub struct TtyPainter<F: Write + Send> { // the physical state of the tty that is b...
else { // like tmux's tty_repeat_space self.io.write_all(&[b'\x20']).ok().expect("failed to write"); // space } self.pen.notify_of_advanced_pos(&self.size); if cell.width > 1 { warn!("cell has width > 1 {:?}, but acting on this infor...
{ self.io.write_all(&cell.chars).ok().expect("failed to write"); }
conditional_block
tty_painter.rs
use std::io::prelude::*; use std::io::BufWriter; use term::terminfo::{parm, TermInfo}; use vterm_sys::{Size, Pos}; use super::pen::*; use ::cell_buffer::*; // TODO: // * [ ] clean up error handling and all the expects on write_all pub struct TtyPainter<F: Write + Send> { // the physical state of the tty that is b...
(&mut self, pos: Pos, is_visible: bool) { trace!("move_cursor pos={:?} is_visible={:?}", pos, is_visible); self.pen.pos = pos; self.pen.visible = is_visible; self.io.write_all(&self.pen.flush(&self.terminfo, &mut self.vars)).ok().expect("failed to write"); } /// Implemented like...
move_cursor
identifier_name
tty_painter.rs
use std::io::prelude::*; use std::io::BufWriter; use term::terminfo::{parm, TermInfo}; use vterm_sys::{Size, Pos}; use super::pen::*; use ::cell_buffer::*; // TODO: // * [ ] clean up error handling and all the expects on write_all pub struct TtyPainter<F: Write + Send> { // the physical state of the tty that is b...
/// Implemented like tmux's tty_redraw_region /// /// If the pane is the full width of the physical terminal this can be optimized by using /// scroll regions, but that isn't implemented. /// /// Tmux also has an optimization where it'll no-op this if the effected region is >= 50% of /// t...
{ trace!("move_cursor pos={:?} is_visible={:?}", pos, is_visible); self.pen.pos = pos; self.pen.visible = is_visible; self.io.write_all(&self.pen.flush(&self.terminfo, &mut self.vars)).ok().expect("failed to write"); }
identifier_body
errors.rs
error_chain! { errors { InvalidRequest(r: String) { description("invalid tracker request") display("invalid tracker request: {}", r) } InvalidResponse(r: &'static str) { description("invalid tracker response") display("invalid tracker response...
} DNSTimeout { description("the tracker url dns resolution timed out") display("tracker dns timeout") } DNSInvalid { description("the tracker url does not correspond to a valid IP address") display("tracker dns invalid") }...
display("tracker timeout")
random_line_split
tokenizer.rs
use operations::{Op, ToOp}; pub struct Tokenizer<'a> { words: Vec<&'a str>, misses: u64, buf: String, } impl<'a> Tokenizer<'a> { pub fn new(words: Vec<&'a str>) -> Tokenizer<'a>
pub fn tokenize(&mut self) -> Vec<Op> { let mut ops = vec![]; for word in self.words.clone().iter() { self.buf.push_str(word); match self.buf.clone().to_op() { Op::Increment => self.push_op(&mut ops, Op::Increment), Op::Decrement => self.push...
{ Tokenizer { words: words, misses: 0, buf: "".to_string() } }
identifier_body
tokenizer.rs
use operations::{Op, ToOp}; pub struct Tokenizer<'a> { words: Vec<&'a str>, misses: u64, buf: String, } impl<'a> Tokenizer<'a> { pub fn new(words: Vec<&'a str>) -> Tokenizer<'a> { Tokenizer { words: words, misses: 0, buf: "".to_string() } } pub fn tokenize(&mut self) -> Vec<Op> { ...
}, } } ops } fn push_op(&mut self, ops: &mut Vec<Op>, op: Op) { ops.push(op); self.misses = 0; self.buf = "".to_string(); } }
{ panic!("syntax error unknown token `{}`", self.buf); }
conditional_block
tokenizer.rs
use operations::{Op, ToOp}; pub struct Tokenizer<'a> { words: Vec<&'a str>, misses: u64, buf: String, } impl<'a> Tokenizer<'a> { pub fn new(words: Vec<&'a str>) -> Tokenizer<'a> { Tokenizer { words: words, misses: 0, buf: "".to_string() } } pub fn tokenize(&mut self) -> Vec<Op> { ...
}
fn push_op(&mut self, ops: &mut Vec<Op>, op: Op) { ops.push(op); self.misses = 0; self.buf = "".to_string(); }
random_line_split
tokenizer.rs
use operations::{Op, ToOp}; pub struct Tokenizer<'a> { words: Vec<&'a str>, misses: u64, buf: String, } impl<'a> Tokenizer<'a> { pub fn new(words: Vec<&'a str>) -> Tokenizer<'a> { Tokenizer { words: words, misses: 0, buf: "".to_string() } } pub fn tokenize(&mut self) -> Vec<Op> { ...
(&mut self, ops: &mut Vec<Op>, op: Op) { ops.push(op); self.misses = 0; self.buf = "".to_string(); } }
push_op
identifier_name
main.rs
struct Point<T> { x: T, y: T, } impl<T> Point<T> { fn swap(&mut self) { std::mem::swap(&mut self.x, &mut self.y); } } fn takes_anything<T>(x: T) { // do something with x } fn takes_two_of_the_same_thing<T>(x: T, y: T) { // do something with x and y } fn takes_two_things<T, U>(x: T, y...
fn main() { let x: Option<i32> = Some(5); // okay // let y: Option<f64> = Some(4); // error let y: Option<f64> = Some(5.0f64); let init_origin = Point { x: 0, y: 0 }; let float_origin = Point { x: 0.0, y: 0.0 }; }
{ // do something with x and y }
identifier_body
main.rs
struct Point<T> { x: T, y: T, } impl<T> Point<T> { fn swap(&mut self) { std::mem::swap(&mut self.x, &mut self.y); } } fn takes_anything<T>(x: T) { // do something with x } fn takes_two_of_the_same_thing<T>(x: T, y: T) { // do something with x and y } fn takes_two_things<T, U>(x: T, y...
() { let x: Option<i32> = Some(5); // okay // let y: Option<f64> = Some(4); // error let y: Option<f64> = Some(5.0f64); let init_origin = Point { x: 0, y: 0 }; let float_origin = Point { x: 0.0, y: 0.0 }; }
main
identifier_name
main.rs
struct Point<T> { x: T, y: T, }
fn swap(&mut self) { std::mem::swap(&mut self.x, &mut self.y); } } fn takes_anything<T>(x: T) { // do something with x } fn takes_two_of_the_same_thing<T>(x: T, y: T) { // do something with x and y } fn takes_two_things<T, U>(x: T, y: U) { // do something with x and y } fn main() { l...
impl<T> Point<T> {
random_line_split
main.rs
#[macro_use] extern crate libeuler; /// The sum of the squares of the first ten natural numbers is, /// 1^2 + 2^2 +... + 10^2 = 385 /// /// The square of the sum of the first ten natural numbers is, /// (1 + 2 +... + 10)^2 = 552 = 3025 /// /// Hence the difference between the sum of the squares of the first ten natura...
solutions!{ inputs: (numbers: i64 = 100) sol naive { let mut sumsq = 0; let mut sum = 0; for i in 0..numbers { let num = i + 1; sumsq += num.pow(2); sum += num; } let sqsum = sum.pow(2); ...
random_line_split
main.rs
#[macro_use] extern crate libeuler; /// The sum of the squares of the first ten natural numbers is, /// 1^2 + 2^2 +... + 10^2 = 385 /// /// The square of the sum of the first ten natural numbers is, /// (1 + 2 +... + 10)^2 = 552 = 3025 /// /// Hence the difference between the sum of the squares of the first ten natura...
{ solutions!{ inputs: (numbers: i64 = 100) sol naive { let mut sumsq = 0; let mut sum = 0; for i in 0..numbers { let num = i + 1; sumsq += num.pow(2); sum += num; } let sqsum = sum.pow(2);...
in()
identifier_name
main.rs
#[macro_use] extern crate libeuler; /// The sum of the squares of the first ten natural numbers is, /// 1^2 + 2^2 +... + 10^2 = 385 /// /// The square of the sum of the first ten natural numbers is, /// (1 + 2 +... + 10)^2 = 552 = 3025 /// /// Hence the difference between the sum of the squares of the first ten natura...
solutions!{ inputs: (numbers: i64 = 100) sol naive { let mut sumsq = 0; let mut sum = 0; for i in 0..numbers { let num = i + 1; sumsq += num.pow(2); sum += num; } let sqsum = sum.pow(2); ...
identifier_body
mod.rs
// Copyright (c) 2015 Daniel Grunwald // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files (the "Software"), to deal in the Software // without restriction, including without limitation the rights to use, copy, modify, merge, // publis...
pub use self::set::PySet; pub use self::tuple::{NoArgs, PyTuple}; #[macro_export] macro_rules! pyobject_newtype( ($name: ident) => ( $crate::py_impl_to_py_object_for_python_object!($name); $crate::py_impl_from_py_object_for_python_object!($name); impl $crate::PythonObject for $name { ...
#[cfg(feature = "python3-sys")] pub use self::num::PyLong as PyInt; pub use self::num::{PyFloat, PyLong}; pub use self::sequence::PySequence;
random_line_split
region.rs
(&self) -> ast::NodeId { match *self { CodeExtent::Misc(node_id) => node_id, } } /// Maps this scope to a potentially new one according to the /// NodeId transformer `f_id`. pub fn map_id(&self, f_id: |ast::NodeId| -> ast::NodeId) -> CodeExtent { match *self { ...
node_id
identifier_name