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
pending.rs
/* * Copyright (C) 2017 AltOS-Rust Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distribute...
} impl ICPR { pub fn clear_pending(&mut self, hardware: Hardware) { let interrupt = hardware as u8; self.0 |= 0b1 << interrupt; } } #[cfg(test)] mod tests { use super::*; #[test] fn test_ispr_set_pending() { let mut ispr = ISPR(0); ispr.set_pending(Hardware::Fla...
{ let interrupt = hardware as u8; self.0 & (0b1 << interrupt) != 0 }
identifier_body
pending.rs
/* * Copyright (C) 2017 AltOS-Rust Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distribute...
} impl ICPR { pub fn clear_pending(&mut self, hardware: Hardware) { let interrupt = hardware as u8; self.0 |= 0b1 << interrupt; } } #[cfg(test)] mod tests { use super::*; #[test] fn test_ispr_set_pending() { let mut ispr = ISPR(0); ispr.set_pending(Hardware::Flas...
let interrupt = hardware as u8; self.0 & (0b1 << interrupt) != 0 }
random_line_split
gas_schedule.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! This module lays out the basic abstract costing schedule for bytecode instructions. //! //! It is important to note that the cost schedule defined in this file does not track hashing //! operations or other native operations; the co...
(instr_gas: GasCarrier, mem_gas: GasCarrier) -> Self { Self { instruction_gas: InternalGasUnits::new(instr_gas), memory_gas: InternalGasUnits::new(mem_gas), } } /// Convert a GasCost to a total gas charge in `InternalGasUnits`. #[inline] pub fn total(&self) -> In...
new
identifier_name
gas_schedule.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! This module lays out the basic abstract costing schedule for bytecode instructions. //! //! It is important to note that the cost schedule defined in this file does not track hashing //! operations or other native operations; the co...
doc: "Units of gas as seen by clients of the Move VM." } define_gas_unit! { name: InternalGasUnits, carrier: GasCarrier, doc: "Units of gas used within the Move VM, scaled for fine-grained accounting." } define_gas_unit! { name: GasPrice, carrier: GasCarrier, doc: "A newtype wrapper around...
define_gas_unit! { name: GasUnits, carrier: GasCarrier,
random_line_split
gas_schedule.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! This module lays out the basic abstract costing schedule for bytecode instructions. //! //! It is important to note that the cost schedule defined in this file does not track hashing //! operations or other native operations; the co...
/// Subtract one `GasAlgebra` from the other. fn sub(self, right: impl GasAlgebra<GasCarrier>) -> Self { self.map2(right, Sub::sub) } /// Multiply two `GasAlgebra`s together. fn mul(self, right: impl GasAlgebra<GasCarrier>) -> Self { self.map2(right, Mul::mul) } /// Divid...
{ self.map2(right, Add::add) }
identifier_body
icon.rs
use image::{Rgba, RgbaImage}; use imageproc::drawing::draw_text_mut; use image::imageops::resize; use rusttype::{Scale, Font}; use std::ptr::null_mut; use std::collections::HashMap; pub type GeneratedIcon = *mut winapi::shared::windef::HICON__; pub struct IconGenerator { icon_cache: HashMap<u8, GeneratedIcon>, }...
fn scale_params(n: usize) -> ((u32, u32), Scale) { match n { 1 => { ((24, 0), Scale { x: 128.0, y: 128.0 }) } 2 => { ((0, 0), Scale { x: 120.0, y: 120.0 }) } _ => { ((0, 20), Scale { x: 80.0, y: 80....
{ if self.icon_cache.contains_key(&value) && value != 0 { return self.icon_cache[&value]; } else { let new_icon = IconGenerator::create_icon(value); self.icon_cache.insert(value, new_icon); new_icon } }
identifier_body
icon.rs
use image::{Rgba, RgbaImage}; use imageproc::drawing::draw_text_mut; use image::imageops::resize; use rusttype::{Scale, Font}; use std::ptr::null_mut; use std::collections::HashMap; pub type GeneratedIcon = *mut winapi::shared::windef::HICON__; pub struct IconGenerator { icon_cache: HashMap<u8, GeneratedIcon>, }...
} _ => { ((0, 20), Scale { x: 80.0, y: 80.0 }) } } } fn create_icon(value: u8) -> GeneratedIcon { let value_to_draw = value.to_string(); let mut image = RgbaImage::new(128, 128); let font = Font::try_from_bytes(include_bytes!...
((0, 0), Scale { x: 120.0, y: 120.0 })
random_line_split
icon.rs
use image::{Rgba, RgbaImage}; use imageproc::drawing::draw_text_mut; use image::imageops::resize; use rusttype::{Scale, Font}; use std::ptr::null_mut; use std::collections::HashMap; pub type GeneratedIcon = *mut winapi::shared::windef::HICON__; pub struct IconGenerator { icon_cache: HashMap<u8, GeneratedIcon>, }...
(&mut self, value: u8) -> GeneratedIcon { if self.icon_cache.contains_key(&value) && value!= 0 { return self.icon_cache[&value]; } else { let new_icon = IconGenerator::create_icon(value); self.icon_cache.insert(value, new_icon); new_icon } } ...
generate
identifier_name
svg.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 https://mozilla.org/MPL/2.0/. */ //! Generic types for CSS values in SVG use crate::parser::{Parse, ParserContext}; use crate::values::{Either, N...
<L> { /// `[ <length> | <percentage> | <number> ]#` #[css(comma)] Values(#[css(if_empty = "none", iterable)] Vec<L>), /// `context-value` ContextValue, } /// An SVG opacity value accepts `context-{fill,stroke}-opacity` in /// addition to opacity value. #[derive( Animate, Clone, ComputeS...
SVGStrokeDashArray
identifier_name
svg.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 https://mozilla.org/MPL/2.0/. */ //! Generic types for CSS values in SVG use crate::parser::{Parse, ParserContext}; use crate::values::{Either, N...
} else if let Ok(color) = input.try(|i| ColorType::parse(context, i)) { Ok(SVGPaint { kind: SVGPaintKind::Color(color), fallback: None, }) } else { Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) } } } /...
{ Ok(SVGPaint { kind: kind, fallback: parse_fallback(context, input), }) }
conditional_block
svg.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 https://mozilla.org/MPL/2.0/. */ //! Generic types for CSS values in SVG use crate::parser::{Parse, ParserContext}; use crate::values::{Either, N...
MallocSizeOf, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss, ToResolvedValue, ToShmem, )] pub enum SVGLength<L> { /// `<length> | <percentage> | <number>` LengthPercentage(L), /// `context-value` #[animation(error)] Context...
ComputeSquaredDistance, Copy, Debug,
random_line_split
overloaded-autoderef-count.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 ...
struct DerefCounter<T> { count_imm: Cell<uint>, count_mut: uint, value: T } impl<T> DerefCounter<T> { fn new(value: T) -> DerefCounter<T> { DerefCounter { count_imm: Cell::new(0), count_mut: 0, value: value } } fn counts(&self) -> (uint, uint...
use std::ops::{Deref, DerefMut}; #[deriving(PartialEq)]
random_line_split
overloaded-autoderef-count.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) -> &T { self.count_imm.set(self.count_imm.get() + 1); &self.value } } impl<T> DerefMut<T> for DerefCounter<T> { fn deref_mut(&mut self) -> &mut T { self.count_mut += 1; &mut self.value } } #[deriving(PartialEq, Show)] struct Point { x: int, y: int } impl Po...
deref
identifier_name
lpo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 later ver...
else if s.is_function() && t.is_variable() { s.occurs_proper(t) } else { false } } /// Checks if s is greater than or equal to t according to the ordering. pub fn lpo_ge(precedence: &Precedence, s: &Term, t: &Term) -> bool { s == t || lpo_gt(precedence, s, t) } fn lexical_ordering(precede...
{ if s.iter().any(|arg| lpo_ge(precedence, arg, t)) { true } else if t.iter().all(|arg| lpo_gt(precedence, s, arg)) { if s.get_id() == t.get_id() && lexical_ordering(precedence, s, t) { true } else { precedence.gt(s, t) } ...
conditional_block
lpo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 later ver...
() { let precedence = Precedence::default(); let x = Term::new_variable(-1); let f_x = Term::new_function(1, vec![x.clone()]); assert!(lpo_gt(&precedence, &f_x, &x)); assert!(!lpo_gt(&precedence, &x, &f_x)); } #[test] fn lpo_gt_3() { let precedence = Preceden...
lpo_gt_2
identifier_name
lpo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 later ver...
#[test] fn lpo_gt_4() { let precedence = Precedence::default(); let x = Term::new_variable(-1); let f_x = Term::new_function(1, vec![x.clone()]); let f_f_x = Term::new_function(1, vec![f_x.clone()]); assert!(lpo_gt(&precedence, &f_f_x, &f_x)); assert!(!lpo_gt(&pr...
assert!(!lpo_gt(&precedence, &f_y, &x)); assert!(!lpo_gt(&precedence, &x, &f_y)); }
random_line_split
lpo.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 later ver...
fn lexical_ordering(precedence: &Precedence, s: &Term, t: &Term) -> bool { assert_eq!(s.get_id(), t.get_id()); assert_eq!(s.get_arity(), t.get_arity()); for i in 0..s.get_arity() { if lpo_gt(precedence, &s[i], &t[i]) { return true; } else if s[i]!= t[i] { return fa...
{ s == t || lpo_gt(precedence, s, t) }
identifier_body
data_loader.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 https://mozilla.org/MPL/2.0/. */ use crate::fetch; use headers_core::HeaderMapExt; use headers_ext::ContentType; use hyper_serde::Serde; use mime:...
() { assert_parse( "data:text/plain;charset=latin1,hello", Some(ContentType::from( "text/plain; charset=latin1".parse::<Mime>().unwrap(), )), Some("latin1"), Some(b"hello"), ); } #[test] fn plain_only_charset() { assert_parse( "data:;charset=utf-8...
plain_charset
identifier_name
data_loader.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 https://mozilla.org/MPL/2.0/. */ use crate::fetch; use headers_core::HeaderMapExt; use headers_ext::ContentType; use hyper_serde::Serde; use mime:...
#[test] fn base64_ct() { assert_parse( "data:application/octet-stream;base64,C62+7w==", Some(ContentType::from(mime::APPLICATION_OCTET_STREAM)), None, Some(&[0x0B, 0xAD, 0xBE, 0xEF]), ); } #[test] fn base64_charset() { assert_parse( "data:text/plain;charset=koi8-r;...
{ assert_parse( "data:;base64,C62+7w==", Some(ContentType::from( "text/plain; charset=US-ASCII".parse::<Mime>().unwrap(), )), Some("us-ascii"), Some(&[0x0B, 0xAD, 0xBE, 0xEF]), ); }
identifier_body
data_loader.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 https://mozilla.org/MPL/2.0/. */ use crate::fetch; use headers_core::HeaderMapExt; use headers_ext::ContentType; use hyper_serde::Serde; use mime:...
Some("us-ascii"), Some(&[0x0B, 0xAD, 0xBE, 0xEF]), ); } #[test] fn base64_ct() { assert_parse( "data:application/octet-stream;base64,C62+7w==", Some(ContentType::from(mime::APPLICATION_OCTET_STREAM)), None, Some(&[0x0B, 0xAD, 0xBE, 0xEF]), ); } #[test] fn ba...
Some(ContentType::from( "text/plain; charset=US-ASCII".parse::<Mime>().unwrap(), )),
random_line_split
variants.rs
#![feature(decl_macro)] #[rustfmt::skip] macro x($macro_name:ident, $macro2_name:ident, $type_name:ident, $variant_name:ident) { #[repr(u8)] pub enum $type_name { Variant = 0, $variant_name = 1, } #[macro_export] macro_rules! $macro_name { () => {{ assert_eq!($t...
test_variants!(); test_variants2!(); }
x!(test_variants, test_variants2, MyEnum, Variant); pub fn check_variants() {
random_line_split
variants.rs
#![feature(decl_macro)] #[rustfmt::skip] macro x($macro_name:ident, $macro2_name:ident, $type_name:ident, $variant_name:ident) { #[repr(u8)] pub enum $type_name { Variant = 0, $variant_name = 1, } #[macro_export] macro_rules! $macro_name { () => {{ assert_eq!($t...
() { test_variants!(); test_variants2!(); }
check_variants
identifier_name
variants.rs
#![feature(decl_macro)] #[rustfmt::skip] macro x($macro_name:ident, $macro2_name:ident, $type_name:ident, $variant_name:ident) { #[repr(u8)] pub enum $type_name { Variant = 0, $variant_name = 1, } #[macro_export] macro_rules! $macro_name { () => {{ assert_eq!($t...
{ test_variants!(); test_variants2!(); }
identifier_body
dsv2.rs
#[doc = "Register `DSV2` reader"] pub struct R(crate::R<DSV2_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DSV2_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<DSV2_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<DSV2_SP...
self.w.bits = (self.w.bits &!0x03ff) | (value as u32 & 0x03ff); self.w } } impl R { #[doc = "Bits 0:9 - DAC reference value 2"] #[inline(always)] pub fn dsv2(&self) -> DSV2_R { DSV2_R::new((self.bits & 0x03ff) as u16) } } impl W { #[doc = "Bits 0:9 - DAC reference value 2...
#[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u16) -> &'a mut W {
random_line_split
dsv2.rs
#[doc = "Register `DSV2` reader"] pub struct R(crate::R<DSV2_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DSV2_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<DSV2_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<DSV2_SP...
(&mut self) -> &mut Self::Target { &mut self.0 } } impl From<crate::W<DSV2_SPEC>> for W { #[inline(always)] fn from(writer: crate::W<DSV2_SPEC>) -> Self { W(writer) } } #[doc = "Field `DSV2` reader - DAC reference value 2"] pub struct DSV2_R(crate::FieldReader<u16, u16>); impl DSV2_R { ...
deref_mut
identifier_name
dsv2.rs
#[doc = "Register `DSV2` reader"] pub struct R(crate::R<DSV2_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DSV2_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<DSV2_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<DSV2_SP...
} #[doc = "Field `DSV2` reader - DAC reference value 2"] pub struct DSV2_R(crate::FieldReader<u16, u16>); impl DSV2_R { pub(crate) fn new(bits: u16) -> Self { DSV2_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for DSV2_R { type Target = crate::FieldReader<u16, u16>; #[inline(always...
{ W(writer) }
identifier_body
float.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ /// `-` will be printed for negative values, but no sign will be emitted /// for positive numbers. SignNeg } const DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11; /// Converts a number to its string representation as a byte vector. /// This is meant to be a common base implementation for all num...
SignFormat
identifier_name
float.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} } } } // if number of digits is not exact, remove all trailing '0's up to // and including the '.' if!exact { let buf_max_i = end - 1; // index to truncate from let mut i = buf_max_i; // discover trailing zeros of fractional part ...
{ buf[i as usize] = value2ascii(0); i -= 1; }
conditional_block
float.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// If limited digits, calculate one digit more for rounding. let (limit_digits, digit_count, exact) = match digits { DigMax(count) => (true, count + 1, false), DigExact(count) => (true, count + 1, true) }; // Decide what sign to put in front match sign { SignNeg if neg => ...
random_line_split
value.rs
use std::collections::HashMap; use std::fmt; use std::cell::RefCell; use std::rc::Rc; use common::util::unescape; use parser::ast::*; use evaluator::types::*; #[derive(Eq, Debug)] pub enum Value { Int(i64), Bool(bool), String(String), Array(Vec<Rc<Value>>), Hash(HashMap<Hashable, Rc<Value>>), F...
Value::Fn { params: vec![], body: vec![], env: Rc::new(RefCell::new(Env::new())), }), "[function]"); assert_eq!(format!("{}", ...
{ assert_eq!(format!("{}", Value::Int(35)), "35"); assert_eq!(format!("{}", Value::Bool(true)), "true"); assert_eq!(format!("{}", Value::String(String::from("hello\nworld"))), "\"hello\\nworld\""); assert_eq!(format!("{}", Value::Array(vec![])), "[]"); assert_e...
identifier_body
value.rs
use std::collections::HashMap; use std::fmt; use std::cell::RefCell; use std::rc::Rc; use common::util::unescape; use parser::ast::*; use evaluator::types::*; #[derive(Eq, Debug)] pub enum Value { Int(i64), Bool(bool), String(String), Array(Vec<Rc<Value>>), Hash(HashMap<Hashable, Rc<Value>>), F...
(&self, other: &Self) -> bool { match (self, other) { (&Value::Int(i1), &Value::Int(i2)) => i1 == i2, (&Value::Bool(b1), &Value::Bool(b2)) => b1 == b2, (&Value::String(ref s1), &Value::String(ref s2)) => s1 == s2, (&Value::Array(ref v1), &Value::Array(ref v2)) => ...
eq
identifier_name
value.rs
use std::collections::HashMap; use std::fmt; use std::cell::RefCell; use std::rc::Rc; use common::util::unescape; use parser::ast::*; use evaluator::types::*; #[derive(Eq, Debug)] pub enum Value { Int(i64), Bool(bool), String(String), Array(Vec<Rc<Value>>), Hash(HashMap<Hashable, Rc<Value>>), F...
pub type BuiltInFn = fn(Vec<((i32, i32), Rc<Value>)>) -> Result<Value>; #[cfg(test)] mod tests { use super::*; use std::iter::FromIterator; fn dummy(_: Vec<((i32, i32), Rc<Value>)>) -> Result<Value> { unreachable!() } #[test] fn value_display() { assert_eq!(format!("{}", Valu...
&Hashable::String(ref s) => Value::String(s.clone()), }) } }
random_line_split
value.rs
use std::collections::HashMap; use std::fmt; use std::cell::RefCell; use std::rc::Rc; use common::util::unescape; use parser::ast::*; use evaluator::types::*; #[derive(Eq, Debug)] pub enum Value { Int(i64), Bool(bool), String(String), Array(Vec<Rc<Value>>), Hash(HashMap<Hashable, Rc<Value>>), F...
, &Value::Fn {.. } => write!(f, "[function]"), &Value::BuiltInFn { ref name,.. } => write!(f, "[built-in function: {}]", name), &Value::Return(ref o) => o.fmt(f), &Value::Null => write!(f, "null"), } } } impl PartialEq for Value { fn eq(&self, other: &Sel...
{ let mut mapped: Vec<String> = m.iter().map(|(h, v)| format!("{}: {}", h, v)).collect(); mapped.sort(); write!(f, "{{{}}}", mapped.join(", ")) }
conditional_block
main.rs
#![feature(box_syntax)] #![feature(asm)] extern crate e2d2; extern crate fnv; extern crate getopts; extern crate rand; extern crate time; use self::nf::*; use e2d2::config::{basic_opts, read_matches}; use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::*; use std::env; use std::fmt::Display; use std::p...
.unwrap_or_else(|| String::from("0")) .parse() .expect("Could not parse test duration"); match initialize_system(&configuration) { Ok(mut context) => { context.start_schedulers(); context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| test(p...
{ let mut opts = basic_opts(); opts.optopt( "", "dur", "Test duration", "If this option is set to a nonzero value, then the \ test will exit after X seconds.", ); let args: Vec<String> = env::args().collect(); let matches = match opts.parse(&args[1..]) { ...
identifier_body
main.rs
#![feature(box_syntax)] #![feature(asm)] extern crate e2d2; extern crate fnv; extern crate getopts; extern crate rand; extern crate time; use self::nf::*; use e2d2::config::{basic_opts, read_matches}; use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::*; use std::env; use std::fmt::Display; use std::p...
() { let mut opts = basic_opts(); opts.optopt( "", "dur", "Test duration", "If this option is set to a nonzero value, then the \ test will exit after X seconds.", ); let args: Vec<String> = env::args().collect(); let matches = match opts.parse(&args[1..]) { ...
main
identifier_name
main.rs
#![feature(box_syntax)] #![feature(asm)] extern crate e2d2; extern crate fnv; extern crate getopts; extern crate rand; extern crate time; use self::nf::*; use e2d2::config::{basic_opts, read_matches}; use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::*; use std::env; use std::fmt::Display; use std::p...
for pipeline in pipelines { sched.add_task(pipeline).unwrap(); } } fn main() { let mut opts = basic_opts(); opts.optopt( "", "dur", "Test duration", "If this option is set to a nonzero value, then the \ test will exit after X seconds.", ); let a...
.map(|port| macswap(ReceiveBatch::new(port.clone())).send(port.clone())) .collect(); println!("Running {} pipelines", pipelines.len());
random_line_split
syntax-ambiguity-2018.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 ...
() { use std::ops::Range; if let Range { start: _, end: _ } = true..true && false { } //~^ ERROR ambiguous use of `&&` if let Range { start: _, end: _ } = true..true || false { } //~^ ERROR ambiguous use of `||` while let Range { start: _, end: _ } = true..true && false { } //~^ ERROR amb...
main
identifier_name
syntax-ambiguity-2018.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 ...
if let true = false && false { } //~^ ERROR ambiguous use of `&&` while let true = (1 == 2) && false { } //~^ ERROR ambiguous use of `&&` // The following cases are not an error as parenthesis are used to // clarify intent: if let Range { start: _, end: _ } = true..(true || false) { } ...
while let Range { start: _, end: _ } = true..true || false { } //~^ ERROR ambiguous use of `||`
random_line_split
syntax-ambiguity-2018.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 ...
// The following cases are not an error as parenthesis are used to // clarify intent: if let Range { start: _, end: _ } = true..(true || false) { } if let Range { start: _, end: _ } = true..(true && false) { } while let Range { start: _, end: _ } = true..(true || false) { } while let Range ...
{ use std::ops::Range; if let Range { start: _, end: _ } = true..true && false { } //~^ ERROR ambiguous use of `&&` if let Range { start: _, end: _ } = true..true || false { } //~^ ERROR ambiguous use of `||` while let Range { start: _, end: _ } = true..true && false { } //~^ ERROR ambigu...
identifier_body
syntax-ambiguity-2018.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 ...
//~^ ERROR ambiguous use of `||` while let Range { start: _, end: _ } = true..true && false { } //~^ ERROR ambiguous use of `&&` while let Range { start: _, end: _ } = true..true || false { } //~^ ERROR ambiguous use of `||` if let true = false && false { } //~^ ERROR ambiguous use of `&...
{ }
conditional_block
bootstrap.rs
// Copyright 2015-2017 Intecture Developers. See the COPYRIGHT file at the // top-level directory of this distribution and at // https://intecture.io/COPYRIGHT. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distribut...
.replace("{{SUDO}}", if self.is_root { "" } else { "sudo" }); let bootstrap_path = self.channel_exec("/bin/sh -c \"mktemp 2>/dev/null || mktemp -t in-bootstrap\"")?; // Deliberately omit terminating EOS delimiter as it breaks // FreeBSD and works fine without ...
{ let mut auth = try!(Auth::new(&env::current_dir().unwrap())); let agent_cert = try!(auth.add("host", &self.hostname)); // As we are in a project directory, it's safe to assume that // the auth public key must be present. let mut fh = File::open("auth.crt")?; let mut au...
identifier_body
bootstrap.rs
// Copyright 2015-2017 Intecture Developers. See the COPYRIGHT file at the // top-level directory of this distribution and at // https://intecture.io/COPYRIGHT. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distribut...
hostname: String, _stream: TcpStream, session: Session, is_root: bool, } impl Bootstrap { pub fn new(hostname: &str, port: Option<u32>, username: Option<&str>, password: Option<&str>, identity_file: Option<&str>) -> Result<Bootstrap> { ...
pub struct Bootstrap {
random_line_split
bootstrap.rs
// Copyright 2015-2017 Intecture Developers. See the COPYRIGHT file at the // top-level directory of this distribution and at // https://intecture.io/COPYRIGHT. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distribut...
else { sess.userauth_agent(u)?; } if sess.authenticated() { Ok(Bootstrap { hostname: hostname.into(), _stream: tcp, session: sess, is_root: u == "root", }) } else { Err(Error::Bootst...
{ sess.userauth_password(u, p).unwrap(); }
conditional_block
bootstrap.rs
// Copyright 2015-2017 Intecture Developers. See the COPYRIGHT file at the // top-level directory of this distribution and at // https://intecture.io/COPYRIGHT. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distribut...
(hostname: &str, port: Option<u32>, username: Option<&str>, password: Option<&str>, identity_file: Option<&str>) -> Result<Bootstrap> { let tcp = TcpStream::connect(&*format!("{}:{}", hostname, port.unwrap_or(22)))?; let mut sess = Session::new...
new
identifier_name
main.rs
#![feature(plugin, no_std, start, core_intrinsics)]
use zinc::drivers::chario::CharIO; platformtree!( tiva_c@mcu { clock { source = "MOSC"; xtal = "X16_0MHz"; pll = true; div = 5; } timer { /* The mcu contain both 16/32bit and "wide" 32/64bit timers. */ timer@w0 { /* prescale sysclk to 1Mhz since th...
#![no_std] #![plugin(macro_platformtree)] extern crate zinc;
random_line_split
main.rs
#![feature(plugin, no_std, start, core_intrinsics)] #![no_std] #![plugin(macro_platformtree)] extern crate zinc; use zinc::drivers::chario::CharIO; platformtree!( tiva_c@mcu { clock { source = "MOSC"; xtal = "X16_0MHz"; pll = true; div = 5; } timer { /* The mc...
(args: &pt::run_args) { use zinc::hal::timer::Timer; use zinc::hal::pin::Gpio; args.uart.puts("Hello, world\r\n"); let mut i = 0; loop { args.txled.set_high(); args.uart.puts("Waiting for "); args.uart.puti(i); args.uart.puts(" seconds...\r\n"); i += 1; args.txled.set_low(); ar...
run
identifier_name
main.rs
#![feature(plugin, no_std, start, core_intrinsics)] #![no_std] #![plugin(macro_platformtree)] extern crate zinc; use zinc::drivers::chario::CharIO; platformtree!( tiva_c@mcu { clock { source = "MOSC"; xtal = "X16_0MHz"; pll = true; div = 5; } timer { /* The mc...
{ use zinc::hal::timer::Timer; use zinc::hal::pin::Gpio; args.uart.puts("Hello, world\r\n"); let mut i = 0; loop { args.txled.set_high(); args.uart.puts("Waiting for "); args.uart.puti(i); args.uart.puts(" seconds...\r\n"); i += 1; args.txled.set_low(); args.timer.wait(1); } ...
identifier_body
htmldatalistelement.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::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
(&self) -> Root<HTMLCollection> { #[derive(JSTraceable, HeapSizeOf)] struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { elem.is::<HTMLOptionElement>() } }...
Options
identifier_name
htmldatalistelement.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::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
} impl HTMLDataListElementMethods for HTMLDataListElement { // https://html.spec.whatwg.org/multipage/#dom-datalist-options fn Options(&self) -> Root<HTMLCollection> { #[derive(JSTraceable, HeapSizeOf)] struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilte...
Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap) }
random_line_split
htmldatalistelement.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::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
} impl HTMLDataListElementMethods for HTMLDataListElement { // https://html.spec.whatwg.org/multipage/#dom-datalist-options fn Options(&self) -> Root<HTMLCollection> { #[derive(JSTraceable, HeapSizeOf)] struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilt...
{ let element = HTMLDataListElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap) }
identifier_body
cipher.rs
use random::{thread_rng, sample}; use serialize::hex::{FromHex, ToHex}; const BLOCK_SIZE_EXP: u32 = 3; // pow(2, 3) == 8 byte blocks pub enum Mode { Encrypt, Decrypt, } // Invokes the helper functions and does its shifting thing pub fn zombify(mode: Mode, data: &[u8], key: &str) -> Vec<u8> { let hex...
, } }
{ let mut i = data.len() - 1; while i >= size { data[i] = data[i] ^ data[i - size]; i -= 1; } let mut stuff = data[size..].to_owned(); for _ in 0..BLOCK_SIZE_EXP { stuff = charred(stuff); } ...
conditional_block
cipher.rs
use random::{thread_rng, sample}; use serialize::hex::{FromHex, ToHex}; const BLOCK_SIZE_EXP: u32 = 3; // pow(2, 3) == 8 byte blocks pub enum Mode { Encrypt, Decrypt, } // Invokes the helper functions and does its shifting thing pub fn zombify(mode: Mode, data: &[u8], key: &str) -> Vec<u8> { let hex...
(text: &[u8], key: &str) -> Vec<u8> { let key_array = key.as_bytes(); let (text_size, key_size) = (text.len(), key.len()); (0..text_size).map(|i| text[i] ^ key_array[i % key_size]).collect() } // CBC mode as a seed to scramble the final ciphertext fn cbc(mode: Mode, mut data: Vec<u8>) -> Vec<u8> { let ...
xor
identifier_name
cipher.rs
use random::{thread_rng, sample}; use serialize::hex::{FromHex, ToHex}; const BLOCK_SIZE_EXP: u32 = 3; // pow(2, 3) == 8 byte blocks pub enum Mode { Encrypt, Decrypt, } // Invokes the helper functions and does its shifting thing pub fn zombify(mode: Mode, data: &[u8], key: &str) -> Vec<u8> { let hex...
match mode { Mode::Encrypt => { let mut cbc_vec: Vec<u8> = sample(&mut thread_rng(), 1..255, size); // hex the bytes until the vector has the required length (an integral multiple of block size) for _ in 0..BLOCK_SIZE_EXP { data = data.to_hex().into_bytes(...
// Well, there's no encryption going on here - just some fireworks to introduce randomness
random_line_split
errors.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 std::local_data; use cssparser::ast::{SyntaxError, SourceLocation}; pub struct ErrorLoggerIterator<I>(I); i...
{ local_data::set(silence_errors, true); let result = f(); local_data::pop(silence_errors); result }
identifier_body
errors.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 std::local_data; use cssparser::ast::{SyntaxError, SourceLocation}; pub struct ErrorLoggerIterator<I>(I); i...
<T>(f: || -> T) -> T { local_data::set(silence_errors, true); let result = f(); local_data::pop(silence_errors); result }
with_errors_silenced
identifier_name
errors.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 std::local_data; use cssparser::ast::{SyntaxError, SourceLocation}; pub struct ErrorLoggerIterator<I>(I); i...
} } } } // FIXME: go back to `()` instead of `bool` after upgrading Rust // past 898669c4e203ae91e2048fb6c0f8591c867bccc6 // Using bool is a work-around for https://github.com/mozilla/rust/issues/13322 local_data_key!(silence_errors: bool) pub fn log_css_error(location: SourceLocation, message...
Some(Ok(v)) => return Some(v), Some(Err(error)) => log_css_error(error.location, format!("{:?}", error.reason)), None => return None,
random_line_split
robot.rs
use wpilib::wpilib_hal::*; /// The base class from which all robots should be derived. /// /// # Usage /// /// ``` /// struct TestRobot {}; /// /// impl Robot for TestRobot { /// fn new() -> TestRobot { /// TestRobot{} /// } /// /// fn run(self) { /// // Do something... /// } /// } /// ...
fn main() { // Initialize HAL unsafe { let status = HAL_Initialize(0); if status!= 1 { panic!("WPILib HAL failed to initialize!"); } } let robot = Self::new(); robot.run(); } }
/// Create an instance of the robot class. fn new() -> Self; /// Run the robot statically.
random_line_split
robot.rs
use wpilib::wpilib_hal::*; /// The base class from which all robots should be derived. /// /// # Usage /// /// ``` /// struct TestRobot {}; /// /// impl Robot for TestRobot { /// fn new() -> TestRobot { /// TestRobot{} /// } /// /// fn run(self) { /// // Do something... /// } /// } /// ...
() { // Initialize HAL unsafe { let status = HAL_Initialize(0); if status!= 1 { panic!("WPILib HAL failed to initialize!"); } } let robot = Self::new(); robot.run(); } }
main
identifier_name
robot.rs
use wpilib::wpilib_hal::*; /// The base class from which all robots should be derived. /// /// # Usage /// /// ``` /// struct TestRobot {}; /// /// impl Robot for TestRobot { /// fn new() -> TestRobot { /// TestRobot{} /// } /// /// fn run(self) { /// // Do something... /// } /// } /// ...
} let robot = Self::new(); robot.run(); } }
{ panic!("WPILib HAL failed to initialize!"); }
conditional_block
robot.rs
use wpilib::wpilib_hal::*; /// The base class from which all robots should be derived. /// /// # Usage /// /// ``` /// struct TestRobot {}; /// /// impl Robot for TestRobot { /// fn new() -> TestRobot { /// TestRobot{} /// } /// /// fn run(self) { /// // Do something... /// } /// } /// ...
}
{ // Initialize HAL unsafe { let status = HAL_Initialize(0); if status != 1 { panic!("WPILib HAL failed to initialize!"); } } let robot = Self::new(); robot.run(); }
identifier_body
flat.rs
// Copyright 2015, 2016 Ethcore (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 later version....
(&self) -> LogBloom { self.action.bloom() | self.result.bloom() } } impl HeapSizeOf for FlatTrace { fn heap_size_of_children(&self) -> usize { self.trace_address.heap_size_of_children() } } impl Encodable for FlatTrace { fn rlp_append(&self, s: &mut RlpStream) { s.begin_list(4); s.append(&self.action); ...
bloom
identifier_name
flat.rs
// Copyright 2015, 2016 Ethcore (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 later version....
to: "412fda7643b37d436cb40628f6dbbb80a07267ed".parse().unwrap(), value: 0.into(), gas: 0x010c78.into(), input: vec![0x41, 0xc0, 0xe1, 0xb5], call_type: CallType::Call, }), result: Res::Call(CallResult { gas_used: 0x0127.into(), output: vec![], }), trace_address: Default::default(...
let flat_trace1 = FlatTrace { action: Action::Call(Call { from: "3d0768da09ce77d25e2d998e6a7b6ed4b9116c2d".parse().unwrap(),
random_line_split
flat.rs
// Copyright 2015, 2016 Ethcore (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 later version....
} impl HeapSizeOf for FlatTransactionTraces { fn heap_size_of_children(&self) -> usize { self.0.heap_size_of_children() } } impl FlatTransactionTraces { /// Returns bloom of all traces in the collection. pub fn bloom(&self) -> LogBloom { self.0.iter().fold(Default::default(), | bloom, trace | bloom | trace.b...
{ FlatTransactionTraces(v) }
identifier_body
unreachable_rule.rs
// Copyright 2018 Chao Lin & William Sergeant (Sorbonne University) // 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...
fn visit_str_literal(&mut self, _this: usize, lit: String) -> Occurence{ let mut seq = vec![]; for c in lit.chars(){ seq.push((Char(c),One)) } let mut res = vec![]; res.push(seq); Occurence{ choice: res } } fn visit_any_single_char(&mut self, _this: usize) -> Occurence{ ...
{ Occurence{ choice: vec![] } }
identifier_body
unreachable_rule.rs
// Copyright 2018 Chao Lin & William Sergeant (Sorbonne University) // 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...
Occurence{ choice: vec![] } } fn visit_one_or_more(&mut self, _this: usize, _child: usize) -> Occurence{ Occurence{ choice: vec![] } } fn visit_optional(&mut self, _this: usize, _child: usize) -> Occurence{ Occurence{ choice: vec![] } } fn visit_not_predicate(&mu...
} fn visit_zero_or_more(&mut self, _this: usize, _child: usize) -> Occurence{
random_line_split
unreachable_rule.rs
// Copyright 2018 Chao Lin & William Sergeant (Sorbonne University) // 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...
} res } fn success_with(&self, seq2: Vec<(Character, Pattern)>) -> bool { let mut res = false; for seq1 in self.choice.clone(){ if self.succeed_before(seq1,seq2.to_vec()) { res = true; } } res } fn succeed_before(&self, seq1: Vec<(Character, Pattern)>, seq2: Vec<(C...
{ res = false; break; }
conditional_block
unreachable_rule.rs
// Copyright 2018 Chao Lin & William Sergeant (Sorbonne University) // 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...
(&mut self, _this: usize, _rule: Ident) -> Occurence{ Occurence{ choice: vec![] } } fn visit_zero_or_more(&mut self, _this: usize, _child: usize) -> Occurence{ Occurence{ choice: vec![] } } fn visit_one_or_more(&mut self, _this: usize, _child: usize) -> Occurence{ Occurence{ ...
visit_non_terminal_symbol
identifier_name
process.rs
//! System calls related to process managment. use arch::context::{context_clone, context_switch, ContextFile}; use arch::regs::Regs; use collections::{BTreeMap, Vec}; use collections::string::ToString; use core::mem; use core::ops::DerefMut; use system::{c_array_to_slice, c_string_to_str}; use system::error::{Err...
else { Err(Error::new(EINVAL)) } } //TODO: Finish implementation, add more functions to WaitMap so that matching any or using WNOHANG works pub fn waitpid(pid: isize, status_ptr: *mut usize, _options: usize) -> Result<usize> { let contexts = unsafe { &mut *::env().contexts.get() }; let current = t...
{ let contexts = unsafe { &mut *::env().contexts.get() }; let mut current = try!(contexts.current_mut()); current.iopl = level; regs.flags &= 0xFFFFFFFFFFFFFFFF - 0x3000; regs.flags |= (current.iopl << 12) & 0x3000; Ok(0) }
conditional_block
process.rs
//! System calls related to process managment. use arch::context::{context_clone, context_switch, ContextFile}; use arch::regs::Regs; use collections::{BTreeMap, Vec}; use collections::string::ToString; use core::mem; use core::ops::DerefMut; use system::{c_array_to_slice, c_string_to_str}; use system::error::{Err...
//TODO: Finish implementation, add more functions to WaitMap so that matching any or using WNOHANG works pub fn waitpid(pid: isize, status_ptr: *mut usize, _options: usize) -> Result<usize> { let contexts = unsafe { &mut *::env().contexts.get() }; let current = try!(contexts.current_mut()); if pid > 0 { ...
Err(Error::new(EINVAL)) } }
random_line_split
process.rs
//! System calls related to process managment. use arch::context::{context_clone, context_switch, ContextFile}; use arch::regs::Regs; use collections::{BTreeMap, Vec}; use collections::string::ToString; use core::mem; use core::ops::DerefMut; use system::{c_array_to_slice, c_string_to_str}; use system::error::{Err...
/// Supervise a child process of the current context. /// /// This will make all syscalls the given process makes mark the process as blocked, until it is /// handled by the supervisor (parrent process) through the returned handle (for details, see the /// docs in the `system` crate). /// /// This routine is done by ...
{ unsafe { context_switch(); } Ok(0) }
identifier_body
process.rs
//! System calls related to process managment. use arch::context::{context_clone, context_switch, ContextFile}; use arch::regs::Regs; use collections::{BTreeMap, Vec}; use collections::string::ToString; use core::mem; use core::ops::DerefMut; use system::{c_array_to_slice, c_string_to_str}; use system::error::{Err...
(regs: &mut Regs) -> Result<usize> { let level = regs.bx; if level <= 3 { let contexts = unsafe { &mut *::env().contexts.get() }; let mut current = try!(contexts.current_mut()); current.iopl = level; regs.flags &= 0xFFFFFFFF - 0x3000; regs.flags |= (current.iopl << 12) &...
iopl
identifier_name
enrichment.rs
use serde_json::Value; use {PassiveTotal, Result}; const URL_DATA: &str = "/enrichment"; const URL_OSINT: &str = "/enrichment/osint"; const URL_MALWARE: &str = "/enrichment/malware"; const URL_SUBDOMAINS: &str = "/enrichment/subdomains"; pub struct EnrichmentRequest<'a> { pt: &'a PassiveTotal, } request_struct!...
(&self) -> EnrichmentRequest { EnrichmentRequest { pt: self } } }
enrichment
identifier_name
enrichment.rs
use serde_json::Value; use {PassiveTotal, Result}; const URL_DATA: &str = "/enrichment"; const URL_OSINT: &str = "/enrichment/osint"; const URL_MALWARE: &str = "/enrichment/malware"; const URL_SUBDOMAINS: &str = "/enrichment/subdomains"; pub struct EnrichmentRequest<'a> { pt: &'a PassiveTotal, } request_struct!...
S: Into<String>, { EnrichmentSubdomains { pt: self.pt, url: URL_SUBDOMAINS, query: query.into(), } } } impl_send!(EnrichmentData); impl_send!(EnrichmentOsint); impl_send!(EnrichmentMalware); impl_send!(EnrichmentSubdomains); impl PassiveTotal { p...
pub fn subdomains<S>(self, query: S) -> EnrichmentSubdomains<'a> where
random_line_split
enrichment.rs
use serde_json::Value; use {PassiveTotal, Result}; const URL_DATA: &str = "/enrichment"; const URL_OSINT: &str = "/enrichment/osint"; const URL_MALWARE: &str = "/enrichment/malware"; const URL_SUBDOMAINS: &str = "/enrichment/subdomains"; pub struct EnrichmentRequest<'a> { pt: &'a PassiveTotal, } request_struct!...
pub fn osint<S>(self, query: S) -> EnrichmentOsint<'a> where S: Into<String>, { EnrichmentOsint { pt: self.pt, url: URL_OSINT, query: query.into(), } } pub fn malware<S>(self, query: S) -> EnrichmentMalware<'a> where S: Into<...
{ EnrichmentData { pt: self.pt, url: URL_DATA, query: query.into(), } }
identifier_body
stability_summary.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 ...
, } } // Produce the summary for an arbitrary item. If the item is a module, include a // module summary. The counts for items with nested items (e.g. modules, traits, // impls) include all children counts. fn summarize_item(item: &Item) -> (Counts, Option<ModuleSummary>) { let item_counts = count_stability(i...
{ Counts::zero() }
conditional_block
stability_summary.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 Ord for ModuleSummary { fn cmp(&self, other: &ModuleSummary) -> Ordering { self.name.cmp(&other.name) } } // is the item considered publically visible? fn visible(item: &Item) -> bool { match item.inner { ImplItem(_) => true, _ => item.visibility == Some(Public) } } fn...
{ self.name.partial_cmp(&other.name) }
identifier_body
stability_summary.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 ...
() -> Counts { Counts { deprecated: 0, experimental: 0, unstable: 0, stable: 0, frozen: 0, locked: 0, unmarked: 0, } } pub fn total(&self) -> uint { self.deprecated + self.exp...
zero
identifier_name
into_iterator.rs
#![allow(dead_code, unused_imports)] #[macro_use] extern crate derive_more; #[derive(IntoIterator)] #[into_iterator(owned, ref, ref_mut)] struct MyVec(Vec<i32>); #[derive(IntoIterator)] #[into_iterator(owned, ref, ref_mut)] struct Numbers { numbers: Vec<i32>, } #[derive(IntoIterator)] struct
{ #[into_iterator(owned, ref, ref_mut)] numbers: Vec<i32>, useless: bool, useless2: bool, } #[derive(IntoIterator)] struct Numbers3 { #[into_iterator(ref, ref_mut)] numbers: Vec<i32>, useless: bool, useless2: bool, } // Test that owned is not enabled when ref/ref_mut are enabled witho...
Numbers2
identifier_name
into_iterator.rs
#![allow(dead_code, unused_imports)]
#[derive(IntoIterator)] #[into_iterator(owned, ref, ref_mut)] struct MyVec(Vec<i32>); #[derive(IntoIterator)] #[into_iterator(owned, ref, ref_mut)] struct Numbers { numbers: Vec<i32>, } #[derive(IntoIterator)] struct Numbers2 { #[into_iterator(owned, ref, ref_mut)] numbers: Vec<i32>, useless: bool, ...
#[macro_use] extern crate derive_more;
random_line_split
ch15-closures.rs
/*Named functions, like those we've seen so far, may not refer to local variables declared outside the function: they do not close over their environment (sometimes referred to as "capturing" variables in their environment). A closure does support accessing the enclosing scope */ let x = 3; // `fun` is an invalid de...
has type || and can directly access local variables in the enclosing scope.*/ let mut max = 0; let f = |x: int| if x > max { max = x }; for x in [1, 2, 3].iter() { f(*x); } /*Stack closures are very efficient because their environment is allocated on the call stack and refers by pointer to captured locals. To en...
println!("{}", square_infer(-20)); // 400 /*There are several forms of closure, each with its own role. The most common, called a stack closure,
random_line_split
ch15-closures.rs
/*Named functions, like those we've seen so far, may not refer to local variables declared outside the function: they do not close over their environment (sometimes referred to as "capturing" variables in their environment). A closure does support accessing the enclosing scope */ let x = 3; // `fun` is an invalid de...
(x: int) { println!("{}", x) } // this is same as saying `-> ()` fn square(x: int) -> uint { (x * x) as uint } // other return types are explicit // Error: mismatched types: expected `()` but found `uint` fn badfun(x: int) { (x * x) as uint } /*On the other hand, the compiler can usually infer ...
fun
identifier_name
ch15-closures.rs
/*Named functions, like those we've seen so far, may not refer to local variables declared outside the function: they do not close over their environment (sometimes referred to as "capturing" variables in their environment). A closure does support accessing the enclosing scope */ let x = 3; // `fun` is an invalid de...
; for x in [1, 2, 3].iter() { f(*x); } /*Stack closures are very efficient because their environment is allocated on the call stack and refers by pointer to captured locals. To ensure that stack closures never outlive the local variables to which they refer, stack closures are not first-class. That is, they can ...
{ max = x }
conditional_block
ch15-closures.rs
/*Named functions, like those we've seen so far, may not refer to local variables declared outside the function: they do not close over their environment (sometimes referred to as "capturing" variables in their environment). A closure does support accessing the enclosing scope */ let x = 3; // `fun` is an invalid de...
let closure = |x | { println!("{}", x) }; // infers `x: int`, return type `()` // For closures, omitting a return type is *not* synonymous with `-> ()` let add_3 = |y | { 3i + y }; // infers `y: int`, return type `int`. fun(10); // Prints 10 closure(20); // Prints 20 closure(add_3(30)); /...
{ println!("{}", x) }
identifier_body
pragma.rs
use std::fmt; use std::ascii::AsciiExt; use header::{Header, Raw, parsing}; /// The `Pragma` header defined by HTTP/1.0. /// /// > The "Pragma" header field allows backwards compatibility with /// > HTTP/1.0 caches, so that clients can specify a "no-cache" request /// > that they will understand (as Cache-Control was...
}) } } #[test] fn test_parse_header() { let a: Pragma = Header::parse_header(&"no-cache".into()).unwrap(); let b = Pragma::NoCache; assert_eq!(a, b); let c: Pragma = Header::parse_header(&"FoObar".into()).unwrap(); let d = Pragma::Ext("FoObar".to_owned()); assert_eq!(c, d); let ...
fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(match *self { Pragma::NoCache => "no-cache", Pragma::Ext(ref string) => &string[..],
random_line_split
pragma.rs
use std::fmt; use std::ascii::AsciiExt; use header::{Header, Raw, parsing}; /// The `Pragma` header defined by HTTP/1.0. /// /// > The "Pragma" header field allows backwards compatibility with /// > HTTP/1.0 caches, so that clients can specify a "no-cache" request /// > that they will understand (as Cache-Control was...
} #[test] fn test_parse_header() { let a: Pragma = Header::parse_header(&"no-cache".into()).unwrap(); let b = Pragma::NoCache; assert_eq!(a, b); let c: Pragma = Header::parse_header(&"FoObar".into()).unwrap(); let d = Pragma::Ext("FoObar".to_owned()); assert_eq!(c, d); let e: ::Result<Prag...
{ f.write_str(match *self { Pragma::NoCache => "no-cache", Pragma::Ext(ref string) => &string[..], }) }
identifier_body
pragma.rs
use std::fmt; use std::ascii::AsciiExt; use header::{Header, Raw, parsing}; /// The `Pragma` header defined by HTTP/1.0. /// /// > The "Pragma" header field allows backwards compatibility with /// > HTTP/1.0 caches, so that clients can specify a "no-cache" request /// > that they will understand (as Cache-Control was...
() { let a: Pragma = Header::parse_header(&"no-cache".into()).unwrap(); let b = Pragma::NoCache; assert_eq!(a, b); let c: Pragma = Header::parse_header(&"FoObar".into()).unwrap(); let d = Pragma::Ext("FoObar".to_owned()); assert_eq!(c, d); let e: ::Result<Pragma> = Header::parse_header(&"".i...
test_parse_header
identifier_name
message_dialog.rs
// Copyright 2013-2016, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use libc::c_char; use ffi; use glib::translate::*; use glib::object::{Cast, IsA}; use std::pt...
}
random_line_split
message_dialog.rs
// Copyright 2013-2016, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use libc::c_char; use ffi; use glib::translate::*; use glib::object::{Cast, IsA}; use std::pt...
<'a, I: Into<Option<&'a str>>>(&self, message: I) { let message = message.into(); match message { Some(m) => unsafe { let message: Stash<*const c_char, _> = m.to_glib_none(); ffi::gtk_message_dialog_format_secondary_markup( self.as_ref().to...
set_secondary_markup
identifier_name
message_dialog.rs
// Copyright 2013-2016, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use libc::c_char; use ffi; use glib::translate::*; use glib::object::{Cast, IsA}; use std::pt...
fn set_secondary_text<'a, I: Into<Option<&'a str>>>(&self, message: I) { let message = message.into(); match message { Some(m) => unsafe { let message: Stash<*const c_char, _> = m.to_glib_none(); ffi::gtk_message_dialog_format_secondary_text( ...
{ let message = message.into(); match message { Some(m) => unsafe { let message: Stash<*const c_char, _> = m.to_glib_none(); ffi::gtk_message_dialog_format_secondary_markup( self.as_ref().to_glib_none().0, b"%s\0".as_ptr() as *const c_char,...
identifier_body
branchify.rs
#![macro_use] use std::str::Chars; use std::vec::Vec; use std::io::IoResult; use std::iter::repeat; use std::ascii::AsciiExt; #[derive(Clone)] pub struct ParseBranch { matches: Vec<u8>, result: Option<String>, children: Vec<ParseBranch>, } impl ParseBranch { fn new() -> ParseBranch { ParseBra...
go_down_moses(&mut branch.children[i], chariter, result, case_sensitive); }, None => { assert!(branch.result.is_none()); branch.result = Some(String::from_str(result)); }, } } ; for &(key, result) in options.iter() { ...
{ match chariter.next() { Some(c) => { let first_case = if case_sensitive { c as u8 } else { c.to_ascii_uppercase() as u8 }; for next_branch in branch.children.iter_mut() { if next_branch.matches[0] == first_case { go_down_m...
identifier_body
branchify.rs
#![macro_use] use std::str::Chars; use std::vec::Vec; use std::io::IoResult; use std::iter::repeat; use std::ascii::AsciiExt; #[derive(Clone)] pub struct ParseBranch { matches: Vec<u8>, result: Option<String>, children: Vec<ParseBranch>, } impl ParseBranch { fn new() -> ParseBranch { ParseBra...
result: None, children: Vec::new() } } } pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBranch> { let mut root = ParseBranch::new(); fn go_down_moses(branch: &mut ParseBranch, mut chariter: Chars, result: &str, case_sensitive: bool) { m...
random_line_split
branchify.rs
#![macro_use] use std::str::Chars; use std::vec::Vec; use std::io::IoResult; use std::iter::repeat; use std::ascii::AsciiExt; #[derive(Clone)] pub struct ParseBranch { matches: Vec<u8>, result: Option<String>, children: Vec<ParseBranch>, } impl ParseBranch { fn
() -> ParseBranch { ParseBranch { matches: Vec::new(), result: None, children: Vec::new() } } } pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBranch> { let mut root = ParseBranch::new(); fn go_down_moses(branch: &mut ParseB...
new
identifier_name
branchify.rs
#![macro_use] use std::str::Chars; use std::vec::Vec; use std::io::IoResult; use std::iter::repeat; use std::ascii::AsciiExt; #[derive(Clone)] pub struct ParseBranch { matches: Vec<u8>, result: Option<String>, children: Vec<ParseBranch>, } impl ParseBranch { fn new() -> ParseBranch { ParseBra...
, } }; for &(key, result) in options.iter() { go_down_moses(&mut root, key.chars(), result, case_sensitive); } root.children } macro_rules! branchify( (case sensitive, $($key:expr => $value:ident),*) => ( ::branchify::branchify(&[$(($key, stringify!($value))),*], true) ...
{ assert!(branch.result.is_none()); branch.result = Some(String::from_str(result)); }
conditional_block
fixed_length_vec_glue.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 ...
// xfail-fast: check-fast screws up repr paths use std::repr; struct Struc { a: u8, b: [int,..3], c: int } pub fn main() { let arr = [1,2,3]; let struc = Struc {a: 13u8, b: arr, c: 42}; let s = repr::repr_to_str(&struc); assert_eq!(s, ~"Struc{a: 13u8, b: [1, 2, 3], c: 42}"); }
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
fixed_length_vec_glue.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 ...
{ a: u8, b: [int,..3], c: int } pub fn main() { let arr = [1,2,3]; let struc = Struc {a: 13u8, b: arr, c: 42}; let s = repr::repr_to_str(&struc); assert_eq!(s, ~"Struc{a: 13u8, b: [1, 2, 3], c: 42}"); }
Struc
identifier_name
fixed_length_vec_glue.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let arr = [1,2,3]; let struc = Struc {a: 13u8, b: arr, c: 42}; let s = repr::repr_to_str(&struc); assert_eq!(s, ~"Struc{a: 13u8, b: [1, 2, 3], c: 42}"); }
identifier_body
hypergeometric.rs
extern crate rand; use crate::distribs::distribution::*; use crate::util::math::*; #[allow(non_snake_case)] #[allow(dead_code)] pub struct Hypergeometric { N: u64, m: u64, n: u64, } #[allow(dead_code)] impl Hypergeometric { pub fn new(total: u64, n_different: u64, n_picked: u64) -> Hypergeometric { ...
}
{ (0..x).fold(0.0f64, |sum, next| sum + self.pdf(next)) }
identifier_body
hypergeometric.rs
extern crate rand; use crate::distribs::distribution::*; use crate::util::math::*; #[allow(non_snake_case)] #[allow(dead_code)] pub struct Hypergeometric { N: u64, m: u64, n: u64, } #[allow(dead_code)] impl Hypergeometric { pub fn new(total: u64, n_different: u64, n_picked: u64) -> Hypergeometric { ...
} fn cdf(&self, x: u64) -> f64 { (0..x).fold(0.0f64, |sum, next| sum + self.pdf(next)) } }
} fn pdf(&self, x: u64) -> f64 { binomial_coeff(self.m, x) * binomial_coeff(self.N - self.m, self.N - x) / binomial_coeff(self.N, self.n)
random_line_split
hypergeometric.rs
extern crate rand; use crate::distribs::distribution::*; use crate::util::math::*; #[allow(non_snake_case)] #[allow(dead_code)] pub struct Hypergeometric { N: u64, m: u64, n: u64, } #[allow(dead_code)] impl Hypergeometric { pub fn new(total: u64, n_different: u64, n_picked: u64) -> Hypergeometric { ...
; let mut cum_prob: f64 = 0.0f64; let mut k: u64 = 0u64; for _ in 0..low_lim { cum_prob += self.pdf(k); if cum_prob > prob { break; } k += 1 } RandomVariable { value: Cell::new(k) } } fn mu(&self) -> f64...
{ self.m }
conditional_block
hypergeometric.rs
extern crate rand; use crate::distribs::distribution::*; use crate::util::math::*; #[allow(non_snake_case)] #[allow(dead_code)] pub struct Hypergeometric { N: u64, m: u64, n: u64, } #[allow(dead_code)] impl Hypergeometric { pub fn new(total: u64, n_different: u64, n_picked: u64) -> Hypergeometric { ...
(&self) -> f64 { let mean = self.mu(); let failure = ((self.N - self.m) as f64) / (self.N as f64); let remaining = ((self.N - self.n) as f64) / ((self.N - 1) as f64); (mean * failure * remaining).sqrt() } fn pdf(&self, x: u64) -> f64 { binomial_coeff(self.m, x) * binomi...
sigma
identifier_name