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
physics.rs
use super::{Unit, ToUnit}; #[deriving(Eq, Ord)] pub struct Vec2 { pub x: Unit, pub y: Unit, } impl Vec2 { pub fn new<A: ToUnit, B: ToUnit>(x: A, y: B) -> Vec2 { Vec2 { x: x.to_unit(), y: y.to_unit(), } } pub fn norm(&self) -> Vec2 { let len = self.l...
pub fn transform(&self, offset: Vec2) -> AABB { AABB { center: self.center + offset, size: self.size, } } pub fn is_collided_with(&self, other: &AABB) -> bool { self.right() >= other.left() && self.left() <= other.right() && self.top() <= ot...
{ AABB { center: Vec2::new(x, y), size: Vec2::new(w, h), } }
identifier_body
physics.rs
use super::{Unit, ToUnit}; #[deriving(Eq, Ord)] pub struct Vec2 { pub x: Unit, pub y: Unit, } impl Vec2 { pub fn new<A: ToUnit, B: ToUnit>(x: A, y: B) -> Vec2 { Vec2 { x: x.to_unit(), y: y.to_unit(), } } pub fn norm(&self) -> Vec2 { let len = self.l...
} } } /// x axis from left to right and y asix from top to bottom pub struct AABB { pub center: Vec2, pub size: Vec2, } impl AABB { pub fn new<A: ToUnit, B: ToUnit, C: ToUnit, D: ToUnit>(x: A, y: B, w: C, h: D) -> AABB { AABB { center: Vec2::new(x, y), size: Ve...
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/. */ #![deny(unsafe_code)] extern crate app_units; extern crate atomic_refcell; #[macro_use] extern crate bitflags; ex...
mod generated_content; pub mod incremental; mod inline; mod linked_list; mod list_item; mod model; mod multicol; pub mod opaque_node; pub mod parallel; mod persistent_list; pub mod query; pub mod sequential; mod table; mod table_caption; mod table_cell; mod table_colgroup; mod table_row; mod table_rowgroup; mod table_w...
pub mod flow_ref; mod fragment;
random_line_split
query.rs
//! Values computed by queries that use MIR. use crate::mir::{abstract_const, Body, Promoted}; use crate::ty::{self, Ty, TyCtxt}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::vec_map::VecMap; use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rust...
} impl<'a, K: Debug, V: Debug> Debug for MapPrinter<'a, K, V> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_map().entries(self.0.take().unwrap()).finish() } } /// Prints the generator variant name. struct GenVar...
{ Self(Cell::new(Some(Box::new(iter)))) }
identifier_body
query.rs
//! Values computed by queries that use MIR. use crate::mir::{abstract_const, Body, Promoted}; use crate::ty::{self, Ty, TyCtxt}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::vec_map::VecMap; use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rust...
(self, def: ty::WithOptConstParam<DefId>) -> &'tcx Body<'tcx> { if let Some((did, param_did)) = def.as_const_arg() { self.mir_for_ctfe_of_const_arg((did, param_did)) } else { self.mir_for_ctfe(def.did) } } #[inline] pub fn mir_abstract_const_opt_const_arg( ...
mir_for_ctfe_opt_const_arg
identifier_name
query.rs
//! Values computed by queries that use MIR. use crate::mir::{abstract_const, Body, Promoted}; use crate::ty::{self, Ty, TyCtxt}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::vec_map::VecMap; use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rust...
impl UnsafetyViolationDetails { pub fn description_and_note(&self) -> (&'static str, &'static str) { use UnsafetyViolationDetails::*; match self { CallToUnsafeFunction => ( "call to unsafe function", "consult the function's documentation for information o...
AccessToUnionField, MutationOfLayoutConstrainedField, BorrowOfLayoutConstrainedField, CallToFunctionWith, }
random_line_split
add_enchantment.rs
use rune_vm::Rune; use rustc_serialize::json; use game_state::GameState; use minion_card::UID; use hlua; #[derive(RustcDecodable, RustcEncodable, Clone)] pub struct AddEnchantment { target_uid: UID, source_uid: UID, } impl AddEnchantment { pub fn new(source_uid: UID, target_uid: UID) -> AddEnchantment {...
fn execute_rune(&self, mut game_state: &mut GameState) { game_state.get_mut_minion(self.target_uid).unwrap().add_enchantment(self.source_uid); } fn can_see(&self, _controller: UID, _game_state: &GameState) -> bool { return true; } fn to_json(&self) -> String { json::encode(...
impl Rune for AddEnchantment {
random_line_split
add_enchantment.rs
use rune_vm::Rune; use rustc_serialize::json; use game_state::GameState; use minion_card::UID; use hlua; #[derive(RustcDecodable, RustcEncodable, Clone)] pub struct AddEnchantment { target_uid: UID, source_uid: UID, } impl AddEnchantment { pub fn
(source_uid: UID, target_uid: UID) -> AddEnchantment { AddEnchantment { source_uid: source_uid, target_uid: target_uid, } } } implement_for_lua!(AddEnchantment, |mut _metatable| {}); impl Rune for AddEnchantment { fn execute_rune(&self, mut game_state: &mut GameState) {...
new
identifier_name
texture_swap.rs
extern crate rand; extern crate piston_window; extern crate image as im; use piston_window::*; fn main() { let texture_count = 1024; let frames = 200; let size = 32.0; let mut window: PistonWindow = WindowSettings::new("piston", [1024; 2]).build().unwrap(); let mut texture_context = TextureConte...
if counter > frames { break; } } window.draw_2d(&e, |c, g, _| { clear([0.0, 0.0, 0.0, 1.0], g); for p in &mut positions { let (x, y) = *p; *p = (x + (rand::random::<f64>() - 0.5) * 0.01, y + (rand::random::<f64>() ...
let mut counter = 0; window.set_bench_mode(true); while let Some(e) = window.next() { if e.render_args().is_some() { counter += 1;
random_line_split
texture_swap.rs
extern crate rand; extern crate piston_window; extern crate image as im; use piston_window::*; fn main() { let texture_count = 1024; let frames = 200; let size = 32.0; let mut window: PistonWindow = WindowSettings::new("piston", [1024; 2]).build().unwrap(); let mut texture_context = TextureConte...
window.draw_2d(&e, |c, g, _| { clear([0.0, 0.0, 0.0, 1.0], g); for p in &mut positions { let (x, y) = *p; *p = (x + (rand::random::<f64>() - 0.5) * 0.01, y + (rand::random::<f64>() - 0.5) * 0.01); } for i in 0...
{ counter += 1; if counter > frames { break; } }
conditional_block
texture_swap.rs
extern crate rand; extern crate piston_window; extern crate image as im; use piston_window::*; fn
() { let texture_count = 1024; let frames = 200; let size = 32.0; let mut window: PistonWindow = WindowSettings::new("piston", [1024; 2]).build().unwrap(); let mut texture_context = TextureContext { factory: window.factory.clone(), encoder: window.factory.create_command_buffer().in...
main
identifier_name
texture_swap.rs
extern crate rand; extern crate piston_window; extern crate image as im; use piston_window::*; fn main()
Texture::from_image( &mut texture_context, &img, &TextureSettings::new() ).unwrap() }).collect::<Vec<Texture<_>>>() }; let mut positions = (0..texture_count) .map(|_| (rand::random(), rand::random())) .collect::<Vec<(...
{ let texture_count = 1024; let frames = 200; let size = 32.0; let mut window: PistonWindow = WindowSettings::new("piston", [1024; 2]).build().unwrap(); let mut texture_context = TextureContext { factory: window.factory.clone(), encoder: window.factory.create_command_buffer().into(...
identifier_body
mutex.rs
use alloc::boxed::Box; use core::borrow::{Borrow, BorrowMut}; use core::ops::{Deref, DerefMut}; use core::cell::{Cell, RefCell, RefMut}; use crate::syscall; use core::marker::Sync; #[link(name="os_init", kind="static")] extern "C" { fn mutex_lock(lock: *mut i32) -> i32; } pub enum TryLockResult { ...
pub struct LockedResource<'a, T: 'a +?Sized> { mutex: &'a Mutex<T>, data_ref: RefMut<'a, T> } impl<T> Mutex<T> { pub fn new(t: T) -> Mutex<T> { Self { data: Box::new(RefCell::new(t)), lock: Cell::new(0), } } } impl<T:?Sized> Mutex<T> { pub fn ...
random_line_split
mutex.rs
use alloc::boxed::Box; use core::borrow::{Borrow, BorrowMut}; use core::ops::{Deref, DerefMut}; use core::cell::{Cell, RefCell, RefMut}; use crate::syscall; use core::marker::Sync; #[link(name="os_init", kind="static")] extern "C" { fn mutex_lock(lock: *mut i32) -> i32; } pub enum TryLockResult { ...
(&mut self) { self.mutex.lock.set(0); } }
drop
identifier_name
mutex.rs
use alloc::boxed::Box; use core::borrow::{Borrow, BorrowMut}; use core::ops::{Deref, DerefMut}; use core::cell::{Cell, RefCell, RefMut}; use crate::syscall; use core::marker::Sync; #[link(name="os_init", kind="static")] extern "C" { fn mutex_lock(lock: *mut i32) -> i32; } pub enum TryLockResult { ...
} Ok(LockedResource { mutex: &self, data_ref: (*self.data).borrow_mut(), }) } } impl<'a, T:?Sized> Deref for LockedResource<'a, T> { type Target = T; fn deref(&self) -> &Self::Target { self.data_ref.borrow() } } i...
{ return Err(TryLockResult::AlreadyLocked) }
conditional_block
trait-pointers.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 ...
trait Trait { fn method(&self) -> int { 0 } } struct Struct { a: int, b: f64 } impl Trait for Struct {} // There is no real test here yet. Just make sure that it compiles without crashing. fn main() { let stack_struct = Struct { a:0, b: 1.0 }; let reference: &Trait = &stack_struct as &Trait; ...
// debugger:run #[allow(unused_variable)];
random_line_split
trait-pointers.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 ...
{ a: int, b: f64 } impl Trait for Struct {} // There is no real test here yet. Just make sure that it compiles without crashing. fn main() { let stack_struct = Struct { a:0, b: 1.0 }; let reference: &Trait = &stack_struct as &Trait; let managed: @Trait = @Struct { a:2, b: 3.0 } as @Trait; let...
Struct
identifier_name
recursive.rs
fn comb<T>(slice: &[T], k: usize) -> Vec<Vec<T>> where T: Copy, { // If k == 1, return a vector containing a vector for each element of the slice. if k == 1 { return slice.iter().map(|x| vec![*x]).collect::<Vec<Vec<T>>>(); } // If k is exactly the slice length, return the slice inside a vect...
() { let computed = comb(&["h", "e", "l", "l", "o"], 2); let expected = vec![ vec!["h", "e"], vec!["h", "l"], vec!["h", "l"], vec!["h", "o"], vec!["e", "l"], vec!["e", "l"], vec!["e", "o"], vec!["l", "l"], ...
four_letters_choose_two
identifier_name
recursive.rs
fn comb<T>(slice: &[T], k: usize) -> Vec<Vec<T>> where T: Copy,
fn main() { let vec1 = vec![1, 2, 3, 4, 5]; println!("{:?}", comb(&vec1, 3)); let vec2 = vec!["A", "B", "C", "D", "E"]; println!("{:?}", comb(&vec2, 3)); } #[cfg(test)] mod tests { use super::*; #[test] fn five_numbers_choose_three() { let computed = comb(&[1, 2, 3, 4, 5], 3); ...
{ // If k == 1, return a vector containing a vector for each element of the slice. if k == 1 { return slice.iter().map(|x| vec![*x]).collect::<Vec<Vec<T>>>(); } // If k is exactly the slice length, return the slice inside a vector. if k == slice.len() { return vec![slice.to_vec()]; ...
identifier_body
recursive.rs
fn comb<T>(slice: &[T], k: usize) -> Vec<Vec<T>> where T: Copy, { // If k == 1, return a vector containing a vector for each element of the slice. if k == 1 { return slice.iter().map(|x| vec![*x]).collect::<Vec<Vec<T>>>(); } // If k is exactly the slice length, return the slice inside a vect...
vec!["e", "o"], vec!["l", "l"], vec!["l", "o"], vec!["l", "o"], ]; assert_eq!(computed, expected); } }
vec!["e", "l"], vec!["e", "l"],
random_line_split
recursive.rs
fn comb<T>(slice: &[T], k: usize) -> Vec<Vec<T>> where T: Copy, { // If k == 1, return a vector containing a vector for each element of the slice. if k == 1
// If k is exactly the slice length, return the slice inside a vector. if k == slice.len() { return vec![slice.to_vec()]; } // Make a vector from the first element + all combinations of k - 1 elements of the rest of the slice. let mut result = comb(&slice[1..], k - 1) .into_iter() ...
{ return slice.iter().map(|x| vec![*x]).collect::<Vec<Vec<T>>>(); }
conditional_block
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.as_slice().fmt(formatter) } } impl Buf { pub fn from_string(s: String) -> Buf { Buf { inner: s.into_bytes() } } pub fn from_str(s: &str) -> Buf { Buf { inner: s.as_bytes().to_vec() } } pub fn as_s...
fmt
identifier_name
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
{ Buf { inner: self.inner.to_vec() } }
identifier_body
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
String::from_utf8_lossy(&self.inner) } pub fn to_owned(&self) -> Buf { Buf { inner: self.inner.to_vec() } } }
str::from_utf8(&self.inner).ok() } pub fn to_string_lossy(&self) -> CowString {
random_line_split
nbody.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi const PI: f64 = 3.141592653589793; const SOLAR_MASS: f64 = 4.0 * PI * PI; const YEAR: f64 = 365.24; const N_BODIES: usize = 5; static BODIES: [Planet;N_BODIES...
{ x: f64, y: f64, z: f64, vx: f64, vy: f64, vz: f64, mass: f64, } fn advance(bodies: &mut [Planet;N_BODIES], dt: f64, steps: i32) { for _ in (0..steps) { let mut b_slice: &mut [_] = bodies; loop { let bi = match shift_mut_ref(&mut b_slice) { Some(bi) => bi, ...
Planet
identifier_name
nbody.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi const PI: f64 = 3.141592653589793; const SOLAR_MASS: f64 = 4.0 * PI * PI; const YEAR: f64 = 365.24; const N_BODIES: usize = 5; static BODIES: [Planet;N_BODIES...
for _ in (0..steps) { let mut b_slice: &mut [_] = bodies; loop { let bi = match shift_mut_ref(&mut b_slice) { Some(bi) => bi, None => break }; for bj in b_slice.iter_mut() { let dx = bi.x - bj.x; let ...
random_line_split
nbody.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi const PI: f64 = 3.141592653589793; const SOLAR_MASS: f64 = 4.0 * PI * PI; const YEAR: f64 = 365.24; const N_BODIES: usize = 5; static BODIES: [Planet;N_BODIES...
fn offset_momentum(bodies: &mut [Planet;N_BODIES]) { let mut px = 0.0; let mut py = 0.0; let mut pz = 0.0; for bi in bodies.iter() { px += bi.vx * bi.mass; py += bi.vy * bi.mass; pz += bi.vz * bi.mass; } let sun = &mut bodies[0]; sun.vx = - px / SOLAR_MASS; sun....
{ let mut e = 0.0; let mut bodies = bodies.iter(); loop { let bi = match bodies.next() { Some(bi) => bi, None => break }; e += (bi.vx * bi.vx + bi.vy * bi.vy + bi.vz * bi.vz) * bi.mass / 2.0; for bj in bodies.clone() { let dx = bi.x - bj.x;...
identifier_body
managed.rs
use gfx::{Encoder, Resources, CommandBuffer, Slice, IndexBuffer}; use gfx::memory::{Usage, TRANSFER_DST}; use gfx::handle::Buffer; use gfx::traits::{Factory, FactoryExt}; use gfx::buffer::Role; use ui::render::Vertex; // step: 128 vertices (4096 bytes, 42 triangles + 2 extra vertices) const ALLOC_STEP: usize = 128; #...
pub fn slice(&self) -> Slice<R> { Slice { start: 0, end: self.tail as u32, base_vertex: 0, instances: None, buffer: IndexBuffer::Auto } } } impl<R> Extend<Vertex> for ManagedBuffer<R> where R: Resources { fn extend<I>(&mut self, iter: I) where I: IntoIterator<Item=Vertex> { if let Some(zone)...
{ &self.remote }
identifier_body
managed.rs
use gfx::{Encoder, Resources, CommandBuffer, Slice, IndexBuffer}; use gfx::memory::{Usage, TRANSFER_DST}; use gfx::handle::Buffer; use gfx::traits::{Factory, FactoryExt}; use gfx::buffer::Role; use ui::render::Vertex; // step: 128 vertices (4096 bytes, 42 triangles + 2 extra vertices) const ALLOC_STEP: usize = 128; #...
{ start: usize, size: usize } pub struct ManagedBuffer<R> where R: Resources { local: Vec<Vertex>, remote: Buffer<R, Vertex>, zones: Vec<(Zone, bool)>, tail: usize } impl<R> ManagedBuffer<R> where R: Resources { pub fn new<F>(factory: &mut F) -> Self where F: Factory<R> { ManagedBuffer { local: Vec::new(...
Zone
identifier_name
managed.rs
use gfx::{Encoder, Resources, CommandBuffer, Slice, IndexBuffer}; use gfx::memory::{Usage, TRANSFER_DST}; use gfx::handle::Buffer; use gfx::traits::{Factory, FactoryExt}; use gfx::buffer::Role; use ui::render::Vertex; // step: 128 vertices (4096 bytes, 42 triangles + 2 extra vertices) const ALLOC_STEP: usize = 128; #...
} }
{ panic!("Tried to extend to a previously created zone, but there are no zones."); }
conditional_block
managed.rs
use gfx::{Encoder, Resources, CommandBuffer, Slice, IndexBuffer}; use gfx::memory::{Usage, TRANSFER_DST}; use gfx::handle::Buffer; use gfx::traits::{Factory, FactoryExt}; use gfx::buffer::Role; use ui::render::Vertex; // step: 128 vertices (4096 bytes, 42 triangles + 2 extra vertices) const ALLOC_STEP: usize = 128; #...
*dirty = true; if zone.size == buffer.len() { let slice = &mut self.local[zone.start..zone.start + zone.size]; slice.copy_from_slice(buffer); } else { // TODO: Shift later elements forward or backwards. unimplemented!() } } fn get_zone(&self, index: usize) -> &[Vertex] { let zone = &self.zo...
let (ref mut zone, ref mut dirty) = self.zones[zone];
random_line_split
typeck_type_placeholder_mismatch.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test1() { let x: Foo<_> = Bar::<uint>; //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Bar<uint>` let y: Foo<uint> = x; } fn test2() { let x: Foo<_> = Bar::<uint>; //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Bar<uint>` }
}
random_line_split
typeck_type_placeholder_mismatch.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test1() { let x: Foo<_> = Bar::<uint>; //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Bar<uint>` let y: Foo<uint> = x; } fn test2() { let x: Foo<_> = Bar::<uint>; //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Bar<uint>` }
{ }
identifier_body
typeck_type_placeholder_mismatch.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 ...
<T>; struct Bar<U>; pub fn main() { } fn test1() { let x: Foo<_> = Bar::<uint>; //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Bar<uint>` let y: Foo<uint> = x; } fn test2() { let x: Foo<_> = Bar::<uint>; //~^ ERROR mismatched types: expected `Foo<<generic #0>>` but found `Ba...
Foo
identifier_name
lzss2.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use huff::adaptive as nested; use error::Error; const WINDOW_BITS: usize = 12; cons...
/// Process a group of 8 literals or match/length pairs. The /// given token is contains the flag bits. fn process_group(&mut self, token: u8) -> io::Result<()> { for i in 0..8 { if token & 0x80 >> i == 0 { // Zero bit indicates a match/length pair. Decode the ...
{ while *written < output.len() && self.returned != self.position { output[*written] = self.window[self.returned]; *written += 1; self.returned = mod_window(self.returned + 1); } }
identifier_body
lzss2.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use huff::adaptive as nested; use error::Error; const WINDOW_BITS: usize = 12; cons...
fn flush(&mut self) -> io::Result<()> { while self.look_ahead_bytes > 0 { try!(self.process()); } try!(self.emit_flush()); self.inner.flush() } } /// Reader for LZSS compressed streams. pub struct Reader<R> { inner: Bytes<nested::Reader<R>>, window: [u8; WIND...
random_line_split
lzss2.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use huff::adaptive as nested; use error::Error; const WINDOW_BITS: usize = 12; cons...
(inner: R) -> Reader<R> { Reader { inner: nested::Reader::new(inner).bytes(), window: [0; WINDOW_SIZE], position: 0, returned: 0, eof: false, } } /// Copy all decompressed data from the window to the output /// buffer. fn copy_...
new
identifier_name
lzss2.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use huff::adaptive as nested; use error::Error; const WINDOW_BITS: usize = 12; cons...
self.out_count += 1; self.out_flags = (self.out_flags << 1) | 1; self.out_data[self.out_len] = lit; self.out_len += 1; Ok(()) } /// Emit a match/length pair, which is already encoded in `m1` and /// `m2`. pub fn emit_match(&mut self, m1: u8, m2: u8) -> io::Resul...
{ try!(self.emit_flush()); }
conditional_block
mouse.rs
use libc::{c_int, c_uint, c_void, uint8_t, uint32_t}; use surface::SDL_Surface; use video::SDL_Window; use sdl::SDL_bool; use event::SDL_State; pub type SDL_Cursor = c_void; pub type SDL_SystemCursor = c_uint; pub const SDL_SYSTEM_CURSOR_ARROW: SDL_SystemCursor = 0; pub const SDL_SYSTEM_CURSOR_IBEAM: SDL_SystemCursor...
pub const SDL_SYSTEM_CURSOR_SIZENESW: SDL_SystemCursor = 6; pub const SDL_SYSTEM_CURSOR_SIZEWE: SDL_SystemCursor = 7; pub const SDL_SYSTEM_CURSOR_SIZENS: SDL_SystemCursor = 8; pub const SDL_SYSTEM_CURSOR_SIZEALL: SDL_SystemCursor = 9; pub const SDL_SYSTEM_CURSOR_NO: SDL_SystemCursor = 10; pub const SDL_SYSTEM_CURSOR_HA...
random_line_split
must-use-ops.rs
// Issue #50124 - Test warning for unused operator expressions // check-pass #![warn(unused_must_use)] fn
() { let val = 1; let val_pointer = &val; // Comparison Operators val == 1; //~ WARNING unused comparison val < 1; //~ WARNING unused comparison val <= 1; //~ WARNING unused comparison val!= 1; //~ WARNING unused comparison val >= 1; //~ WARNING unused comparison val > 1; //~ WARNING un...
main
identifier_name
must-use-ops.rs
// Issue #50124 - Test warning for unused operator expressions // check-pass #![warn(unused_must_use)] fn main()
true && true; //~ WARNING unused logical operation false || true; //~ WARNING unused logical operation // Bitwise Operators 5 ^ val; //~ WARNING unused bitwise operation 5 & val; //~ WARNING unused bitwise operation 5 | val; //~ WARNING unused bitwise operation 5 << val; //~ WARNING unused bitw...
{ let val = 1; let val_pointer = &val; // Comparison Operators val == 1; //~ WARNING unused comparison val < 1; //~ WARNING unused comparison val <= 1; //~ WARNING unused comparison val != 1; //~ WARNING unused comparison val >= 1; //~ WARNING unused comparison val > 1; //~ WARNING unus...
identifier_body
must-use-ops.rs
// Issue #50124 - Test warning for unused operator expressions // check-pass #![warn(unused_must_use)] fn main() { let val = 1;
val == 1; //~ WARNING unused comparison val < 1; //~ WARNING unused comparison val <= 1; //~ WARNING unused comparison val!= 1; //~ WARNING unused comparison val >= 1; //~ WARNING unused comparison val > 1; //~ WARNING unused comparison // Arithmetic Operators val + 2; //~ WARNING unused ar...
let val_pointer = &val; // Comparison Operators
random_line_split
test.rs
extern crate mio; extern crate bytes; #[macro_use] extern crate log; extern crate env_logger; extern crate tempdir; pub use ports::localhost; mod test_battery; mod test_close_on_drop; mod test_echo_server; mod test_multicast; mod test_notify; mod test_register_deregister; mod test_timer; mod test_udp_socket; mod tes...
pub fn sleep_ms(ms: usize) { use std::thread; thread::sleep_ms(ms as u32); }
random_line_split
test.rs
extern crate mio; extern crate bytes; #[macro_use] extern crate log; extern crate env_logger; extern crate tempdir; pub use ports::localhost; mod test_battery; mod test_close_on_drop; mod test_echo_server; mod test_multicast; mod test_notify; mod test_register_deregister; mod test_timer; mod test_udp_socket; mod tes...
() -> SocketAddr { let s = format!("127.0.0.1:{}", next_port()); FromStr::from_str(&s).unwrap() } } pub fn sleep_ms(ms: usize) { use std::thread; thread::sleep_ms(ms as u32); }
localhost
identifier_name
test.rs
extern crate mio; extern crate bytes; #[macro_use] extern crate log; extern crate env_logger; extern crate tempdir; pub use ports::localhost; mod test_battery; mod test_close_on_drop; mod test_echo_server; mod test_multicast; mod test_notify; mod test_register_deregister; mod test_timer; mod test_udp_socket; mod tes...
{ use std::thread; thread::sleep_ms(ms as u32); }
identifier_body
htmlsourceelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLSourceElementBinding; use dom::bindings::codegen::InheritTypes::HTMLSour...
(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLSourceElement> { let element = HTMLSourceElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLSourceElementBinding::Wrap) } } impl Reflectable for HTMLSourceEl...
new
identifier_name
htmlsourceelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLSourceElementBinding; use dom::bindings::codegen::InheritTypes::HTMLSour...
} impl HTMLSourceElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLSourceElement { HTMLSourceElement { htmlelement: HTMLElement::new_inherited(HTMLSourceElementTypeId, localName, prefix, document) } } #[allow(unrooted_...
}
random_line_split
htmlsourceelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLSourceElementBinding; use dom::bindings::codegen::InheritTypes::HTMLSour...
}
{ self.htmlelement.reflector() }
identifier_body
mod.rs
// Copyright (c) 2017 Atsushi Miyake // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or http://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 th...
mod reflector; mod plugboard; mod alphabets; pub use self::enigma::Enigma; pub use self::router::Router; pub use self::router::RouterProtocol; pub use self::router::Digit; pub use self::router_manager::RouterManager; pub use self::reflector::Reflector; pub use self::substitution_table::SubstitutionTable; pub use self:...
random_line_split
unknown.rs
// Copyright (c) 2016 com-rs developers // // 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. All files in the project carrying such notice may not be copied, //...
{ query_interface: extern "stdcall" fn( *const IUnknown, &IID, *mut *mut c_void) -> HResult, add_ref: extern "stdcall" fn(*const IUnknown) -> u32, release: extern "stdcall" fn(*const IUnknown) -> u32 } extern { static IID_IUnknown: IID; } impl IUnknown { /// Retrieves pointers to the supp...
IUnknownVtbl
identifier_name
unknown.rs
// Copyright (c) 2016 com-rs developers // // 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. All files in the project carrying such notice may not be copied, //...
/// /// None of the methods on this struct should be called directly, /// use [`ComPtr`](struct.ComPtr.html) instead. #[derive(Debug)] #[repr(C)] pub struct IUnknown { vtable: *const IUnknownVtbl } #[allow(missing_debug_implementations)] #[repr(C)] #[doc(hidden)] pub struct IUnknownVtbl { query_interface: ext...
use super::{AsComPtr, HResult, IID}; /// Base interface for all COM types.
random_line_split
cross-crate-trait-method.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(_: isize, _: *const *const u8) -> isize { // The object code of these methods is contained in the external crate, so // calling them should *not* introduce codegen items in the current crate. let _: (u32, u32) = Trait::without_default_impl(0); let _: (char, u32) = Trait::without_default_impl(0); /...
start
identifier_name
cross-crate-trait-method.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
//~ MONO_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<char, i16> let _ = Trait::with_default_impl_generic('x', 1i16); //~ MONO_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<char, i32> let _ = Trait::with_default_impl_generic('y', 0i32); //~ MONO...
{ // The object code of these methods is contained in the external crate, so // calling them should *not* introduce codegen items in the current crate. let _: (u32, u32) = Trait::without_default_impl(0); let _: (char, u32) = Trait::without_default_impl(0); // Currently, no object code is generated ...
identifier_body
cross-crate-trait-method.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// except according to those terms. // ignore-tidy-linelength // compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] #![feature(start)] // aux-build:cgu_export_trait_method.rs extern crate cgu_export_trait_method; use cgu_export_trait_method::Trait; //~ MONO_ITEM fn cross_crate_trait_method::start[0] #[star...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed
random_line_split
tumor_mutational_burden.rs
use std::collections::BTreeMap; use std::str; use std::str::FromStr; use anyhow::Result; use bio::stats::{LogProb, PHREDProb}; use itertools::Itertools; use itertools_num::linspace; use rust_htslib::bcf::{self, Read}; use serde_json::{json, Value}; use crate::errors; use crate::variants::model::AlleleFreq; use crate:...
(rec: &mut bcf::Record) -> Result<bool> { for ann in rec .info(b"ANN") .string()? .expect("ANN field not found. Annotate VCF with e.g. snpEff.") .iter() { let mut coding = false; for (i, entry) in ann.split(|c| *c == b'|').enumerate() { if i == 7 { ...
is_valid_variant
identifier_name
tumor_mutational_burden.rs
use std::collections::BTreeMap; use std::str; use std::str::FromStr; use anyhow::Result; use bio::stats::{LogProb, PHREDProb}; use itertools::Itertools; use itertools_num::linspace; use rust_htslib::bcf::{self, Read}; use serde_json::{json, Value}; use crate::errors; use crate::variants::model::AlleleFreq; use crate:...
struct TMBStrat { min_vaf: f64, tmb: f64, vartype: Vartype, } #[derive(Debug, Clone, Serialize)] struct TMBBin { vaf: f64, tmb: f64, vartype: Vartype, } struct Record { prob: LogProb, vartype: Vartype, } #[derive( Display, Debug, Clone, Copy, Serialize, Deseria...
#[derive(Debug, Clone, Serialize)]
random_line_split
build.rs
use std::env; use std::path::{Path, PathBuf}; use std::process::Command; fn gurobi_home() -> String { let var = env::var("GUROBI_HOME").expect("failed to retrieve the value of GUROBI_HOME"); if!Path::new(&var).exists() { panic!("GUROBI_HOME is invalid path"); } var } fn append_path(addpath: PathBuf)
fn get_version_triple() -> (i32, i32, i32) { append_path(PathBuf::from(gurobi_home()).join("bin")); let output = Command::new("gurobi_cl").arg("--version").output().expect("failed to execute gurobi_cl"); let verno: Vec<_> = String::from_utf8_lossy(&output.stdout) .into_owned() .split_whitespace() .nth...
{ let path = env::var_os("PATH").expect("failed to retrieve the value of PATH"); let mut paths: Vec<_> = env::split_paths(&path).collect(); paths.push(addpath); let new_path = env::join_paths(paths).unwrap(); env::set_var("PATH", &new_path); }
identifier_body
build.rs
use std::env; use std::path::{Path, PathBuf}; use std::process::Command; fn gurobi_home() -> String { let var = env::var("GUROBI_HOME").expect("failed to retrieve the value of GUROBI_HOME"); if!Path::new(&var).exists()
var } fn append_path(addpath: PathBuf) { let path = env::var_os("PATH").expect("failed to retrieve the value of PATH"); let mut paths: Vec<_> = env::split_paths(&path).collect(); paths.push(addpath); let new_path = env::join_paths(paths).unwrap(); env::set_var("PATH", &new_path); } fn get_version_tripl...
{ panic!("GUROBI_HOME is invalid path"); }
conditional_block
build.rs
use std::env; use std::path::{Path, PathBuf}; use std::process::Command; fn gurobi_home() -> String { let var = env::var("GUROBI_HOME").expect("failed to retrieve the value of GUROBI_HOME"); if!Path::new(&var).exists() { panic!("GUROBI_HOME is invalid path"); } var } fn append_path(addpath: PathBuf) { l...
fn get_version_triple() -> (i32, i32, i32) { append_path(PathBuf::from(gurobi_home()).join("bin")); let output = Command::new("gurobi_cl").arg("--version").output().expect("failed to execute gurobi_cl"); let verno: Vec<_> = String::from_utf8_lossy(&output.stdout) .into_owned() .split_whitespace() .nth(3...
random_line_split
build.rs
use std::env; use std::path::{Path, PathBuf}; use std::process::Command; fn gurobi_home() -> String { let var = env::var("GUROBI_HOME").expect("failed to retrieve the value of GUROBI_HOME"); if!Path::new(&var).exists() { panic!("GUROBI_HOME is invalid path"); } var } fn
(addpath: PathBuf) { let path = env::var_os("PATH").expect("failed to retrieve the value of PATH"); let mut paths: Vec<_> = env::split_paths(&path).collect(); paths.push(addpath); let new_path = env::join_paths(paths).unwrap(); env::set_var("PATH", &new_path); } fn get_version_triple() -> (i32, i32, i32) {...
append_path
identifier_name
camera.rs
extern crate cgmath; use self::cgmath::{Point3, Vector3, Matrix4, SquareMatrix, Deg}; #[derive(Copy, Clone)] /// Holds view and projection matrices. /// /// See `Scene`. pub struct Camera { view_matrix: Matrix4<f32>, proj_matrix: Matrix4<f32>, // Reduces draw call computations vp_matrix: Matrix4<f32> ...
}
{ self.proj_matrix = cgmath::perspective(Deg::new(fovy), aspect, near, far); self.vp_matrix = self.proj_matrix * self.view_matrix; }
identifier_body
camera.rs
extern crate cgmath; use self::cgmath::{Point3, Vector3, Matrix4, SquareMatrix, Deg}; #[derive(Copy, Clone)] /// Holds view and projection matrices. /// /// See `Scene`. pub struct Camera { view_matrix: Matrix4<f32>, proj_matrix: Matrix4<f32>, // Reduces draw call computations vp_matrix: Matrix4<f32> ...
(&self) -> Matrix4<f32> { return self.vp_matrix; } /// Update the view matrix. pub fn look_at(&mut self, eye: Point3<f32>, center: Point3<f32>, up: Vector3<f32>) { self.view_matrix = Matrix4::look_at(eye, center, up); self.vp_matrix = self.proj_matrix * self.view_matrix; } ...
vp_matrix
identifier_name
camera.rs
extern crate cgmath; use self::cgmath::{Point3, Vector3, Matrix4, SquareMatrix, Deg}; #[derive(Copy, Clone)] /// Holds view and projection matrices. /// /// See `Scene`. pub struct Camera { view_matrix: Matrix4<f32>, proj_matrix: Matrix4<f32>, // Reduces draw call computations vp_matrix: Matrix4<f32> ...
/// Create a new `Camera` from view and projection matrices. pub fn from_matrices(view_matrix: Matrix4<f32>, proj_matrix: Matrix4<f32>) -> Camera { return Camera { view_matrix: view_matrix, proj_matrix: proj_matrix, vp_matrix: proj_matrix * view_matrix }; ...
random_line_split
binop-mul-bool.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
// <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. // error-pattern:`*` cannot be applied to type `bool` fn main() { let x = true * false; } // ^^^^ERR(<1.19.0) binary operation // ...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
random_line_split
binop-mul-bool.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 = true * false; } // ^^^^ERR(<1.19.0) binary operation // ^^^^NOTE(<1.19.0) an implementation of // ^^^^^^^^^^^^ERR(>=1.19.0,<1.35.0-beta) binary operation // ^^^^^^^^^^^^NOTE(>=1.19.0,<1.35.0-beta) an implementation of // ...
main
identifier_name
binop-mul-bool.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 ...
// ^^^^ERR(<1.19.0) binary operation // ^^^^NOTE(<1.19.0) an implementation of // ^^^^^^^^^^^^ERR(>=1.19.0,<1.35.0-beta) binary operation // ^^^^^^^^^^^^NOTE(>=1.19.0,<1.35.0-beta) an implementation of // ^ERR(>=1.35.0-beta,<1.42...
{ let x = true * false; }
identifier_body
text.rs
use std::cmp; use { Align, Backend, CharacterCache, Color, Colorable, Dimension, FontSize, LineBreak, Range, Rect, Scalar, Ui, Widget, }; use widget; /// Displays some given text centred within a rectangular area. /// /// By default, the rectangular dimensions are f...
} /// Align the text to the right of its bounding **Rect**'s *x* axis range. pub fn align_text_right(mut self) -> Self { self.style.text_align = Some(Align::End); self } /// The height of the space used between consecutive lines. pub fn line_spacing(mut self, height: Scalar) ->...
/// Align the text to the middle of its bounding **Rect**'s *x* axis range. pub fn align_text_middle(mut self) -> Self { self.style.text_align = Some(Align::Middle); self
random_line_split
text.rs
use std::cmp; use { Align, Backend, CharacterCache, Color, Colorable, Dimension, FontSize, LineBreak, Range, Rect, Scalar, Ui, Widget, }; use widget; /// Displays some given text centred within a rectangular area. /// /// By default, the rectangular dimensions are f...
(&self) -> Style { self.style.clone() } /// If no specific width was given, we'll use the width of the widest line as a default. fn default_x_dimension<B: Backend>(&self, ui: &Ui<B>) -> Dimension { let font_size = self.style.font_size(&ui.theme); let mut max_width = 0.0; for...
style
identifier_name
text.rs
use std::cmp; use { Align, Backend, CharacterCache, Color, Colorable, Dimension, FontSize, LineBreak, Range, Rect, Scalar, Ui, Widget, }; use widget; /// Displays some given text centred within a rectangular area. /// /// By default, the rectangular dimensions are f...
/// Specify that the **Text** should not wrap lines around the width. pub fn no_line_wrap(mut self) -> Self { self.style.maybe_wrap = Some(None); self } /// Line wrap the **Text** at the beginning of the first word that exceeds the width. pub fn wrap_by_word(mut self) -> Self { ...
{ self.style.font_size = Some(size); self }
identifier_body
sprite.rs
#[derive(Copy, Clone, Eq, PartialEq)] pub enum Color { Navy, Green, Teal, Maroon, Purple, Brown, Gray, Dark, Blue, Lime, Aqua, Red, Pink, Yellow, White, } use self::Color::*; pub const NAVY: &'static [Color] = &[Navy]; pub const GREEN: &'static [Color] = &[Green]; pub const TEAL: &'static [Color] = &[T...
(appearance: u8, bright: bool) -> Self { Sprite { character: ('!' as u8 + (appearance & 0b00011111)) as char, color: match (appearance >> 5, bright) { (0b000, false) => DARK, (0b001, false) => NAVY, (0b010, false) => GREEN, ...
of_byte
identifier_name
sprite.rs
#[derive(Copy, Clone, Eq, PartialEq)] pub enum Color { Navy, Green, Teal, Maroon, Purple, Brown, Gray, Dark, Blue, Lime, Aqua, Red, Pink, Yellow, White, } use self::Color::*; pub const NAVY: &'static [Color] = &[Navy]; pub const GREEN: &'static [Color] = &[Green]; pub const TEAL: &'static [Color] = &[T...
pub const HIDDEN: Sprite = Sprite { character:'', color: DARK }; impl Sprite { pub fn of_byte(appearance: u8, bright: bool) -> Self { Sprite { character: ('!' as u8 + (appearance & 0b00011111)) as char, color: match (appearance >> 5, bright) { (0b000, false) ...
random_line_split
gen.rs
use backend::obj::*; use csv; use num; use rand; use rand::Rng; use serialize::base64::{self, FromBase64, ToBase64}; use std::cmp; use std::f32::consts; use std::fmt; use std::slice::Iter; pub type Dna = Box<[u8]>; const MAX_POLY_SIDES: u8 = 8; // in conformity with box2d? fn bit_count(p: usize) -> usize { p << 3 } ...
(&mut self, upside_down: bool) -> Shape { let n = self.next_integer(3, MAX_POLY_SIDES); self.npoly(n, upside_down) } fn any_poly(&mut self) -> Shape { let n = self.next_integer(3, MAX_POLY_SIDES); let upside_down = self.next_bool(); self.npoly(n, upside_down) } fn npoly(&mut self, n: AttachmentIndex, up...
poly
identifier_name
gen.rs
use backend::obj::*; use csv; use num; use rand; use rand::Rng; use serialize::base64::{self, FromBase64, ToBase64}; use std::cmp; use std::f32::consts; use std::fmt; use std::slice::Iter; pub type Dna = Box<[u8]>; const MAX_POLY_SIDES: u8 = 8; // in conformity with box2d? fn bit_count(p: usize) -> usize { p << 3 } ...
else { Shape::new_star(n, corrected_radius, ratio1, ratio2) } } } } #[allow(dead_code)] pub struct Randomizer<R> where R: rand::Rng { rng: R, } #[allow(dead_code)] impl Randomizer<rand::ThreadRng> { pub fn new() -> Randomizer<rand::ThreadRng> { Randomizer { rng: rand::thread_rng() } } } impl Generator f...
{ Shape::new_star(n, corrected_radius, ratio2, ratio1) }
conditional_block
gen.rs
use backend::obj::*; use csv; use num; use rand; use rand::Rng; use serialize::base64::{self, FromBase64, ToBase64}; use std::cmp; use std::f32::consts; use std::fmt; use std::slice::Iter; pub type Dna = Box<[u8]>; const MAX_POLY_SIDES: u8 = 8; // in conformity with box2d? fn bit_count(p: usize) -> usize { p << 3 } ...
Shape::new_star(n, radius, ratio1, ratio2) } fn poly(&mut self, upside_down: bool) -> Shape { let n = self.next_integer(3, MAX_POLY_SIDES); self.npoly(n, upside_down) } fn any_poly(&mut self) -> Shape { let n = self.next_integer(3, MAX_POLY_SIDES); let upside_down = self.next_bool(); self.npoly(n, ups...
// if pie slices are too small physics freaks out let n = self.next_integer(3, if radius > 1.5 { MAX_POLY_SIDES } else { MAX_POLY_SIDES - 2 }); let ratio1 = self.next_float(0.5, 1.0); let ratio2 = self.next_float(0.7, 0.9) * (1. / ratio1);
random_line_split
type-path-err-node-types.rs
// Copyright 2017 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 ufcs_item() { NonExistent::Assoc::<u8>; //~ ERROR undeclared type or module `NonExistent` } fn method() { nonexistent.nonexistent::<u8>(); //~ ERROR cannot find value `nonexistent` } fn closure() { let _ = |a, b: _| -> _ { 0 }; // OK } fn main() {}
{ <u8 as Tr<u8>>::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent` }
identifier_body
type-path-err-node-types.rs
// Copyright 2017 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 ...
nonexistent.nonexistent::<u8>(); //~ ERROR cannot find value `nonexistent` } fn closure() { let _ = |a, b: _| -> _ { 0 }; // OK } fn main() {}
random_line_split
type-path-err-node-types.rs
// Copyright 2017 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 ...
() { <u8 as Tr<u8>>::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent` } fn ufcs_item() { NonExistent::Assoc::<u8>; //~ ERROR undeclared type or module `NonExistent` } fn method() { nonexistent.nonexistent::<u8>(); //~ ERROR cannot find value `nonexistent` } fn closure() { ...
ufcs_trait
identifier_name
role.rs
use std::cmp::Ordering; use std::fmt::{Display, Formatter, Result as FmtResult}; use model::*; #[cfg(feature = "cache")] use CACHE; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] use builder::EditRole; #[cfg(feature = "cache")] use internal::prelude::*; #[cfg(all(feature = "cache", feature = "m...
/// Checks whether the role has all of the given permissions. /// /// The 'precise' argument is used to check if the role's permissions are /// precisely equivalent to the given permissions. If you need only check /// that the role has at least the given permissions, pass `false`. pub fn has_per...
#[inline] pub fn has_permission(&self, permission: Permissions) -> bool { self.permissions.contains(permission) }
random_line_split
role.rs
use std::cmp::Ordering; use std::fmt::{Display, Formatter, Result as FmtResult}; use model::*; #[cfg(feature = "cache")] use CACHE; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] use builder::EditRole; #[cfg(feature = "cache")] use internal::prelude::*; #[cfg(all(feature = "cache", feature = "m...
} impl<'a> From<&'a Role> for RoleId { /// Gets the Id of a role. fn from(role: &Role) -> RoleId { role.id } }
{ role.id }
identifier_body
role.rs
use std::cmp::Ordering; use std::fmt::{Display, Formatter, Result as FmtResult}; use model::*; #[cfg(feature = "cache")] use CACHE; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] use builder::EditRole; #[cfg(feature = "cache")] use internal::prelude::*; #[cfg(all(feature = "cache", feature = "m...
(&self, other: &Role) -> Option<Ordering> { Some(self.cmp(other)) } } #[cfg(feature = "model")] impl RoleId { /// Search the cache for the role. #[cfg(feature = "cache")] pub fn find(&self) -> Option<Role> { let cache = CACHE.read().unwrap(); for guild in cache.guilds.values() { ...
partial_cmp
identifier_name
role.rs
use std::cmp::Ordering; use std::fmt::{Display, Formatter, Result as FmtResult}; use model::*; #[cfg(feature = "cache")] use CACHE; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] use builder::EditRole; #[cfg(feature = "cache")] use internal::prelude::*; #[cfg(all(feature = "cache", feature = "m...
if let Some(role) = guild.roles.get(self) { return Some(role.clone()); } } None } } impl Display for RoleId { fn fmt(&self, f: &mut Formatter) -> FmtResult { Display::fmt(&self.0, f) } } impl From<Role> for RoleId { /// Gets the Id of a role. ...
{ continue; }
conditional_block
vaesenc.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn
() { run_test(&Instruction { mnemonic: Mnemonic::VAESENC, operand1: Some(Direct(XMM0)), operand2: Some(Direct(XMM2)), operand3: Some(Direct(XMM6)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 226, 105, 220, 198], OperandSize::Dword) } fn vae...
vaesenc_1
identifier_name
vaesenc.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vaesenc_1() { run_test(&Instruction { mnemonic: Mnemonic::VAESENC, operand1: Some(Direct(XMM0)), operand2: Some(Direct(...
run_test(&Instruction { mnemonic: Mnemonic::VAESENC, operand1: Some(Direct(XMM0)), operand2: Some(Direct(XMM7)), operand3: Some(Indirect(EDI, Some(OperandSize::Xmmword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 226, 65, 220, 7], Op...
fn vaesenc_2() {
random_line_split
vaesenc.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vaesenc_1() { run_test(&Instruction { mnemonic: Mnemonic::VAESENC, operand1: Some(Direct(XMM0)), operand2: Some(Direct(...
{ run_test(&Instruction { mnemonic: Mnemonic::VAESENC, operand1: Some(Direct(XMM7)), operand2: Some(Direct(XMM4)), operand3: Some(IndirectScaledIndexedDisplaced(RDX, RAX, Two, 1425141855, Some(OperandSize::Xmmword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, ...
identifier_body
pbrt.rs
use std::str::{self, FromStr}; use nom::{digit, space}; use linalg::vector::Vector3; use linalg::transform::Transform; named!(unsigned_float<f64>, map_res!( map_res!( recognize!( alt_complete!( delimited!(digit, tag!("."), opt!(complete!(digit))) | delimited!(opt!(digit), tag!("."), digit...
() { assert_eq!(signed_float(&b"134"[..]), Done(&b""[..], 134.0)); assert_eq!(signed_float(&b"-1234."[..]), Done(&b""[..], -1234.0)); assert_eq!(signed_float(&b"0.145"[..]), Done(&b""[..], 0.145)); assert_eq!(signed_float(&b"-2.45"[..]), Done(&b""[..], -2.45)); } #[test] ...
test_signed_float
identifier_name
pbrt.rs
use std::str::{self, FromStr}; use nom::{digit, space}; use linalg::vector::Vector3; use linalg::transform::Transform; named!(unsigned_float<f64>, map_res!( map_res!( recognize!( alt_complete!( delimited!(digit, tag!("."), opt!(complete!(digit))) | delimited!(opt!(digit), tag!("."), digit...
z: signed_float >> (Vector3::new(x, y, z)) )); named!(look_at<Transform>, do_parse!( tag!("LookAt") >> space >> eye: vector3 >> space >> look: vector3 >> space >> up: vector3 >> (Transform::look_at(eye, look, up)) )); named!(transformation<Trans...
space >> y: signed_float >> space >>
random_line_split
pbrt.rs
use std::str::{self, FromStr}; use nom::{digit, space}; use linalg::vector::Vector3; use linalg::transform::Transform; named!(unsigned_float<f64>, map_res!( map_res!( recognize!( alt_complete!( delimited!(digit, tag!("."), opt!(complete!(digit))) | delimited!(opt!(digit), tag!("."), digit...
}
{ assert_eq!( look_at(&b"LookAt 0 10 100 0 -1 0 0 1 0"[..]), Done( &b""[..], Transform::look_at( Vector3::new(0.0, 10.0, 100.0), Vector3::new(0.0, -1.0, 0.0), Vector3::new(0.0, 1.0, 0.0) ...
identifier_body
plane.rs
// Copyright GFX Developers 2014-2017 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable ...
self.x = 0; } let x = self.vert(self.x, self.y); let y = self.vert(self.x + 1, self.y); let z = self.vert(self.x + 1, self.y + 1); let w = self.vert(self.x, self.y + 1); self.x += 1; Some(Quad::new(x, y, z, w)) } } impl SharedVertex<Vertex> for...
{ return None; }
conditional_block
plane.rs
// Copyright GFX Developers 2014-2017 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable ...
} #[test] fn test_shared_vertex_count() { let plane = Plane::new(); assert_eq!(plane.shared_vertex_count(), 4); assert_eq!(plane.indexed_polygon_count(), 1); let plane = Plane::subdivide(2, 2); assert_eq!(plane.shared_vertex_count(), 9); assert_eq!(plane.indexed_polygon_count(), 4); let...
{ self.subdivide_x * self.subdivide_y }
identifier_body
plane.rs
// Copyright GFX Developers 2014-2017 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable ...
(&self) -> usize { self.subdivide_x * self.subdivide_y } } #[test] fn test_shared_vertex_count() { let plane = Plane::new(); assert_eq!(plane.shared_vertex_count(), 4); assert_eq!(plane.indexed_polygon_count(), 1); let plane = Plane::subdivide(2, 2); assert_eq!(plane.shared_vertex_coun...
indexed_polygon_count
identifier_name
plane.rs
// Copyright GFX Developers 2014-2017 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable ...
Some(Quad::new(x, y, z, w)) } } impl SharedVertex<Vertex> for Plane { fn shared_vertex(&self, idx: usize) -> Vertex { let y = idx / (self.subdivide_x + 1); let x = idx % (self.subdivide_x + 1); self.vert(x, y) } fn shared_vertex_count(&self) -> usize { (self.s...
let y = self.vert(self.x + 1, self.y); let z = self.vert(self.x + 1, self.y + 1); let w = self.vert(self.x, self.y + 1); self.x += 1;
random_line_split
union-ub-fat-ptr.rs
// Copyright 2018 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 ...
//~^ ERROR it is undefined behavior to use this value fn main() { }
const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str };
random_line_split
union-ub-fat-ptr.rs
// Copyright 2018 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 ...
{ ptr: *const u8, len: &'static u8, } union SliceTransmute { repr: SliceRepr, bad: BadSliceRepr, slice: &'static [u8], str: &'static str, my_str: &'static MyStr, my_slice: &'static MySliceBool, } #[repr(C)] #[derive(Copy, Clone)] struct DynRepr { ptr: *const u8, vtable: *const...
BadSliceRepr
identifier_name
union-ub-fat-ptr.rs
// Copyright 2018 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 ...
{ }
identifier_body
xoshiro128plusplus.rs
// Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed /...
(&mut self) -> u64 { next_u64_via_u32(self) } #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { fill_bytes_via_next(self, dest); } #[inline] fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { self.fill_bytes(dest); Ok(()) } } #[cfg(tes...
next_u64
identifier_name
xoshiro128plusplus.rs
// Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed /...
#[inline] fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { self.fill_bytes(dest); Ok(()) } } #[cfg(test)] mod tests { use super::*; #[test] fn reference() { let mut rng = Xoshiro128PlusPlus::from_seed( [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, ...
{ fill_bytes_via_next(self, dest); }
identifier_body
xoshiro128plusplus.rs
// Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed /...
let mut state = [0; 4]; read_u32_into(&seed, &mut state); Xoshiro128PlusPlus { s: state } } /// Create a new `Xoshiro128PlusPlus` from a `u64` seed. /// /// This uses the SplitMix64 generator internally. fn seed_from_u64(mut state: u64) -> Self { const PHI: u64 = 0x...
{ return Self::seed_from_u64(0); }
conditional_block
xoshiro128plusplus.rs
// Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed /...
mod tests { use super::*; #[test] fn reference() { let mut rng = Xoshiro128PlusPlus::from_seed( [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]); // These values were produced with the reference implementation: // http://xoshiro.di.unimi.it/xoshiro128plusplus.c ...
} #[cfg(test)]
random_line_split
sr_masterctl.rs
// SairaDB - A distributed database // Copyright (C) 2015 by Siyu Wang // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later ver...
fn master_connection() { }
{ let addr: &str = &(ip + ":" + &port); let count = Arc::new(AtomicUsize::new(0)); loop { let stream = TcpStream::connect(addr); //match stream.write_all(cookie.as_bytes()); } }
identifier_body
sr_masterctl.rs
// SairaDB - A distributed database // Copyright (C) 2015 by Siyu Wang // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later ver...
(ip: String, port: String, vnodes: Arc<Vec<u64>>, cookie: String, log_sender: Sender<String>) { let addr: &str = &(ip + ":" + &port); let count = Arc::new(AtomicUsize::new(0)); loop { let stream = TcpStream::connect(addr); //match stream.write_all(cookie.as_bytes()); ...
master_task
identifier_name