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
stylesheet.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::StyleSheetBinding; use dom::bindings::codegen::Bindings::StyleSheetBinding::...
StyleSheet { reflector_: Reflector::new(), type_: type_, href: href, title: title } } #[allow(unrooted_must_root)] pub fn new(window: &Window, type_: DOMString, href: Option<DOMString>, title: Option<DOMString>) -...
impl StyleSheet { #[allow(unrooted_must_root)] fn new_inherited(type_: DOMString, href: Option<DOMString>, title: Option<DOMString>) -> StyleSheet {
random_line_split
stylesheet.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::StyleSheetBinding; use dom::bindings::codegen::Bindings::StyleSheetBinding::...
(&self) -> Option<DOMString> { self.title.clone() } }
GetTitle
identifier_name
stylesheet.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::StyleSheetBinding; use dom::bindings::codegen::Bindings::StyleSheetBinding::...
// https://drafts.csswg.org/cssom/#dom-stylesheet-title fn GetTitle(&self) -> Option<DOMString> { self.title.clone() } }
{ self.href.clone() }
identifier_body
cabi_powerpc.rs
// Copyright 2014-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...
} fn is_reg_ty(ty: Type) -> bool { return match ty.kind() { Integer | Pointer | Float | Double => true, _ => false }; } fn padding_ty(ccx: &CrateContext, align: uint, offset: uint) -> Option<Type> { if ((align - 1 ) & offset) > 0 { Some(Type::i32(ccx)) ...
{ let orig_offset = *offset; let size = ty_size(ty) * 8; let mut align = ty_align(ty); align = cmp::min(cmp::max(align, 4), 8); *offset = align_up_to(*offset, align); *offset += align_up_to(size, align * 8) / 8; if is_reg_ty(ty) { let attr = if ty == Type::i1(ccx) { Some(ZExtAttrib...
identifier_body
cabi_powerpc.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //
use libc::c_uint; use llvm; use llvm::{Integer, Pointer, Float, Double, Struct, Array}; use llvm::{StructRetAttribute, ZExtAttribute}; use trans::cabi::{FnType, ArgType}; use trans::context::CrateContext; use trans::type_::Type; use std::cmp; fn align_up_to(off: uint, a: uint) -> uint { return (off + a - 1) / a ...
// 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.
random_line_split
cabi_powerpc.rs
// Copyright 2014-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...
(ty: Type) -> uint { match ty.kind() { Integer => { unsafe { ((llvm::LLVMGetIntTypeWidth(ty.to_ref()) as uint) + 7) / 8 } } Pointer => 4, Float => 4, Double => 8, Struct => { if ty.is_packed() { let s...
ty_size
identifier_name
cabi_powerpc.rs
// Copyright 2014-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...
Array => { let len = ty.array_length(); let elt = ty.element_type(); let eltsz = ty_size(elt); len * eltsz } _ => panic!("ty_size: unhandled type") } } fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { if is_reg_ty(ty) { ...
{ if ty.is_packed() { let str_tys = ty.field_types(); str_tys.iter().fold(0, |s, t| s + ty_size(*t)) } else { let str_tys = ty.field_types(); let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t)); alig...
conditional_block
borrowck-insert-during-each.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 ...
{ n: HashSet<isize>, } impl Foo { pub fn foo<F>(&mut self, mut fun: F) where F: FnMut(&isize) { for f in &self.n { fun(f); } } } fn bar(f: &mut Foo) { f.foo( |a| { //~ ERROR closure requires unique access to `f` f.n.insert(*a); }) } fn main() { l...
Foo
identifier_name
borrowck-insert-during-each.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { let mut f = Foo { n: HashSet::new() }; bar(&mut f); }
random_line_split
os.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
node::IntValue(i) => (cx.ty_ident(DUMMY_SP, cx.ident_of("u32")), quote_expr!(&*cx, $i)), node::BoolValue(b) => (cx.ty_ident(DUMMY_SP, cx.ident_of("bool")), quote_expr!(&*cx, $b)), node::StrValue(ref string) => { let static_lifetime = cx.lifetime(DUMMY_S...
let (ty, val) = match v.value {
random_line_split
os.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
(cx: &ExtCtxt, ty: &str, params: Vec<String>) -> ast::Path { let mut lifetimes = vec!(); let mut types = vec!(); for p in params.iter() { let slice = p.as_str(); if slice.starts_with("'") { let lifetime = cx.lifetime(DUMMY_SP, intern(slice)); lifetimes.push(lifetime); } else { let pa...
type_name_as_path
identifier_name
os.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
} let val_slice = TokenString(rname.clone()); let a_lifetime = cx.lifetime(DUMMY_SP, intern("'a")); (cx.ty_rptr( DUMMY_SP, cx.ty_path(type_name_as_path(cx, reftype.as_str(), refparams)), Some(a_lifetime), ast::MutImmutable), quote_expr!(&*cx, &$va...
{ ty_params.insert(param.clone()); }
conditional_block
os.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
} } fn build_args(builder: &mut Builder, cx: &mut ExtCtxt, struct_name: &String, node: Rc<node::Node>) -> P<ast::Expr> { let mut fields = vec!(); let mut expr_fields = vec!(); let node_attr = node.attributes.borrow(); let mut ty_params = HashSet::new(); // this is a bit slower than for (k, v) in node...
{ let some_loop_fn = node.get_required_string_attr(cx, "loop"); match some_loop_fn { Some(loop_fn) => { let args_node = node.get_by_path("args"); let args = match args_node.and_then(|args| { Some(build_args(builder, cx, &loop_fn, args)) }) { None => vec!(), Some(arg) =>...
identifier_body
sleep.rs
#![crate_name = "sleep"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; use std::io::Write; u...
static NAME: &'static str = "sleep"; static VERSION: &'static str = "1.0.0"; pub fn uumain(args: Vec<String>) -> i32 { let mut opts = getopts::Options::new(); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = mat...
#[macro_use] mod util; #[path = "../common/parse_time.rs"] mod parse_time;
random_line_split
sleep.rs
#![crate_name = "sleep"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; use std::io::Write; u...
(args: Vec<String>) { let sleep_time = args.iter().fold(0.0, |result, arg| match parse_time::from_str(&arg[..]) { Ok(m) => m + result, Err(f) => crash!(1, "{}", f), }); let sleep_dur = if sleep_time > (U32_MAX as f64) { U32_MAX } else { (1000.0 * sl...
sleep
identifier_name
sleep.rs
#![crate_name = "sleep"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; use std::io::Write; u...
Pause for NUMBER seconds. SUFFIX may be's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time specified by the sum of...
{ let mut opts = getopts::Options::new(); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(f) => { show_error!("{}", f); retur...
identifier_body
htmldialogelement.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use dom::bind...
(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> Root<HTMLDialogElement> { Node::reflect_node(box HTMLDialogElement::new_inherited(local_name, prefix, document), document, HTMLDialogElementBinding::Wrap) ...
new
identifier_name
htmldialogelement.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use dom::bind...
#[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> Root<HTMLDialogElement> { Node::reflect_node(box HTMLDialogElement::new_inherited(local_name, prefix, document), document, ...
random_line_split
htmldialogelement.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use dom::bind...
// Step 3 if let Some(new_value) = return_value { *self.return_value.borrow_mut() = new_value; } // TODO: Step 4 implement pending dialog stack removal // Step 5 win.dom_manipulation_task_source().queue_simple_event(target, atom!("close"), &win); } }
{ return; }
conditional_block
marker.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...
; macro_rules! impls{ ($t: ident) => ( impl<T:?Sized> Hash for $t<T> { #[inline] fn hash<H: Hasher>(&self, _: &mut H) { } } impl<T:?Sized> cmp::PartialEq for $t<T> { fn eq(&self, _other: &$t<T>) -> bool { true } ...
NoCopy
identifier_name
marker.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...
impl<T>!Send for *const T { } impl<T>!Send for *mut T { } /// Types with a constant size known at compile-time. #[stable(feature = "rust1", since = "1.0.0")] #[lang = "sized"] #[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"] #[fundamental] // for Default, for example, which r...
random_line_split
main.rs
use std::str::FromStr; fn group_by_sum(packages: &[usize], target: usize) -> Vec<Vec<usize>> { let mut results = Vec::new(); struct Iter<'a> { f: &'a Fn(&mut Iter, usize, usize, Vec<usize>) -> (), results: &'a mut Vec<Vec<usize>> } { let mut iter = Iter {results: &mut results, f: &|iter, index, s...
iter.results.push(current.clone()); } else if index < packages.len() { if packages[index] <= target - so_far { let mut current = current.clone(); current.push(index); (iter.f)(iter, index + 1, so_far + packages[index...
random_line_split
main.rs
use std::str::FromStr; fn group_by_sum(packages: &[usize], target: usize) -> Vec<Vec<usize>> { let mut results = Vec::new(); struct Iter<'a> { f: &'a Fn(&mut Iter, usize, usize, Vec<usize>) -> (), results: &'a mut Vec<Vec<usize>> } { let mut iter = Iter {results: &mut results, f: &|iter, index, s...
fn quantum_entanglement(xs: &Vec<usize>) -> usize { xs.iter().fold(1, |acc, x| acc * x) } fn split_into_groups(packages: &Vec<usize>, target_weight: usize) -> Vec<Vec<usize>> { let mut grouped_by_sum: Vec<Vec<usize>> = group_by_sum(&packages, target_weight) .iter() // assuming that values are ...
{ a.iter().any(|x| b.contains(x)) }
identifier_body
main.rs
use std::str::FromStr; fn group_by_sum(packages: &[usize], target: usize) -> Vec<Vec<usize>> { let mut results = Vec::new(); struct Iter<'a> { f: &'a Fn(&mut Iter, usize, usize, Vec<usize>) -> (), results: &'a mut Vec<Vec<usize>> } { let mut iter = Iter {results: &mut results, f: &|iter, index, s...
() { let input = include_str!("../input.txt"); let packages: Vec<_> = input.lines().map(|i|usize::from_str(i).unwrap()).rev().collect(); let sum = packages.iter().fold(0, |acc, x| acc + x); let target = sum / 3; let grouped_by_sum = split_into_groups(&packages, target); for group in grouped_by...
main
identifier_name
main.rs
use std::str::FromStr; fn group_by_sum(packages: &[usize], target: usize) -> Vec<Vec<usize>> { let mut results = Vec::new(); struct Iter<'a> { f: &'a Fn(&mut Iter, usize, usize, Vec<usize>) -> (), results: &'a mut Vec<Vec<usize>> } { let mut iter = Iter {results: &mut results, f: &|iter, index, s...
} let target = sum / 4; let grouped_by_sum = split_into_groups(&packages, target); 'outer: for first in grouped_by_sum.iter() { for second in grouped_by_sum.iter() { for third in grouped_by_sum.iter() { if!intersects(first, second) && !intersects(...
{ println!("Part 1. Min quantum entanglement: {}", quantum_entanglement(&group)); break; }
conditional_block
self-impl.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 ...
Foo } } // Test uses when implementing a trait and with a type parameter. pub struct Baz<X> { pub f: X, } trait Bar<X> { fn bar(x: Self, y: &Self, z: Box<Self>) -> Self; fn dummy(&self, x: X) { } } impl Bar<int> for Box<Baz<int>> { fn bar(_x: Self, _y: &Self, _z: Box<Self>) -> Self { ...
random_line_split
self-impl.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 ...
} impl Bar<int> for Box<Baz<int>> { fn bar(_x: Self, _y: &Self, _z: Box<Self>) -> Self { box Baz { f: 42 } } } fn main() { let _: Foo = Foo::foo(Foo, &Foo, box Foo); let _: Box<Baz<int>> = Bar::bar(box Baz { f: 42 }, &box Baz { f: 42 }, ...
{ }
identifier_body
self-impl.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 ...
(&self, x: X) { } } impl Bar<int> for Box<Baz<int>> { fn bar(_x: Self, _y: &Self, _z: Box<Self>) -> Self { box Baz { f: 42 } } } fn main() { let _: Foo = Foo::foo(Foo, &Foo, box Foo); let _: Box<Baz<int>> = Bar::bar(box Baz { f: 42 }, &box Baz { f: 42 }, ...
dummy
identifier_name
lib.rs
pub struct
{ rows: Vec<Vec<u32>> } impl PascalsTriangle { fn next_row(current_row: &Vec<u32>) -> Vec<u32> { let mut row1 = current_row.clone(); let mut row2 = current_row.clone(); row1.push(0); row1.reverse(); row2.push(0); row1.iter().zip(row2).map(|(x, y)| x+y).collect()...
PascalsTriangle
identifier_name
lib.rs
pub struct PascalsTriangle { rows: Vec<Vec<u32>> } impl PascalsTriangle { fn next_row(current_row: &Vec<u32>) -> Vec<u32> { let mut row1 = current_row.clone(); let mut row2 = current_row.clone(); row1.push(0); row1.reverse(); row2.push(0); row1.iter().zip(row2).m...
pub fn rows(self) -> Vec<Vec<u32>> { self.rows } }
{ let mut rows: Vec<Vec<u32>> = Vec::new(); let mut current = vec![1]; for i in 0..row_count { rows.push(current.clone()); current = PascalsTriangle::next_row(&current); }; PascalsTriangle{rows: rows} }
identifier_body
lib.rs
pub struct PascalsTriangle { rows: Vec<Vec<u32>> } impl PascalsTriangle { fn next_row(current_row: &Vec<u32>) -> Vec<u32> { let mut row1 = current_row.clone(); let mut row2 = current_row.clone(); row1.push(0); row1.reverse(); row2.push(0); row1.iter().zip(row2).m...
rows.push(current.clone()); current = PascalsTriangle::next_row(&current); }; PascalsTriangle{rows: rows} } pub fn rows(self) -> Vec<Vec<u32>> { self.rows } }
for i in 0..row_count {
random_line_split
ref_with_cost.rs
//! A reference packed with a cost value. use std::cmp::Ordering; /// A reference packed with a cost value. pub struct RefWithCost<'a, N, T: 'a> { /// The reference to an object. pub object: &'a T, /// The cost of the object. pub cost: N } impl<'a, N, T> RefWithCost<'a, N, T> { /// Creates a ne...
(&self, other: &RefWithCost<'a, N, T>) -> Ordering { if self.cost < other.cost { Ordering::Less } else if self.cost > other.cost { Ordering::Greater } else { Ordering::Equal } } }
cmp
identifier_name
ref_with_cost.rs
//! A reference packed with a cost value. use std::cmp::Ordering; /// A reference packed with a cost value. pub struct RefWithCost<'a, N, T: 'a> { /// The reference to an object. pub object: &'a T, /// The cost of the object. pub cost: N } impl<'a, N, T> RefWithCost<'a, N, T> { /// Creates a ne...
else if self.cost > other.cost { Ordering::Greater } else { Ordering::Equal } } }
{ Ordering::Less }
conditional_block
ref_with_cost.rs
//! A reference packed with a cost value. use std::cmp::Ordering; /// A reference packed with a cost value. pub struct RefWithCost<'a, N, T: 'a> { /// The reference to an object. pub object: &'a T, /// The cost of the object. pub cost: N } impl<'a, N, T> RefWithCost<'a, N, T> { /// Creates a ne...
#[inline] fn eq(&self, other: &RefWithCost<'a, N, T>) -> bool { self.cost.eq(&other.cost) } } impl<'a, N: PartialEq, T> Eq for RefWithCost<'a, N, T> { } impl<'a, N: PartialOrd, T> PartialOrd for RefWithCost<'a, N, T> { #[inline] fn partial_cmp(&self, other: &RefWithCost<'a, N, T>) -> Optio...
impl<'a, N: PartialEq, T> PartialEq for RefWithCost<'a, N, T> {
random_line_split
player.rs
use graphics::math::{ Scalar, Matrix2d }; use piston_window::{ G2d }; use operation::Operation; use game::Context; pub const DEFAULT_LENGTH: Scalar = 150.0; pub const LENGTH_RANGE: Scalar = 240.0; const LENGTH_TRANS_STEP: i32 = 200; pub const DEFAULT_Y: Scalar = 0.95; const MAX_Y: Scalar = 0.95; const MIN_Y: Scalar =...
} if self.pos[1] > con.height as f64 * MAX_Y { self.pos[1] = con.height as f64 * MAX_Y; self.vec[1] = 0.; } self } pub fn press(&mut self, op: &Operation) { use operation::{ Operation, Direction, }; match op { &Operation::Move...
self.vec[1] = 0.;
random_line_split
player.rs
use graphics::math::{ Scalar, Matrix2d }; use piston_window::{ G2d }; use operation::Operation; use game::Context; pub const DEFAULT_LENGTH: Scalar = 150.0; pub const LENGTH_RANGE: Scalar = 240.0; const LENGTH_TRANS_STEP: i32 = 200; pub const DEFAULT_Y: Scalar = 0.95; const MAX_Y: Scalar = 0.95; const MIN_Y: Scalar =...
, &Operation::Move(Direction::Right) => { self.vec = [self.vec[0] + MOVE, self.vec[1]]; }, &Operation::Move(Direction::Up) => { self.vec = [self.vec[0], self.vec[1] - MOVE]; }, &Operation::Move(Direction::Down) => { ...
{ self.vec = [self.vec[0] - MOVE, self.vec[1]]; }
conditional_block
player.rs
use graphics::math::{ Scalar, Matrix2d }; use piston_window::{ G2d }; use operation::Operation; use game::Context; pub const DEFAULT_LENGTH: Scalar = 150.0; pub const LENGTH_RANGE: Scalar = 240.0; const LENGTH_TRANS_STEP: i32 = 200; pub const DEFAULT_Y: Scalar = 0.95; const MAX_Y: Scalar = 0.95; const MIN_Y: Scalar =...
(&mut self, con: &Context) -> &mut Self { self.transform(); self.pos = [self.pos[0] + self.vec[0], self.pos[1] + self.vec[1]]; for v in &mut self.vec { *v = *v * FRICTION; } if self.pos[1] < con.height as f64 * MIN_Y { self.pos[1] = con.height as f64 * MI...
update
identifier_name
player.rs
use graphics::math::{ Scalar, Matrix2d }; use piston_window::{ G2d }; use operation::Operation; use game::Context; pub const DEFAULT_LENGTH: Scalar = 150.0; pub const LENGTH_RANGE: Scalar = 240.0; const LENGTH_TRANS_STEP: i32 = 200; pub const DEFAULT_Y: Scalar = 0.95; const MAX_Y: Scalar = 0.95; const MIN_Y: Scalar =...
fn transform(&mut self) { if self.length_trans_step!= 0 { self.length_trans_step -= 1; self.length += (self.length_trans - self.length) / LENGTH_TRANS_STEP as Scalar; } } pub fn transform_length(&mut self, trans: Scalar) { self.length_trans_step = LENGTH_TR...
{ Player { pos: [(con.width / 2) as Scalar, con.height as f64 * DEFAULT_Y], vec: [0.0, 0.0], length: DEFAULT_LENGTH, length_trans: 0.0, length_trans_step: 0, } }
identifier_body
mod.rs
// Copyright 2017-2021 int08h LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
"plaintext seed value must be 32 characters long, found {}", cfg.seed().len() ); is_valid = false; } else if *cfg.kms_protection()!= KmsProtection::Plaintext && cfg.seed().len() <= SEED_LENGTH as usize { error!("KMS use enabled but seed value is too short ...
{ let mut is_valid = true; if cfg.port() == 0 { error!("server port not set: {}", cfg.port()); is_valid = false; } if cfg.interface().is_empty() { error!("'interface' is missing"); is_valid = false; } if cfg.seed().is_empty() { error!("'seed' value is m...
identifier_body
mod.rs
// Copyright 2017-2021 int08h LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
else if *cfg.kms_protection() == KmsProtection::Plaintext && cfg.seed().len()!= SEED_LENGTH as usize { error!( "plaintext seed value must be 32 characters long, found {}", cfg.seed().len() ); is_valid = false; } else if *cfg.kms_protection()!= KmsProtecti...
{ error!("'seed' value is missing"); is_valid = false; }
conditional_block
mod.rs
// Copyright 2017-2021 int08h LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
(cfg: &dyn ServerConfig) -> bool { let mut is_valid = true; if cfg.port() == 0 { error!("server port not set: {}", cfg.port()); is_valid = false; } if cfg.interface().is_empty() { error!("'interface' is missing"); is_valid = false; } if cfg.seed().is_empty() { ...
is_valid_config
identifier_name
mod.rs
// Copyright 2017-2021 int08h LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
); is_valid = false; } else if *cfg.kms_protection()!= KmsProtection::Plaintext && cfg.seed().len() <= SEED_LENGTH as usize { error!("KMS use enabled but seed value is too short to be an encrypted blob"); is_valid = false; } if cfg.batch_size() < 1 || cfg.batch_s...
{ error!( "plaintext seed value must be 32 characters long, found {}", cfg.seed().len()
random_line_split
instr_roundpd.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 roundpd_1() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDPD, operand1: Some(Direct(...
#[test] fn roundpd_4() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDPD, operand1: Some(Direct(XMM5)), operand2: Some(IndirectScaledDisplaced(RCX, Eight, 1594162194, Some(OperandSize::Xmmword), None)), operand3: Some(Literal8(99)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false...
}
random_line_split
instr_roundpd.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 roundpd_1() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDPD, operand1: Some(Direct(...
#[test] fn roundpd_3() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDPD, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM0)), operand3: Some(Literal8(2)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 58, 9, 232, 2], OperandSi...
{ run_test(&Instruction { mnemonic: Mnemonic::ROUNDPD, operand1: Some(Direct(XMM0)), operand2: Some(IndirectScaledIndexed(ECX, ECX, Two, Some(OperandSize::Xmmword), None)), operand3: Some(Literal8(44)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[...
identifier_body
instr_roundpd.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 roundpd_1() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDPD, operand1: Some(Direct(...
() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDPD, operand1: Some(Direct(XMM0)), operand2: Some(IndirectScaledIndexed(ECX, ECX, Two, Some(OperandSize::Xmmword), None)), operand3: Some(Literal8(44)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None },...
roundpd_2
identifier_name
user.rs
use aardwolf_models::user::{ email::Email, {AuthenticatedUser, UserLike}, }; use rocket::{ http::Status, outcome::IntoOutcome, request::{self, FromRequest}, {Outcome, Request, State}, }; use Pool; pub struct SignedInUser(pub AuthenticatedUser); impl<'l, 'r> FromRequest<'l, 'r> for SignedInUse...
AuthenticatedUser::get_authenticated_user_by_id(user_id, &db) .ok() .and_then(|user| { user.primary_email() .and_then(|primary_email| Email::by_id(primary_email, &db).ok()) .or_else(|| Ema...
request .cookies() .get_private("user_id") .and_then(|c| c.value().parse::<i32>().ok()) .and_then(|user_id| {
random_line_split
user.rs
use aardwolf_models::user::{ email::Email, {AuthenticatedUser, UserLike}, }; use rocket::{ http::Status, outcome::IntoOutcome, request::{self, FromRequest}, {Outcome, Request, State}, }; use Pool; pub struct
(pub AuthenticatedUser); impl<'l, 'r> FromRequest<'l, 'r> for SignedInUser { type Error = (); fn from_request(request: &'l Request<'r>) -> request::Outcome<Self, Self::Error> { let pool = request.guard::<State<Pool>>()?; let db = match pool.get() { Ok(db) => db, Err(_) ...
SignedInUser
identifier_name
instructions.rs
fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}", opcode_name(*self)) } } impl Opcode { /// Get the instruction format for this opcode. pub fn format(self) -> InstructionFormat { OPCODE_FORMAT[self as usize - 1] } /// Get the constraint descriptor for this opcode. ...
} /// Information about branch and jump instructions. pub enum BranchInfo<'a> { /// This is not a branch or jump instruction. /// This instruction will not transfer control to another EBB in the function, but it may still /// affect control flow by returning or trapping. NotABranch, /// This is a...
{ match *self { InstructionData::Call { func_ref, ref args, .. } => CallInfo::Direct(func_ref, args.as_slice(pool)), InstructionData::CallIndirect { sig_ref, ref args, .. } => CallInfo::Indirect(sig_ref, &args.as_slice(pool)[1..]), ...
identifier_body
instructions.rs
fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}", opcode_name(*self)) } } impl Opcode { /// Get the instruction format for this opcode. pub fn format(self) -> InstructionFormat { OPCODE_FORMAT[self as usize - 1] } /// Get the constraint descriptor for this opcode. ...
<'a>(&'a self, pool: &'a ValueListPool) -> BranchInfo<'a> { match *self { InstructionData::Jump { destination, ref args, .. } => BranchInfo::SingleDest(destination, args.as_slice(pool)), InstructionData::BranchInt { ...
analyze_branch
identifier_name
instructions.rs
Table}; impl<'a> Table<&'a str> for [Option<Opcode>] { fn len(&self) -> usize { self.len() } fn key(&self, idx: usize) -> Option<&'a str> { self[idx].map(opcode_name) } } match probe::<&str, [Option<Self>]>(&OPCO...
ints: BitSet8::from_range(4, 7), floats: BitSet8::from_range(0, 0), bools: BitSet8::from_range(3, 7), };
random_line_split
union-fields-2.rs
// Copyright 2016 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 u = U {}; //~ ERROR union expressions should have exactly one field let u = U { a: 0 }; // OK let u = U { a: 0, b: 1 }; //~ ERROR union expressions should have exactly one field let u = U { a: 0, b: 1, c: 2 }; //~ ERROR union expressions should have exactly one field ...
fn main() {
random_line_split
union-fields-2.rs
// Copyright 2016 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 u = U {}; //~ ERROR union expressions should have exactly one field let u = U { a: 0 }; // OK let u = U { a: 0, b: 1 }; //~ ERROR union expressions should have exactly one field let u = U { a: 0, b: 1, c: 2 }; //~ ERROR union expressions should have exactly one field ...
main
identifier_name
union-fields-2.rs
// Copyright 2016 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 u = U {}; //~ ERROR union expressions should have exactly one field let u = U { a: 0 }; // OK let u = U { a: 0, b: 1 }; //~ ERROR union expressions should have exactly one field let u = U { a: 0, b: 1, c: 2 }; //~ ERROR union expressions should have exactly one field ...
identifier_body
lib.rs
// @generated by Thrift for src/mod.thrift // This file is probably not the place you want to edit! #![recursion_limit = "100000000"] #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies)] pub use self::errors::*; pub use self::types::*; /// Thrift type definitions for `mo...
(pub(crate) ()); #[allow(dead_code)] // if serde isn't being used pub(super) fn default_for_serde_deserialize() -> OtherFields { OtherFields(()) } } } /// Error return types. pub mod errors { }
OtherFields
identifier_name
lib.rs
// @generated by Thrift for src/mod.thrift // This file is probably not the place you want to edit! #![recursion_limit = "100000000"] #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies)] pub use self::errors::*; pub use self::types::*; /// Thrift type definitions for `mo...
pub struct WithCustomDerives { pub a: ::std::primitive::bool, // This field forces `..Default::default()` when instantiating this // struct, to make code future-proof against new fields added later to // the definition in Thrift. If you don't want this, add the annotation // ...
random_line_split
lib.rs
// @generated by Thrift for src/mod.thrift // This file is probably not the place you want to edit! #![recursion_limit = "100000000"] #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies)] pub use self::errors::*; pub use self::types::*; /// Thrift type definitions for `mo...
} } /// Error return types. pub mod errors { }
{ OtherFields(()) }
identifier_body
stream.rs
use ffi::{sockaddr, socklen_t, AF_UNIX, SOCK_STREAM}; use core::{Endpoint, Protocol}; use socket_listener::SocketListener; use stream_socket::StreamSocket; use local::LocalEndpoint; use std::fmt; use std::mem; /// The stream-oriented UNIX domain protocol. /// /// # Example /// Create a server and client sockets. /// ...
fn socket_type(&self) -> i32 { SOCK_STREAM } fn protocol_type(&self) -> i32 { 0 } unsafe fn uninitialized(&self) -> Self::Endpoint { mem::uninitialized() } } impl Endpoint<LocalStream> for LocalEndpoint<LocalStream> { fn protocol(&self) -> LocalStream { Lo...
}
random_line_split
stream.rs
use ffi::{sockaddr, socklen_t, AF_UNIX, SOCK_STREAM}; use core::{Endpoint, Protocol}; use socket_listener::SocketListener; use stream_socket::StreamSocket; use local::LocalEndpoint; use std::fmt; use std::mem; /// The stream-oriented UNIX domain protocol. /// /// # Example /// Create a server and client sockets. /// ...
(&self) -> socklen_t { self.sun.size() as socklen_t } unsafe fn resize(&mut self, size: socklen_t) { debug_assert!(size <= self.capacity()); self.sun.resize(size as u8) } } impl fmt::Debug for LocalEndpoint<LocalStream> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...
size
identifier_name
stream.rs
use ffi::{sockaddr, socklen_t, AF_UNIX, SOCK_STREAM}; use core::{Endpoint, Protocol}; use socket_listener::SocketListener; use stream_socket::StreamSocket; use local::LocalEndpoint; use std::fmt; use std::mem; /// The stream-oriented UNIX domain protocol. /// /// # Example /// Create a server and client sockets. /// ...
fn as_ptr(&self) -> *const sockaddr { &self.sun as *const _ as *const _ } fn as_mut_ptr(&mut self) -> *mut sockaddr { &mut self.sun as *mut _ as *mut _ } fn capacity(&self) -> socklen_t { self.sun.capacity() as socklen_t } fn size(&self) -> socklen_t { se...
{ LocalStream }
identifier_body
bad-mid-path-type-params.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 ...
<'a>() { let _ = S::new::<isize,f64>(1, 1.0); //~^ ERROR too many type parameters provided let _ = S::<'a,isize>::new::<f64>(1, 1.0); //~^ ERROR wrong number of lifetime parameters let _: S2 = Trait::new::<isize,f64>(1, 1.0); //~^ ERROR too many type parameters provided let _: S2 = Trait:...
foo
identifier_name
bad-mid-path-type-params.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 foo<'a>() { let _ = S::new::<isize,f64>(1, 1.0); //~^ ERROR too many type parameters provided let _ = S::<'a,isize>::new::<f64>(1, 1.0); //~^ ERROR wrong number of lifetime parameters let _: S2 = Trait::new::<isize,f64>(1, 1.0); //~^ ERROR too many type parameters provided let _: S...
{ S2 { contents: x, } }
identifier_body
bad-mid-path-type-params.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 main() {}
random_line_split
mod.rs
mod err; use libc; use ::descriptor::Descriptor; pub use self::err::{MasterError, Result}; use std::io; use std::os::unix::io::{AsRawFd, RawFd}; #[derive(Debug, Copy, Clone)] pub struct Master { pty: RawFd, } impl Master { pub fn new(path: *const ::libc::c_char) -> Result<Self> { match Self::open(p...
(&self) -> Result<libc::c_int> { unsafe { match libc::grantpt(self.as_raw_fd()) { -1 => Err(MasterError::GrantptError), c => Ok(c), } } } /// Unlock the slave pty associated with the master to which fd refers. pub fn unlockpt(&self) ->...
grantpt
identifier_name
mod.rs
mod err;
pub use self::err::{MasterError, Result}; use std::io; use std::os::unix::io::{AsRawFd, RawFd}; #[derive(Debug, Copy, Clone)] pub struct Master { pty: RawFd, } impl Master { pub fn new(path: *const ::libc::c_char) -> Result<Self> { match Self::open(path, libc::O_RDWR, None) { Err(cause) =...
use libc; use ::descriptor::Descriptor;
random_line_split
bignum.rs
Ops for $ty { fn full_add(self, other: $ty, carry: bool) -> (bool, $ty) { // This cannot overflow; the output is between `0` and `2 * 2^nbits - 1`. // FIXME: will LLVM optimize this into ADC or similar? let (v, carry1) = intrinsics::add_with_ov...
assert!(noborrow); self.size = sz; self } /// Multiplies itself by a digit-sized `other` and returns its own /// mutable reference. pub fn mul_small(&mut self, other: $ty) -> &mut $name { use crate::num::big...
random_line_split
class-implement-traits.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
else { println!("Not hungry!"); return false; } } } impl noisy for cat { fn speak(&mut self) { self.meow(); } } fn cat(in_x : uint, in_y : int, in_name: String) -> cat { cat { meows: in_x, how_hungry: in_y, name: in_name.clone() } } fn make_sp...
{ println!("OM NOM NOM"); self.how_hungry -= 2; return true; }
conditional_block
class-implement-traits.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn make_speak<C:noisy>(mut c: C) { c.speak(); } pub fn main() { let mut nyan = cat(0u, 2, "nyan".to_string()); nyan.eat(); assert!((!nyan.eat())); for _ in range(1u, 10u) { make_speak(nyan.clone()); } }
{ cat { meows: in_x, how_hungry: in_y, name: in_name.clone() } }
identifier_body
class-implement-traits.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ meows : uint, how_hungry : int, name : String, } impl cat { fn meow(&mut self) { println!("Meow"); self.meows += 1u; if self.meows % 5u == 0u { self.how_hungry += 1; } } } impl cat { pub fn eat(&mut self) -> bool { if self.how_hungry > 0 ...
cat
identifier_name
class-implement-traits.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
how_hungry : int, name : String, } impl cat { fn meow(&mut self) { println!("Meow"); self.meows += 1u; if self.meows % 5u == 0u { self.how_hungry += 1; } } } impl cat { pub fn eat(&mut self) -> bool { if self.how_hungry > 0 { println...
} #[deriving(Clone)] struct cat { meows : uint,
random_line_split
tetromino.rs
use self::Rotation::*; use self::Color::*; pub static SHAPES: [Tetromino,..7] = [ Tetromino { color: Cyan, points: [[(0,2),(1,2),(2,2),(3,2)],[(2,0),(2,1),(2,2),(2,3)],[(0,2),(1,2),(2,2),(3,2)],[(2,0),(2,1),(2,2),(2,3)]] }, Tetromino { color: Blue, points: [[(0,1),(1,1),(2,1),(2,2)],[(1,0),(1,1),(0,2),(1,2)...
}, Tetromino { color: Red, points: [[(0,1),(1,1),(1,2),(2,2)],[(2,0),(1,1),(2,1),(1,2)],[(0,1),(1,1),(1,2),(2,2)],[(2,0),(1,1),(2,1),(1,2)]] } ]; pub struct Tetromino { color: Color, points: [[(uint,uint),..4],..4] } impl Tetromino { pub fn points(&'static self, rotation: Rotation) -> &'static [(uint,uint),...
random_line_split
tetromino.rs
use self::Rotation::*; use self::Color::*; pub static SHAPES: [Tetromino,..7] = [ Tetromino { color: Cyan, points: [[(0,2),(1,2),(2,2),(3,2)],[(2,0),(2,1),(2,2),(2,3)],[(0,2),(1,2),(2,2),(3,2)],[(2,0),(2,1),(2,2),(2,3)]] }, Tetromino { color: Blue, points: [[(0,1),(1,1),(2,1),(2,2)],[(1,0),(1,1),(0,2),(1,2)...
(&self) -> Rotation { match *self { R0 => R1, R1 => R2, R2 => R3, R3 => R0 } } pub fn decrease(&self) -> Rotation { match *self { R0 => R3, R1 => R0, R2 => R1, R3 => R2 } } } pub enum Color { Cyan, Blue, Orange, Yellow, Lime, Purple, Red } impl Color { pub fn as_rgba(&self) -> [f32...
increase
identifier_name
os.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 ...
(&mut self) -> u32 { self.inner.next_u32() } fn next_u64(&mut self) -> u64 { self.inner.next_u64() } fn fill_bytes(&mut self, v: &mut [u8]) { self.inner.fill_bytes(v) } } #[cfg(windows)] impl Rng for OSRng { fn next_u32(&mut self) -> u32 { let mut v = [0u8,.. 4];...
next_u32
identifier_name
os.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 ...
// assume they work when we call them. /// A random number generator that retrieves randomness straight from /// the operating system. Platform sources: /// /// - Unix-like systems (Linux, Android, Mac OSX): read directly from /// `/dev/urandom`. /// - Windows: calls `CryptGenRandom`, using the default cryptographic...
// the extern functions imported from the runtime on Windows are // implemented so that they either succeed or abort(), so we can just
random_line_split
os.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 ...
} #[cfg(unix)] impl Rng for OSRng { fn next_u32(&mut self) -> u32 { self.inner.next_u32() } fn next_u64(&mut self) -> u64 { self.inner.next_u64() } fn fill_bytes(&mut self, v: &mut [u8]) { self.inner.fill_bytes(v) } } #[cfg(windows)] impl Rng for OSRng { fn next_u3...
{ extern { fn rust_win32_rand_acquire(phProv: *mut HCRYPTPROV); } let mut hcp = 0; unsafe {rust_win32_rand_acquire(&mut hcp)}; OSRng { hcryptprov: hcp } }
identifier_body
safe.rs
use std::fmt; #[link(name = "m")] extern { fn ccosf(z: Complex) -> Complex; } // safe wrapper fn cos(z: Complex) -> Complex { unsafe { ccosf(z) } } fn main()
// Minimal implementation of single precision complex numbers #[repr(C)] #[deriving(Copy)] struct Complex { re: f32, im: f32, } impl fmt::Show for Complex { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.im < 0. { write!(f, "{}-{}i", self.re, -self.im) } else {...
{ // z = 0 + 1i let z = Complex { re: 0., im: 1. }; println!("cos({}) = {}", z, cos(z)); }
identifier_body
safe.rs
use std::fmt; #[link(name = "m")] extern { fn ccosf(z: Complex) -> Complex; } // safe wrapper fn cos(z: Complex) -> Complex { unsafe { ccosf(z) } } fn main() { // z = 0 + 1i let z = Complex { re: 0., im: 1. }; println!("cos({}) = {}", z, cos(z)); } // Minimal implementation of single precision ...
else { write!(f, "{}+{}i", self.re, self.im) } } }
{ write!(f, "{}-{}i", self.re, -self.im) }
conditional_block
safe.rs
use std::fmt; #[link(name = "m")] extern { fn ccosf(z: Complex) -> Complex; } // safe wrapper fn cos(z: Complex) -> Complex {
unsafe { ccosf(z) } } fn main() { // z = 0 + 1i let z = Complex { re: 0., im: 1. }; println!("cos({}) = {}", z, cos(z)); } // Minimal implementation of single precision complex numbers #[repr(C)] #[deriving(Copy)] struct Complex { re: f32, im: f32, } impl fmt::Show for Complex { fn fmt(&...
random_line_split
safe.rs
use std::fmt; #[link(name = "m")] extern { fn ccosf(z: Complex) -> Complex; } // safe wrapper fn cos(z: Complex) -> Complex { unsafe { ccosf(z) } } fn
() { // z = 0 + 1i let z = Complex { re: 0., im: 1. }; println!("cos({}) = {}", z, cos(z)); } // Minimal implementation of single precision complex numbers #[repr(C)] #[deriving(Copy)] struct Complex { re: f32, im: f32, } impl fmt::Show for Complex { fn fmt(&self, f: &mut fmt::Formatter) -> f...
main
identifier_name
rec-align-u32.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...
() { unsafe { let x = Outer {c8: 22, t: Inner {c64: 44}}; // Send it through the shape code let y = format!("{:?}", x); println!("align inner = {:?}", rusti::min_align_of::<Inner>()); println!("size outer = {:?}", mem::size_of::<Outer>()); println!("y = {:?}", y); ...
main
identifier_name
rec-align-u32.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...
t: Inner } mod m { pub fn align() -> usize { 4 } pub fn size() -> usize { 8 } } pub fn main() { unsafe { let x = Outer {c8: 22, t: Inner {c64: 44}}; // Send it through the shape code let y = format!("{:?}", x); println!("align inner = {:?}", rusti::min_align_of::<Inne...
c8: u8,
random_line_split
rec-align-u32.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...
} pub fn main() { unsafe { let x = Outer {c8: 22, t: Inner {c64: 44}}; // Send it through the shape code let y = format!("{:?}", x); println!("align inner = {:?}", rusti::min_align_of::<Inner>()); println!("size outer = {:?}", mem::size_of::<Outer>()); println!("y...
{ 8 }
identifier_body
time.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 ...
() -> libc::LARGE_INTEGER { static mut FREQUENCY: libc::LARGE_INTEGER = 0; static ONCE: Once = ONCE_INIT; unsafe { ONCE.call_once(|| { libc::QueryPerformanceFrequency(&mut FREQUENCY); }); FREQUENCY } } impl<'a> Sub for &'a SteadyTime { type Output = Duration; ...
frequency
identifier_name
time.rs
// 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. use libc; use ops::Sub; use time::Duration; use sync::{Once, ONCE_INIT}; pub struct Stea...
// 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
random_line_split
time.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 ...
pub fn ns(&self) -> u64 { self.t as u64 * 1_000_000_000 / frequency() as u64 } } fn frequency() -> libc::LARGE_INTEGER { static mut FREQUENCY: libc::LARGE_INTEGER = 0; static ONCE: Once = ONCE_INIT; unsafe { ONCE.call_once(|| { libc::QueryPerformanceFrequency(&mut FRE...
{ let mut t = SteadyTime { t: 0 }; unsafe { libc::QueryPerformanceCounter(&mut t.t); } t }
identifier_body
htmlappletelement.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::HTMLAppletElementBinding; use dom::bindings::codegen::Bindings::HTMLAppletEl...
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { match name { &local_name!("name") => AttrValue::from_atomic(value.into()), _ => self.super_type().unwrap().parse_plain_attribute(name, value), } } }
{ Some(self.upcast::<HTMLElement>() as &VirtualMethods) }
identifier_body
htmlappletelement.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::HTMLAppletElementBinding; use dom::bindings::codegen::Bindings::HTMLAppletEl...
(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> DomRoot<HTMLAppletElement> { Node::reflect_node(box HTMLAppletElement::new_inherited(local_name, prefix, document), document, HTMLAppletElementBinding::Wrap...
new
identifier_name
htmlappletelement.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::HTMLAppletElementBinding; use dom::bindings::codegen::Bindings::HTMLAppletEl...
prefix: Option<Prefix>, document: &Document) -> HTMLAppletElement { HTMLAppletElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document) } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalNa...
impl HTMLAppletElement { fn new_inherited(local_name: LocalName,
random_line_split
borrowck-move-out-of-vec-tail.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 ...
println!("{:?}", z); } _ => { unreachable!(); } } }
{ let x = vec!( Foo { string: "foo".to_string() }, Foo { string: "bar".to_string() }, Foo { string: "baz".to_string() } ); let x: &[Foo] = &x; match x { [_, tail..] => { match tail { [Foo { string: a }, //~ ERROR cannot move out of borrowed con...
identifier_body
borrowck-move-out-of-vec-tail.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 ...
} _ => { unreachable!(); } } let z = tail[0].clone(); println!("{:?}", z); } _ => { unreachable!(); } } }
//~^^ NOTE attempting to move value to here //~^^ NOTE and here
random_line_split
borrowck-move-out-of-vec-tail.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 ...
{ string: String } pub fn main() { let x = vec!( Foo { string: "foo".to_string() }, Foo { string: "bar".to_string() }, Foo { string: "baz".to_string() } ); let x: &[Foo] = &x; match x { [_, tail..] => { match tail { [Foo { string: a }, //...
Foo
identifier_name
borrowck-move-out-of-vec-tail.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 ...
} }
{ unreachable!(); }
conditional_block
arb.rs
use quickcheck::{Arbitrary, Gen}; use rand::{ distributions::{weighted::WeightedIndex, Distribution}, Rng, }; use crate::MultihashGeneric; /// Generates a random valid multihash. impl<const S: usize> Arbitrary for MultihashGeneric<S> { fn
<G: Gen>(g: &mut G) -> Self { // In real world lower multihash codes are more likely to happen, hence distribute them // with bias towards smaller values. let weights = [128, 64, 32, 16, 8, 4, 2, 1]; let dist = WeightedIndex::new(weights.iter()).unwrap(); let code = match dist.sa...
arbitrary
identifier_name
arb.rs
use quickcheck::{Arbitrary, Gen}; use rand::{ distributions::{weighted::WeightedIndex, Distribution}, Rng, }; use crate::MultihashGeneric; /// Generates a random valid multihash. impl<const S: usize> Arbitrary for MultihashGeneric<S> { fn arbitrary<G: Gen>(g: &mut G) -> Self { // In real world low...
let size = g.gen_range(0, S); let mut data = [0; S]; g.fill_bytes(&mut data); MultihashGeneric::wrap(code, &data[..size]).unwrap() } }
// Maximum size is S byte due to the generic.
random_line_split
arb.rs
use quickcheck::{Arbitrary, Gen}; use rand::{ distributions::{weighted::WeightedIndex, Distribution}, Rng, }; use crate::MultihashGeneric; /// Generates a random valid multihash. impl<const S: usize> Arbitrary for MultihashGeneric<S> { fn arbitrary<G: Gen>(g: &mut G) -> Self
g.fill_bytes(&mut data); MultihashGeneric::wrap(code, &data[..size]).unwrap() } }
{ // In real world lower multihash codes are more likely to happen, hence distribute them // with bias towards smaller values. let weights = [128, 64, 32, 16, 8, 4, 2, 1]; let dist = WeightedIndex::new(weights.iter()).unwrap(); let code = match dist.sample(g) { 0 => g...
identifier_body
lib.rs
#![feature(box_syntax, box_patterns)] #![feature(associated_consts)] #![feature(collections, collections_bound, btree_range)] #![feature(unicode)] extern crate libc; extern crate docopt; extern crate toml; extern crate term; extern crate rustc_serialize; extern crate collections; mod bar; pub use self::bar::Bar; pub ...
fn version() -> String { format!("bar {}", env!("CARGO_PKG_VERSION")) }
{ if let Some(mut t) = term::stderr() { let _ = t.fg(color::RED); let _ = writeln!(t, "{}", err); let _ = t.reset(); } ::std::process::exit(1) }
identifier_body
lib.rs
#![feature(box_syntax, box_patterns)] #![feature(associated_consts)] #![feature(collections, collections_bound, btree_range)] #![feature(unicode)] extern crate libc; extern crate docopt; extern crate toml; extern crate term; extern crate rustc_serialize; extern crate collections; mod bar; pub use self::bar::Bar; pub ...
<A>(usage: &str) -> A where A: Decodable { let docopt = Docopt::new(usage).unwrap() .help(true) .version(Some(::version())); docopt.decode().unwrap_or_else(|e| e.exit()) } fn handle_error(err: Error) ->! { if let Some(mut t) = term::stderr() { let _ = t.fg(color::RED); le...
decode_args
identifier_name
lib.rs
#![feature(box_syntax, box_patterns)] #![feature(associated_consts)] #![feature(collections, collections_bound, btree_range)] #![feature(unicode)] extern crate libc; extern crate docopt; extern crate toml; extern crate term; extern crate rustc_serialize; extern crate collections; mod bar; pub use self::bar::Bar; pub ...
::std::process::exit(1) } fn version() -> String { format!("bar {}", env!("CARGO_PKG_VERSION")) }
{ let _ = t.fg(color::RED); let _ = writeln!(t, "{}", err); let _ = t.reset(); }
conditional_block
lib.rs
#![feature(box_syntax, box_patterns)] #![feature(associated_consts)] #![feature(collections, collections_bound, btree_range)] #![feature(unicode)] extern crate libc; extern crate docopt; extern crate toml; extern crate term; extern crate rustc_serialize; extern crate collections; mod bar; pub use self::bar::Bar; pub ...
match (exec)(args) { Ok(..) => {}, Err(e) => handle_error(e), } } fn decode_args<A>(usage: &str) -> A where A: Decodable { let docopt = Docopt::new(usage).unwrap() .help(true) .version(Some(::version())); docopt.decode().unwrap_or_else(|e| e.exit()) } fn handle_error...
where A: Decodable, V: Encodable, { let args: A = decode_args(usage);
random_line_split
data.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 construct::ConstructionResult; use script_layout_interface::restyle_damage::RestyleDamage; use style::data::Pe...
} bitflags! { pub flags LayoutDataFlags: u8 { #[doc = "Whether a flow has been newly constructed."] const HAS_NEWLY_CONSTRUCTED_FLOW = 0x01 } }
{ PersistentLayoutData { style_data: PersistentStyleData::new(), restyle_damage: RestyleDamage::empty(), flow_construction_result: ConstructionResult::None, before_flow_construction_result: ConstructionResult::None, after_flow_construction_result: Cons...
identifier_body
data.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 construct::ConstructionResult; use script_layout_interface::restyle_damage::RestyleDamage; use style::data::Pe...
/// Description of how to account for recent style changes. pub restyle_damage: RestyleDamage, /// The current results of flow construction for this node. This is either a /// flow or a `ConstructionItem`. See comments in `construct.rs` for more /// details. pub flow_construction_result: Constr...
random_line_split