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 |
|---|---|---|---|---|
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/. */
//! Servo's compiler plugin/macro crate
//!
//! Attributes this crate provides:
//!
//! - `#[derive(DenyPublicFie... | mod unrooted_must_root;
/// Utilities for writing plugins
mod utils;
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_late_lint_pass(Box::new(unrooted_must_root::UnrootedPass::new()));
reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted);
reg.register_att... | extern crate syntax;
use rustc_plugin::Registry;
use syntax::feature_gate::AttributeType::Whitelisted;
| 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/. */
//! Servo's compiler plugin/macro crate
//!
//! Attributes this crate provides:
//!
//! - `#[derive(DenyPublicFie... | (reg: &mut Registry) {
reg.register_late_lint_pass(Box::new(unrooted_must_root::UnrootedPass::new()));
reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted);
reg.register_attribute("must_root".to_string(), Whitelisted);
}
| plugin_registrar | identifier_name |
graphviz.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) -> dot::Edges<Edge> {
debug!("constraint graph has {} edges", self.map.len());
self.map.keys().map(|e|*e).collect()
}
fn source(&self, edge: &Edge) -> Node {
let (n1, _) = constraint_to_nodes(edge);
debug!("edge {:?} has source {:?}", edge, n1);
n1
}
fn ta... | edges | identifier_name |
graphviz.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 ... |
Err(e) => {
let msg = format!("io error dumping region constraints: {}", e);
region_vars.tcx.sess.err(msg.as_slice())
}
}
}
struct ConstraintGraph<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
graph_name: String,
map: &'a FnvHashMap<Constraint, SubregionOrigin<'tcx>>... | {} | conditional_block |
graphviz.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 ... | if output_template.len() == 0 {
tcx.sess.bug("empty string provided as RUST_REGION_GRAPH");
}
if output_template.contains_char('%') {
let mut new_str = String::new();
for c in output_template.chars() {
if c == '%' {
new_str... | random_line_split | |
graphviz.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
pub type ConstraintMap<'tcx> = FnvHashMap<Constraint, SubregionOrigin<'tcx>>;
fn dump_region_constraints_to<'a, 'tcx:'a >(tcx: &'a ty::ctxt<'tcx>,
map: &ConstraintMap<'tcx>,
path: &str) -> io::IoResult<()> {
debug!("dump_re... | {
let (_, n2) = constraint_to_nodes(edge);
debug!("edge {:?} has target {:?}", edge, n2);
n2
} | identifier_body |
color.rs | // SPDX-License-Identifier: MIT
use core::fmt;
/// A color
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct Color {
pub data: u32,
}
impl Color {
/// Create a new color from RGB
pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
Color {
#[cfg(not(target_arch = "wasm32"))]
... | (start_color: Color, end_color: Color, scale: f64) -> Color {
let r = Color::interp(start_color.r(), end_color.r(), scale);
let g = Color::interp(start_color.g(), end_color.g(), scale);
let b = Color::interp(start_color.b(), end_color.b(), scale);
let a = Color::interp(start_color.a(), e... | interpolate | identifier_name |
color.rs | // SPDX-License-Identifier: MIT
use core::fmt;
/// A color
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct Color {
pub data: u32,
}
impl Color {
/// Create a new color from RGB
pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
Color {
#[cfg(not(target_arch = "wasm32"))]
... |
#[test]
fn alignment() {
assert_eq!(4, core::mem::size_of::<Color>());
assert_eq!(8, core::mem::size_of::<[Color; 2]>());
assert_eq!(12, core::mem::size_of::<[Color; 3]>());
assert_eq!(16, core::mem::size_of::<[Color; 4]>());
assert_eq!(20, core::mem::size_of::<[Color; ... | {
assert_eq!(Color::rgb(1, 2, 3), Color::rgba(1, 2, 3, 200));
assert_ne!(Color::rgb(1, 2, 3), Color::rgba(11, 2, 3, 200));
assert_eq!(Color::rgba(1, 2, 3, 200), Color::rgba(1, 2, 3, 200));
} | identifier_body |
color.rs | // SPDX-License-Identifier: MIT
use core::fmt;
/// A color
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct Color {
pub data: u32,
}
impl Color {
/// Create a new color from RGB
pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
Color {
#[cfg(not(target_arch = "wasm32"))]
... | }
fn interp(start_color: u8, end_color: u8, scale: f64) -> u8 {
((end_color as f64 - start_color as f64) * scale + start_color as f64) as u8
}
}
/// Compare two colors (Do not take care of alpha)
impl PartialEq for Color {
fn eq(&self, other: &Color) -> bool {
self.r() == other.r() && ... | let g = Color::interp(start_color.g(), end_color.g(), scale);
let b = Color::interp(start_color.b(), end_color.b(), scale);
let a = Color::interp(start_color.a(), end_color.a(), scale);
Color::rgba(r, g, b, a) | random_line_split |
build.rs | // Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
fn main() {
#[cfg(feature = "powerd")]
{
extern crate protoc_rust;
use std::env;
use std::fmt::Write as FmtWrite;
... |
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let proto_root = match env::var("SYSROOT") {
Ok(dir) => PathBuf::from(dir).join("usr/include/chromeos"),
// Make this work when typing "cargo build" in platform/crosvm/power_monitor
Err(_) => PathBuf::from("... | {
paths
.iter()
.map(|p| p.as_ref().as_os_str().to_str().unwrap())
.collect()
} | identifier_body |
build.rs | // Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
fn main() {
#[cfg(feature = "powerd")]
{
extern crate protoc_rust;
use std::env;
use std::fmt::Write as FmtWrite;
... | <P: AsRef<Path>>(paths: &[P]) -> Vec<&str> {
paths
.iter()
.map(|p| p.as_ref().as_os_str().to_str().unwrap())
.collect()
}
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let proto_root = match env::var("SYSROOT") {
... | paths_to_strs | identifier_name |
build.rs | // Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
| {
extern crate protoc_rust;
use std::env;
use std::fmt::Write as FmtWrite;
use std::fs;
use std::io::Write;
use std::path::{Path, PathBuf};
fn paths_to_strs<P: AsRef<Path>>(paths: &[P]) -> Vec<&str> {
paths
.iter()
.... | fn main() {
#[cfg(feature = "powerd")] | random_line_split |
method.rs | struct Circle {
x: f64,
y: f64,
radius: f64,
}
impl Circle {
fn area(&self) -> f64 {
std::f64::consts::PI * (self.radius * self.radius)
}
fn reference(&self) {
println!("taking self by reference!");
}
fn mutable_reference(&mut self) {
println!("... |
let c = Circle::new(0.0, 0.0, 2.0);
} | random_line_split | |
method.rs | struct Circle {
x: f64,
y: f64,
radius: f64,
}
impl Circle {
fn area(&self) -> f64 {
std::f64::consts::PI * (self.radius * self.radius)
}
fn reference(&self) {
println!("taking self by reference!");
}
fn mutable_reference(&mut self) {
println!("... |
// Ассоциированная функция. Не имеет параметра self,
// вызывается через ::
// В других языках это "статичная" функция
fn new(x: f64, y: f64, radius: f64) -> Circle {
Circle {
x: x,
y: y,
radius: radius,
}
}
}
fn main() {
let ... | {
Circle { x: self.x, y: self.y, radius: self.radius + increment }
} | identifier_body |
method.rs | struct Circle {
x: f64,
y: f64,
radius: f64,
}
impl Circle {
fn area(&self) -> f64 {
std::f64::consts::PI * (self.radius * self.radius)
}
fn reference(&self) {
println!("taking self by reference!");
}
fn mutable_reference(&mut self) {
println!("... | ));
let d = c.grow(2.0).area();
println!("{}", d);
let c = Circle::new(0.0, 0.0, 2.0);
}
| rea( | identifier_name |
lib.rs | extern crate cgmath;
#[macro_use]
extern crate puck_core;
extern crate alto;
extern crate lewton;
extern crate time;
extern crate notify;
extern crate rand;
extern crate image;
#[macro_use]
extern crate gfx;
extern crate gfx_device_gl;
extern crate gfx_window_glutin;
extern crate glutin;
extern crate rayon;
extern c... | fn from(val: io::Error) -> PuckError {
PuckError::IO(val)
}
}
#[derive(Copy, Clone)]
pub struct RenderTick {
pub n: u64,
pub accu_alpha: f64, // percentage of a frame that has accumulated
pub tick_rate: u64, // per second
} | }
impl From<io::Error> for PuckError { | random_line_split |
lib.rs | extern crate cgmath;
#[macro_use]
extern crate puck_core;
extern crate alto;
extern crate lewton;
extern crate time;
extern crate notify;
extern crate rand;
extern crate image;
#[macro_use]
extern crate gfx;
extern crate gfx_device_gl;
extern crate gfx_window_glutin;
extern crate glutin;
extern crate rayon;
extern c... | {
pub n: u64,
pub accu_alpha: f64, // percentage of a frame that has accumulated
pub tick_rate: u64, // per second
}
| RenderTick | identifier_name |
tac.rs | #![crate_name = "uu_tac"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alex Lyon <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;
#[macro_use]
extern crate uucore;
use... | Ok(m) => m,
Err(f) => crash!(1, "{}", f),
};
if matches.opt_present("help") {
let msg = format!(
"{0} {1}
Usage:
{0} [OPTION]... [FILE]...
Write each file to standard output, last line first.",
NAME, VERSION
);
print!("{}", opts.usage(&msg));
... | );
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..]) { | random_line_split |
tac.rs | #![crate_name = "uu_tac"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alex Lyon <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;
#[macro_use]
extern crate uucore;
use... | (args: Vec<String>) -> i32 {
let mut opts = getopts::Options::new();
opts.optflag(
"b",
"before",
"attach the separator before instead of after",
);
opts.optflag(
"r",
"regex",
"interpret the sequence as a regular expression (NOT IMPLEMENTED)",
);
... | uumain | identifier_name |
tac.rs | #![crate_name = "uu_tac"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alex Lyon <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;
#[macro_use]
extern crate uucore;
use... | opts.optflag("V", "version", "output version information and exit");
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(f) => crash!(1, "{}", f),
};
if matches.opt_present("help") {
let msg = format!(
"{0} {1}
Usage:
{0} [OPTION]... [FILE]...
Write each... | {
let mut opts = getopts::Options::new();
opts.optflag(
"b",
"before",
"attach the separator before instead of after",
);
opts.optflag(
"r",
"regex",
"interpret the sequence as a regular expression (NOT IMPLEMENTED)",
);
opts.optopt(
"s",
... | identifier_body |
euler.rs | use super::matrix4::Matrix4;
use super::vector3::Vector3;
use super::quaternion::Quaternion;
use super::math_static::clamp;
use std::mem;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum RotationOrders {
XYZ,
YZX,
ZXY,
XZY,
YXZ,
ZYX,
}
impl From<u8> for RotationOrders {
fn from(t:u8) -> RotationOrders ... | }
pub fn copy(&mut self, euler: &Euler) {
self.x = euler.x;
self.y = euler.y;
self.z = euler.z;
self.order = euler.order;
}
pub fn set_from_rotation_matrix(&mut self, m: &Matrix4, order: Option<RotationOrders>) {
let te = m.get_elements();
let m11 = te[ 0 ];
let m12 = te[ 4 ];
let m13 = te[ 8 ];
... | self.y = y;
self.z = z;
self.order = order; | random_line_split |
euler.rs | use super::matrix4::Matrix4;
use super::vector3::Vector3;
use super::quaternion::Quaternion;
use super::math_static::clamp;
use std::mem;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum RotationOrders {
XYZ,
YZX,
ZXY,
XZY,
YXZ,
ZYX,
}
impl From<u8> for RotationOrders {
fn from(t:u8) -> RotationOrders ... |
}
pub fn copy_to_array(&self, array: &mut [f32], offset: Option<usize>) {
let offset = match offset {
Some(off) => off,
None => 0usize,
};
array[ offset ] = self.x;
array[ offset + 1 ] = self.y;
array[ offset + 2 ] = self.z;
// I know this is bad, but its necessary to get api compatibility
array... | {
self.order = RotationOrders::from(array[3] as u8);
} | conditional_block |
euler.rs | use super::matrix4::Matrix4;
use super::vector3::Vector3;
use super::quaternion::Quaternion;
use super::math_static::clamp;
use std::mem;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum RotationOrders {
XYZ,
YZX,
ZXY,
XZY,
YXZ,
ZYX,
}
impl From<u8> for RotationOrders {
fn from(t:u8) -> RotationOrders ... | (&mut self, q: &Quaternion, order: Option<RotationOrders>) {
let mut matrix = Matrix4::new();
matrix.make_rotation_from_quaternion(q);
self.set_from_rotation_matrix(&matrix, order);
}
pub fn set_from_vector3(&mut self, v: &Vector3, order: Option<RotationOrders>) {
let order = match order {
Some(ord) => or... | set_from_quaternion | identifier_name |
euler.rs | use super::matrix4::Matrix4;
use super::vector3::Vector3;
use super::quaternion::Quaternion;
use super::math_static::clamp;
use std::mem;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum RotationOrders {
XYZ,
YZX,
ZXY,
XZY,
YXZ,
ZYX,
}
impl From<u8> for RotationOrders {
fn from(t:u8) -> RotationOrders ... | if m13.abs() < 0.99999f32 {
self.x = (-m23).atan2(m33);
self.z = (-m12).atan2(m11);
} else {
self.x = m32.atan2(m22);
self.z = 0.0f32;
}
},
RotationOrders::YXZ => {
self.x = (-clamp(m23, -1.0, 1.0)).asin();
if m23.abs() < 0.99999f32 {
self.y = m13.atan2(m33);
sel... | {
let te = m.get_elements();
let m11 = te[ 0 ];
let m12 = te[ 4 ];
let m13 = te[ 8 ];
let m21 = te[ 1 ];
let m22 = te[ 5 ];
let m23 = te[ 9 ];
let m31 = te[ 2 ];
let m32 = te[ 6 ];
let m33 = te[ 10 ];
let order = match order {
Some(ord) => ord,
None => self.order,
};
match order {
Ro... | identifier_body |
helpers.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | {
let keys = one.keys();
for key in keys.keys() {
assert_eq!(one.get(&key).unwrap(), two.get(&key).unwrap());
}
} | identifier_body | |
helpers.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | ;
for (k, v) in map.make_with(seed) {
trie.insert(&k, &v).unwrap();
}
}
}
/// Compare two state dbs.
pub fn compare_dbs(one: &HashDB, two: &HashDB) {
let keys = one.keys();
for key in keys.keys() {
assert_eq!(one.get(&key).unwrap(), two.get(&key).unwrap());
}
}
| {
SecTrieDBMut::from_existing(&mut db, root).unwrap()
} | conditional_block |
helpers.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | use rand::Rng;
use util::DBValue;
use util::hash::{FixedHash, H256};
use util::hashdb::HashDB;
use util::trie::{Alphabet, StandardMap, SecTrieDBMut, TrieMut, ValueMode};
use util::trie::{TrieDB, TrieDBMut, Trie};
use util::sha3::SHA3_NULL_RLP;
// the proportion of accounts we will alter each tick.
const ACCOUNT_CHURN... | //! which can be queried before and after a full snapshot/restore cycle.
use basic_account::BasicAccount;
use account_db::AccountDBMut; | random_line_split |
helpers.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | (&self) -> H256 {
self.state_root
}
}
/// Fill the storage of an account.
pub fn fill_storage(mut db: AccountDBMut, root: &mut H256, seed: &mut H256) {
let map = StandardMap {
alphabet: Alphabet::All,
min_key: 6,
journal_key: 6,
value_mode: ValueMode::Random,
count: 100,
};
{
let mut trie = if *root ... | state_root | identifier_name |
main.rs | extern crate xmz_mod_touch_test_tool;
use xmz_mod_touch_test_tool::errors::*;
fn run() -> Result<()> |
fn main() {
println!("{} Version: {}\n",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"));
if let Err(ref e) = run() {
use ::std::io::Write;
let stderr = &mut ::std::io::stderr();
let errmsg = "Error writing to stderr";
writeln!(stderr, "error: {}", e).exp... | {
xmz_mod_touch_test_tool::gui::gtk3::launch();
Ok(())
} | identifier_body |
main.rs | extern crate xmz_mod_touch_test_tool;
use xmz_mod_touch_test_tool::errors::*;
fn | () -> Result<()> {
xmz_mod_touch_test_tool::gui::gtk3::launch();
Ok(())
}
fn main() {
println!("{} Version: {}\n",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"));
if let Err(ref e) = run() {
use ::std::io::Write;
let stderr = &mut ::std::io::stderr();
let... | run | identifier_name |
main.rs | extern crate xmz_mod_touch_test_tool;
use xmz_mod_touch_test_tool::errors::*;
fn run() -> Result<()> {
xmz_mod_touch_test_tool::gui::gtk3::launch();
Ok(())
}
fn main() {
println!("{} Version: {}\n",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"));
if let Err(ref e) = run() {
... |
::std::process::exit(1);
}
}
| {
writeln!(stderr, "backtrace: {:?}", backtrace).expect(errmsg);
} | conditional_block |
main.rs | extern crate xmz_mod_touch_test_tool;
use xmz_mod_touch_test_tool::errors::*;
fn run() -> Result<()> {
xmz_mod_touch_test_tool::gui::gtk3::launch();
Ok(()) | env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"));
if let Err(ref e) = run() {
use ::std::io::Write;
let stderr = &mut ::std::io::stderr();
let errmsg = "Error writing to stderr";
writeln!(stderr, "error: {}", e).expect(errmsg);
for e in e.iter().skip(1) ... | }
fn main() {
println!("{} Version: {}\n", | random_line_split |
cstore_impl.rs | cdata.get_generics(def_id.index, tcx.sess) }
explicit_predicates_of => { cdata.get_explicit_predicates(def_id.index, tcx) }
inferred_outlives_of => { cdata.get_inferred_outlives(def_id.index, tcx) }
super_predicates_of => { cdata.get_super_predicates(def_id.index, tcx) }
explicit_item_bounds => { cdata... | {
self.get_crate_data(def.krate).def_path(def.index)
} | identifier_body | |
cstore_impl.rs | ::query::query_values::$name<$lt> {
let _prof_timer =
$tcx.prof.generic_activity(concat!("metadata_decode_entry_", stringify!($name)));
#[allow(unused_variables)]
let ($def_id, $other) = def_id_arg.into_args();
assert!(!$def_id.is_loca... | })
}
pub fn visibility_untracked(&self, def: DefId) -> Visibility {
self.get_crate_data(def.krate).get_visibility(def.index)
}
pub fn item_children_untracked(
&self,
def_id: DefId,
sess: &Session,
) -> Vec<Export<hir::HirId>> {
let mut result = vec![... | random_line_split | |
cstore_impl.rs | id.index, tcx) }
explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
adt_destructor => {
let _ = cdata;
tcx.calculate_dtor(def_id, |_,_| Ok(()))
... | def_path_hash_to_def_id | identifier_name | |
issue-9957.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
pub use std::bool; //~ ERROR: imports in functions are never reachable
priv use std::bool; //~ ERROR: unnecessary visibility qualifier
use std::bool;
} | identifier_body | |
issue-9957.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
pub use std::bool; //~ ERROR: imports in functions are never reachable
priv use std::bool; //~ ERROR: unnecessary visibility qualifier
use std::bool;
}
| main | identifier_name |
issue-9957.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 ... | // except according to those terms.
pub extern crate std; //~ ERROR: `pub` visibility is not allowed
priv extern crate std; //~ ERROR: unnecessary visibility qualifier
extern crate std;
pub use std::bool;
priv use std::bool; //~ ERROR: unnecessary visibility qualifier
use std::bool;
fn main() {
pub use std::bool... | // option. This file may not be copied, modified, or distributed | random_line_split |
assign-to-static-within-other-static.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 ... | () {}
| main | identifier_name |
assign-to-static-within-other-static.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 | |
assign-to-static-within-other-static.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 ... | static mut FOO: u32 = 42;
static BOO: () = unsafe {
FOO = 5; //~ ERROR cannot mutate statics in the initializer of another static
};
fn main() {} | #![feature(const_raw_ptr_deref)]
#![feature(const_let)]
use std::cell::UnsafeCell;
| random_line_split |
simple.rs | extern crate escposify;
extern crate tempfile;
use std::io;
use escposify::device::File;
use escposify::printer::Printer;
use tempfile::NamedTempFileOptions;
fn main() -> io::Result<()> | {
let tempf = NamedTempFileOptions::new().create().unwrap();
let file = File::from(tempf);
let mut printer = Printer::new(file, None, None);
printer
.chain_font("C")?
.chain_align("lt")?
.chain_style("bu")?
.chain_size(0, 0)?
.chain_text("The quick brown fox jum... | identifier_body | |
simple.rs | extern crate escposify;
extern crate tempfile;
use std::io;
use escposify::device::File;
use escposify::printer::Printer;
| let tempf = NamedTempFileOptions::new().create().unwrap();
let file = File::from(tempf);
let mut printer = Printer::new(file, None, None);
printer
.chain_font("C")?
.chain_align("lt")?
.chain_style("bu")?
.chain_size(0, 0)?
.chain_text("The quick brown fox jumps over... | use tempfile::NamedTempFileOptions;
fn main() -> io::Result<()> { | random_line_split |
simple.rs | extern crate escposify;
extern crate tempfile;
use std::io;
use escposify::device::File;
use escposify::printer::Printer;
use tempfile::NamedTempFileOptions;
fn | () -> io::Result<()> {
let tempf = NamedTempFileOptions::new().create().unwrap();
let file = File::from(tempf);
let mut printer = Printer::new(file, None, None);
printer
.chain_font("C")?
.chain_align("lt")?
.chain_style("bu")?
.chain_size(0, 0)?
.chain_text("The qui... | main | identifier_name |
sepcomp-lib-lto.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 ... | {
assert_eq!(one(), 1);
assert_eq!(two(), 2);
assert_eq!(three(), 3);
} | identifier_body | |
sepcomp-lib-lto.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
// Chec... | // | random_line_split |
sepcomp-lib-lto.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 ... | () {
assert_eq!(one(), 1);
assert_eq!(two(), 2);
assert_eq!(three(), 3);
}
| main | identifier_name |
self-without-lifetime-constraint.rs | use std::error::Error;
use std::fmt;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ValueRef<'a> {
Null,
Integer(i64),
Real(f64),
Text(&'a [u8]),
Blob(&'a [u8]),
}
impl<'a> ValueRef<'a> {
pub fn as_str(&self) -> FromSqlResult<&'a str, &'a &'a str> {
match *self {
ValueRe... | (value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
//~^ ERROR `impl` item signature doesn't match `trait` item signature
value.as_str()
}
}
pub fn main() {
println!("{}", "Hello World");
}
| column_result | identifier_name |
self-without-lifetime-constraint.rs | use std::error::Error;
use std::fmt;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ValueRef<'a> {
Null,
Integer(i64),
Real(f64),
Text(&'a [u8]),
Blob(&'a [u8]),
}
impl<'a> ValueRef<'a> {
pub fn as_str(&self) -> FromSqlResult<&'a str, &'a &'a str> |
}
#[derive(Debug)]
#[non_exhaustive]
pub enum FromSqlError {
InvalidType
}
impl fmt::Display for FromSqlError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "InvalidType")
}
}
impl Error for FromSqlError {}
pub type FromSqlResult<T, K> = Result<(T, K), FromSqlError>;
pu... | {
match *self {
ValueRef::Text(t) => {
std::str::from_utf8(t).map_err(|_| FromSqlError::InvalidType).map(|x| (x, &x))
}
_ => Err(FromSqlError::InvalidType),
}
} | identifier_body |
self-without-lifetime-constraint.rs | use std::error::Error;
use std::fmt;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ValueRef<'a> {
Null,
Integer(i64),
Real(f64),
Text(&'a [u8]),
Blob(&'a [u8]),
}
impl<'a> ValueRef<'a> {
pub fn as_str(&self) -> FromSqlResult<&'a str, &'a &'a str> {
match *self {
ValueRe... | }
pub fn main() {
println!("{}", "Hello World");
} | random_line_split | |
mod.rs | // The MIT License (MIT)
//
// Copyright (c) 2016-2022 Ivan Dejanovic
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to ... | pub ld: &'static str,
pub st: &'static str,
pub jmp: &'static str,
pub jgr: &'static str,
pub jge: &'static str,
pub jeq: &'static str,
pub jne: &'static str,
pub jle: &'static str,
pub jls: &'static str,
}
pub const INSTRUCTIONS: Instructions = Instructions {
halt: "HALT",
... | pub con: &'static str,
pub push: &'static str,
pub pop: &'static str, | random_line_split |
mod.rs | // The MIT License (MIT)
//
// Copyright (c) 2016-2022 Ivan Dejanovic
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to ... | {
pub halt: &'static str,
pub in_n: &'static str,
pub out_n: &'static str,
pub in_s: &'static str,
pub out_s: &'static str,
pub add: &'static str,
pub sub: &'static str,
pub mul: &'static str,
pub div: &'static str,
pub con: &'static str,
pub push: &'static str,
pub pop:... | Instructions | identifier_name |
particle.rs | use geometry::{Advance, Position, Vector};
use geometry_derive::{Advance, Position};
/// A model representing a particle
///
/// Particles are visible objects that have a time to live and move around
/// in a given direction until their time is up. They are spawned when the
/// player or an enemy is killed
#[derive(Ad... | (&mut self, elapsed_time: f32) {
self.ttl -= elapsed_time;
let speed = 500.0 * self.ttl * self.ttl;
self.advance(elapsed_time * speed);
}
}
| update | identifier_name |
particle.rs | use geometry::{Advance, Position, Vector};
use geometry_derive::{Advance, Position};
/// A model representing a particle
///
/// Particles are visible objects that have a time to live and move around
/// in a given direction until their time is up. They are spawned when the
/// player or an enemy is killed
#[derive(Ad... | impl Particle {
/// Create a particle with the given vector and time to live in seconds
pub fn new(vector: Vector, ttl: f32) -> Particle {
Particle {
vector: vector,
ttl: ttl,
}
}
/// Update the particle
pub fn update(&mut self, elapsed_time: f32) {
s... | pub vector: Vector,
pub ttl: f32,
}
| random_line_split |
particle.rs | use geometry::{Advance, Position, Vector};
use geometry_derive::{Advance, Position};
/// A model representing a particle
///
/// Particles are visible objects that have a time to live and move around
/// in a given direction until their time is up. They are spawned when the
/// player or an enemy is killed
#[derive(Ad... |
}
| {
self.ttl -= elapsed_time;
let speed = 500.0 * self.ttl * self.ttl;
self.advance(elapsed_time * speed);
} | identifier_body |
main.rs | /*
Este programa genera soluciones al azar para el problema de las reinas
*/
extern crate rand;
use rand::Rng;
use rand::distributions::{IndependentSample, Range};
use std::io;
use std::io::prelude::*;
fn pause() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
// We want the cursor to ... | {
vec.clear();
for _ in 0..8 {
vec.push((step.ind_sample(&mut rng),step.ind_sample(&mut rng)));
}
} | identifier_body | |
main.rs | /*
Este programa genera soluciones al azar para el problema de las reinas
*/
extern crate rand;
use rand::Rng;
use rand::distributions::{IndependentSample, Range};
use std::io;
use std::io::prelude::*;
fn pause() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
// We want the cursor to ... | (vec : & Vec<(isize,isize)> ) -> isize {
let mut collisions = 0;
for a in 0..8 {
for b in a+1.. 8 {
if vec[a].0 == vec[b].0 {
collisions += 1;
}
if vec[a].1 == vec[b].1 {
collisions += 1;
}
if ( vec[a].0 - vec[... | get_collisions | identifier_name |
main.rs | /*
Este programa genera soluciones al azar para el problema de las reinas
*/
extern crate rand;
use rand::Rng;
use rand::distributions::{IndependentSample, Range};
use std::io;
use std::io::prelude::*;
fn pause() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
// We want the cursor to ... |
if ( vec[a].0 - vec[b].1 ).abs() == ( vec[a].1 - vec[b].0 ).abs() {
collisions += 1;
}
}
}
collisions
}
fn get_random_vector(vec: & mut Vec<(isize,isize)>, step: & Range<isize>, mut rng: & mut Rng ) {
vec.clear();
for _ in 0..8 {
vec.push((step.in... | {
collisions += 1;
} | conditional_block |
main.rs | /*
Este programa genera soluciones al azar para el problema de las reinas
*/
extern crate rand;
use rand::Rng;
use rand::distributions::{IndependentSample, Range};
use std::io;
use std::io::prelude::*;
fn pause() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
// We want the cursor to ... | fn main() {
let rep = 10000;
let mut vector_of_queens = Vec::<(isize,isize)>::with_capacity(8);
let step = Range::new(1, 9);
let mut rng = rand::thread_rng();
get_random_vector(& mut vector_of_queens, & step, & mut rng);
let mut collisions = get_collisions( & vector_of_queens );
let mut... | // Read a single byte and discard
let _ = stdin.read(&mut [0u8]).unwrap();
}
| random_line_split |
build.rs | /*!
The build script has two primary jobs:
1. Do code generation. Currently, this consists of turning `data/winver.json` into an appropriate `enum`.
2. Tell Cargo to link against Clang.
*/
extern crate itertools;
extern crate serde;
use std::env;
use std::fs;
use std::io;
use std::io::prelude::*;
use std::path::{Pa... | (s: &str) -> u32 {
if s.starts_with("0x") || s.starts_with("0X") {
u32::from_str_radix(&s[2..], 16).unwrap()
} else {
s.parse().unwrap()
}
}
fn read_file_str<P>(path: P) -> String
where P: AsRef<Path> + ::std::fmt::Debug {
let mut s = String::new();
let _ = fs::File::open(&path).ok(... | parse_int | identifier_name |
build.rs | /*!
The build script has two primary jobs:
1. Do code generation. Currently, this consists of turning `data/winver.json` into an appropriate `enum`.
2. Tell Cargo to link against Clang.
*/
extern crate itertools;
extern crate serde;
use std::env;
use std::fs;
use std::io;
use std::io::prelude::*;
use std::path::{Pa... | let reverse: HashMap<u32, &str> = primary.iter().map(|(k, v)| (*v, *k)).collect();
assert_eq!(primary.len(), reverse.len());
// Make the map of non-primary aliases.
let mut aliases: Vec<(&str, u32)> = root.iter().filter(|&(k, _)| k.starts_with("*"))
.map(|(k, v)| (&k[1..], *v)).collect();
al... | {
use std::collections::HashMap;
use serde::json;
println!("# gen_winver_enum(..)");
let root: HashMap<String, String> = json::from_str(json_str).unwrap();
// First, parse those version numbers!
let root: HashMap<_, u32> = root.into_iter()
.map(|(k, v)| (k, parse_int(&v)))
... | identifier_body |
build.rs | /*!
The build script has two primary jobs:
1. Do code generation. Currently, this consists of turning `data/winver.json` into an appropriate `enum`.
2. Tell Cargo to link against Clang.
*/
extern crate itertools;
extern crate serde;
use std::env;
use std::fs;
use std::io;
use std::io::prelude::*;
use std::path::{Pa... | else {
s.parse().unwrap()
}
}
fn read_file_str<P>(path: P) -> String
where P: AsRef<Path> + ::std::fmt::Debug {
let mut s = String::new();
let _ = fs::File::open(&path).ok().expect(&format!("open {:?}", path))
.read_to_string(&mut s).ok().expect(&format!("read from {:?}", path));
s
}
f... | {
u32::from_str_radix(&s[2..], 16).unwrap()
} | conditional_block |
build.rs | 1. Do code generation. Currently, this consists of turning `data/winver.json` into an appropriate `enum`.
2. Tell Cargo to link against Clang.
*/
extern crate itertools;
extern crate serde;
use std::env;
use std::fs;
use std::io;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use itertools::Itertools;
///... | /*!
The build script has two primary jobs:
| random_line_split | |
main.rs | fn main() {
println!("-459.67 F == {}", fht_to_celsius(-459.67));
let mut input = String::new();
let n = {
println!("Print fib(n) for n: (choose 1-90, I'm not using bigints)");
std::io::stdin().read_line(&mut input)
.expect("Readline failed");
match input.trim().parse() ... |
fn fib_no_brute(n: u32) -> u64 {
if n == 0 || n == 1 {
return n as u64;
}
let mut tmp0 = 0;
let mut tmp1 = 1;
let mut result = 0;
for _ in 2..n {
result = tmp0 + tmp1;
tmp0 = tmp1;
tmp1 = result;
}
return result;
} | if n == 0 || n == 1 {
return n;
}
fib(n-1) + fib(n-2)
} | random_line_split |
main.rs | fn main() {
println!("-459.67 F == {}", fht_to_celsius(-459.67));
let mut input = String::new();
let n = {
println!("Print fib(n) for n: (choose 1-90, I'm not using bigints)");
std::io::stdin().read_line(&mut input)
.expect("Readline failed");
match input.trim().parse() ... |
fn fib(n: u32) -> u32 {
if n == 0 || n == 1 {
return n;
}
fib(n-1) + fib(n-2)
}
fn fib_no_brute(n: u32) -> u64 {
if n == 0 || n == 1 {
return n as u64;
}
let mut tmp0 = 0;
let mut tmp1 = 1;
let mut result = 0;
for _ in 2..n {
result = tmp0 + tmp1;
t... | {
(fahrenheit - 32.0) * 5.0 / 9.0
} | identifier_body |
main.rs | fn main() {
println!("-459.67 F == {}", fht_to_celsius(-459.67));
let mut input = String::new();
let n = {
println!("Print fib(n) for n: (choose 1-90, I'm not using bigints)");
std::io::stdin().read_line(&mut input)
.expect("Readline failed");
match input.trim().parse() ... |
let mut tmp0 = 0;
let mut tmp1 = 1;
let mut result = 0;
for _ in 2..n {
result = tmp0 + tmp1;
tmp0 = tmp1;
tmp1 = result;
}
return result;
}
| {
return n as u64;
} | conditional_block |
main.rs | fn main() {
println!("-459.67 F == {}", fht_to_celsius(-459.67));
let mut input = String::new();
let n = {
println!("Print fib(n) for n: (choose 1-90, I'm not using bigints)");
std::io::stdin().read_line(&mut input)
.expect("Readline failed");
match input.trim().parse() ... | (n: u32) -> u64 {
if n == 0 || n == 1 {
return n as u64;
}
let mut tmp0 = 0;
let mut tmp1 = 1;
let mut result = 0;
for _ in 2..n {
result = tmp0 + tmp1;
tmp0 = tmp1;
tmp1 = result;
}
return result;
}
| fib_no_brute | identifier_name |
x86.rs | pub type sig_atomic_t = ::int_t;
pub type sigset_t = [u32; 32];
#[repr(C)]
#[derive(Copy)]
pub struct siginfo_t {
pub si_signo: ::int_t,
pub si_errno: ::int_t,
pub si_code: ::int_t,
_sifields: [u32; 29],
}
new!(siginfo_t);
#[repr(C)]
#[derive(Copy)]
pub struct sigval {
_data: [u32; 1usize],
}
new!(s... | (&mut self) -> &mut ::int_t {
unsafe { ::std::mem::transmute(self) }
}
pub fn sival_ptr_mut(&mut self) -> &mut *mut ::void_t {
unsafe { ::std::mem::transmute(self) }
}
}
#[repr(C)]
#[derive(Copy)]
pub struct sigevent {
pub sigev_value: sigval,
pub sigev_signo: ::int_t,
pub sigev... | sival_int_mut | identifier_name |
x86.rs | pub type sig_atomic_t = ::int_t;
pub type sigset_t = [u32; 32];
#[repr(C)]
#[derive(Copy)]
pub struct siginfo_t {
pub si_signo: ::int_t,
pub si_errno: ::int_t,
pub si_code: ::int_t,
_sifields: [u32; 29],
}
new!(siginfo_t);
#[repr(C)]
#[derive(Copy)]
pub struct sigval {
_data: [u32; 1usize],
}
new!(s... |
pub fn sival_int_mut(&mut self) -> &mut ::int_t {
unsafe { ::std::mem::transmute(self) }
}
pub fn sival_ptr_mut(&mut self) -> &mut *mut ::void_t {
unsafe { ::std::mem::transmute(self) }
}
}
#[repr(C)]
#[derive(Copy)]
pub struct sigevent {
pub sigev_value: sigval,
pub sigev_sig... | {
unsafe { ::std::mem::transmute(self) }
} | identifier_body |
x86.rs | pub type sig_atomic_t = ::int_t;
pub type sigset_t = [u32; 32];
#[repr(C)]
#[derive(Copy)]
pub struct siginfo_t {
pub si_signo: ::int_t,
pub si_errno: ::int_t,
pub si_code: ::int_t,
_sifields: [u32; 29],
}
new!(siginfo_t);
#[repr(C)]
#[derive(Copy)]
pub struct sigval {
_data: [u32; 1usize],
}
new!(s... | pub struct mcontext_t {
pub gregs: [::int_t; 19],
pub fpregs: [u32; 28],
pub oldmask: ::ulong_t,
pub cr2: ::ulong_t,
}
new!(mcontext_t);
#[repr(C)]
#[derive(Copy)]
pub struct ucontext {
pub uc_flags: ::ulong_t,
pub uc_link: *mut ucontext,
pub uc_stack: stack_t,
pub uc_mcontext: mcontext_... | #[repr(C)]
#[derive(Copy)] | random_line_split |
lib.rs | /*
* Copyright (C) 2015 Benjamin Fry <benjaminfry@me.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.org/licenses/LICENSE-2.0
*
* Unless required by ap... |
mod tls_client_stream;
pub mod tls_server;
mod tls_stream;
pub use self::tls_client_stream::{TlsClientStream, TlsClientStreamBuilder};
pub use self::tls_stream::{tls_stream_from_existing_tls_stream, TlsStream, TlsStreamBuilder}; | extern crate tokio_openssl;
extern crate trust_dns_proto; | random_line_split |
lcg128xsl64.rs | use rand_core::{RngCore, SeedableRng};
use rand_pcg::{Lcg128Xsl64, Pcg64};
#[test]
fn test_lcg128xsl64_advancing() {
for seed in 0..20 {
let mut rng1 = Lcg128Xsl64::seed_from_u64(seed);
let mut rng2 = rng1.clone();
for _ in 0..20 {
rng1.next_u64();
}
rng2.advance... | () {
use bincode;
use std::io::{BufReader, BufWriter};
let mut rng = Lcg128Xsl64::seed_from_u64(0);
let buf: Vec<u8> = Vec::new();
let mut buf = BufWriter::new(buf);
bincode::serialize_into(&mut buf, &rng).expect("Could not serialize");
let buf = buf.into_inner().unwrap();
let mut rea... | test_lcg128xsl64_serde | identifier_name |
lcg128xsl64.rs | use rand_core::{RngCore, SeedableRng};
use rand_pcg::{Lcg128Xsl64, Pcg64};
#[test]
fn test_lcg128xsl64_advancing() {
for seed in 0..20 {
let mut rng1 = Lcg128Xsl64::seed_from_u64(seed);
let mut rng2 = rng1.clone();
for _ in 0..20 {
rng1.next_u64();
}
rng2.advance... | } | random_line_split | |
lcg128xsl64.rs | use rand_core::{RngCore, SeedableRng};
use rand_pcg::{Lcg128Xsl64, Pcg64};
#[test]
fn test_lcg128xsl64_advancing() {
for seed in 0..20 {
let mut rng1 = Lcg128Xsl64::seed_from_u64(seed);
let mut rng2 = rng1.clone();
for _ in 0..20 {
rng1.next_u64();
}
rng2.advance... |
#[test]
fn test_lcg128xsl64_true_values() {
// Numbers copied from official test suite (C version).
let mut rng = Lcg128Xsl64::new(42, 54);
let mut results = [0u64; 6];
for i in results.iter_mut() {
*i = rng.next_u64();
}
let expected: [u64; 6] = [
0x86b1da1d72062b68,
... | {
// Test that various construction techniques produce a working RNG.
#[rustfmt::skip]
let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16,
17,18,19,20, 21,22,23,24, 25,26,27,28, 29,30,31,32];
let mut rng1 = Lcg128Xsl64::from_seed(seed);
assert_eq!(rng1.next_u64(), 8740028313290271629)... | identifier_body |
radionodelist.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::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen... |
_ => {}
}
}
}
}
// FIXME: This shouldn't need to be implemented here since NodeList (the parent of
// RadioNodeList) implements IndexedGetter.
// https://github.com/servo/servo/issues/5875
//
// https://dom.spec.whatwg.org/#dom-nodelist-i... | {
// Step 2
if input.Value() == value {
input.SetChecked(true);
return;
}
} | conditional_block |
radionodelist.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::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen... |
pub fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<RadioNodeList>
where T: Iterator<Item=DomRoot<Node>> {
RadioNodeList::new(window, NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect()))
}
// FIXME: This shouldn't need to be implemented here s... | {
reflect_dom_object(Box::new(RadioNodeList::new_inherited(list_type)),
window,
RadioNodeListBinding::Wrap)
} | identifier_body |
radionodelist.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::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen... | node_list: NodeList::new_inherited(list_type)
}
}
#[allow(unrooted_must_root)]
pub fn new(window: &Window, list_type: NodeListType) -> DomRoot<RadioNodeList> {
reflect_dom_object(Box::new(RadioNodeList::new_inherited(list_type)),
window,
... | impl RadioNodeList {
#[allow(unrooted_must_root)]
fn new_inherited(list_type: NodeListType) -> RadioNodeList {
RadioNodeList { | random_line_split |
radionodelist.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::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen... | (&self) -> DOMString {
self.upcast::<NodeList>().as_simple_list().iter().filter_map(|node| {
// Step 1
node.downcast::<HTMLInputElement>().and_then(|input| {
if input.input_type() == InputType::Radio && input.Checked() {
// Step 3-4
... | Value | identifier_name |
MZ.rs | // fn main() {
// let nums = vec![0,1,0,3,12];
// let mut result:Vec<i32> = Vec::new();
// let mut zeros = 0;
// for i in &nums {
// if *i!= 0 {
// result.push(*i);
// }else {
// zeros += 1;
// }
// }
// for _ in 0..zeros {
// result.push... | let len = nums.len().clone();
for i in 0..len {
if nums[i]!= 0 {
result.push(nums[i].clone());
} else {
zeros += 1;
}
}
for _ in 0..zeros {
result.push(0)
}
*nums = result;
}
fn main() {
let mut testcase = vec![0, 1, 0, 3, 12];
... | random_line_split | |
MZ.rs | // fn main() {
// let nums = vec![0,1,0,3,12];
// let mut result:Vec<i32> = Vec::new();
// let mut zeros = 0;
// for i in &nums {
// if *i!= 0 {
// result.push(*i);
// }else {
// zeros += 1;
// }
// }
// for _ in 0..zeros {
// result.push... |
fn main() {
let mut testcase = vec![0, 1, 0, 3, 12];
move_zeroes(&mut testcase);
println!("{:?}", testcase);
}
| {
let mut result: Vec<i32> = Vec::new();
let mut zeros = 0;
let len = nums.len().clone();
for i in 0..len {
if nums[i] != 0 {
result.push(nums[i].clone());
} else {
zeros += 1;
}
}
for _ in 0..zeros {
result.push(0)
}
*nums = re... | identifier_body |
MZ.rs | // fn main() {
// let nums = vec![0,1,0,3,12];
// let mut result:Vec<i32> = Vec::new();
// let mut zeros = 0;
// for i in &nums {
// if *i!= 0 {
// result.push(*i);
// }else {
// zeros += 1;
// }
// }
// for _ in 0..zeros {
// result.push... | (nums: &mut Vec<i32>) {
let mut result: Vec<i32> = Vec::new();
let mut zeros = 0;
for i in nums.clone() {
if i!= 0 {
result.push(i);
} else {
zeros += 1;
}
}
for _ in 0..zeros {
result.push(0)
}
*nums = result;
}
pub fn move_zeroes_... | move_zeroes | identifier_name |
MZ.rs | // fn main() {
// let nums = vec![0,1,0,3,12];
// let mut result:Vec<i32> = Vec::new();
// let mut zeros = 0;
// for i in &nums {
// if *i!= 0 {
// result.push(*i);
// }else {
// zeros += 1;
// }
// }
// for _ in 0..zeros {
// result.push... |
}
for _ in 0..zeros {
result.push(0)
}
*nums = result;
}
pub fn move_zeroes_new(nums: &mut Vec<i32>) {
let mut result: Vec<i32> = Vec::new();
let mut zeros = 0;
let len = nums.len().clone();
for i in 0..len {
if nums[i]!= 0 {
result.push(nums[i].clone())... | {
zeros += 1;
} | conditional_block |
error.rs | // Copyright 2017 PingCAP, Inc.
//
// 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 i... | (e: grpc::Error) -> Error {
Error::Grpc(e)
}
}
impl From<TimerError> for Error {
fn from(e: TimerError) -> Error {
Error::Timer(e)
}
}
pub type Result<T> = result::Result<T, Error>;
| from | identifier_name |
error.rs | // Copyright 2017 PingCAP, Inc.
//
// 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 i... |
}
impl From<TimerError> for Error {
fn from(e: TimerError) -> Error {
Error::Timer(e)
}
}
pub type Result<T> = result::Result<T, Error>;
| {
Error::Grpc(e)
} | identifier_body |
error.rs | // Copyright 2017 PingCAP, Inc.
//
// 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 i... | }
pub type Result<T> = result::Result<T, Error>; | random_line_split | |
lib.rs | //! Farbfeld is a simple image encoding format from suckless.
//! # Related Links
//! * http://git.suckless.org/farbfeld/tree/FORMAT.
#![deny(unsafe_code)]
#![deny(trivial_casts, trivial_numeric_casts)]
#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations)]
#![deny(unused_extern_crates, unu... | (&self) -> Option<&error::Error> {
match *self {
Error::IoError(ref e) => Some(e),
_ => None
}
}
}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Error {
Error::IoError(err)
}
}
| cause | identifier_name |
lib.rs | //! Farbfeld is a simple image encoding format from suckless.
//! # Related Links
//! * http://git.suckless.org/farbfeld/tree/FORMAT.
#![deny(unsafe_code)]
#![deny(trivial_casts, trivial_numeric_casts)]
#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations)]
#![deny(unused_extern_crates, unu... | Error::IoError(err)
}
} |
impl From<io::Error> for Error {
fn from(err: io::Error) -> Error { | random_line_split |
lib.rs | //! Farbfeld is a simple image encoding format from suckless.
//! # Related Links
//! * http://git.suckless.org/farbfeld/tree/FORMAT.
#![deny(unsafe_code)]
#![deny(trivial_casts, trivial_numeric_casts)]
#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations)]
#![deny(unused_extern_crates, unu... |
}
| {
Error::IoError(err)
} | identifier_body |
depth.rs | //! Compute the depth of coverage in a BAM file for a list of reference sequences and positions.
//!
//! ## Input:
//! A BAM file and a positions file.
//! The positions file contains the name of one reference sequence and one position per line (tab separated).
//! Example:
//! ```
//! 16 1
//! 17 1
//! 17 2
/... | {
chrom: String,
pos: u32,
}
pub fn depth<P: AsRef<Path>>(
bam_path: P,
max_read_length: u32,
include_flags: u16,
exclude_flags: u16,
min_mapq: u8,
) -> Result<()> {
let mut bam_reader = bam::IndexedReader::from_path(&bam_path)?;
let bam_header = bam_reader.header().clone();
le... | PosRecord | identifier_name |
depth.rs | //! Compute the depth of coverage in a BAM file for a list of reference sequences and positions.
//!
//! ## Input:
//! A BAM file and a positions file.
//! The positions file contains the name of one reference sequence and one position per line (tab separated).
//! Example:
//! ```
//! 16 1
//! 17 1
//! 17 2
/... | }
pub fn depth<P: AsRef<Path>>(
bam_path: P,
max_read_length: u32,
include_flags: u16,
exclude_flags: u16,
min_mapq: u8,
) -> Result<()> {
let mut bam_reader = bam::IndexedReader::from_path(&bam_path)?;
let bam_header = bam_reader.header().clone();
let mut pos_reader = csv::ReaderBuilde... | random_line_split | |
depth.rs | //! Compute the depth of coverage in a BAM file for a list of reference sequences and positions.
//!
//! ## Input:
//! A BAM file and a positions file.
//! The positions file contains the name of one reference sequence and one position per line (tab separated).
//! Example:
//! ```
//! 16 1
//! 17 1
//! 17 2
/... | start as i64 + (max_read_length * 2) as i64,
))?;
// iterate over pileups
let mut covered = false;
for pileup in bam_reader.pileup() {
let pileup = pileup?;
covered = pileup.pos() == record.pos - 1;
if covered {
let depth ... | {
let mut bam_reader = bam::IndexedReader::from_path(&bam_path)?;
let bam_header = bam_reader.header().clone();
let mut pos_reader = csv::ReaderBuilder::new()
.has_headers(false)
.delimiter(b'\t')
.from_reader(io::stdin());
let mut csv_writer = csv::WriterBuilder::new()
.... | identifier_body |
depth.rs | //! Compute the depth of coverage in a BAM file for a list of reference sequences and positions.
//!
//! ## Input:
//! A BAM file and a positions file.
//! The positions file contains the name of one reference sequence and one position per line (tab separated).
//! Example:
//! ```
//! 16 1
//! 17 1
//! 17 2
/... |
}
Ok(())
}
| {
info!("{} records written.", i + 1);
} | conditional_block |
async-fn.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 |
// edition:2018
// compile-flags:-Z unstable-options
// FIXME: once `--edition` is stable in rustdoc, remove that `compile-flags` directive
#![feature(async_await, futures_api)]
// @has async_fn/struct.S.html
// @has - '//code' 'pub async fn f()'
pub struct S;
impl S {
pub async fn f() {}
} | // <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 |
async-fn.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 ... | () {}
}
| f | identifier_name |
sodium_type.rs | // This macro allows to wrap Sodimoxide type to libindy type keeping the same behaviour
macro_rules! sodium_type (($newtype:ident, $sodiumtype:path, $len:ident) => (
pub struct $newtype(pub(super) $sodiumtype);
impl $newtype {
#[allow(dead_code)]
pub fn new(bytes: [u8; $len]) -> $newtype {
... |
impl ::std::cmp::Eq for $newtype {}
impl ::serde::Serialize for $newtype {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: ::serde::Serializer
{
serializer.serialize_bytes(&self.0[..])
}
}
impl<'de> ::serde::Deserialize<'de> for $newtype {... | self.0.eq(&other.0)
}
} | random_line_split |
test.rs | // use msg_parse::{ParsingResult, Parsing, add_char};
// use test_diff;
// pub const MSG_TEST_WIKIPEDIA1: &'static str = "8=FIX.4.2|9=178|35=8|49=PHLX|56=PERS|52=20071123-05:\
// 30:00.000|11=ATOMNOCCC9990900|20=3|150=E|39=E|55=MSFT|167=CS|54=1|38=15|40=2|44=15|58=PHLX ... | // let mut parser = Parsing::new();
// parser = add_char_incomplete(parser, '1');
// ass_eqdf!{
// parser.parsed.orig_msg => "1".to_string(),
// parser.parsed.msg_length => 1,
// parser.reading_tag => 1
// };
// } | // fn init_add_char() { | random_line_split |
cssrulelist.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::CSSRuleListBinding;
use dom::bindings::... | (&self, index: u32) -> ErrorResult {
let index = index as usize;
match self.rules {
RulesSource::Rules(ref css_rules) => {
css_rules.write().remove_rule(index)?;
let mut dom_rules = self.dom_rules.borrow_mut();
dom_rules[index].get().map(|r| r... | remove_rule | identifier_name |
cssrulelist.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::CSSRuleListBinding;
use dom::bindings::... | match self.rules {
RulesSource::Rules(ref css_rules) => {
css_rules.write().remove_rule(index)?;
let mut dom_rules = self.dom_rules.borrow_mut();
dom_rules[index].get().map(|r| r.detach());
dom_rules.remove(index);
Ok(()... | random_line_split | |
cssrulelist.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::CSSRuleListBinding;
use dom::bindings::... |
}
})
})
}
/// Add a rule to the list of DOM rules. This list is lazy,
/// so we just append a placeholder.
///
/// Should only be called for keyframes-backed rules, use insert_rule
/// for CssRules-backed rules
pub fn append_lazy_dom_rule(&self) {
... | {
Root::upcast(CSSKeyframeRule::new(self.global().as_window(),
parent_stylesheet,
rules.read()
.keyframes[idx as usi... | conditional_block |
cssrulelist.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::CSSRuleListBinding;
use dom::bindings::... |
// https://drafts.csswg.org/cssom/#dom-cssrulelist-length
fn Length(&self) -> u32 {
self.dom_rules.borrow().len() as u32
}
// check-tidy: no specs after this line
fn IndexedGetter(&self, index: u32) -> Option<Root<CSSRule>> {
self.Item(index)
}
}
| {
self.item(idx)
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.