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
mod.rs
//! If an extern token is provided, then this pass validates that //! terminal IDs have conversions. Otherwise, it generates a //! tokenizer. This can only be done after macro expansion because //! some macro arguments never make it into an actual production and //! are only used in `if` conditions; we use string liter...
TerminalString::Literal(l) => { self.all_literals.entry(l).or_insert(span); } } } Ok(()) } } /////////////////////////////////////////////////////////////////////////// // Construction phase -- if we are constructing a tokenizer, this...
// defined for them that indicates they are a // terminal; otherwise it's just an unresolved // identifier. panic!("bare literal `{}` without extern token definition", c); }
random_line_split
mod.rs
//! If an extern token is provided, then this pass validates that //! terminal IDs have conversions. Otherwise, it generates a //! tokenizer. This can only be done after macro expansion because //! some macro arguments never make it into an actual production and //! are only used in `if` conditions; we use string liter...
<'grammar> { grammar: &'grammar Grammar, all_literals: Map<TerminalLiteral, Span>, conversions: Option<Set<TerminalString>>, } impl<'grammar> Validator<'grammar> { fn validate(&mut self) -> NormResult<()> { for item in &self.grammar.items { match *item { GrammarItem:...
Validator
identifier_name
protocol.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/. */ //! Low-level wire protocol implementation. Currently only supports //! [JSON packets] //! (https://wiki.mozilla.o...
<'a, T: Encodable>(&mut self, obj: &T) { let s = json::encode(obj).unwrap().replace("__type__", "type"); println!("<- {}", s); self.write_all(s.len().to_string().as_bytes()).unwrap(); self.write_all(&[':' as u8]).unwrap(); self.write_all(s.as_bytes()).unwrap(); } fn read...
write_json_packet
identifier_name
protocol.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
//! Low-level wire protocol implementation. Currently only supports //! [JSON packets] //! (https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets). use rustc_serialize::json::Json; use rustc_serialize::json::ParserError::{IoError, SyntaxError}; use rustc_serialize::{json, Encodable}; use std...
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
random_line_split
protocol.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/. */ //! Low-level wire protocol implementation. Currently only supports //! [JSON packets] //! (https://wiki.mozilla.o...
fn read_json_packet<'a>(&mut self) -> Result<Option<Json>, String> { // https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport // In short, each JSON packet is [ascii length]:[JSON data of given length] let mut buffer = vec!(); loop { let mut buf = [0]; ...
{ let s = json::encode(obj).unwrap().replace("__type__", "type"); println!("<- {}", s); self.write_all(s.len().to_string().as_bytes()).unwrap(); self.write_all(&[':' as u8]).unwrap(); self.write_all(s.as_bytes()).unwrap(); }
identifier_body
main.rs
#![feature(iter_arith)] #[macro_use] extern crate libeuler; // Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over // five-thousand first names, begin by sorting it into alphabetical order. Then working out the // alphabetical value for each name, multiply this value by its alph...
let mut names: Vec<&str> = include_str!("names.txt") .split(",") .map(|a| a.trim_matches(&['"'] as &[char])) .collect(); names.sort(); solutions! { sol naive { names.iter().zip(0..names.len()).map(|(&name, index)| { name.chars() ...
identifier_body
main.rs
#![feature(iter_arith)] #[macro_use] extern crate libeuler;
// to obtain a name score. // // For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 // + 9 + 14 = 53, is the 938th name in the list. So, COLIN would obtain a score of 938 × 53 = // 49714. // // What is the total of all the name scores in the file? fn main() { let mut na...
// Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over // five-thousand first names, begin by sorting it into alphabetical order. Then working out the // alphabetical value for each name, multiply this value by its alphabetical position in the list
random_line_split
main.rs
#![feature(iter_arith)] #[macro_use] extern crate libeuler; // Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over // five-thousand first names, begin by sorting it into alphabetical order. Then working out the // alphabetical value for each name, multiply this value by its alph...
) { let mut names: Vec<&str> = include_str!("names.txt") .split(",") .map(|a| a.trim_matches(&['"'] as &[char])) .collect(); names.sort(); solutions! { sol naive { names.iter().zip(0..names.len()).map(|(&name, index)| { name.chars() ...
ain(
identifier_name
bytes.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
_ => { cx.span_err(expr.span, "unsupported literal in bytes!"); err = true; } }, _ => { cx.span_err(expr.span, "non-literal in bytes!"); err = true; } } } // Fo...
{ if v.is_ascii() { bytes.push(cx.expr_u8(expr.span, v as u8)); } else { cx.span_err(expr.span, "non-ascii char literal in bytes!"); err = true; } }
conditional_block
bytes.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
ast::ExprLit(ref lit) => match lit.node { // string literal, push each byte to vector expression ast::LitStr(ref s, _) => { for byte in s.get().bytes() { bytes.push(cx.expr_u8(expr.span, byte)); } ...
{ cx.span_warn(sp, "`bytes!` is deprecated, use `b\"foo\"` literals instead"); cx.parse_sess.span_diagnostic.span_note(sp, "see http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals \ for documentation"); cx.parse_sess.span_diagnostic.span_note(sp, "see https://githu...
identifier_body
bytes.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box<base::MacResult+'cx> { cx.span_warn(sp, "`bytes!` is deprecated, use `b\"foo\"` literals instead"); cx.parse_sess.span_diagnostic.span_note(sp, "...
expand_syntax_ext
identifier_name
bytes.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
cx.span_err(expr.span, "negative integer literal in bytes!"); err = true; } ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => { if v > 0xFF { cx.span_err(expr.span, "too large integer literal in bytes!"...
ast::LitInt(_, ast::UnsuffixedIntLit(ast::Minus)) => {
random_line_split
lib.rs
//! [![Build Status](https://travis-ci.org/lawliet89/rowdy.svg)](https://travis-ci.org/lawliet89/rowdy) //! [![Dependency Status](https://dependencyci.com/github/lawliet89/rowdy/badge)](https://dependencyci.com/github/lawliet89/rowdy) //! [![Crates.io](https://img.shields.io/crates/v/rowdy.svg)](https://crates.io/crate...
{ let test = TestUrl { url: not_err!(Url::from_str("https://www.example.com/")), }; assert_tokens( &test, &[ Token::Struct { name: "TestUrl", len: 1, }, Token::Str("url")...
l_serialization_token_round_trip()
identifier_name
lib.rs
//! [![Build Status](https://travis-ci.org/lawliet89/rowdy.svg)](https://travis-ci.org/lawliet89/rowdy) //! [![Dependency Status](https://dependencyci.com/github/lawliet89/rowdy/badge)](https://dependencyci.com/github/lawliet89/rowdy) //! [![Crates.io](https://img.shields.io/crates/v/rowdy.svg)](https://crates.io/crate...
serializer.serialize_str(self.0.as_str()) } } impl<'de> Deserialize<'de> for Url { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { struct UrlVisitor; impl<'de> de::Visitor<'de> for UrlVisitor { type Value = Url; ...
impl Serialize for Url { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, {
random_line_split
window_update.rs
// Copyright 2017 ThetaSinner // // This file is part of Osmium. // Osmium 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. // Osmi...
} pub struct WindowUpdateFrame { window_size_increment: u32 } impl WindowUpdateFrame { pub fn new_conn(frame_header: &super::FrameHeader, frame: &mut IntoIter<u8>) -> Result<Self, error::HttpError> { if frame_header.length!= 4 { return Err(error::HttpError::ConnectionError( ...
{ let mut result = Vec::new(); // include the window size increment let window_size_increment_first_octet = (self.window_size_increment >> 24) as u8; // TODO handle error assert_eq!(0, window_size_increment_first_octet & WINDOW_SIZE_INCREMENT_BIT_MASK); result.push(windo...
identifier_body
window_update.rs
// Copyright 2017 ThetaSinner // // This file is part of Osmium. // Osmium 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. // Osmi...
(frame_header: &super::StreamFrameHeader, frame: &mut IntoIter<u8>) -> Result<Self, error::HttpError> { if frame_header.length!= 4 { return Err(error::HttpError::ConnectionError( error::ErrorCode::FrameSizeError, error::ErrorName::InvalidFrameLengthForConnectionWindow...
new_stream
identifier_name
window_update.rs
// Copyright 2017 ThetaSinner // // This file is part of Osmium. // Osmium 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. // Osmi...
let window_size_increment_first_octet = frame.next().unwrap(); assert_eq!(0, window_size_increment_first_octet & WINDOW_SIZE_INCREMENT_BIT_MASK); Ok(WindowUpdateFrame { window_size_increment: (((window_size_increment_first_octet &!WINDOW_SIZE_INCREMENT_BIT_MASK) ...
{ return Err(error::HttpError::ConnectionError( error::ErrorCode::FrameSizeError, error::ErrorName::InvalidFrameLengthForConnectionWindowUpdateFrame )); }
conditional_block
window_update.rs
// Copyright 2017 ThetaSinner // // This file is part of Osmium. // Osmium 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. // Osmi...
impl WindowUpdateFrameCompressModel { pub fn new(window_size_increment: u32) -> Self { WindowUpdateFrameCompressModel { window_size_increment: window_size_increment } } } impl CompressibleHttpFrame for WindowUpdateFrameCompressModel { fn get_length(&self) -> i32 { // 4 o...
}
random_line_split
panic.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/. */ #[macro_use] extern crate mozjs; use std::ptr; use mozjs::jsapi::{JSAutoRealm, JSContext, OnNewGlobalHookOption,...
(_cx: *mut JSContext, _argc: u32, _vp: *mut Value) -> bool { let mut result = false; wrap_panic(&mut || { panic!(); #[allow(unreachable_code)] { result = true } }); result }
test
identifier_name
panic.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/. */ #[macro_use] extern crate mozjs; use std::ptr; use mozjs::jsapi::{JSAutoRealm, JSContext, OnNewGlobalHookOption,...
result }
} });
random_line_split
panic.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/. */ #[macro_use] extern crate mozjs; use std::ptr; use mozjs::jsapi::{JSAutoRealm, JSContext, OnNewGlobalHookOption,...
{ let mut result = false; wrap_panic(&mut || { panic!(); #[allow(unreachable_code)] { result = true } }); result }
identifier_body
damage-chart.rs
use std::io::Write; use world::{attack_damage, roll}; fn ev<F>(n: usize, f: F) -> f32 where F: Fn(&mut rand::prelude::ThreadRng) -> f32, { let mut acc = 0.0; let mut rng = rand::thread_rng(); for _ in 0..n { acc += f(&mut rng); } acc / n as f32 } fn expected_dmg(advantage: i32) -> f32...
}); println!("Hello, world!"); println!("Expected dmg: {}", e); }
{ print!(" "); for one in 0..10 { print!(" 0{}", one); } println!(""); for tens in -3..10 { print!("{:>3}0 ", tens); for ones in 0..10 { let n = tens * 10 + ones; print!("{:.3} ", expected_dmg(n)); let _ = ::std::io::stdout().flush...
identifier_body
damage-chart.rs
use std::io::Write; use world::{attack_damage, roll}; fn ev<F>(n: usize, f: F) -> f32 where F: Fn(&mut rand::prelude::ThreadRng) -> f32, { let mut acc = 0.0; let mut rng = rand::thread_rng(); for _ in 0..n { acc += f(&mut rng); } acc / n as f32 } fn
(advantage: i32) -> f32 { const REPEAT_ROLLS: usize = 1_000_000; ev(REPEAT_ROLLS, |rng| { let roll = roll(rng); let dmg = attack_damage(roll, advantage, 100); dmg as f32 / 100.0 }) } fn main() { print!(" "); for one in 0..10 { print!(" 0{}", one); } p...
expected_dmg
identifier_name
damage-chart.rs
use std::io::Write; use world::{attack_damage, roll}; fn ev<F>(n: usize, f: F) -> f32 where F: Fn(&mut rand::prelude::ThreadRng) -> f32, { let mut acc = 0.0; let mut rng = rand::thread_rng(); for _ in 0..n { acc += f(&mut rng); }
} fn expected_dmg(advantage: i32) -> f32 { const REPEAT_ROLLS: usize = 1_000_000; ev(REPEAT_ROLLS, |rng| { let roll = roll(rng); let dmg = attack_damage(roll, advantage, 100); dmg as f32 / 100.0 }) } fn main() { print!(" "); for one in 0..10 { print!(" 0{}",...
acc / n as f32
random_line_split
shootout-spectralnorm.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>, tmp: Arc<RWLock<Vec<f64>>>) { mult_Av(v, tmp.clone()); mult_Atv(tmp, out); } fn main() { let args = os::args(); let n = if os::getenv("RUST_BENCH").is_some() { 5500 } else if args.len() < 2 { 2000 } else { ...
mult_AtAv
identifier_name
shootout-spectralnorm.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
2000 } else { FromStr::from_str(args[1]).unwrap() }; let u = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); let v = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); let tmp = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); for _ in range(0, 10) { mult_AtAv(u.clone(), v.clone(),...
fn main() { let args = os::args(); let n = if os::getenv("RUST_BENCH").is_some() { 5500 } else if args.len() < 2 {
random_line_split
shootout-spectralnorm.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn mult_AtAv(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>, tmp: Arc<RWLock<Vec<f64>>>) { mult_Av(v, tmp.clone()); mult_Atv(tmp, out); } fn main() { let args = os::args(); let n = if os::getenv("RUST_BENCH").is_some() { 5500 } else if args.len() < 2 { 2000 ...
{ mult(v, out, mult_Atv_impl); }
identifier_body
shootout-spectralnorm.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
else if args.len() < 2 { 2000 } else { FromStr::from_str(args[1]).unwrap() }; let u = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); let v = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); let tmp = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); for _ in range(0, 10) { mult_...
{ 5500 }
conditional_block
keychain.rs
use std::collections::HashMap; use super::operations::BurnchainOpSigner; use stacks::chainstate::stacks::{StacksTransactionSigner, TransactionAuth, StacksPublicKey, StacksPrivateKey, StacksAddress}; use stacks::address::AddressHashMode; use stacks::burnchains::{BurnchainSigner, PrivateKey}; use stacks::util::vrf::{VR...
pub fn get_burnchain_signer(&self) -> BurnchainSigner { let public_keys = self.secret_keys.iter().map(|ref pk| StacksPublicKey::from_private(pk)).collect(); BurnchainSigner { hash_mode: self.hash_mode, num_sigs: self.threshold as usize, public_keys } ...
{ StacksAddress::from_public_keys( signer.hash_mode.to_version_testnet(), &signer.hash_mode, signer.num_sigs, &signer.public_keys).unwrap() }
identifier_body
keychain.rs
use std::collections::HashMap; use super::operations::BurnchainOpSigner; use stacks::chainstate::stacks::{StacksTransactionSigner, TransactionAuth, StacksPublicKey, StacksPrivateKey, StacksAddress}; use stacks::address::AddressHashMode; use stacks::burnchains::{BurnchainSigner, PrivateKey}; use stacks::util::vrf::{VR...
{ secret_keys: Vec<StacksPrivateKey>, threshold: u16, hash_mode: AddressHashMode, pub hashed_secret_state: Sha256Sum, microblocks_secret_keys: Vec<StacksPrivateKey>, vrf_secret_keys: Vec<VRFPrivateKey>, vrf_map: HashMap<VRFPublicKey, VRFPrivateKey>, } impl Keychain { pub fn new(secre...
Keychain
identifier_name
keychain.rs
use std::collections::HashMap; use super::operations::BurnchainOpSigner; use stacks::chainstate::stacks::{StacksTransactionSigner, TransactionAuth, StacksPublicKey, StacksPrivateKey, StacksAddress}; use stacks::address::AddressHashMode; use stacks::burnchains::{BurnchainSigner, PrivateKey}; use stacks::util::vrf::{VR...
} pub fn address_from_burnchain_signer(signer: &BurnchainSigner) -> StacksAddress { StacksAddress::from_public_keys( signer.hash_mode.to_version_testnet(), &signer.hash_mode, signer.num_sigs, &signer.public_keys).unwrap() } pub fn get_burnchain_s...
self.threshold as usize, &public_keys).unwrap()
random_line_split
params-on-stack.rs
// build-fail // compile-flags: --target thumbv8m.main-none-eabi --crate-type lib // needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)] #![no_core] #[lang="sized"] pub trait Sized { } #[lang="copy"] pub trait Copy { } extern "rust-intrinsic" { pub fn transmute<T, U>(...
(a: u32, b: u32, c: u32, d: u32, e: u32) -> u32 { let non_secure_function = unsafe { transmute::< usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32> ( 0x10000004, ) }; non_secure_function(a, b, c, d, e) }
test
identifier_name
params-on-stack.rs
// build-fail // compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
#[lang="sized"] pub trait Sized { } #[lang="copy"] pub trait Copy { } extern "rust-intrinsic" { pub fn transmute<T, U>(e: T) -> U; } #[no_mangle] pub fn test(a: u32, b: u32, c: u32, d: u32, e: u32) -> u32 { let non_secure_function = unsafe { transmute::< usize, extern "C-cmse-n...
// needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)] #![no_core]
random_line_split
params-on-stack.rs
// build-fail // compile-flags: --target thumbv8m.main-none-eabi --crate-type lib // needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)] #![no_core] #[lang="sized"] pub trait Sized { } #[lang="copy"] pub trait Copy { } extern "rust-intrinsic" { pub fn transmute<T, U>(...
{ let non_secure_function = unsafe { transmute::< usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32> ( 0x10000004, ) }; non_secure_function(a, b, c, d, e) }
identifier_body
filter.rs
use std::default::Default; use std::str; use nom::IResult; use nom::{be_u8, digit, is_alphabetic, is_alphanumeric, is_hex_digit}; use lber::common::TagClass; use lber::structures::{Boolean, ExplicitTag, OctetString, Sequence, Tag}; #[doc(hidden)] pub fn parse(input: &str) -> Result<Tag, ()> { match filtexpr(inpu...
inner.push(Tag::OctetString(OctetString { class: TagClass::Context, id: 3, inner: value })); if dn { inner.push(Tag::Boolean(Boolean { class: TagClass::Context, id: 4, inner: dn })); } Tag::Sequence(Sequence { class...
{ inner.push(Tag::OctetString(OctetString { class: TagClass::Context, id: 2, inner: attr.to_vec() })); }
conditional_block
filter.rs
use std::default::Default; use std::str; use nom::IResult; use nom::{be_u8, digit, is_alphabetic, is_alphanumeric, is_hex_digit}; use lber::common::TagClass; use lber::structures::{Boolean, ExplicitTag, OctetString, Sequence, Tag}; #[doc(hidden)] pub fn parse(input: &str) -> Result<Tag, ()> { match filtexpr(inpu...
})); if dn { inner.push(Tag::Boolean(Boolean { class: TagClass::Context, id: 4, inner: dn })); } Tag::Sequence(Sequence { class: TagClass::Context, id: EXT_MATCH, inner: inner }) } named!(attributedescription<&[u8]>, recog...
{ let mut inner = vec![]; if let Some(mrule) = mrule { inner.push(Tag::OctetString(OctetString { class: TagClass::Context, id: 1, inner: mrule.to_vec() })); } if let Some(attr) = attr { inner.push(Tag::OctetString(OctetString { clas...
identifier_body
filter.rs
use std::default::Default; use std::str; use nom::IResult; use nom::{be_u8, digit, is_alphabetic, is_alphanumeric, is_hex_digit}; use lber::common::TagClass; use lber::structures::{Boolean, ExplicitTag, OctetString, Sequence, Tag}; #[doc(hidden)] pub fn parse(input: &str) -> Result<Tag, ()> { match filtexpr(inpu...
(filterop: &[u8]) -> u64 { match filterop { b">=" => GTE_MATCH, b"<=" => LTE_MATCH, b"~=" => APPROX_MATCH, _ => unimplemented!(), } } named!(eq<Tag>, do_parse!( attr: attributedescription >> tag!("=") >> initial: unescaped >> mid_final: map_res!(many0!(preceded!(...
filtertag
identifier_name
filter.rs
use std::default::Default; use std::str; use nom::IResult; use nom::{be_u8, digit, is_alphabetic, is_alphanumeric, is_hex_digit}; use lber::common::TagClass; use lber::structures::{Boolean, ExplicitTag, OctetString, Sequence, Tag}; #[doc(hidden)] pub fn parse(input: &str) -> Result<Tag, ()> { match filtexpr(inpu...
Unescaper::Error } }, Unescaper::WantSecond(partial) => { if is_hex_digit(c) { Unescaper::Value((partial << 4) + (c - if c <= b'9' { b'0' } else { (c & 0x20) + b'A' - 10 })) } else { Unesc...
if is_hex_digit(c) { Unescaper::WantSecond(c - if c <= b'9' { b'0' } else { (c & 0x20) + b'A' - 10 }) } else {
random_line_split
unary-op-disambig.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 ...
() -> isize { { f() }; -1 } fn block_nosemi() -> isize { ({ 0 }) - 1 } fn if_semi() -> isize { if true { f() } else { f() }; -1 } fn if_nosemi() -> isize { (if true { 0 } else { 0 }) - 1 } fn alt_semi() -> isize { match true { true => { f() } _ => { } }; -1 } fn alt_no_semi() -> isize { (match true { true => { 0 }...
block_semi
identifier_name
unary-op-disambig.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn alt_semi() -> isize { match true { true => { f() } _ => { } }; -1 } fn alt_no_semi() -> isize { (match true { true => { 0 } _ => { 1 } }) - 1 } fn stmt() { { f() }; -1; }
fn if_nosemi() -> isize { (if true { 0 } else { 0 }) - 1 }
random_line_split
unary-op-disambig.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn block_nosemi() -> isize { ({ 0 }) - 1 } fn if_semi() -> isize { if true { f() } else { f() }; -1 } fn if_nosemi() -> isize { (if true { 0 } else { 0 }) - 1 } fn alt_semi() -> isize { match true { true => { f() } _ => { } }; -1 } fn alt_no_semi() -> isize { (match true { true => { 0 } _ => { 1 } }) - 1 } fn st...
{ { f() }; -1 }
identifier_body
lib.rs
}; use msg::constellation_msg::{PipelineId, PipelineNamespaceId, TraversalDirection}; use net_traits::{ReferrerPolicy, ResourceThreads}; use net_traits::image::base::Image; use net_traits::image_cache::ImageCache; use net_traits::response::HttpsState; use net_traits::storage_thread::StorageType; use profile_traits::mem...
ResizeInactive(PipelineId, WindowSizeData), /// Notifies the script that a pipeline should be closed. ExitPipeline(PipelineId, DiscardBrowsingContext), /// Notifies the script that the whole thread should be closed. ExitScriptThread, /// Sends a DOM event. SendEvent(PipelineId, CompositorEve...
Resize(PipelineId, WindowSizeData, WindowSizeType), /// Notifies script that window has been resized but to not take immediate action.
random_line_split
lib.rs
use msg::constellation_msg::{PipelineId, PipelineNamespaceId, TraversalDirection}; use net_traits::{ReferrerPolicy, ResourceThreads}; use net_traits::image::base::Image; use net_traits::image_cache::ImageCache; use net_traits::response::HttpsState; use net_traits::storage_thread::StorageType; use profile_traits::mem; ...
} /// Specifies whether the script or layout thread needs to be ticked for animation. #[derive(Deserialize, Serialize)] pub enum AnimationTickType { /// The script thread. Script, /// The layout thread. Layout, } /// The scroll state of a stacking context. #[derive(Copy, Clone, Debug, Deserialize, Se...
{ match *self { MozBrowserErrorType::Fatal => "fatal", } }
identifier_body
lib.rs
use msg::constellation_msg::{PipelineId, PipelineNamespaceId, TraversalDirection}; use net_traits::{ReferrerPolicy, ResourceThreads}; use net_traits::image::base::Image; use net_traits::image_cache::ImageCache; use net_traits::response::HttpsState; use net_traits::storage_thread::StorageType; use profile_traits::mem; ...
{ /// Mouse button clicked Click, /// Mouse button down MouseDown, /// Mouse button up MouseUp, } /// Events from the compositor that the script thread needs to know about #[derive(Deserialize, Serialize)] pub enum CompositorEvent { /// The window was resized. ResizeEvent(WindowSizeDat...
MouseEventType
identifier_name
twitch.rs
use std; extern crate serde_json; extern crate serde; use std::io::Read; use emote; use emote::{EmoteError,JsonError}; use http; const GLOBAL_URL:&'static str = "https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=0"; pub struct Emote<'a>{ http: &'a http::Http, } #[derive(Serialize, Deserialize,Default)]...
}; let mut emotes = Vec::new(); for set in sets{ let emote = try_map!(serde_json::from_value(set),EmoteError::Json(JsonError::ParseError)); emotes.push(emote); } Ok(emotes) } } #[cfg(test)] mod test { #[test] fn twitch_test(){ let http...
let v:serde_json::Value = try_map!(serde_json::from_str(&s),EmoteError::Json(JsonError::ParseError)); let emoticon_sets = &v["emoticon_sets"]; let mut sets = match emoticon_sets["0"].as_array(){ Some(a)=>a.clone(), None=>return Err(EmoteError::Json(JsonError::ParseError))...
random_line_split
twitch.rs
use std; extern crate serde_json; extern crate serde; use std::io::Read; use emote; use emote::{EmoteError,JsonError}; use http; const GLOBAL_URL:&'static str = "https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=0"; pub struct
<'a>{ http: &'a http::Http, } #[derive(Serialize, Deserialize,Default)] pub struct Set{ id: u64, code: String, } impl emote::Emote for Set{ fn name(&self)->&str{ &self.code } } impl <'a>Emote<'a>{ pub fn new(http:&http::Http)->Result<Emote,String>{ Ok(Emote{ http ...
Emote
identifier_name
nodept.rs
pub type Node = usize; #[derive(Debug, Copy, Clone)] pub struct NodePt { pub id: Node, pub x: f64, pub y: f64, } impl NodePt { pub fn
(node_id: Node, x: f64, y: f64) -> NodePt { NodePt { id: node_id, x: x, y: y, } } pub fn distance_to(self, other: NodePt) -> f64 { let xx = (self.x - other.x) * (self.x - other.x); let yy = (self.y - other.y) * (self.y - other.y); (xx...
new
identifier_name
nodept.rs
pub type Node = usize; #[derive(Debug, Copy, Clone)] pub struct NodePt { pub id: Node, pub x: f64, pub y: f64, } impl NodePt { pub fn new(node_id: Node, x: f64, y: f64) -> NodePt { NodePt {
} } pub fn distance_to(self, other: NodePt) -> f64 { let xx = (self.x - other.x) * (self.x - other.x); let yy = (self.y - other.y) * (self.y - other.y); (xx + yy).sqrt().round() } } impl PartialEq for NodePt { fn eq(&self, other: &NodePt) -> bool { self.id == o...
id: node_id, x: x, y: y,
random_line_split
mod.rs
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // Core/vfs/mod.rs //! Virtual File System #[allow(unused_imports)] use prelude::*; use metadevs::storage::VolumeHandle; module_define!(VFS, [], init); pub type Result<T> = ::core::result::Result<T,Error>; #[derive(Debug)] pub enum Error { /// File not found...
(v: ::metadevs::storage::IoError) -> Error { Error::BlockIoError(v) } } pub use self::path::{Path,PathBuf}; pub mod node; pub mod mount; pub mod handle; mod path; mod ramfs; fn init() { // 1. Initialise global structures mount::init(); node::init(); ramfs::init(); // 2. Start the root/builtin filesystems mo...
from
identifier_name
mod.rs
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // Core/vfs/mod.rs //! Virtual File System #[allow(unused_imports)] use prelude::*; use metadevs::storage::VolumeHandle; module_define!(VFS, [], init); pub type Result<T> = ::core::result::Result<T,Error>; #[derive(Debug)] pub enum Error { /// File not found...
Err(e) => panic!("BUG - Opening '/' failed: {:?}", e), }; root.mkdir("system").unwrap(); root.mkdir("volumes").unwrap(); root.mkdir("temp").unwrap(); }
{ Ok(v) => v,
random_line_split
nested-class.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 ...
() { struct b { i: int, } impl b { fn do_stuff(&self) -> int { return 37; } } fn b(i:int) -> b { b { i: i } } // fn b(x:int) -> int { panic!(); } let z = b(42); assert_eq!(z.i, 42); assert_eq!(z.do_stuff(), 37); }
main
identifier_name
nested-class.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// fn b(x:int) -> int { panic!(); } let z = b(42); assert_eq!(z.i, 42); assert_eq!(z.do_stuff(), 37); }
{ b { i: i } }
identifier_body
nested-class.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 ...
struct b { i: int, } impl b { fn do_stuff(&self) -> int { return 37; } } fn b(i:int) -> b { b { i: i } } // fn b(x:int) -> int { panic!(); } let z = b(42); assert_eq!(z.i, 42); assert_eq!(z.do_stuff(), 37); }
random_line_split
mod.rs
use {Function, Functions, Context, Contexts, Compiled, Value}; use tree::Tree; use error::Error; use serde::Serialize; use to_value; use std::fmt; /// Expression builder pub struct Expr { expression: String, compiled: Option<Compiled>, functions: Functions, contexts: Contexts, } impl ...
compiled: if self.compiled.is_some() { Some(Tree::new(self.expression.clone()).compile().unwrap()) } else { None }, contexts: self.contexts.clone(), functions: Functions::new(), } } } impl fmt::Debug for ...
random_line_split
mod.rs
use {Function, Functions, Context, Contexts, Compiled, Value}; use tree::Tree; use error::Error; use serde::Serialize; use to_value; use std::fmt; /// Expression builder pub struct Expr { expression: String, compiled: Option<Compiled>, functions: Functions, contexts: Contexts, } imp...
(&mut self, contexts: &'a [Context]) -> &'a mut ExecOptions { self.contexts = Some(contexts); self } /// Set functions. pub fn functions(&mut self, functions: &'a Functions) -> &'a mut ExecOptions { self.functions = Some(functions); self } /// Execute the...
contexts
identifier_name
mod.rs
use {Function, Functions, Context, Contexts, Compiled, Value}; use tree::Tree; use error::Error; use serde::Serialize; use to_value; use std::fmt; /// Expression builder pub struct Expr { expression: String, compiled: Option<Compiled>, functions: Functions, contexts: Contexts, } imp...
else { None }, contexts: self.contexts.clone(), functions: Functions::new(), } } } impl fmt::Debug for Expr { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { write!(formatter, "{:?}", self.expression) ...
{ Some(Tree::new(self.expression.clone()).compile().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...
rlp.append_list(&uncles); rlp.out() } pub fn generate_dummy_client(block_number: u32) -> Arc<Client> { generate_dummy_client_with_spec_and_data(Spec::new_test, block_number, 0, &[]) } pub fn generate_dummy_client_with_data(block_number: u32, txs_per_block: usize, tx_gas_prices: &[U256]) -> Arc<Client> { generate_...
rlp.begin_list(transactions.len()); for t in transactions { rlp.append_raw(&rlp::encode(t).into_vec(), 1); }
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...
} client.flush_queue(); client.import_verified_blocks(); client } fn new_db() -> Arc<KeyValueDB> { Arc::new(::util::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0))) } pub fn generate_dummy_blockchain(block_number: u32) -> BlockChain { let db = new_db(); let bc = BlockChain::new(BlockChainConfig::default(), &c...
{ panic!("panic importing block which is well-formed"); }
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...
() -> State<::state_db::StateDB> { let journal_db = get_temp_state_db(); State::new(journal_db, U256::from(0), Default::default()) } pub fn get_temp_state_with_factory(factory: EvmFactory) -> State<::state_db::StateDB> { let journal_db = get_temp_state_db(); let mut factories = Factories::default(); factories.vm ...
get_temp_state
identifier_name
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...
pub fn get_temp_state() -> State<::state_db::StateDB> { let journal_db = get_temp_state_db(); State::new(journal_db, U256::from(0), Default::default()) } pub fn get_temp_state_with_factory(factory: EvmFactory) -> State<::state_db::StateDB> { let journal_db = get_temp_state_db(); let mut factories = Factories::de...
{ let db = new_db(); let bc = BlockChain::new(BlockChainConfig::default(), &create_unverifiable_block(0, H256::zero()), db.clone()); bc }
identifier_body
shift-various-bad-types.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(p: &Panolpy) { 22 >> p.char; //~^ ERROR E0277 //~| ERROR E0277 22 >> p.str; //~^ ERROR E0277 //~| ERROR E0277 22 >> p; //~^ ERROR E0277 //~| ERROR E0277 let x; 22 >> x; // ambiguity error winds up being suppressed 22 >> 1; // Integer literal types are OK // ...
foo
identifier_name
shift-various-bad-types.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() { }
//~| found i64)
random_line_split
FeatherFilter.rs
#pragma version(1) #pragma rs java_package_name(cn.louispeng.imagefilter.renderscript) // 羽化效果 #include "Clamp.rsh" // set from the java SDK level rs_allocation gIn; rs_allocation gOut; rs_script gScript; // magic factor const static float _Size = 0.5f; // static variables static uint32_t _width; static uint32_t ...
static uint32_t _max; static uint32_t _min; static uint32_t _diff; static void setup() { _width = rsAllocationGetDimX(gIn); _height = rsAllocationGetDimY(gIn); _ratio = (_width > _height)? ((float)_height / _width) : ((float)_width / _height); _centerX = _width >> 1; _centerY = _height >> 1; _max = _centerX *...
static uint32_t _centerX; static uint32_t _centerY;
random_line_split
FeatherFilter.rs
#pragma version(1) #pragma rs java_package_name(cn.louispeng.imagefilter.renderscript) // 羽化效果 #include "Clamp.rsh" // set from the java SDK level rs_allocation gIn; rs_allocation gOut; rs_script gScript; // magic factor const static float _Size = 0.5f; // static variables static uint32_t _width; static uint32_t ...
distanceY = distanceY * _ratio; } uint32_t distSq = distanceX * distanceX + distanceY * distanceY; float v = (float)distSq / _diff; float3 f3 = f4.rgb + v; f3 = FClamp01Float3(f3); *v_out = rsPackColorTo8888(f3); }
anceX = distanceX * _ratio; } else {
conditional_block
build.rs
use std::env; fn main() { let target = env::var("TARGET").unwrap_or("".to_string()); let tundra_dir = env::var("TUNDRA_OBJECTDIR").unwrap_or("".to_string()); let libs = env::var("TUNDRA_STATIC_LIBS").unwrap_or("".to_string()); let native_libs = libs.split(" "); println!("cargo:rustc-link-search=nati...
else if target.contains("windows") { } else { println!("cargo:rustc-flags=-l dylib=stdc++"); println!("cargo:rustc-flags=-l dylib=X11"); println!("cargo:rustc-flags=-l dylib=GL"); println!("cargo:rustc-flags=-l dylib=dl"); } }
{ println!("cargo:rustc-flags=-l dylib=stdc++"); println!("cargo:rustc-flags=-l framework=Cocoa"); println!("cargo:rustc-flags=-l framework=Metal"); println!("cargo:rustc-flags=-l framework=OpenGL"); println!("cargo:rustc-flags=-l framework=QuartzCore"); }
conditional_block
build.rs
use std::env; fn main()
} else if target.contains("windows") { } else { println!("cargo:rustc-flags=-l dylib=stdc++"); println!("cargo:rustc-flags=-l dylib=X11"); println!("cargo:rustc-flags=-l dylib=GL"); println!("cargo:rustc-flags=-l dylib=dl"); } }
{ let target = env::var("TARGET").unwrap_or("".to_string()); let tundra_dir = env::var("TUNDRA_OBJECTDIR").unwrap_or("".to_string()); let libs = env::var("TUNDRA_STATIC_LIBS").unwrap_or("".to_string()); let native_libs = libs.split(" "); println!("cargo:rustc-link-search=native={}", tundra_dir); ...
identifier_body
build.rs
use std::env; fn main() { let target = env::var("TARGET").unwrap_or("".to_string()); let tundra_dir = env::var("TUNDRA_OBJECTDIR").unwrap_or("".to_string()); let libs = env::var("TUNDRA_STATIC_LIBS").unwrap_or("".to_string()); let native_libs = libs.split(" ");
for lib in native_libs { println!("cargo:rustc-link-lib=static={}", lib); println!("cargo:rerun-if-changed={}", lib); } if target.contains("darwin") { println!("cargo:rustc-flags=-l dylib=stdc++"); println!("cargo:rustc-flags=-l framework=Cocoa"); println!("cargo:rustc-flags=-l...
println!("cargo:rustc-link-search=native={}", tundra_dir);
random_line_split
build.rs
use std::env; fn
() { let target = env::var("TARGET").unwrap_or("".to_string()); let tundra_dir = env::var("TUNDRA_OBJECTDIR").unwrap_or("".to_string()); let libs = env::var("TUNDRA_STATIC_LIBS").unwrap_or("".to_string()); let native_libs = libs.split(" "); println!("cargo:rustc-link-search=native={}", tundra_dir); ...
main
identifier_name
lex_unique_vecs_length_inclusive_range.rs
use itertools::Itertools; use malachite_base::bools::exhaustive::exhaustive_bools; use malachite_base::nevers::nevers; use malachite_base::tuples::exhaustive::exhaustive_units; use malachite_base::vecs::exhaustive::lex_unique_vecs_length_inclusive_range; use std::fmt::Debug; fn lex_unique_vecs_length_inclusive_range_s...
1, 'a'..='c', 3, &[&['a'], &['b'], &['c']], ); }
&[&[false, true], &[true, false]], ); lex_unique_vecs_length_inclusive_range_small_helper( 1,
random_line_split
lex_unique_vecs_length_inclusive_range.rs
use itertools::Itertools; use malachite_base::bools::exhaustive::exhaustive_bools; use malachite_base::nevers::nevers; use malachite_base::tuples::exhaustive::exhaustive_units; use malachite_base::vecs::exhaustive::lex_unique_vecs_length_inclusive_range; use std::fmt::Debug; fn lex_unique_vecs_length_inclusive_range_s...
1, 1, 'a'..='c', 3, &[&['a'], &['b'], &['c']], ); }
{ lex_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]); lex_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]); lex_unique_vecs_length_inclusive_range_small_helper(0, 4, exhaustive_units(), 2, &[&[], &[()]]); lex_unique_vecs_length_inclusive_range_small_hel...
identifier_body
lex_unique_vecs_length_inclusive_range.rs
use itertools::Itertools; use malachite_base::bools::exhaustive::exhaustive_bools; use malachite_base::nevers::nevers; use malachite_base::tuples::exhaustive::exhaustive_units; use malachite_base::vecs::exhaustive::lex_unique_vecs_length_inclusive_range; use std::fmt::Debug; fn lex_unique_vecs_length_inclusive_range_s...
() { lex_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]); lex_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]); lex_unique_vecs_length_inclusive_range_small_helper(0, 4, exhaustive_units(), 2, &[&[], &[()]]); lex_unique_vecs_length_inclusive_range_small_...
test_lex_unique_vecs_length_inclusive_range
identifier_name
time.rs
// Copyright 2015 juggle-tux // // This file is part of srttool. // // srttool 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. // //...
return Ok(StartEnd(buf[0], buf[1])); } } impl Display for StartEnd { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { write!(f, "{} --> {}", self.0, self.1) } } /// used for the start or end time of a Block #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pu...
{ return Err(ParseError::InvalidTimeLine); }
conditional_block
time.rs
// Copyright 2015 juggle-tux // // This file is part of srttool. // // srttool 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, rhs: Duration) -> Time { if self.0.gt(&rhs) { Time(self.0 - rhs) } else { Time::default() } } } impl From<Duration> for Time { fn from(d: Duration) -> Time { Time(d) } } impl From<Time> for Duration { fn from(t: Time) -> Duration { ...
sub
identifier_name
time.rs
// Copyright 2015 juggle-tux // // This file is part of srttool. // // srttool 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. // //...
pub struct StartEnd(pub Time, pub Time); impl Add for StartEnd { type Output = StartEnd; fn add(self, rhs: StartEnd) -> StartEnd { StartEnd(self.0 + rhs.0, self.1 + rhs.1) } } impl Add<Time> for StartEnd { type Output = StartEnd; fn add(self, rhs: Time) -> StartEnd { self + rhs.0...
/// start and end time of a Block #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
random_line_split
unwind-box-res.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 ...
() { fail!(); } struct r { v: *int, } impl Drop for r { fn drop(&mut self) { unsafe { let _v2: ~int = cast::transmute(self.v); } } } fn r(v: *int) -> r { r { v: v } } fn main() { unsafe { let i1 = ~0; let i1p = cast::transmute_copy(&i1); ...
failfn
identifier_name
unwind-box-res.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 ...
{ unsafe { let i1 = ~0; let i1p = cast::transmute_copy(&i1); cast::forget(i1); let x = @r(i1p); failfn(); error!(x); } }
identifier_body
unwind-box-res.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn r(v: *int) -> r { r { v: v } } fn main() { unsafe { let i1 = ~0; let i1p = cast::transmute_copy(&i1); cast::forget(i1); let x = @r(i1p); failfn(); error!(x); } }
unsafe { let _v2: ~int = cast::transmute(self.v); } } }
random_line_split
mutex.rs
use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut, Drop}; use core::sync::atomic::{AtomicBool, Ordering}; use common::debug::*; use syscall::call::sys_yield; /// A mutex, i.e. a form of safe shared memory between threads. See rust std's Mutex. pub struct Mutex<T:?Sized> { lock: AtomicBool, value: U...
} }
{ d("Mutex was already unlocked!\n"); }
conditional_block
mutex.rs
use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut, Drop}; use core::sync::atomic::{AtomicBool, Ordering}; use common::debug::*; use syscall::call::sys_yield; /// A mutex, i.e. a form of safe shared memory between threads. See rust std's Mutex. pub struct Mutex<T:?Sized> { lock: AtomicBool, value: U...
(&mut self) { if!self.lock.compare_and_swap(true, false, Ordering::SeqCst) { d("Mutex was already unlocked!\n"); } } }
drop
identifier_name
mutex.rs
use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut, Drop}; use core::sync::atomic::{AtomicBool, Ordering}; use common::debug::*; use syscall::call::sys_yield; /// A mutex, i.e. a form of safe shared memory between threads. See rust std's Mutex. pub struct Mutex<T:?Sized> { lock: AtomicBool, value: U...
impl<'mutex, T:?Sized> Deref for MutexGuard<'mutex, T> { type Target = T; fn deref<'a>(&'a self) -> &'a T { unsafe { &*self.data.get() } } } impl<'mutex, T:?Sized> DerefMut for MutexGuard<'mutex, T> { fn deref_mut<'a>(&'a mut self) -> &'a mut T { unsafe { &mut *self.data.get() } } ...
random_line_split
xorshift.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
impl Rng for XorShiftPlusRng { #[inline] fn next_u32(&mut self) -> u32 { self.next_u64() as u32 } #[inline] fn next_u64(&mut self) -> u64 { let mut s1 = self.s[0]; let s0 = self.s[1]; self.s[0] = s0; s1 = s1 ^ (s1 << 23); // a self.s[1] = s1 ^ s0 ^ (s...
s: [w(0x193a6754a8a7d469), w(0x97830e05113ba7bb)] } } }
random_line_split
xorshift.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self) -> u32 { self.next_u64() as u32 } #[inline] fn next_u64(&mut self) -> u64 { let mut s1 = self.s[0]; let s0 = self.s[1]; self.s[0] = s0; s1 = s1 ^ (s1 << 23); // a self.s[1] = s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26); // b, c (self.s[1] + s0).0 ...
next_u32
identifier_name
asm.rs
use super::BackendTypes; use crate::mir::operand::OperandRef; use crate::mir::place::PlaceRef; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_hir::def_id::DefId; use rustc_hir::LlvmInlineAsmInner; use rustc_middle::ty::Instance; use rustc_span::Span; use rustc_target::asm::InlineAsmRegOrRegClass; ...
Const { string: String, }, SymFn { instance: Instance<'tcx>, }, SymStatic { def_id: DefId, }, } #[derive(Debug)] pub enum GlobalAsmOperandRef { Const { string: String }, } pub trait AsmBuilderMethods<'tcx>: BackendTypes { /// Take an inline assembly expression a...
out_place: Option<PlaceRef<'tcx, B::Value>>, },
random_line_split
asm.rs
use super::BackendTypes; use crate::mir::operand::OperandRef; use crate::mir::place::PlaceRef; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_hir::def_id::DefId; use rustc_hir::LlvmInlineAsmInner; use rustc_middle::ty::Instance; use rustc_span::Span; use rustc_target::asm::InlineAsmRegOrRegClass; ...
<'tcx, B: BackendTypes +?Sized> { In { reg: InlineAsmRegOrRegClass, value: OperandRef<'tcx, B::Value>, }, Out { reg: InlineAsmRegOrRegClass, late: bool, place: Option<PlaceRef<'tcx, B::Value>>, }, InOut { reg: InlineAsmRegOrRegClass, late: bool...
InlineAsmOperandRef
identifier_name
const-fields-and-indexing.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 ...
println!("{:?}", q); println!("{:?}", t); assert_eq!(p, 3); assert_eq!(q, 3); assert_eq!(t, 20); }
pub fn main() { println!("{:?}", p);
random_line_split
const-fields-and-indexing.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 ...
{ d: int, e: int } static k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}}; static m : int = k.c.e; pub fn main() { println!("{:?}", p); println!("{:?}", q); println!("{:?}", t); assert_eq!(p, 3); assert_eq!(q, 3); assert_eq!(t, 20); }
D
identifier_name
iter.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...
<A> { range: Range<A>, done: bool, } /// Return an iterator over the range [start, stop] #[inline] pub fn range_inclusive<A>(start: A, stop: A) -> RangeInclusive<A> where A: Add<A, Output = A> + PartialOrd + Clone + One { RangeInclusive{range: range(start, stop), done: false} } impl<A> Iterator for Ra...
RangeInclusive
identifier_name
iter.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 !self.done && ((self.rev && self.state >= self.stop) || (!self.rev && self.state <= self.stop)) { let result = self.state.clone(); match self.state.checked_add(&self.step) { Some(x) => self.state = x, None => self.done = true...
identifier_body
iter.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
/// /// let array = [0, 1, 2, 3, 4]; /// /// for i in iter::range(0, 5) { /// println!("{}", i); /// assert_eq!(i, array[i]); /// } /// ``` #[inline] pub fn range<A>(start: A, stop: A) -> Range<A> where A: Add<A, Output = A> + PartialOrd + Clone + One { Range{state: start, stop: stop, one: One::one()} ...
/// # Example /// /// ```rust /// use num::iter;
random_line_split
iter.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...
} } } #[inline] fn size_hint(&self) -> (usize, Option<usize>) { let (lo, hi) = self.range.size_hint(); if self.done { (lo, hi) } else { let lo = lo.saturating_add(1); let hi = match hi { Some(x) => x.checked_ad...
{ None }
conditional_block
test_terminal.rs
use crate::input::Key; use crate::models::application::Event; use scribe::buffer::Position; use std::sync::Mutex; use super::Terminal; use crate::view::{Colors, Style}; const WIDTH: usize = 10; const HEIGHT: usize = 10; // A headless terminal that tracks printed data, which can be // returned as a String to test disp...
} } data } } impl Terminal for TestTerminal { fn listen(&self) -> Option<Event> { // This implementation will return a key once, followed by nothing. // This allows us to test both scenarios, the latter being crucial // to stopping the application in test m...
{ for _ in last_row_with_data..y { data.push('\n'); last_column_with_data = 0; } for _ in last_column_with_data..x { data.push(' '); } data.push(c...
conditional_block
test_terminal.rs
use crate::input::Key; use crate::models::application::Event; use scribe::buffer::Position; use std::sync::Mutex; use super::Terminal; use crate::view::{Colors, Style}; const WIDTH: usize = 10; const HEIGHT: usize = 10; // A headless terminal that tracks printed data, which can be // returned as a String to test disp...
} } } data } } impl Terminal for TestTerminal { fn listen(&self) -> Option<Event> { // This implementation will return a key once, followed by nothing. // This allows us to test both scenarios, the latter being crucial // to stopping the appl...
// set it ahead when we've run into a character to // differentiate from leading spaces. last_column_with_data = x+1;
random_line_split
test_terminal.rs
use crate::input::Key; use crate::models::application::Event; use scribe::buffer::Position; use std::sync::Mutex; use super::Terminal; use crate::view::{Colors, Style}; const WIDTH: usize = 10; const HEIGHT: usize = 10; // A headless terminal that tracks printed data, which can be // returned as a String to test disp...
fn present(&self) { } fn width(&self) -> usize { WIDTH } fn height(&self) -> usize { HEIGHT } fn set_cursor(&self, position: Option<Position>) { let mut cursor = self.cursor.lock().unwrap(); *cursor = position; } fn suspend(&self) { } fn print(&self, position: &Position, _: ...
{ for row in self.data.lock().unwrap().iter_mut() { *row = [None; WIDTH]; } }
identifier_body
test_terminal.rs
use crate::input::Key; use crate::models::application::Event; use scribe::buffer::Position; use std::sync::Mutex; use super::Terminal; use crate::view::{Colors, Style}; const WIDTH: usize = 10; const HEIGHT: usize = 10; // A headless terminal that tracks printed data, which can be // returned as a String to test disp...
() { let terminal = Box::new(TestTerminal::new()); // Setting a non-zero x coordinate on a previous line exercises column resetting. terminal.print(&Position{ line: 0, offset: 2 }, Style::Default, Colors::Default, &"some"); terminal.print(&Position{ line: 2, offset: 5 }, Style::Default,...
data_uses_newlines_and_spaces_to_represent_structure
identifier_name
rw_lock.rs
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut}; use core::fmt; use core::default::Default; use util::cpu_relax; /// A reader-writer lock /// /// This type of lock allows a number of readers or at most one writer at any /// point in time...
} impl<'rwlock, T:?Sized> Drop for RwLockWriteGuard<'rwlock, T> { fn drop(&mut self) { debug_assert_eq!(self.lock.load(Ordering::Relaxed), USIZE_MSB); self.lock.store(0, Ordering::Relaxed); } } #[cfg(test)] mod tests { use std::prelude::v1::*; use std::sync::Arc; use std::sync::m...
{ debug_assert!(self.lock.load(Ordering::Relaxed) & (!USIZE_MSB) > 0); self.lock.fetch_sub(1, Ordering::SeqCst); }
identifier_body
rw_lock.rs
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut}; use core::fmt; use core::default::Default; use util::cpu_relax; /// A reader-writer lock /// /// This type of lock allows a number of readers or at most one writer at any /// point in time...
} // Wait for children to pass their asserts for r in children { assert!(r.join().is_ok()); } // Wait for writer to finish rx.recv().unwrap(); let lock = arc.read(); assert_eq!(*lock, 10); } #[test] fn test_rw_arc_access_in_unwin...
assert!(*lock >= 0); }));
random_line_split
rw_lock.rs
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut}; use core::fmt; use core::default::Default; use util::cpu_relax; /// A reader-writer lock /// /// This type of lock allows a number of readers or at most one writer at any /// point in time...
(&mut self) { self.0.fetch_add(1, Ordering::SeqCst); } } let num_drops = Arc::new(AtomicUsize::new(0)); let m = RwLock::new(Foo(num_drops.clone())); assert_eq!(num_drops.load(Ordering::SeqCst), 0); { let _inner = m.into_inner(); ...
drop
identifier_name
root.rs
/* The library provides a simple datastructure to access geolocated labels with an additional elimination time t and a label size factor. The library provides method to query a set of such labels with a bounding box and a minimum elimination time. Copyright (C) {2017} {Filip Krumpe <filip.krumpe@fmi.u...
} else { SplitDimension::Y }; r.m_split = split_value; r.m_left_child = left_child_idx; r.m_right_child = right_child_idx; Some(root_idx) } #[test] fn test_root_new() { let r = Root::new(Label::new(1., 2., 9., 1, 1, 1.5, "A".to_string())); assert!(r.m_t == 9.); assert!(*r....
random_line_split
root.rs
/* The library provides a simple datastructure to access geolocated labels with an additional elimination time t and a label size factor. The library provides method to query a set of such labels with a bounding box and a minimum elimination time. Copyright (C) {2017} {Filip Krumpe <filip.krumpe@fmi.u...
// append the right subtree if let Some(idx) = self.m_right_child { assert!(idx < data.len()); result = format!("{}\nr{}", result, data[idx].to_string(level + 1, &data)); } result } } /// /// The struct represents a reference to a root node and contains all...
{ assert!(idx < data.len()); result = format!("{}\nl{}", result, data[idx].to_string(level + 1, &data)); }
conditional_block
root.rs
/* The library provides a simple datastructure to access geolocated labels with an additional elimination time t and a label size factor. The library provides method to query a set of such labels with a bounding box and a minimum elimination time. Copyright (C) {2017} {Filip Krumpe <filip.krumpe@fmi.u...
<'a>(&'a self, bbox: &BBox, min_t: f64, data: &'a Vec<Root>) -> Vec<&'a Label> { let mut r: Vec<&Label> = Vec::new(); if self.m_t <= min_t { return r; } if bbox.is_contained(&self.m_data) { r.push(&self.m_data); } // append the left child if it ...
get
identifier_name