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
fun-call-variants.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 a: isize = direct(3); // direct let b: isize = ho(direct); // indirect unbound assert_eq!(a, b); }
{ return x + 1; }
identifier_body
fun-call-variants.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<F>(f: F) -> isize where F: FnOnce(isize) -> isize { let n: isize = f(3); return n; } fn direct(x: isize) -> isize { return x + 1; } pub fn main() { let a: isize = direct(3); // direct let b: isize = ho(direct); // indirect unbound assert_eq!(a, b); }
ho
identifier_name
24.rs
/* Problem 24: Lexicographic permutations * * A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation * of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, * we call it lexicographic order. The lexicographic permutations of 0, 1...
{ let digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let result = digits.permutations().skip(1_000_000 - 1).next().unwrap(); println!("{}", result.into_iter().join("")); }
identifier_body
24.rs
/* Problem 24: Lexicographic permutations * * A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation * of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, * we call it lexicographic order. The lexicographic permutations of 0, 1...
}
random_line_split
24.rs
/* Problem 24: Lexicographic permutations * * A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation * of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, * we call it lexicographic order. The lexicographic permutations of 0, 1...
() { let digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let result = digits.permutations().skip(1_000_000 - 1).next().unwrap(); println!("{}", result.into_iter().join("")); }
main
identifier_name
issue-54505-no-std.rs
// error-pattern: `#[panic_handler]` function required, but not found // Regression test for #54505 - range borrowing suggestion had // incorrect syntax (missing parentheses). // This test doesn't use std // (so all Ranges resolve to core::ops::Range...) #![no_std] #![feature(lang_items)] use core::ops::RangeBounds...
() {} // take a reference to any built-in range fn take_range(_r: &impl RangeBounds<i8>) {} fn main() { take_range(0..1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..1) take_range(1..); //~^ ERROR mismatched types [E0308] //~| HELP consider...
eh_unwind_resume
identifier_name
issue-54505-no-std.rs
// error-pattern: `#[panic_handler]` function required, but not found // Regression test for #54505 - range borrowing suggestion had // incorrect syntax (missing parentheses). // This test doesn't use std // (so all Ranges resolve to core::ops::Range...) #![no_std] #![feature(lang_items)] use core::ops::RangeBounds...
take_range(0..=1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..=1) take_range(..5); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..5) take_range(..=42); //~^ ERROR mismatched types [E0308]...
//~| SUGGESTION &(..)
random_line_split
issue-54505-no-std.rs
// error-pattern: `#[panic_handler]` function required, but not found // Regression test for #54505 - range borrowing suggestion had // incorrect syntax (missing parentheses). // This test doesn't use std // (so all Ranges resolve to core::ops::Range...) #![no_std] #![feature(lang_items)] use core::ops::RangeBounds...
fn main() { take_range(0..1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..1) take_range(1..); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(1..) take_range(..); //~^ ERROR mismatched typ...
{}
identifier_body
git.rs
use std::collections::HashMap; use std::env; use crate::config; use crate::errors::*; use crate::ConfigScope; pub struct Repo { repo: git2::Repository, } impl Repo { pub fn new() -> Result<Self> { let repo = env::current_dir() .chain_err(|| "") .and_then(|current_dir| git2::Repo...
fn include_paths(&self) -> Result<Vec<String>> { let config = self.local_config()?; let include_paths: Vec<String> = config .entries(Some("include.path")) .chain_err(|| "")? .into_iter() .map(|entry| { entry .chain_err(||...
.and(Ok(())) .chain_err(|| "") }
random_line_split
git.rs
use std::collections::HashMap; use std::env; use crate::config; use crate::errors::*; use crate::ConfigScope; pub struct Repo { repo: git2::Repository, } impl Repo { pub fn new() -> Result<Self> { let repo = env::current_dir() .chain_err(|| "") .and_then(|current_dir| git2::Repo...
(&mut self, name: &str, value: &str) -> Result<()> { self.config .set_multivar(name, "^$", value) .chain_err(|| format!("error adding git config '{}': '{}'", name, value)) } fn set(&mut self, name: &str, value: &str) -> Result<()> { self.config .set_str(name, va...
add
identifier_name
git.rs
use std::collections::HashMap; use std::env; use crate::config; use crate::errors::*; use crate::ConfigScope; pub struct Repo { repo: git2::Repository, } impl Repo { pub fn new() -> Result<Self> { let repo = env::current_dir() .chain_err(|| "") .and_then(|current_dir| git2::Repo...
let include_paths = self.include_paths()?; if include_paths.contains(&include_path) { return Ok(()); } let mut config = self.local_config()?; config .set_multivar("include.path", "^$", &include_path) .and(Ok(())) .chain_err(|| "") ...
{ return Ok(()); }
conditional_block
git.rs
use std::collections::HashMap; use std::env; use crate::config; use crate::errors::*; use crate::ConfigScope; pub struct Repo { repo: git2::Repository, } impl Repo { pub fn new() -> Result<Self> { let repo = env::current_dir() .chain_err(|| "") .and_then(|current_dir| git2::Repo...
fn add(&mut self, name: &str, value: &str) -> Result<()> { self.config .set_multivar(name, "^$", value) .chain_err(|| format!("error adding git config '{}': '{}'", name, value)) } fn set(&mut self, name: &str, value: &str) -> Result<()> { self.config .set_...
{ let mut result = HashMap::new(); let entries = self .config .entries(Some(glob)) .chain_err(|| "error getting git config entries")?; for entry in &entries { let entry = entry.chain_err(|| "error getting git config entry")?; if let (So...
identifier_body
partialeq_ne_impl.rs
use clippy_utils::diagnostics::span_lint_hir; use clippy_utils::is_automatically_derived; use if_chain::if_chain; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { /// ### What i...
declare_lint_pass!(PartialEqNeImpl => [PARTIALEQ_NE_IMPL]); impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { if_chain! { if let ItemKind::Impl(Impl { of_trait: Some(ref trait_ref), items: impl_items,.. }) = item.kind; ...
/// ``` pub PARTIALEQ_NE_IMPL, complexity, "re-implementing `PartialEq::ne`" }
random_line_split
partialeq_ne_impl.rs
use clippy_utils::diagnostics::span_lint_hir; use clippy_utils::is_automatically_derived; use if_chain::if_chain; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { /// ### What i...
}; } }
{ if_chain! { if let ItemKind::Impl(Impl { of_trait: Some(ref trait_ref), items: impl_items, .. }) = item.kind; let attrs = cx.tcx.hir().attrs(item.hir_id()); if !is_automatically_derived(attrs); if let Some(eq_trait) = cx.tcx.lang_items().eq_trait(); ...
identifier_body
partialeq_ne_impl.rs
use clippy_utils::diagnostics::span_lint_hir; use clippy_utils::is_automatically_derived; use if_chain::if_chain; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { /// ### What i...
(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { if_chain! { if let ItemKind::Impl(Impl { of_trait: Some(ref trait_ref), items: impl_items,.. }) = item.kind; let attrs = cx.tcx.hir().attrs(item.hir_id()); if!is_automatically_derived(attrs); if let Some(...
check_item
identifier_name
lib.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! This crate prov...
// file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //
random_line_split
installed_packages.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 ...
(p: &Path) -> Option<~str> { let files = { let _guard = io::ignore_io_error(); fs::readdir(p) }; for path in files.iter() { if path.extension_str() == Some(os::consts::DLL_EXTENSION) { let stuff : &str = path.filestem_str().expect("has_library: weird path"); l...
has_library
identifier_name
installed_packages.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let workspaces = rust_path(); for p in workspaces.iter() { let binfiles = { let _guard = io::ignore_io_error(); fs::readdir(&p.join("bin")) }; for exec in binfiles.iter() { // FIXME (#9639): This needs to handle non-utf8 paths match exec.fi...
pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
random_line_split
installed_packages.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } let libfiles = { let _guard = io::ignore_io_error(); fs::readdir(&p.join("lib")) }; for lib in libfiles.iter() { debug!("Full name: {}", lib.display()); match has_library(lib) { Some(basename) => { ...
{ if !f(&CrateId::new(exec_path)) { return false; } }
conditional_block
installed_packages.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut is_installed = false; list_installed_packages(|installed| { if installed == p { is_installed = true; false } else { true } }); is_installed }
identifier_body
mod.rs
mod boss; mod player; use Item; use num::integer::Integer; pub use self::boss::Boss; pub use self::player::Player; pub fn player(weapon: &Item, armor: &Item, rings: Vec<&Item>) -> Player { Player::new(weapon, armor, rings) } pub fn boss(hit_points: u32, damage: u32, armor: u32) -> Boss { Boss::new(hit_poin...
; let (div, rem) = hit_points.div_rem(&effective_damage); if rem == 0 { div } else { div + 1 } }
{ 1 }
conditional_block
mod.rs
mod boss; mod player; use Item; use num::integer::Integer; pub use self::boss::Boss; pub use self::player::Player; pub fn player(weapon: &Item, armor: &Item, rings: Vec<&Item>) -> Player { Player::new(weapon, armor, rings) } pub fn boss(hit_points: u32, damage: u32, armor: u32) -> Boss { Boss::new(hit_poin...
(damage: u32, hit_points: u32, armor: u32) -> u32 { let effective_damage = if damage > armor { damage - armor } else { 1 }; let (div, rem) = hit_points.div_rem(&effective_damage); if rem == 0 { div } else { div + 1 } }
turns_to_beat
identifier_name
mod.rs
mod boss; mod player; use Item; use num::integer::Integer; pub use self::boss::Boss; pub use self::player::Player; pub fn player(weapon: &Item, armor: &Item, rings: Vec<&Item>) -> Player
pub fn boss(hit_points: u32, damage: u32, armor: u32) -> Boss { Boss::new(hit_points, damage, armor) } pub trait Character { fn hit_points(&self) -> u32; fn damage(&self) -> u32; fn armor(&self) -> u32; fn beats(&self, other: &Character) -> bool { let win_after = turns_to_beat(self.damag...
{ Player::new(weapon, armor, rings) }
identifier_body
mod.rs
mod boss; mod player; use Item; use num::integer::Integer; pub use self::boss::Boss; pub use self::player::Player; pub fn player(weapon: &Item, armor: &Item, rings: Vec<&Item>) -> Player { Player::new(weapon, armor, rings) } pub fn boss(hit_points: u32, damage: u32, armor: u32) -> Boss { Boss::new(hit_poin...
fn damage(&self) -> u32; fn armor(&self) -> u32; fn beats(&self, other: &Character) -> bool { let win_after = turns_to_beat(self.damage(), other.hit_points(), other.armor()); let lose_after = turns_to_beat(other.damage(), self.hit_points(), self.armor()); win_after <= lose_after ...
fn hit_points(&self) -> u32;
random_line_split
parallel.rs
// Benchmark from https://github.com/lschmierer/ecs_bench #![feature(test)] extern crate test; use calx_ecs::{build_ecs, Entity}; use serde::{Deserialize, Serialize}; use test::Bencher; pub const N: usize = 10000; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct R { pub x: f32, } #[d...
#[bench] fn bench_update(b: &mut Bencher) { let mut ecs = build(); b.iter(|| { let es: Vec<Entity> = ecs.r.ent_iter().cloned().collect(); for &e in &es { let rx = ecs.r[e].x; ecs.w1.get_mut(e).map(|w1| w1.x = rx); } for &e in &es { let rx =...
{ b.iter(build); }
identifier_body
parallel.rs
// Benchmark from https://github.com/lschmierer/ecs_bench #![feature(test)] extern crate test; use calx_ecs::{build_ecs, Entity}; use serde::{Deserialize, Serialize}; use test::Bencher;
pub const N: usize = 10000; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct R { pub x: f32, } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct W1 { pub x: f32, } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct W2 { pub x: ...
random_line_split
parallel.rs
// Benchmark from https://github.com/lschmierer/ecs_bench #![feature(test)] extern crate test; use calx_ecs::{build_ecs, Entity}; use serde::{Deserialize, Serialize}; use test::Bencher; pub const N: usize = 10000; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct R { pub x: f32, } #[d...
(b: &mut Bencher) { let mut ecs = build(); b.iter(|| { let es: Vec<Entity> = ecs.r.ent_iter().cloned().collect(); for &e in &es { let rx = ecs.r[e].x; ecs.w1.get_mut(e).map(|w1| w1.x = rx); } for &e in &es { let rx = ecs.r[e].x; e...
bench_update
identifier_name
mod.rs
#[macro_use] pub mod macros; /// Constants like memory locations pub mod consts; /// Debugging support pub mod debug; /// Devices pub mod device; /// Global descriptor table pub mod gdt; /// Graphical debug #[cfg(feature = "graphical_debug")] mod graphical_debug; /// Interrupt instructions #[macro_use] pub mod in...
pub mod ipi; /// Paging pub mod paging; /// Page table isolation pub mod pti; pub mod rmm; /// Initialization and start function pub mod start; /// Stop function pub mod stop; pub use ::rmm::X8664Arch as CurrentRmmArch; // Flags pub mod flags { pub const SHIFT_SINGLESTEP: usize = 8; pub const FLAG_SINGLE...
/// Inter-processor interrupts
random_line_split
moves-based-on-type-no-recursive-stack-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 ...
let mut x = Some("hello".to_string()); conspirator(|f, writer| { if writer { x = None; } else { match x { Some(ref msg) => { (f.c)(f, true); //~^ ERROR: cannot borrow `*f` as mutable because print...
} fn innocent_looking_victim() {
random_line_split
moves-based-on-type-no-recursive-stack-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 ...
fn conspirator(f: |&mut R, bool|) { let mut r = R {c: f}; f(&mut r, false) //~ ERROR use of moved value } fn main() { innocent_looking_victim() }
{ let mut x = Some("hello".to_string()); conspirator(|f, writer| { if writer { x = None; } else { match x { Some(ref msg) => { (f.c)(f, true); //~^ ERROR: cannot borrow `*f` as mutable because pri...
identifier_body
moves-based-on-type-no-recursive-stack-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 ...
}) } fn conspirator(f: |&mut R, bool|) { let mut r = R {c: f}; f(&mut r, false) //~ ERROR use of moved value } fn main() { innocent_looking_victim() }
{ match x { Some(ref msg) => { (f.c)(f, true); //~^ ERROR: cannot borrow `*f` as mutable because println!("{:?}", msg); }, None => fail!("oops"), } }
conditional_block
moves-based-on-type-no-recursive-stack-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 ...
() { let mut x = Some("hello".to_string()); conspirator(|f, writer| { if writer { x = None; } else { match x { Some(ref msg) => { (f.c)(f, true); //~^ ERROR: cannot borrow `*f` as mutable because ...
innocent_looking_victim
identifier_name
bouncy_circles.rs
#![feature (test)] #![feature (macro_vis_matcher)] extern crate test; #[macro_use] extern crate time_steward; #[macro_use] extern crate glium; extern crate nalgebra; extern crate rand; extern crate boolinator; extern crate docopt; extern crate serde; #[macro_use] extern crate serde_derive; use test::Bencher; use...
(bencher: &mut Bencher) { bencher.iter(|| { let mut steward: Steward = Steward::from_globals (make_globals()); steward.insert_fiat_event(0, DeterministicRandomId::new(&0), Initialize {}).unwrap(); for index in 1..10 { steward.insert_fiat_event (index*SECOND, DeterministicRandomId::new (& index), Di...
bouncy_circles_disturbed
identifier_name
bouncy_circles.rs
#![feature (test)] #![feature (macro_vis_matcher)] extern crate test; #[macro_use] extern crate time_steward; #[macro_use] extern crate glium; extern crate nalgebra; extern crate rand; extern crate boolinator; extern crate docopt; extern crate serde; #[macro_use] extern crate serde_derive; use test::Bencher; use...
/* #[bench] fn bouncy_circles_disturbed_retroactive (bencher: &mut Bencher) { bencher.iter(|| { let mut steward: amortized::Steward<Basics> = amortized::Steward::from_constants(()); steward.insert_fiat_event(0, DeterministicRandomId::new(&0), Initialize::new()).unwrap(); steward.snapshot_before(& (10*SEC...
{ bencher.iter(|| { let mut steward: Steward = Steward::from_globals (make_globals()); steward.insert_fiat_event(0, DeterministicRandomId::new(&0), Initialize {}).unwrap(); for index in 1..10 { steward.insert_fiat_event (index*SECOND, DeterministicRandomId::new (& index), Disturb{ coordinates: [AREN...
identifier_body
bouncy_circles.rs
#![feature (test)] #![feature (macro_vis_matcher)] extern crate test; #[macro_use] extern crate time_steward; #[macro_use] extern crate glium; extern crate nalgebra; extern crate rand; extern crate boolinator; extern crate docopt; extern crate serde; #[macro_use] extern crate serde_derive; use test::Bencher; use...
steward.insert_fiat_event(0, DeterministicRandomId::new(&0), Initialize {}).unwrap(); for index in 1..10 { steward.insert_fiat_event (index*SECOND, DeterministicRandomId::new (& index), Disturb{ coordinates: [ARENA_SIZE/3,ARENA_SIZE/3]}).unwrap(); } for index in 0..1000 { let time = 10*SECON...
let mut steward: Steward = Steward::from_globals (make_globals());
random_line_split
logging-separate-lines.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ let args = os::args(); let args = args.as_slice(); if args.len() > 1 && args[1].as_slice() == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(args[0].as_slice()) .arg("child") .spawn().unwrap().wait_with_output(...
identifier_body
logging-separate-lines.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
let p = Command::new(args[0].as_slice()) .arg("child") .spawn().unwrap().wait_with_output().unwrap(); assert!(p.status.success()); let mut lines = str::from_utf8(p.error.as_slice()).unwrap().lines(); assert!(lines.next().unwrap().contains("foo")); assert!(line...
{ debug!("foo"); debug!("bar"); return }
conditional_block
logging-separate-lines.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
extern crate log; use std::io::Command; use std::os; use std::str; fn main() { let args = os::args(); let args = args.as_slice(); if args.len() > 1 && args[1].as_slice() == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(args[0].as_slice()) ...
// ignore-android // ignore-windows // exec-env:RUST_LOG=debug #[macro_use]
random_line_split
logging-separate-lines.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let args = os::args(); let args = args.as_slice(); if args.len() > 1 && args[1].as_slice() == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(args[0].as_slice()) .arg("child") .spawn().unwrap().wait_with_output...
main
identifier_name
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
Up, PageUp, PageDown, Home, End, CapsLock, ScrollLock, NumLock, PrintScreen, Pause, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23...
Down,
random_line_split
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
} impl fmt::Display for PipelineId { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let PipelineNamespaceId(namespace_id) = self.namespace_id; let PipelineIndex(index) = self.index; write!(fmt, "({},{})", namespace_id, index.get()) } } #[derive(Clone, Copy, Debug, Deserializ...
{ webrender_api::ClipAndScrollInfo::simple(self.root_scroll_node()) }
identifier_body
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
(pipeline: webrender_api::PipelineId) -> PipelineId { let webrender_api::PipelineId(namespace_id, index) = pipeline; unsafe { PipelineId { namespace_id: PipelineNamespaceId(namespace_id), index: PipelineIndex(NonZero::new_unchecked(index)), } ...
from_webrender
identifier_name
server.rs
extern crate music_server; extern crate systray; use music_server::*; use std::{process, env, thread}; use std::io::{Read, Write}; use std::net::TcpListener; use std::sync::{Arc, Mutex}; /// Listens on a TcpListener, parses the commands and add them to the queue. fn start_server(listener: &TcpListener, queue: &Arc<Mu...
} }, Err(_) => println!("Error"), } } } /// Creates a library from /home/$USER/Music, creates a tray icon if the feature is enabled, and /// starts the server and the event loop. fn main() { // Initialize library let library_path = env::home_dir(); i...
{ let mut queue = queue.lock().unwrap(); queue.push(command.unwrap(), Some(stream)); }
conditional_block
server.rs
extern crate music_server; extern crate systray; use music_server::*; use std::{process, env, thread}; use std::io::{Read, Write}; use std::net::TcpListener; use std::sync::{Arc, Mutex}; /// Listens on a TcpListener, parses the commands and add them to the queue. fn start_server(listener: &TcpListener, queue: &Arc<Mu...
if let Ok(listener) = listener { thread::spawn(move || { start_server(&listener, &queue_for_server); }); library.borrow_mut().event_loop(); } else { let _ = writeln!(&mut std::io::stderr(), "Error: could not start server"); process::exit(1); } }
// Initialize server let listener = TcpListener::bind("127.0.0.1:5000");
random_line_split
server.rs
extern crate music_server; extern crate systray; use music_server::*; use std::{process, env, thread}; use std::io::{Read, Write}; use std::net::TcpListener; use std::sync::{Arc, Mutex}; /// Listens on a TcpListener, parses the commands and add them to the queue. fn start_server(listener: &TcpListener, queue: &Arc<Mu...
let queue_for_tray = Arc::clone(&queue_for_server); // Initialize tray icon thread::spawn(move || { tray::start_tray(&queue_for_tray); }); // Initialize server let listener = TcpListener::bind("127.0.0.1:5000"); if let Ok(listener) = listener { thread::spawn(move || { ...
{ // Initialize library let library_path = env::home_dir(); if library_path.is_none() { let _ = writeln!(&mut std::io::stderr(), "Error: cannot read home dir"); process::exit(1); } let library_path = library_path.unwrap().join("Music"); let library = Library::new_rc(&library_...
identifier_body
server.rs
extern crate music_server; extern crate systray; use music_server::*; use std::{process, env, thread}; use std::io::{Read, Write}; use std::net::TcpListener; use std::sync::{Arc, Mutex}; /// Listens on a TcpListener, parses the commands and add them to the queue. fn start_server(listener: &TcpListener, queue: &Arc<Mu...
() { // Initialize library let library_path = env::home_dir(); if library_path.is_none() { let _ = writeln!(&mut std::io::stderr(), "Error: cannot read home dir"); process::exit(1); } let library_path = library_path.unwrap().join("Music"); let library = Library::new_rc(&libra...
main
identifier_name
sokoban.rs
#![crate_type = "bin"] #![allow(unused_must_use)] //extern crate native; extern crate libc; use std::from_str::{FromStr}; use std::io::{File}; use std::io::stdio::{stdin}; use std::path::{Path}; use std::os; use sokoboard::{SokoBoard}; use sokoannotatedboard::{SokoAnnotatedBoard, do_sylvan}; mod raw; mod bdd; mod ...
{ let args = os::args(); let contents; if args.len() > 1 { contents = File::open(&Path::new(args[1].as_slice())).read_to_str(); println!("Reading from file."); } else { contents = stdin().read_to_str(); println!("Reading from stdin."); } let board: SokoBoard = FromStr::from_str( contents.un...
identifier_body
sokoban.rs
#![crate_type = "bin"]
//extern crate native; extern crate libc; use std::from_str::{FromStr}; use std::io::{File}; use std::io::stdio::{stdin}; use std::path::{Path}; use std::os; use sokoboard::{SokoBoard}; use sokoannotatedboard::{SokoAnnotatedBoard, do_sylvan}; mod raw; mod bdd; mod sokoboard; mod sokoannotatedboard; fn main() { le...
#![allow(unused_must_use)]
random_line_split
sokoban.rs
#![crate_type = "bin"] #![allow(unused_must_use)] //extern crate native; extern crate libc; use std::from_str::{FromStr}; use std::io::{File}; use std::io::stdio::{stdin}; use std::path::{Path}; use std::os; use sokoboard::{SokoBoard}; use sokoannotatedboard::{SokoAnnotatedBoard, do_sylvan}; mod raw; mod bdd; mod ...
() { let args = os::args(); let contents; if args.len() > 1 { contents = File::open(&Path::new(args[1].as_slice())).read_to_str(); println!("Reading from file."); } else { contents = stdin().read_to_str(); println!("Reading from stdin."); } let board: SokoBoard = FromStr::from_str( contents...
main
identifier_name
sokoban.rs
#![crate_type = "bin"] #![allow(unused_must_use)] //extern crate native; extern crate libc; use std::from_str::{FromStr}; use std::io::{File}; use std::io::stdio::{stdin}; use std::path::{Path}; use std::os; use sokoboard::{SokoBoard}; use sokoannotatedboard::{SokoAnnotatedBoard, do_sylvan}; mod raw; mod bdd; mod ...
let board: SokoBoard = FromStr::from_str( contents.unwrap() ) .expect("Invalid sokoban board"); let annotated = SokoAnnotatedBoard::fromSokoBoard(board); do_sylvan(&annotated); }
{ contents = stdin().read_to_str(); println!("Reading from stdin."); }
conditional_block
config.rs
use errors::*; use modules::{centerdevice, pocket, slack}; use std::fs::File; use std::io::Read; use std::path::Path; use toml; #[derive(Debug, Deserialize)] #[serde(tag = "format")] #[derive(PartialOrd, PartialEq, Eq)] #[derive(Clone, Copy)] pub enum OutputFormat { JSON, HUMAN, } impl<'a> From<&'a str> for ...
(format: &'a str) -> Self { let format_sane: &str = &format.to_string().to_uppercase(); match format_sane { "JSON" => OutputFormat::JSON, _ => OutputFormat::HUMAN } } } #[derive(Debug, Deserialize)] #[serde(tag = "verbosity")] #[derive(PartialOrd, PartialEq, Eq)] #[d...
from
identifier_name
config.rs
use errors::*; use modules::{centerdevice, pocket, slack}; use std::fs::File; use std::io::Read; use std::path::Path;
#[derive(PartialOrd, PartialEq, Eq)] #[derive(Clone, Copy)] pub enum OutputFormat { JSON, HUMAN, } impl<'a> From<&'a str> for OutputFormat { fn from(format: &'a str) -> Self { let format_sane: &str = &format.to_string().to_uppercase(); match format_sane { "JSON" => OutputFormat:...
use toml; #[derive(Debug, Deserialize)] #[serde(tag = "format")]
random_line_split
method-two-trait-defer-resolution-2.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() { assert_eq!(call_foo_copy(), 1); assert_eq!(call_foo_other(), 2); }
{ let mut x = Vec::new(); let y = x.foo(); x.push(box 0i); y }
identifier_body
method-two-trait-defer-resolution-2.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 ...
(&self) -> int {2} } fn call_foo_copy() -> int { let mut x = Vec::new(); let y = x.foo(); x.push(0u); y } fn call_foo_other() -> int { let mut x = Vec::new(); let y = x.foo(); x.push(box 0i); y } fn main() { assert_eq!(call_foo_copy(), 1); assert_eq!(call_foo_other(), 2); }
foo
identifier_name
instr_pminsb.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn pminsb_1() { run_test(&Instruction { mnemonic: Mnemonic::PMINSB, operand1: Some(Direct(XM...
() { run_test(&Instruction { mnemonic: Mnemonic::PMINSB, operand1: Some(Direct(XMM2)), operand2: Some(IndirectDisplaced(EAX, 1779304913, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 5...
pminsb_2
identifier_name
instr_pminsb.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*;
use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn pminsb_1() { run_test(&Instruction { mnemonic: Mnemonic::PMINSB, operand1: Some(Direct(XMM3)), operand2: Some(Direct(XMM7)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: No...
random_line_split
instr_pminsb.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn pminsb_1()
#[test] fn pminsb_2() { run_test(&Instruction { mnemonic: Mnemonic::PMINSB, operand1: Some(Direct(XMM2)), operand2: Some(IndirectDisplaced(EAX, 1779304913, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: Non...
{ run_test(&Instruction { mnemonic: Mnemonic::PMINSB, operand1: Some(Direct(XMM3)), operand2: Some(Direct(XMM7)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 56, 223], OperandSize::Dword) }
identifier_body
day_4.rs
use std::str::Chars; use self::DisplayResult::{Output, NotANumber}; use self::Number::{One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero}; #[derive(PartialEq, Debug)] pub enum
{ Output(Vec<Number>), NotANumber } impl From<Chars<'static>> for DisplayResult { fn from(chars: Chars) -> DisplayResult { let len = chars.as_str().len(); let mut vec = Vec::with_capacity(len); for c in chars { if c < '0' || c > '9' { return NotANumber;...
DisplayResult
identifier_name
day_4.rs
use std::str::Chars; use self::DisplayResult::{Output, NotANumber}; use self::Number::{One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero}; #[derive(PartialEq, Debug)] pub enum DisplayResult { Output(Vec<Number>), NotANumber } impl From<Chars<'static>> for DisplayResult { fn from(chars: Chars) -...
input: None } } pub fn output(&self) -> DisplayResult { match self.input { Some(data) => DisplayResult::from(data.chars()), None => Output(vec![]), } } pub fn input(&mut self, data: &'static str) { self.input = Some(data); } }
pub fn new() -> Display { Display {
random_line_split
day_4.rs
use std::str::Chars; use self::DisplayResult::{Output, NotANumber}; use self::Number::{One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero}; #[derive(PartialEq, Debug)] pub enum DisplayResult { Output(Vec<Number>), NotANumber } impl From<Chars<'static>> for DisplayResult { fn from(chars: Chars) -...
}
{ self.input = Some(data); }
identifier_body
init.rs
use std::fs::{canonicalize, create_dir}; use std::path::Path; use std::path::PathBuf; use errors::{bail, Result}; use utils::fs::create_file; use crate::console; use crate::prompt::{ask_bool, ask_url}; const CONFIG: &str = r#" # The URL the site will be built for base_url = "%BASE_URL%" # Whether to automatically c...
create_dir(&dir).expect("Could not create test directory"); let mut content = dir.clone(); content.push("content"); create_dir(&content).unwrap(); let allowed = is_directory_quasi_empty(&dir) .expect("An error happened reading the directory's contents"); remov...
{ remove_dir_all(&dir).expect("Could not free test directory"); }
conditional_block
init.rs
use std::fs::{canonicalize, create_dir}; use std::path::Path; use std::path::PathBuf; use errors::{bail, Result}; use utils::fs::create_file; use crate::console; use crate::prompt::{ask_bool, ask_url}; const CONFIG: &str = r#" # The URL the site will be built for base_url = "%BASE_URL%" # Whether to automatically c...
#[test] fn init_quasi_empty_directory() { let mut dir = temp_dir(); dir.push("test_quasi_empty_dir"); if dir.exists() { remove_dir_all(&dir).expect("Could not free test directory"); } create_dir(&dir).expect("Could not create test directory"); let mu...
{ let mut dir = temp_dir(); dir.push("test_non_empty_dir"); if dir.exists() { remove_dir_all(&dir).expect("Could not free test directory"); } create_dir(&dir).expect("Could not create test directory"); let mut content = dir.clone(); content.push("conte...
identifier_body
init.rs
use std::fs::{canonicalize, create_dir}; use std::path::Path; use std::path::PathBuf; use errors::{bail, Result}; use utils::fs::create_file; use crate::console; use crate::prompt::{ask_bool, ask_url}; const CONFIG: &str = r#" # The URL the site will be built for base_url = "%BASE_URL%" # Whether to automatically c...
() { let mut dir = temp_dir(); dir.push("test_non_empty_dir"); if dir.exists() { remove_dir_all(&dir).expect("Could not free test directory"); } create_dir(&dir).expect("Could not create test directory"); let mut content = dir.clone(); content.push("co...
init_non_empty_directory
identifier_name
init.rs
use std::fs::{canonicalize, create_dir}; use std::path::Path; use std::path::PathBuf; use errors::{bail, Result}; use utils::fs::create_file; use crate::console; use crate::prompt::{ask_bool, ask_url}; const CONFIG: &str = r#" # The URL the site will be built for base_url = "%BASE_URL%" # Whether to automatically c...
); } }; // If any entry raises an error or isn't hidden (i.e. starts with `.`), we raise an error if entries.any(|x| match x { Ok(file) =>!file .file_name() .to_str() .expect("Could not convert filename to &str"...
Err(e) => { bail!( "Could not read `{}` because of error: {}", path.to_string_lossy().to_string(), e
random_line_split
assignment_tracker.rs
use common::*; use disassembler::*; use instruction_graph::*; pub struct AssignmentTracker; impl AssignmentTracker { // NOTE: expects reversed graph pub fn find( graph: &InstructionGraph, address: u64, register: Reg, try_match: &mut FnMut(&Insn, Reg) -> bool, ) -> Option<u64...
} None } }
} }
random_line_split
assignment_tracker.rs
use common::*; use disassembler::*; use instruction_graph::*; pub struct
; impl AssignmentTracker { // NOTE: expects reversed graph pub fn find( graph: &InstructionGraph, address: u64, register: Reg, try_match: &mut FnMut(&Insn, Reg) -> bool, ) -> Option<u64> { let mut skipped_initial_instruction = false; let mut stack = vec![addre...
AssignmentTracker
identifier_name
assignment_tracker.rs
use common::*; use disassembler::*; use instruction_graph::*; pub struct AssignmentTracker; impl AssignmentTracker { // NOTE: expects reversed graph pub fn find( graph: &InstructionGraph, address: u64, register: Reg, try_match: &mut FnMut(&Insn, Reg) -> bool, ) -> Option<u64...
let insn = graph.get_vertex(&address); if try_match(insn, register) { match insn.operands[1] { Operand::Register(_, r) => { return AssignmentTracker::find(graph, insn.address, r, &mut |i, reg| { if let Opera...
{ let mut skipped_initial_instruction = false; let mut stack = vec![address]; while !stack.is_empty() { let address = stack.pop().unwrap(); for pair in graph.get_adjacent(&address).into_iter().rev() { if let Ok((addr, link)) = pair { m...
identifier_body
unwind.rs
// taken from https://github.com/thepowersgang/rust-barebones-kernel #[lang="panic_fmt"] #[no_mangle] pub extern "C" fn rust_begin_unwind(args: ::core::fmt::Arguments, file: &str, line: usize) ->! { // 'args' will print to the formatted string passed to panic! log!("file='{}', line={} :: {}", file, line, args)...
() ->! { loop {} } #[allow(non_camel_case_types)] #[repr(C)] #[derive(Clone,Copy)] pub enum _Unwind_Reason_Code { _URC_NO_REASON = 0, _URC_FOREIGN_EXCEPTION_CAUGHT = 1, _URC_FATAL_PHASE2_ERROR = 2, _URC_FATAL_PHASE1_ERROR = 3, _URC_NORMAL_STOP = 4, _URC_END_OF_STACK = 5, _URC_HANDLER_F...
__morestack
identifier_name
unwind.rs
// taken from https://github.com/thepowersgang/rust-barebones-kernel #[lang="panic_fmt"] #[no_mangle] pub extern "C" fn rust_begin_unwind(args: ::core::fmt::Arguments, file: &str, line: usize) ->! { // 'args' will print to the formatted string passed to panic! log!("file='{}', line={} :: {}", file, line, args)...
loop {} } #[allow(non_camel_case_types)] #[repr(C)] #[derive(Clone,Copy)] pub enum _Unwind_Reason_Code { _URC_NO_REASON = 0, _URC_FOREIGN_EXCEPTION_CAUGHT = 1, _URC_FATAL_PHASE2_ERROR = 2, _URC_FATAL_PHASE1_ERROR = 3, _URC_NORMAL_STOP = 4, _URC_END_OF_STACK = 5, _URC_HANDLER_FOUND = 6,...
#[lang="stack_exhausted"] #[no_mangle] pub extern "C" fn __morestack() -> ! {
random_line_split
unwind.rs
// taken from https://github.com/thepowersgang/rust-barebones-kernel #[lang="panic_fmt"] #[no_mangle] pub extern "C" fn rust_begin_unwind(args: ::core::fmt::Arguments, file: &str, line: usize) ->! { // 'args' will print to the formatted string passed to panic! log!("file='{}', line={} :: {}", file, line, args)...
#[no_mangle] #[allow(non_snake_case)] pub extern "C" fn _Unwind_Resume() { loop {} }
{ loop {} }
identifier_body
cond-macro.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { assert_eq!(clamp(1, 2, 4), 2); assert_eq!(clamp(8, 2, 4), 4); assert_eq!(clamp(3, 2, 4), 3); }
{ cond!( (x > mx) { mx } (x < mn) { mn } _ { x } ) }
identifier_body
cond-macro.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 ...
// except according to those terms. fn clamp<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T { cond!( (x > mx) { mx } (x < mn) { mn } _ { x } ) } fn main() { assert_eq!(clamp(1, 2, 4), 2); assert_eq!(clamp(8, 2, 4), 4); assert_eq!(clamp(3, 2, 4), 3); }
random_line_split
cond-macro.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 ...
<T:Copy + Ord + Signed>(x: T, mn: T, mx: T) -> T { cond!( (x > mx) { mx } (x < mn) { mn } _ { x } ) } fn main() { assert_eq!(clamp(1, 2, 4), 2); assert_eq!(clamp(8, 2, 4), 4); assert_eq!(clamp(3, 2, 4), 3); }
clamp
identifier_name
result.rs
//! A module describing Lox-specific Result and Error types use object::Object; use std::result; use std::error; use std::fmt; use std::io; /// A Lox-Specific Result Type pub type Result<T> = result::Result<T, Error>; /// A Lox-Specific Error #[derive(Debug)] pub enum
{ /// Returned if the CLI command is used incorrectly Usage, /// Returned if there is an error reading from a file or stdin IO(io::Error), /// Returned if the scanner encounters an error Lexical(u64, String, String), /// Returned if the parser encounters an error Parse(u64, String, Stri...
Error
identifier_name
result.rs
//! A module describing Lox-specific Result and Error types
use std::fmt; use std::io; /// A Lox-Specific Result Type pub type Result<T> = result::Result<T, Error>; /// A Lox-Specific Error #[derive(Debug)] pub enum Error { /// Returned if the CLI command is used incorrectly Usage, /// Returned if there is an error reading from a file or stdin IO(io::Error), ...
use object::Object; use std::result; use std::error;
random_line_split
input.rs
//! Provides utilities for tracking the state of various input devices use cable_math::Vec2; const MOUSE_KEYS: usize = 5; const KEYBOARD_KEYS: usize = 256; // This MUST be `u8::max_value() + 1` /// Passed to `Window::poll_events` each frame to get updated. #[derive(Clone)] pub struct Input { /// The position of ...
Tab = 0xf, // CapsLock = 0x42, LShift = 0x2a, LCtrl = 0x1d, // LAlt = 0x40, // RAlt = 0x6c, // RMeta = 0x86, // RCtrl = 0x1d, // Same scancode as LCtrl :/ RShift = 0x36, Return = 0x1c, Back = 0xe, Right = 0x4d, Left = 0x4b, Down = 0x50, Up = 0x48, ...
Escape = 0x1, // Grave = 0x31,
random_line_split
input.rs
//! Provides utilities for tracking the state of various input devices use cable_math::Vec2; const MOUSE_KEYS: usize = 5; const KEYBOARD_KEYS: usize = 256; // This MUST be `u8::max_value() + 1` /// Passed to `Window::poll_events` each frame to get updated. #[derive(Clone)] pub struct Input { /// The position of...
else { gamepad.buttons = [KeyState::Up; GAMEPAD_BUTTON_COUNT]; gamepad.left = Vec2::ZERO; gamepad.right = Vec2::ZERO; gamepad.left_trigger = 0.0; gamepad.right_trigger = 0.0; } } self.received_events_this_...
{ for state in gamepad.buttons.iter_mut() { if *state == KeyState::Released { *state = KeyState::Up; } if *state == KeyState::Pressed { *state = KeyState::Down; } assert!(*state != KeyState::PressedRepeat); } }
conditional_block
input.rs
//! Provides utilities for tracking the state of various input devices use cable_math::Vec2; const MOUSE_KEYS: usize = 5; const KEYBOARD_KEYS: usize = 256; // This MUST be `u8::max_value() + 1` /// Passed to `Window::poll_events` each frame to get updated. #[derive(Clone)] pub struct Input { /// The position of...
(self) -> bool { !self.down() } /// Returns true if the button is being held down, but was not held down in the last /// frame (`Pressed`) pub fn pressed(self) -> bool { self == KeyState::Pressed } /// Returns true either if this button is being held down and was not held down in the /// ...
up
identifier_name
insert.rs
use redox::*; use super::*;
pub enum InsertMode { Append, Insert, Replace, } #[derive(Clone, PartialEq, Copy)] /// The insert options pub struct InsertOptions { /// The mode type pub mode: InsertMode, } impl Editor { /// Insert text pub fn insert(&mut self, c: Key) { let x = self.x(); let y = self.y()...
use core::iter::FromIterator; #[derive(Clone, PartialEq, Copy)] /// The type of the insert mode
random_line_split
insert.rs
use redox::*; use super::*; use core::iter::FromIterator; #[derive(Clone, PartialEq, Copy)] /// The type of the insert mode pub enum InsertMode { Append, Insert, Replace, } #[derive(Clone, PartialEq, Copy)] /// The insert options pub struct
{ /// The mode type pub mode: InsertMode, } impl Editor { /// Insert text pub fn insert(&mut self, c: Key) { let x = self.x(); let y = self.y(); match c { Key::Char('\n') => { let ln = self.text[y].clone(); let (slice, _) = ln.as_slic...
InsertOptions
identifier_name
insert.rs
use redox::*; use super::*; use core::iter::FromIterator; #[derive(Clone, PartialEq, Copy)] /// The type of the insert mode pub enum InsertMode { Append, Insert, Replace, } #[derive(Clone, PartialEq, Copy)] /// The insert options pub struct InsertOptions { /// The mode type pub mode: InsertMode, }...
_ => {}, } } }
{ self.text[y].insert(x, ch); self.next(); }
conditional_block
gen_lines.rs
// Copyright (c) Carl-Erwin Griffith // // 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, // p...
let mut string = String::new(); let table = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r','s', 't', 'u', 'v', 'w', 'x', 'y', 'z']; for x in 0..linewidth { string.push(tabl...
buff.write_fmt(format_args!("{:012} {}", x, string)).unwrap(); } } fn gen_line(linewidth: u64) -> String {
random_line_split
gen_lines.rs
// Copyright (c) Carl-Erwin Griffith // // 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, // p...
let start_num = args[1].trim_end().parse::<u64>().unwrap_or(0); let stop_num = args[2].trim_end().parse::<u64>().unwrap_or(0); let width_num = args[3].trim_end().parse::<u64>().unwrap_or(0); gen_lines(start_num, stop_num, width_num); } fn gen_lines(start: u64, stop: u64, linewidth: u64) -> () { ...
{ println!("usage : {} start numline width", args[0]); return; }
conditional_block
gen_lines.rs
// Copyright (c) Carl-Erwin Griffith // // 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, // p...
fn gen_line(linewidth: u64) -> String { let mut string = String::new(); let table = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r','s', 't', 'u', 'v', 'w', 'x', 'y', 'z']; for x ...
{ let string = gen_line(linewidth); let stdout = io::stdout(); let mut buff = BufWriter::new(stdout); for x in start..start + stop + 1 { buff.write_fmt(format_args!("{:012} {}", x, string)).unwrap(); } }
identifier_body
gen_lines.rs
// Copyright (c) Carl-Erwin Griffith // // 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, // p...
(linewidth: u64) -> String { let mut string = String::new(); let table = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r','s', 't', 'u', 'v', 'w', 'x', 'y', 'z']; for x in 0..linewid...
gen_line
identifier_name
message.rs
use std::net::SocketAddr; use std::sync::mpsc::Sender; #[derive(Debug, Clone)] pub struct Member { pub name: String, pub addr: SocketAddr } pub struct Request { pub addr: SocketAddr, pub body: RequestBody } pub enum RequestBody { Join { tx: Sender<Notify> }, Leave, List, Rename { name...
{ Join { name: String }, Leave, List(Vec<(Member)>), Rename(bool), Submit(bool), Message(String) } #[derive(Debug, Clone)] pub enum BroadcastNotify { Join { name: String, addr: SocketAddr }, Leave { name: String, addr: SocketAddr }, Rename { old_name: String, new_name: String, addr...
UnicastNotify
identifier_name
message.rs
use std::net::SocketAddr; use std::sync::mpsc::Sender; #[derive(Debug, Clone)] pub struct Member { pub name: String, pub addr: SocketAddr } pub struct Request { pub addr: SocketAddr, pub body: RequestBody } pub enum RequestBody { Join { tx: Sender<Notify> }, Leave, List, Rename { name...
pub enum BroadcastNotify { Join { name: String, addr: SocketAddr }, Leave { name: String, addr: SocketAddr }, Rename { old_name: String, new_name: String, addr: SocketAddr }, Submit { name: String, addr: SocketAddr, message: String }, }
#[derive(Debug, Clone)]
random_line_split
rcvr-borrowed-to-region.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let x = box(GC) 6; let y = x.get(); assert_eq!(y, 6); let x = box(GC) 6; let y = x.get(); println!("y={}", y); assert_eq!(y, 6); let x = box 6; let y = x.get(); println!("y={}", y); assert_eq!(y, 6); let x = &6; let y = x.get(); println!("y={}", y); asser...
identifier_body
rcvr-borrowed-to-region.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x = box(GC) 6; let y = x.get(); assert_eq!(y, 6); let x = box(GC) 6; let y = x.get(); println!("y={}", y); assert_eq!(y, 6); let x = box 6; let y = x.get(); println!("y={}", y); assert_eq!(y, 6); let x = &6; let y = x.get(); println!("y={}", y); as...
main
identifier_name
rcvr-borrowed-to-region.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(managed_...
random_line_split
diepempmsk.rs
#[doc = "Register `DIEPEMPMSK` reader"] pub struct R(crate::R<DIEPEMPMSK_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DIEPEMPMSK_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<DIEPEMPMSK_SPEC>> for R { #[inline(always)] fn from(...
pub struct INEPTXFEMPMSK_R(crate::FieldReader<u16, u16>); impl INEPTXFEMPMSK_R { pub(crate) fn new(bits: u16) -> Self { INEPTXFEMPMSK_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for INEPTXFEMPMSK_R { type Target = crate::FieldReader<u16, u16>; #[inline(always)] fn deref(&self)...
} } #[doc = "Field `InEpTxfEmpMsk` reader - IN EP Tx FIFO Empty Interrupt Mask Bits"]
random_line_split
diepempmsk.rs
#[doc = "Register `DIEPEMPMSK` reader"] pub struct R(crate::R<DIEPEMPMSK_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DIEPEMPMSK_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<DIEPEMPMSK_SPEC>> for R { #[inline(always)] fn from(...
(&mut self) -> &mut Self::Target { &mut self.0 } } impl From<crate::W<DIEPEMPMSK_SPEC>> for W { #[inline(always)] fn from(writer: crate::W<DIEPEMPMSK_SPEC>) -> Self { W(writer) } } #[doc = "Field `InEpTxfEmpMsk` reader - IN EP Tx FIFO Empty Interrupt Mask Bits"] pub struct INEPTXFEMPMSK_...
deref_mut
identifier_name
diepempmsk.rs
#[doc = "Register `DIEPEMPMSK` reader"] pub struct R(crate::R<DIEPEMPMSK_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DIEPEMPMSK_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<DIEPEMPMSK_SPEC>> for R { #[inline(always)] fn from(...
} #[doc = "Field `InEpTxfEmpMsk` writer - IN EP Tx FIFO Empty Interrupt Mask Bits"] pub struct INEPTXFEMPMSK_W<'a> { w: &'a mut W, } impl<'a> INEPTXFEMPMSK_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u16) -> &'a mut W { self.w.bits = (self....
{ &self.0 }
identifier_body
path.rs
recursive: true, .. PathSource::new(root, id, config) } } pub fn root_package(&mut self) -> CargoResult<Package> { trace!("root_package; source={:?}", self); self.update()?; match self.packages.iter().find(|p| p.root() == &*self.path) { Some(pkg) => Ok(...
else { self.config .shell() .warn(format!( "Pattern matching for Cargo's include/exclude fields is changing and \ file `{}` WILL NOT be included in a future Cargo version.\n\ ...
{ self.config .shell() .warn(format!( "Pattern matching for Cargo's include/exclude fields is changing and \ file `{}` WILL be excluded in a future Cargo version.\n\ ...
conditional_block
path.rs
/// /// 2) Switch to the new strategy and upate documents. Still keep warning /// affected users. /// /// 3) Drop the old strategy and no mor warnings. /// /// See <https://github.com/rust-lang/cargo/issues/4268> for more info. pub fn list_files(&self, pkg: &Package) -> CargoResult<V...
supports_checksums
identifier_name
path.rs
}) }; let glob_exclude = pkg.manifest() .exclude() .iter() .map(|p| glob_parse(p)) .collect::<Result<Vec<_>, _>>()?; let glob_include = pkg.manifest() .include() .iter() .map(|p| glob_parse(p)) ...
{ trace!("getting packages; id={}", id); let pkg = self.packages.iter().find(|pkg| pkg.package_id() == id); pkg.cloned().ok_or_else(|| { internal(format!("failed to find {} in path source", id)) }) }
identifier_body
path.rs
glob_match(&glob_include, relative_path) } }; // ignore-like matching rules let mut exclude_builder = GitignoreBuilder::new(root); for rule in pkg.manifest().exclude() { exclude_builder.add_line(None, rule)?; } let ignore_exclude = exclude_build...
random_line_split
typeid-intrinsic2.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 ...
() -> TypeId { TypeId::of::<B>() } pub unsafe fn id_C() -> TypeId { TypeId::of::<C>() } pub unsafe fn id_D() -> TypeId { TypeId::of::<D>() } pub unsafe fn id_E() -> TypeId { TypeId::of::<E>() } pub unsafe fn id_F() -> TypeId { TypeId::of::<F>() } pub unsafe fn id_G() -> TypeId { TypeId::of::<G>() } pub unsafe fn id_H()...
id_B
identifier_name
typeid-intrinsic2.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 ...
use std::any::TypeId; pub struct A; pub struct B(Option<A>); pub struct C(Option<int>); pub struct D(Option<&'static str>); pub struct E(Result<&'static str, int>); pub type F = Option<int>; pub type G = uint; pub type H = &'static str; pub unsafe fn id_A() -> TypeId { TypeId::of::<A>() } pub unsafe fn id_B() -> Ty...
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
typeid-intrinsic2.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 ...
pub unsafe fn id_D() -> TypeId { TypeId::of::<D>() } pub unsafe fn id_E() -> TypeId { TypeId::of::<E>() } pub unsafe fn id_F() -> TypeId { TypeId::of::<F>() } pub unsafe fn id_G() -> TypeId { TypeId::of::<G>() } pub unsafe fn id_H() -> TypeId { TypeId::of::<H>() } pub unsafe fn foo<T:'static>() -> TypeId { TypeId::of...
{ TypeId::of::<C>() }
identifier_body