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
tendermint.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
}
{ let s = r#"{ "params": { "gasLimitBoundDivisor": "0x0400", "validators": { "list": ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"] }, "blockReward": "0x50" } }"#; let deserialized: Tendermint = serde_json::from_str(s).unwrap(); assert_eq!(deserialized.params.gas_limit_bound_divisor,...
identifier_body
tendermint.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...
mod tests { use serde_json; use uint::Uint; use util::U256; use hash::Address; use util::hash::H160; use spec::tendermint::Tendermint; use spec::validator_set::ValidatorSet; #[test] fn tendermint_deserialization() { let s = r#"{ "params": { "gasLimitBoundDivisor": "0x0400", "validators": { "...
#[cfg(test)]
random_line_split
tendermint.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...
{ /// Gas limit divisor. #[serde(rename="gasLimitBoundDivisor")] pub gas_limit_bound_divisor: Uint, /// Valid validators. pub validators: ValidatorSet, /// Propose step timeout in milliseconds. #[serde(rename="timeoutPropose")] pub timeout_propose: Option<Uint>, /// Prevote step timeout in milliseconds. #[se...
TendermintParams
identifier_name
local-modularized-tricky-pass-2.rs
// check-pass // // `#[macro_export] macro_rules` that doesn't originate from macro expansions can be placed // into the root module soon enough to act as usual items and shadow globs and preludes. #![feature(decl_macro)] // `macro_export` shadows globs use inner1::*; mod inner1 { pub macro exported() {} } expo...
mod inner3 { #[macro_export] macro_rules! panic { () => ( struct Г; ) } } // `macro_export` shadows builtin macros include!(); mod inner4 { #[macro_export] macro_rules! include { () => ( struct Д; ) } }
panic!(); }
identifier_body
local-modularized-tricky-pass-2.rs
// check-pass // // `#[macro_export] macro_rules` that doesn't originate from macro expansions can be placed // into the root module soon enough to act as usual items and shadow globs and preludes. #![feature(decl_macro)] // `macro_export` shadows globs use inner1::*; mod inner1 { pub macro exported() {} } expo...
() { type Deeper = [u8; { #[macro_export] macro_rules! exported { () => ( struct Б; ) } 0 }]; } } // `macro_export` shadows std prelude fn main() { panic!(); } mod inner3 { #[macro_export] macro_rules! panic { () ...
deep
identifier_name
local-modularized-tricky-pass-2.rs
// check-pass // // `#[macro_export] macro_rules` that doesn't originate from macro expansions can be placed // into the root module soon enough to act as usual items and shadow globs and preludes.
// `macro_export` shadows globs use inner1::*; mod inner1 { pub macro exported() {} } exported!(); mod deep { fn deep() { type Deeper = [u8; { #[macro_export] macro_rules! exported { () => ( struct Б; ) } 0 }]; } } // `macr...
#![feature(decl_macro)]
random_line_split
set_map_velocity.rs
use specs::{ReadStorage, System, WriteStorage}; use crate::campaign::components::MapIntent; use crate::campaign::components::map_intent::{MapCommand, XAxis, YAxis}; use crate::combat::components::{Velocity}; pub struct SetMapVelocity; impl<'a> System<'a> for SetMapVelocity { type SystemData = (ReadStorage<'a, Ma...
} }
random_line_split
set_map_velocity.rs
use specs::{ReadStorage, System, WriteStorage}; use crate::campaign::components::MapIntent; use crate::campaign::components::map_intent::{MapCommand, XAxis, YAxis}; use crate::combat::components::{Velocity}; pub struct
; impl<'a> System<'a> for SetMapVelocity { type SystemData = (ReadStorage<'a, MapIntent>, WriteStorage<'a, Velocity>); fn run(&mut self, (intent, mut velocity): Self::SystemData) { use specs::Join; for (intent, velocity) in (&intent, &mut velocity).join() { match intent.command { ...
SetMapVelocity
identifier_name
set_map_velocity.rs
use specs::{ReadStorage, System, WriteStorage}; use crate::campaign::components::MapIntent; use crate::campaign::components::map_intent::{MapCommand, XAxis, YAxis}; use crate::combat::components::{Velocity}; pub struct SetMapVelocity; impl<'a> System<'a> for SetMapVelocity { type SystemData = (ReadStorage<'a, Ma...
} }
{ use specs::Join; for (intent, velocity) in (&intent, &mut velocity).join() { match intent.command { MapCommand::Move { x, y } => { if x == XAxis::Centre && y == YAxis::Centre { velocity.x = 0; velocity.y =...
identifier_body
decode.rs
// Claxon -- A FLAC decoding library in Rust // Copyright 2015 Ruud van Asseldonk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy of the License has been included in the root of the repository. // This file implements a...
() { let mut no_args = true; for fname in env::args().skip(1) { no_args = false; print!("{}", fname); decode_file(&Path::new(&fname)); println!(": done"); } if no_args { println!("no files to decode"); } }
main
identifier_name
decode.rs
// Claxon -- A FLAC decoding library in Rust // Copyright 2015 Ruud van Asseldonk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy of the License has been included in the root of the repository. // This file implements a...
let mut wav_writer = WavWriter::create(fname_wav, spec).expect("failed to create wav file"); let mut frame_reader = reader.blocks(); let mut block = Block::empty(); loop { // Read a single frame. Recycle the buffer from the previous frame to // avoid allocations as much as possible. ...
bits_per_sample: reader.streaminfo().bits_per_sample as u16, sample_format: hound::SampleFormat::Int, }; let fname_wav = fname.with_extension("wav");
random_line_split
decode.rs
// Claxon -- A FLAC decoding library in Rust // Copyright 2015 Ruud van Asseldonk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy of the License has been included in the root of the repository. // This file implements a...
// Read a single frame. Recycle the buffer from the previous frame to // avoid allocations as much as possible. match frame_reader.read_next_or_eof(block.into_buffer()) { Ok(Some(next_block)) => block = next_block, Ok(None) => break, // EOF. Err(error) => pani...
{ let mut reader = FlacReader::open(fname).expect("failed to open FLAC stream"); // TODO: Write fallback for other sample widths and channel numbers. assert!(reader.streaminfo().bits_per_sample == 16); assert!(reader.streaminfo().channels == 2); let spec = WavSpec { channels: reader.stream...
identifier_body
dst-tuple.rs
// run-pass #![allow(type_alias_bounds)] #![feature(unsized_tuple_coercion)] type Fat<T:?Sized> = (isize, &'static str, T); // x is a fat pointer fn foo(x: &Fat<[isize]>) { let y = &x.2; assert_eq!(x.2.len(), 3); assert_eq!(y[0], 1); assert_eq!(x.2[1], 2); assert_eq!(x.0, 5); assert_eq!(x.1, ...
foo(f5); // With a vec of Bars. let bar = Bar; let f1 = (5, "some str", [bar, bar, bar]); foo2(&f1); let f2 = &f1; foo2(f2); let f3: &Fat<[Bar]> = f2; foo2(f3); let f4: &Fat<[Bar]> = &f1; foo2(f4); let f5: &Fat<[Bar]> = &(5, "some str", [bar, bar, bar]); foo2(f5); ...
random_line_split
dst-tuple.rs
// run-pass #![allow(type_alias_bounds)] #![feature(unsized_tuple_coercion)] type Fat<T:?Sized> = (isize, &'static str, T); // x is a fat pointer fn foo(x: &Fat<[isize]>)
fn foo2<T:ToBar>(x: &Fat<[T]>) { let y = &x.2; let bar = Bar; assert_eq!(x.2.len(), 3); assert_eq!(y[0].to_bar(), bar); assert_eq!(x.2[1].to_bar(), bar); assert_eq!(x.0, 5); assert_eq!(x.1, "some str"); } fn foo3(x: &Fat<Fat<[isize]>>) { let y = &(x.2).2; assert_eq!(x.0, 5); a...
{ let y = &x.2; assert_eq!(x.2.len(), 3); assert_eq!(y[0], 1); assert_eq!(x.2[1], 2); assert_eq!(x.0, 5); assert_eq!(x.1, "some str"); }
identifier_body
dst-tuple.rs
// run-pass #![allow(type_alias_bounds)] #![feature(unsized_tuple_coercion)] type Fat<T:?Sized> = (isize, &'static str, T); // x is a fat pointer fn foo(x: &Fat<[isize]>) { let y = &x.2; assert_eq!(x.2.len(), 3); assert_eq!(y[0], 1); assert_eq!(x.2[1], 2); assert_eq!(x.0, 5); assert_eq!(x.1, ...
; trait ToBar { fn to_bar(&self) -> Bar; } impl ToBar for Bar { fn to_bar(&self) -> Bar { *self } } pub fn main() { // With a vec of ints. let f1 = (5, "some str", [1, 2, 3]); foo(&f1); let f2 = &f1; foo(f2); let f3: &Fat<[isize]> = f2; foo(f3); let f4: &Fat<[isize...
Bar
identifier_name
rpath.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn test_minimize1() { let res = minimize_rpaths(&[ "rpath1".to_string(), "rpath2".to_string(), "rpath1".to_string() ]); assert!(res == [ "rpath1", "rpath2", ]); } #[test] fn test_minimize2() { let res = ...
["-Wl,-rpath,path1", "-Wl,-rpath,path2"]); } #[test]
random_line_split
rpath.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(config: &mut RPathConfig, lib: &Path) -> String { // Mac doesn't appear to support $ORIGIN let prefix = if config.is_like_osx { "@loader_path" } else { "$ORIGIN" }; let cwd = env::current_dir().unwrap(); let mut lib = fs::canonicalize(&cwd.join(lib)).unwrap_or(cwd.join(lib)); ...
get_rpath_relative_to_output
identifier_name
rpath.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String { // Mac doesn't appear to support $ORIGIN let prefix = if config.is_like_osx { "@loader_path" } else { "$ORIGIN" }; let cwd = env::current_dir().unwrap(); let mut lib = fs::canonicalize(&cwd.join(...
{ libs.iter().map(|a| get_rpath_relative_to_output(config, a)).collect() }
identifier_body
lib.rs
use std::fmt::{Display, Error, Formatter}; pub struct Game { intended_word: String, guessed: Vec<CharState>, } impl Game { pub fn new(intended_word: String) -> Game { let guessed = intended_word.chars().map(|ch| CharState::new(ch, false)).collect(); Game { intended_word: intend...
} pub type Guessed = Option<char>; #[derive(Debug)] pub struct CurrentProgress { vec : Vec<Guessed>, } impl Display for CurrentProgress { fn fmt(&self, f : &mut Formatter) -> Result<(), Error> { let mut result = String::with_capacity(self.vec.len() * 2); for guess in self.vec.iter() { ...
} }
random_line_split
lib.rs
use std::fmt::{Display, Error, Formatter}; pub struct Game { intended_word: String, guessed: Vec<CharState>, } impl Game { pub fn new(intended_word: String) -> Game { let guessed = intended_word.chars().map(|ch| CharState::new(ch, false)).collect(); Game { intended_word: intend...
{ ch : char, is_guessed : bool, } impl CharState { fn new(ch : char, is_guessed : bool) -> CharState { CharState { ch : ch, is_guessed : is_guessed, } } fn to_enum(&self) -> Guessed { if self.is_guessed { Some(self.ch) } else { ...
CharState
identifier_name
lib.rs
use std::fmt::{Display, Error, Formatter}; pub struct Game { intended_word: String, guessed: Vec<CharState>, } impl Game { pub fn new(intended_word: String) -> Game { let guessed = intended_word.chars().map(|ch| CharState::new(ch, false)).collect(); Game { intended_word: intend...
fn to_enum(&self) -> Guessed { if self.is_guessed { Some(self.ch) } else { None } } } pub type Guessed = Option<char>; #[derive(Debug)] pub struct CurrentProgress { vec : Vec<Guessed>, } impl Display for CurrentProgress { fn fmt(&self, f : &mut Format...
{ CharState { ch : ch, is_guessed : is_guessed, } }
identifier_body
read_message.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...
<A> { ReadHeader(ReadHeader<A>), ReadPayload(ReadPayload<A>), Finished, } /// Future for read single message from the stream. pub struct ReadMessage<A> { key: Option<KeyPair>, state: ReadMessageState<A>, } impl<A> Future for ReadMessage<A> where A: AsyncRead { type Item = (A, Result<Message, Error>); type Erro...
ReadMessageState
identifier_name
read_message.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...
// by polling again, we register new future Async::NotReady => self.poll(), result => Ok(result) } } }
self.state = next; match result {
random_line_split
read_message.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...
, ReadMessageState::Finished => panic!("poll ReadMessage after it's done"), }; self.state = next; match result { // by polling again, we register new future Async::NotReady => self.poll(), result => Ok(result) } } }
{ let (read, payload) = try_ready!(future.poll()); (ReadMessageState::Finished, Async::Ready((read, payload))) }
conditional_block
mod.rs
//! First set construction and computation. use collections::{map, Map}; use grammar::repr::*; use lr1::lookahead::{Token, TokenSet}; #[cfg(test)] mod test; #[derive(Clone)] pub struct FirstSets { map: Map<NonterminalString, TokenSet>, } impl FirstSets { pub fn new(grammar: &Grammar) -> FirstSets { ...
set } }
{ set.union_with(&lookahead); }
conditional_block
mod.rs
//! First set construction and computation. use collections::{map, Map}; use grammar::repr::*; use lr1::lookahead::{Token, TokenSet}; #[cfg(test)] mod test; #[derive(Clone)] pub struct FirstSets { map: Map<NonterminalString, TokenSet>, } impl FirstSets { pub fn new(grammar: &Grammar) -> FirstSets
/// Returns `FIRST(...symbols)`. If `...symbols` may derive /// epsilon, then this returned set will include EOF. (This is /// kind of repurposing EOF to serve as a binary flag of sorts.) pub fn first0<'s, I>(&self, symbols: I) -> TokenSet where I: IntoIterator<Item = &'s Symbol>, { ...
{ let mut this = FirstSets { map: map() }; let mut changed = true; while changed { changed = false; for production in grammar.nonterminals.values().flat_map(|p| &p.productions) { let nt = &production.nonterminal; let lookahead = this.first0...
identifier_body
mod.rs
//! First set construction and computation. use collections::{map, Map}; use grammar::repr::*; use lr1::lookahead::{Token, TokenSet}; #[cfg(test)] mod test; #[derive(Clone)] pub struct FirstSets { map: Map<NonterminalString, TokenSet>, } impl FirstSets { pub fn new(grammar: &Grammar) -> FirstSets { ...
(&self, symbols: &[Symbol], lookahead: &TokenSet) -> TokenSet { let mut set = self.first0(symbols); // we use EOF as the signal that `symbols` derives epsilon: let epsilon = set.take_eof(); if epsilon { set.union_with(&lookahead); } set } }
first1
identifier_name
mod.rs
//! First set construction and computation. use collections::{map, Map}; use grammar::repr::*; use lr1::lookahead::{Token, TokenSet}; #[cfg(test)] mod test; #[derive(Clone)] pub struct FirstSets { map: Map<NonterminalString, TokenSet>, } impl FirstSets { pub fn new(grammar: &Grammar) -> FirstSets { ...
}
random_line_split
schema_tests.rs
//! //! Test Schema Loading, XML Validating //! use libxml::schemas::SchemaParserContext; use libxml::schemas::SchemaValidationContext; use libxml::parser::Parser; static SCHEMA: &'static str = r#"<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="note"> <xs:complexT...
() { let xml = Parser::default() .parse_string(INVALID_XML) .expect("Expected to be able to parse XML Document from string"); let mut xsdparser = SchemaParserContext::from_buffer(SCHEMA); let xsd = SchemaValidationContext::from_parser(&mut xsdparser); if let Err(errors) = xsd { for err in &errors { ...
schema_from_string_generates_errors
identifier_name
schema_tests.rs
//! //! Test Schema Loading, XML Validating //! use libxml::schemas::SchemaParserContext; use libxml::schemas::SchemaValidationContext; use libxml::parser::Parser; static SCHEMA: &'static str = r#"<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="note"> <xs:complexT...
assert_eq!( "Element 'bad': This element is not expected. Expected is ( to ).\n", err.message() ); } } } }
{ let xml = Parser::default() .parse_string(INVALID_XML) .expect("Expected to be able to parse XML Document from string"); let mut xsdparser = SchemaParserContext::from_buffer(SCHEMA); let xsd = SchemaValidationContext::from_parser(&mut xsdparser); if let Err(errors) = xsd { for err in &errors { ...
identifier_body
schema_tests.rs
//! //! Test Schema Loading, XML Validating //! use libxml::schemas::SchemaParserContext; use libxml::schemas::SchemaValidationContext; use libxml::parser::Parser; static SCHEMA: &'static str = r#"<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="note"> <xs:complexT...
let mut xsdvalidator = xsd.unwrap(); for _ in 0..5 { if let Err(errors) = xsdvalidator.validate_document(&xml) { for err in &errors { assert_eq!( "Element 'bad': This element is not expected. Expected is ( to ).\n", err.message() ); } } } }
{ for err in &errors { println!("{}", err.message()); } panic!("Failed to parse schema"); }
conditional_block
schema_tests.rs
//! //! Test Schema Loading, XML Validating //! use libxml::schemas::SchemaParserContext; use libxml::schemas::SchemaValidationContext; use libxml::parser::Parser; static SCHEMA: &'static str = r#"<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="note"> <xs:complexT...
if let Err(errors) = xsdvalidator.validate_document(&xml) { for err in &errors { assert_eq!( "Element 'bad': This element is not expected. Expected is ( to ).\n", err.message() ); } } } }
} let mut xsdvalidator = xsd.unwrap(); for _ in 0..5 {
random_line_split
error.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
RegionsInsufficientlyPolymorphic(br, _) => { write!(f, "expected bound lifetime parameter{}{}, found concrete lifetime", if br.is_named() { " " } else { "" }, br) } RegionsOverlyPolymorphic(br, _) =...
{ write!(f, "lifetime mismatch") }
conditional_block
error.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
/// in parentheses after some larger message. You should also invoke `note_and_explain_type_err()` /// afterwards to present additional details, particularly when it comes to lifetime-related /// errors. impl<'tcx> fmt::Display for TypeError<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...
random_line_split
error.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(self, db: &mut DiagnosticBuilder<'_>, err: &TypeError<'tcx>, sp: Span) { use self::TypeError::*; match err.clone() { Sorts(values) => { let expected_str = values.e...
note_and_explain_type_err
identifier_name
logging-separate-lines.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 args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(&args[0]) .arg("child") .spawn().unwrap().wait_with_output().unwrap(); assert!(p.status....
use std::env; use std::str; fn main() {
random_line_split
logging-separate-lines.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 p = Command::new(&args[0]) .arg("child") .spawn().unwrap().wait_with_output().unwrap(); assert!(p.status.success()); let mut lines = str::from_utf8(&p.error).unwrap().lines(); assert!(lines.next().unwrap().contains("foo")); assert!(lines.next().unwrap().co...
{ debug!("foo"); debug!("bar"); return }
conditional_block
logging-separate-lines.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 args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(&args[0]) .arg("child") .spawn().unwrap().wait_with_output().unwrap(); assert!(p.st...
main
identifier_name
logging-separate-lines.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 args: Vec<String> = env::args().collect(); if args.len() > 1 && args[1] == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(&args[0]) .arg("child") .spawn().unwrap().wait_with_output().unwrap(); assert!(p.sta...
identifier_body
issue-33884.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(stream: TcpStream) -> io::Result<()> { stream.write_fmt(format!("message received")) //~^ ERROR mismatched types } fn main() { if let Ok(listener) = TcpListener::bind("127.0.0.1:8080") { for incoming in listener.incoming() { if let Ok(stream) = incoming { handle_client(...
handle_client
identifier_name
issue-33884.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { if let Ok(listener) = TcpListener::bind("127.0.0.1:8080") { for incoming in listener.incoming() { if let Ok(stream) = incoming { handle_client(stream); } } } }
{ stream.write_fmt(format!("message received")) //~^ ERROR mismatched types }
identifier_body
issue-33884.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use std::net::TcpStream; use std::io::{self, Read, Write}; fn handle_client(stream: TcpStream) -> io::Result<()> { stream.write_fmt(format!("message received")) //~^ ERROR mismatched types } fn main() { if let Ok(listener) = TcpListener::bind("127.0.0.1:8080") { for incoming in listener.incoming()...
random_line_split
issue-33884.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } }
{ handle_client(stream); }
conditional_block
util.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 ...
pub fn min_stack() -> uint { static MIN: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; match MIN.load(atomic::SeqCst) { 0 => {} n => return n - 1, } let amt = os::getenv("RUST_MIN_STACK").and_then(|s| from_str(s.as_slice())); let amt = amt.unwrap_or(2 * 1024 * 1024); // 0 is o...
{ (cfg!(target_os="macos")) && running_on_valgrind() }
identifier_body
util.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 ...
// 0 is our sentinel value, so ensure that we'll never see 0 after // initialization has run MIN.store(amt + 1, atomic::SeqCst); return amt; } /// Get's the number of scheduler threads requested by the environment /// either `RUST_THREADS` or `num_cpus`. pub fn default_sched_threads() -> uint { mat...
random_line_split
util.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 ...
() -> uint { match os::getenv("RUST_THREADS") { Some(nstr) => { let opt_n: Option<uint> = FromStr::from_str(nstr.as_slice()); match opt_n { Some(n) if n > 0 => n, _ => panic!("`RUST_THREADS` is `{}`, should be a positive integer", nstr) } ...
default_sched_threads
identifier_name
lib.rs
use std::collections::HashMap; use std::fmt::Display; use std::path::Path; use std::sync::Arc; use log::debug; use serde::{Deserialize, Serialize}; mod eval; pub mod util; #[derive(Clone, Serialize, Deserialize, Default, PartialEq, Debug)] struct EvalServiceCfg { timeout: usize, languages: HashMap<String, La...
context: Option<U>, ) -> Result<String, String> where T: AsRef<str>, U: AsRef<str>, { debug!("evaluating {}: \"{}\"", self.name, code.as_ref()); let timeout = match timeout { Some(0) => None, Some(n) => Some(n), None => self.timeout...
impl Language { pub async fn eval<T, U>( &self, code: T, timeout: Option<usize>,
random_line_split
lib.rs
use std::collections::HashMap; use std::fmt::Display; use std::path::Path; use std::sync::Arc; use log::debug; use serde::{Deserialize, Serialize}; mod eval; pub mod util; #[derive(Clone, Serialize, Deserialize, Default, PartialEq, Debug)] struct EvalServiceCfg { timeout: usize, languages: HashMap<String, La...
{ Exec(ExecBackend), Network(NetworkBackend), UnixSocket(UnixSocketBackend), } #[derive(Clone, Debug)] pub struct EvalService { timeout: usize, languages: HashMap<String, Arc<Language>>, } #[derive(Clone, PartialEq, Debug)] pub struct Language { name: String, code_before: Option<String>, ...
BackendCfg
identifier_name
tilemap.rs
extern crate gl; extern crate nalgebra; use gl::types::*; use nalgebra::na::{Mat4}; use nalgebra::na; use std::mem; use std::ptr; use super::engine; use super::shader; use super::math; //static CHUNK_SIZE : u8 = 10; pub struct TilemapChunk { shader :shader::ShaderProgram, vao : u32, vbo_vertices : u32, vbo_in...
/* fn set_program_variable_vbo(&self, name: &str) { //in } */ //move to shader? fn set_program_uniform_mat4(&self, name: &str, m: &Mat4<f32>) { //self.shader let id = self.shader.get_uniform(name); unsafe { gl::UniformMatrix4fv(id, 1, gl::FALSE as u8, mem::transmute(m)); } } } impl engine::Draw...
random_line_split
tilemap.rs
extern crate gl; extern crate nalgebra; use gl::types::*; use nalgebra::na::{Mat4}; use nalgebra::na; use std::mem; use std::ptr; use super::engine; use super::shader; use super::math; //static CHUNK_SIZE : u8 = 10; pub struct TilemapChunk { shader :shader::ShaderProgram, vao : u32, vbo_vertices : u32, vbo_i...
} self.indices_count = tilemap_chunk_indices.len() as u32; //println!("tilemap::setup() Count of vertices: {}", tilemap_chunk_vertices.len()/2); //x,y so /2 //println!("tilemap::setup() Count of indices: {}", self.indices_count); //println!("tilemap::setup() vertices: {}", tilemap_chunk_vertices); //...
{ let index_of = |x :u32, y:u32| x + (y * (tile_count_x+1)); //requires 2 triangles per tile (quad) tilemap_chunk_indices.push(i); //index of (x,y) tilemap_chunk_indices.push(index_of(x+1,y)); tilemap_chunk_indices.push(index_of(x, y+1)); //println!("\ttriangle_one: {}", tilemap_chunk_indices.sl...
conditional_block
tilemap.rs
extern crate gl; extern crate nalgebra; use gl::types::*; use nalgebra::na::{Mat4}; use nalgebra::na; use std::mem; use std::ptr; use super::engine; use super::shader; use super::math; //static CHUNK_SIZE : u8 = 10; pub struct TilemapChunk { shader :shader::ShaderProgram, vao : u32, vbo_vertices : u32, vbo_i...
} impl engine::Drawable for TilemapChunk { fn draw(&self, rc: &engine::RenderContext) { //use shader self.shader.use_program(); let mut model : Mat4<f32> = na::zero(); math::set_identity(&mut model); //set uniform //let mvp = /*rc.projm **/ rc.view; let mvp = rc.projm * rc.view * model; self.set_p...
{ //self.shader let id = self.shader.get_uniform(name); unsafe { gl::UniformMatrix4fv(id, 1, gl::FALSE as u8, mem::transmute(m)); } }
identifier_body
tilemap.rs
extern crate gl; extern crate nalgebra; use gl::types::*; use nalgebra::na::{Mat4}; use nalgebra::na; use std::mem; use std::ptr; use super::engine; use super::shader; use super::math; //static CHUNK_SIZE : u8 = 10; pub struct
{ shader :shader::ShaderProgram, vao : u32, vbo_vertices : u32, vbo_indices: u32, vbo_tileid : u32, indices_count : u32 //save model matrix //hold ref/owned to TilemapChunkData logical part? // tile_texture_atlas // tile_texture_atlas_normal? <- normal map for tiles? } impl TilemapChunk { pub fn new(...
TilemapChunk
identifier_name
main.rs
use std::collections::HashSet; fn main() { struct PentNums { n: usize, curr: usize } impl PentNums { fn new(index: usize) -> PentNums { if index == 0
PentNums{n: index, curr: PentNums::get(index)} } fn get(index: usize) -> usize { (index * ((index * 3) - 1)) / 2 } } impl Iterator for PentNums { type Item = usize; fn next(&mut self) -> Option<usize> { self.n += 1; sel...
{ return PentNums{n: index, curr: 0}; }
conditional_block
main.rs
use std::collections::HashSet; fn main() { struct PentNums { n: usize, curr: usize } impl PentNums { fn new(index: usize) -> PentNums { if index == 0 { return PentNums{n: index, curr: 0}; } PentNums{n: index, curr: PentNums::get...
(a: usize, b: usize, mut h: &mut HashSet<usize>) -> bool { if a >= b { return false; } let e = a + b; // println!("{:?}", e); if!is_pent(e, &mut h) { return false; } let d = b - a; // println!("{:?}", d); if!is_pent(d,...
sum_diff_pent
identifier_name
main.rs
use std::collections::HashSet; fn main() { struct PentNums { n: usize, curr: usize } impl PentNums { fn new(index: usize) -> PentNums { if index == 0 { return PentNums{n: index, curr: 0}; } PentNums{n: index, curr: PentNums::get...
// assumes a and b are pentagonal fn sum_diff_pent(a: usize, b: usize, mut h: &mut HashSet<usize>) -> bool { if a >= b { return false; } let e = a + b; // println!("{:?}", e); if!is_pent(e, &mut h) { return false; } let d = b...
{ if h.contains(&num) { return true } let mut p = PentNums::new(h.len()); for elem in p { if num == elem { h.insert(num); return true; } else if elem > num { return false; } } ...
identifier_body
main.rs
use std::collections::HashSet; fn main() { struct PentNums { n: usize, curr: usize } impl PentNums { fn new(index: usize) -> PentNums { if index == 0 { return PentNums{n: index, curr: 0}; } PentNums{n: index, curr: PentNums::get...
} 'outer: for curr in pA { // println!("{:?}", curr); let mut pB = PentNums::new(4) .take(2500) .collect::<Vec<_>>(); for elem in pB { // println!("{:?}", elem); if elem >= curr { continue 'outer; } ...
h.insert(num);
random_line_split
builder.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/. */ //! Helper module to build up a selector safely and efficiently. //! //! Our selector representation is designed t...
combinator, builder, ); } Component::PseudoElement(..) | Component::LocalName(..) => { specificity.element_selectors += 1 }, Component::Slotted(ref selector) => { specificity.element_s...
unreachable!( "Found combinator {:?} in simple selectors vector? {:?}",
random_line_split
builder.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/. */ //! Helper module to build up a selector safely and efficiently. //! //! Our selector representation is designed t...
self) -> usize { self.current_simple_selectors.len() + self.rest_of_simple_selectors.len() + self.combinators.len() } } impl<'a, Impl: SelectorImpl> Iterator for SelectorBuilderIter<'a, Impl> { type Item = Component<Impl>; #[inline(always)] fn next(&mut self) -> Option<Self::Item> {...
n(&
identifier_name
builder.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/. */ //! Helper module to build up a selector safely and efficiently. //! //! Our selector representation is designed t...
self.build_with_specificity_and_flags(spec) } /// Builds with an explicit SpecificityAndFlags. This is separated from build() so /// that unit tests can pass an explicit specificity. #[inline(always)] pub fn build_with_specificity_and_flags( &mut self, spec: SpecificityAnd...
{ spec.0 |= HAS_SLOTTED_BIT; }
conditional_block
builder.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/. */ //! Helper module to build up a selector safely and efficiently. //! //! Our selector representation is designed t...
#[inline] pub fn is_slotted(&self) -> bool { (self.0 & HAS_SLOTTED_BIT)!= 0 } } const MAX_10BIT: u32 = (1u32 << 10) - 1; #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] struct Specificity { id_selectors: u32, class_like_selectors: u32, element_selectors: u32, } impl AddAssign for ...
(self.0 & HAS_PSEUDO_BIT) != 0 }
identifier_body
vec-dst.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 ...
() { sub_expr(); index(); }
main
identifier_name
vec-dst.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 ...
assert!(x[2] == 3); } pub fn main() { sub_expr(); index(); }
{ // Tests for indexing into box/& [T, ..n] let x: [int, ..3] = [1, 2, 3]; let mut x: Box<[int, ..3]> = box x; assert!(x[0] == 1); assert!(x[1] == 2); assert!(x[2] == 3); x[1] = 45; assert!(x[0] == 1); assert!(x[1] == 45); assert!(x[2] == 3); let mut x: [int, ..3] = [1, 2, 3...
identifier_body
vec-dst.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
fn sub_expr() { // Test for a &[T] => &&[T] coercion in sub-expression position // (surpisingly, this can cause errors which are not caused by either of: // `let x = vec.slice_mut(0, 2);` // `foo(vec.slice_mut(0, 2));` ). let mut vec: Vec<int> = vec!(1, 2, 3, 4); let b: &mut [int] = [1, 2]...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
expr-block.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(dead_code)] // Tests for standalone blocks as expressions fn test_basic() { let rs: bool = { true }; assert!((rs)); } struct RS { v1: isize...
random_line_split
expr-block.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 RS { v1: isize, v2: isize } fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; assert_eq!(rs.v2, 20); } fn test_filled_with_stuff() { let rs = { let mut a = 0; while a < 10 { a += 1; } a }; assert_eq!(rs, 10); } pub fn main() { test_basic(); test_rec(); test_filled_with_stuff(); }
{ let rs: bool = { true }; assert!((rs)); }
identifier_body
expr-block.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 ...
() { test_basic(); test_rec(); test_filled_with_stuff(); }
main
identifier_name
crypter.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use byteorder::{BigEndian, ByteOrder}; use derive_more::Deref; use engine_traits::EncryptionMethod as DBEncryptionMethod; use kvproto::encryptionpb::EncryptionMethod; use openssl::symm::{self, Cipher as OCipher}; use rand::{rngs::OsRng, RngCore}; use t...
(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("PlainKey") .field(&"REDACTED".to_string()) .finish() } } // Don't expose the key in a display print impl_display_as_debug!(PlainKey); #[cfg(test)] mod tests { use hex::FromHex; use super::*; #...
fmt
identifier_name
crypter.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use byteorder::{BigEndian, ByteOrder}; use derive_more::Deref; use engine_traits::EncryptionMethod as DBEncryptionMethod; use kvproto::encryptionpb::EncryptionMethod; use openssl::symm::{self, Cipher as OCipher}; use rand::{rngs::OsRng, RngCore}; use t...
&mut tag.0, )?; Ok((ciphertext, tag)) } pub fn decrypt(&self, ct: &[u8], tag: AesGcmTag) -> Result<Vec<u8>> { let cipher = OCipher::aes_256_gcm(); let plaintext = symm::decrypt_aead( cipher, &self.key.0, Some(self.iv.as_slice()), ...
Some(self.iv.as_slice()), &[], /* AAD */ pt,
random_line_split
regions-fn-subtyping.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 ...
(f: Box<FnMut(&usize)>) { // Here, g is a function that can accept a usize pointer with // lifetime r, and f is a function that can accept a usize pointer // with any lifetime. The assignment g = f should be OK (i.e., // f's type should be a subtype of g's type), because f can be // used in any con...
ok
identifier_name
regions-fn-subtyping.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 ...
{ }
identifier_body
regions-fn-subtyping.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 ...
}
pub fn main() {
random_line_split
lib.rs
//! Asynchronous channels. //! //! This crate provides channels that can be used to communicate between //! asynchronous tasks. //! //! All items of this library are only available when the `std` or `alloc` feature of this //! library is activated, and it is activated by default. #![cfg_attr(feature = "cfg-target-has-...
($($item:item)*) => {$( #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] $item )*}; } cfg_target_has_atomic! { #[cfg(feature = "alloc")] extern crate alloc; #[cfg(feature = "alloc")] mod lock; #[cfg(feature = "std")] pub mod mpsc; #[cfg...
macro_rules! cfg_target_has_atomic {
random_line_split
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
my_env.push(env); // run child let p = Command::new(&child_path) .arg(arg) .cwd(&cwd) .env_set_all(&my_env) .spawn().unwrap().wait_with_output().unwrap(); // display the output assert!(o...
assert!(fs::copy(&my_path, &child_path).is_ok()); let mut my_env = my_env;
random_line_split
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert!(old_io::stdout().write(&p.output).is_ok()); assert!(old_io::stderr().write(&p.error).is_ok()); // make sure the child succeeded assert!(p.status.success()); } else { // child // check working directory (don't try to compare with `cwd` he...
{ // parent let child_filestem = Path::new(child_name); let child_filename = child_filestem.with_extension(my_ext); let child_path = cwd.join(child_filename); // make a separate directory for the child drop(fs::mkdir(&cwd, old_io::USER_RWX).is_ok()); ass...
conditional_block
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let my_args = os::args(); let my_cwd = os::getcwd().unwrap(); let my_env = os::env(); let my_path = Path::new(os::self_exe_name().unwrap()); let my_dir = my_path.dir_path(); let my_ext = my_path.extension_str().unwrap_or(""); // some non-ASCII characters let blah = "\u03c...
main
identifier_name
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
if my_args.len() == 1 { // parent let child_filestem = Path::new(child_name); let child_filename = child_filestem.with_extension(my_ext); let child_path = cwd.join(child_filename); // make a separate directory for the child drop(fs::mkdir(&cwd, old_io::USER_...
{ let my_args = os::args(); let my_cwd = os::getcwd().unwrap(); let my_env = os::env(); let my_path = Path::new(os::self_exe_name().unwrap()); let my_dir = my_path.dir_path(); let my_ext = my_path.extension_str().unwrap_or(""); // some non-ASCII characters let blah = "\u03c0\u...
identifier_body
section_table.rs
use crate::error::{self, Error}; use crate::pe::relocation; use alloc::string::{String, ToString}; use scroll::{ctx, Pread, Pwrite}; #[repr(C)] #[derive(Debug, PartialEq, Clone, Default)] pub struct SectionTable { pub name: [u8; 8], pub real_name: Option<String>, pub virtual_size: u32, pub virtual_addr...
}
{ let mut section = SectionTable::default(); for &(offset, name) in [ (0usize, b"/0\0\0\0\0\0\0"), (1, b"/1\0\0\0\0\0\0"), (9_999_999, b"/9999999"), (10_000_000, b"//AAmJaA"), #[cfg(target_pointer_width = "64")] (0xfff_fff_fff, b"//...
identifier_body
section_table.rs
use crate::error::{self, Error}; use crate::pe::relocation; use alloc::string::{String, ToString}; use scroll::{ctx, Pread, Pwrite}; #[repr(C)] #[derive(Debug, PartialEq, Clone, Default)] pub struct SectionTable { pub name: [u8; 8], pub real_name: Option<String>, pub virtual_size: u32, pub virtual_addr...
Ok(()) } else if idx as u64 <= 0xfff_fff_fff { // 64^6 - 1 self.name[0] = b'/'; self.name[1] = b'/'; for i in 0..6 { let rem = (idx % 64) as u8; idx /= 64; let c = match rem { 0..=25 ...
{ // 10^7 - 1 // write!(&mut self.name[1..], "{}", idx) without using io::Write. // We write into a temporary since we calculate digits starting at the right. let mut name = [0; 7]; let mut len = 0; if idx == 0 { name[6] = b'0'; ...
conditional_block
section_table.rs
use crate::error::{self, Error}; use crate::pe::relocation; use alloc::string::{String, ToString}; use scroll::{ctx, Pread, Pwrite}; #[repr(C)] #[derive(Debug, PartialEq, Clone, Default)] pub struct SectionTable { pub name: [u8; 8], pub real_name: Option<String>, pub virtual_size: u32, pub virtual_addr...
} else if c == b'/' { // 63 63 } else { return Err(()); }; val = val * 64 + v as usize; } Ok(val) } impl SectionTable { pub fn parse( bytes: &[u8], offset: &mut usize, string_table_offset: usize, ) -> error::Res...
62
random_line_split
section_table.rs
use crate::error::{self, Error}; use crate::pe::relocation; use alloc::string::{String, ToString}; use scroll::{ctx, Pread, Pwrite}; #[repr(C)] #[derive(Debug, PartialEq, Clone, Default)] pub struct SectionTable { pub name: [u8; 8], pub real_name: Option<String>, pub virtual_size: u32, pub virtual_addr...
(_ctx: &scroll::Endian) -> usize { SIZEOF_SECTION_TABLE } } impl ctx::TryIntoCtx<scroll::Endian> for SectionTable { type Error = error::Error; fn try_into_ctx(self, bytes: &mut [u8], ctx: scroll::Endian) -> Result<usize, Self::Error> { let offset = &mut 0; bytes.gwrite(&self.name[.....
size_with
identifier_name
mod.rs
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CNDTR2 { #[doc = r" Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R...
#[doc = r" Value of the field"] pub struct NDTR { bits: u16, } impl NDTR { #[doc = r" Value of the field as raw bits"] #[inline(always)] pub fn bits(&self) -> u16 { self.bits } } #[doc = r" Proxy"] pub struct _NDTW<'a> { w: &'a mut W, } impl<'a> _NDTW<'a> { #[doc = r" Writes raw bits...
random_line_split
mod.rs
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CNDTR2 { #[doc = r" Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R...
<F>(&self, f: F) where F: FnOnce(&mut W) -> &mut W, { let mut w = W::reset_value(); f(&mut w); self.register.set(w.bits); } #[doc = r" Writes the reset value to the register"] #[inline(always)] pub fn reset(&self) { self.write(|w| w) } } #[doc = r" Val...
write
identifier_name
mod.rs
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CNDTR2 { #[doc = r" Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R...
#[doc = r" Reads the contents of the register"] #[inline(always)] pub fn read(&self) -> R { R { bits: self.register.get(), } } #[doc = r" Writes to the register"] #[inline(always)] pub fn write<F>(&self, f: F) where F: FnOnce(&mut W) -> &mut W, { ...
{ let bits = self.register.get(); let r = R { bits: bits }; let mut w = W { bits: bits }; f(&r, &mut w); self.register.set(w.bits); }
identifier_body
lint-ctypes.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 ...
() { }
main
identifier_name
lint-ctypes.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![deny(ctypes)] e...
// 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. //
random_line_split
lint-ctypes.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 ...
{ }
identifier_body
4_traitsbounds_mistake1.rs
/* Writing a function which adds 2 to every element of vector and a function to multiply 2 to every element of the vector */ /* NOTES: OWNERSHIP AND BORROW RULES 1. Only one owner at a time 2. Only 1 active mutable borrow at a time 3. Every other borrow after a shared borrow should be a shared borrow...
} fn vec_add<T: Arith>(vec: &mut Vec<T>){ for e in vec.iter_mut(){ /* e is of type &mut i32. But you can give it to print() which expects i32 because rust derefs it implicitly */ e.print(); e.add(5); } } fn main(){ println!("Hello World"); let mut vec: Vec<i32> = vec...
random_line_split
4_traitsbounds_mistake1.rs
/* Writing a function which adds 2 to every element of vector and a function to multiply 2 to every element of the vector */ /* NOTES: OWNERSHIP AND BORROW RULES 1. Only one owner at a time 2. Only 1 active mutable borrow at a time 3. Every other borrow after a shared borrow should be a shared borrow...
(self, b: i32) -> i32{ self + b } fn mult(self, b: Self) -> Self{ self * b } fn print(self) { println!("Val = {}", self); } } fn vec_add<T: Arith>(vec: &mut Vec<T>){ for e in vec.iter_mut(){ /* e is of type &mut i32. But you can give it to print() which...
add
identifier_name
4_traitsbounds_mistake1.rs
/* Writing a function which adds 2 to every element of vector and a function to multiply 2 to every element of the vector */ /* NOTES: OWNERSHIP AND BORROW RULES 1. Only one owner at a time 2. Only 1 active mutable borrow at a time 3. Every other borrow after a shared borrow should be a shared borrow...
fn main(){ println!("Hello World"); let mut vec: Vec<i32> = vec![1,2,3,4,5]; vec_add(&mut vec); } /* What's the mistake with e.add(5) which is throwing below error. Isn't 'b:Self' of type i32 for the current example <anon>:35:15: 35:16 error: mismatched types: expected `T`, found `_` (expected ty...
{ for e in vec.iter_mut(){ /* e is of type &mut i32. But you can give it to print() which expects i32 because rust derefs it implicitly */ e.print(); e.add(5); } }
identifier_body
fn.rs
// Function that returns a boolean value fn is_divisible_by(lhs: uint, rhs: uint) -> bool { // Corner case, early return if rhs == 0 { return false;
// This is an expression, the `return` keyword is not necessary here lhs % rhs == 0 } // Functions that "don't" return a value, actually return the unit type `()` fn fizzbuzz(n: uint) -> () { if is_divisible_by(n, 15) { println!("fizzbuzz"); } else if is_divisible_by(n, 3) { println!("...
}
random_line_split
fn.rs
// Function that returns a boolean value fn is_divisible_by(lhs: uint, rhs: uint) -> bool { // Corner case, early return if rhs == 0 { return false; } // This is an expression, the `return` keyword is not necessary here lhs % rhs == 0 } // Functions that "don't" return a value, actually re...
(n: uint) { for n in range(1, n + 1) { fizzbuzz(n); } } fn main() { fizzbuzz_to(100); }
fizzbuzz_to
identifier_name
fn.rs
// Function that returns a boolean value fn is_divisible_by(lhs: uint, rhs: uint) -> bool { // Corner case, early return if rhs == 0 { return false; } // This is an expression, the `return` keyword is not necessary here lhs % rhs == 0 } // Functions that "don't" return a value, actually re...
} // When a function returns `()`, the return type can be omitted from the // signature fn fizzbuzz_to(n: uint) { for n in range(1, n + 1) { fizzbuzz(n); } } fn main() { fizzbuzz_to(100); }
{ println!("{}", n); }
conditional_block
fn.rs
// Function that returns a boolean value fn is_divisible_by(lhs: uint, rhs: uint) -> bool { // Corner case, early return if rhs == 0 { return false; } // This is an expression, the `return` keyword is not necessary here lhs % rhs == 0 } // Functions that "don't" return a value, actually re...
fn main() { fizzbuzz_to(100); }
{ for n in range(1, n + 1) { fizzbuzz(n); } }
identifier_body
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // macro_rules! ord_impl { // ($($t:ty)*) => ($( // #[stable(feature = "rust1", since = "1.0.0")] // impl Ord for $t { // #[i...
// } // ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } macro_rules! cmp_test { ($($t:ty)*) => ($({ let v1: $t = 68 as $t; { let result: Ordering = v1.cmp(&v1); assert_eq!(result, Equal); } let v2: $t = 100 as $t; { let result: Ordering = v1.cmp(&v2); ...
// )*)
random_line_split
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // macro_rules! ord_impl { // ($($t:ty)*) => ($( // #[stable(feature = "rust1", since = "1.0.0")] // impl Ord for $t { // #[i...
}
{ cmp_test! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 }; }
identifier_body
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // macro_rules! ord_impl { // ($($t:ty)*) => ($( // #[stable(feature = "rust1", since = "1.0.0")] // impl Ord for $t { // #[i...
() { cmp_test! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 }; } }
cmp_test1
identifier_name
mod.rs
extern crate chrono; extern crate chrono_tz; extern crate clap; extern crate ical; use std::fs::File; use std::io::BufReader; use self::chrono::{DateTime, TimeZone}; use self::chrono_tz::{Tz, UTC}; use self::clap::SubCommand; use self::ical::IcalParser; #[derive(Debug)] enum LineInfo { TextInfo { name: String, v...
let input = IcalParser::new(BufReader::new(file)); for line in input { let line = line.unwrap(); for evt in line.events { println!("EVENT"); for prop in evt.properties { let parsedval: LineInfo = match prop.value { Some(mut v) => { let tz = if (&v).ends_with("Z") { v.pop(); ...
random_line_split
mod.rs
extern crate chrono; extern crate chrono_tz; extern crate clap; extern crate ical; use std::fs::File; use std::io::BufReader; use self::chrono::{DateTime, TimeZone}; use self::chrono_tz::{Tz, UTC}; use self::clap::SubCommand; use self::ical::IcalParser; #[derive(Debug)] enum
{ TextInfo { name: String, value: Option<String>, }, DateTimeInfo { name: String, value: DateTime<UTC>, } } pub fn entry(m: &SubCommand) -> i32 { let fname = m.matches.value_of("filename").unwrap(); let file = match File::open(fname) { Ok(f) => f, Err(f) => { println!("{}", f); return 1; } ...
LineInfo
identifier_name
tester.rs
use std::comm; use std::fmt::Show; use std::io::ChanWriter; use std::iter; use std::rand; use std::task::TaskBuilder; use super::{Arbitrary, Gen, Shrinker, StdGen}; use tester::trap::safe; use tester::Status::{Discard, Fail, Pass}; /// The main QuickCheck type for setting configuration and running QuickCheck. pub stru...
{ Pass, Fail, Discard } impl TestResult { /// Produces a test result that indicates the current test has passed. pub fn passed() -> TestResult { TestResult::from_bool(true) } /// Produces a test result that indicates the current test has failed. pub fn failed() -> TestResult { TestResult::from_bool(f...
Status
identifier_name
tester.rs
use std::comm; use std::fmt::Show; use std::io::ChanWriter; use std::iter; use std::rand; use std::task::TaskBuilder; use super::{Arbitrary, Gen, Shrinker, StdGen}; use tester::trap::safe; use tester::Status::{Discard, Fail, Pass}; /// The main QuickCheck type for setting configuration and running QuickCheck. pub stru...
} impl<A, B, C, D, T> Fun<A, B, C, D, T> for fn(A) -> T where A: AShow, B: AShow, C: AShow, D: AShow, T: Testable { fn call<G: Gen>(&self, g: &mut G, a: Option<&A>, _: Option<&B>, _: Option<&C>, _: Option<&D>) -> TestResult { impl_fun_call!(*s...
{ let f = *self; safe(proc() { f() }).result(g) }
identifier_body