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
main.rs
extern crate md5; use std::io; use std::io::Read; use md5::Digest; struct StopWhenIterator<I, P> { parent: I, predicate: P, completed: bool } trait StopWhen<P: FnMut(&Self::Item) -> bool> : Iterator where Self:Sized { /// Iterates over items untill while the given predicate is evaluated to true ...
} Some(x) }) } } } fn read_input() -> io::Result<String> { let mut buffer = String::new(); try!(io::stdin().read_to_string(&mut buffer)); Ok(buffer.trim().to_string()) } fn starts_with_five_zeros(digest: &Digest) -> bool { digest[0] == 0 && diges...
self.parent.next().and_then(|x| { if (self.predicate)(&x) { self.completed = true;
random_line_split
main.rs
extern crate md5; use std::io; use std::io::Read; use md5::Digest; struct StopWhenIterator<I, P> { parent: I, predicate: P, completed: bool } trait StopWhen<P: FnMut(&Self::Item) -> bool> : Iterator where Self:Sized { /// Iterates over items untill while the given predicate is evaluated to true ...
fn starts_with_five_zeros(digest: &Digest) -> bool { digest[0] == 0 && digest[1] == 0 && digest[2] < 16 } fn sixth_item_is_also_zero(digest: &Digest) -> bool { digest[2] == 0 } fn main() { let input = read_input().unwrap(); let start_with_zero: Vec<_> = (0..i64::max_value()) .map(|i| (i, inp...
{ let mut buffer = String::new(); try!(io::stdin().read_to_string(&mut buffer)); Ok(buffer.trim().to_string()) }
identifier_body
main.rs
extern crate md5; use std::io; use std::io::Read; use md5::Digest; struct StopWhenIterator<I, P> { parent: I, predicate: P, completed: bool } trait StopWhen<P: FnMut(&Self::Item) -> bool> : Iterator where Self:Sized { /// Iterates over items untill while the given predicate is evaluated to true ...
else { self.parent.next().and_then(|x| { if (self.predicate)(&x) { self.completed = true; } Some(x) }) } } } fn read_input() -> io::Result<String> { let mut buffer = String::new(); try!(io::stdin().read_to_...
{ None }
conditional_block
main.rs
extern crate md5; use std::io; use std::io::Read; use md5::Digest; struct StopWhenIterator<I, P> { parent: I, predicate: P, completed: bool } trait StopWhen<P: FnMut(&Self::Item) -> bool> : Iterator where Self:Sized { /// Iterates over items untill while the given predicate is evaluated to true ...
(digest: &Digest) -> bool { digest[0] == 0 && digest[1] == 0 && digest[2] < 16 } fn sixth_item_is_also_zero(digest: &Digest) -> bool { digest[2] == 0 } fn main() { let input = read_input().unwrap(); let start_with_zero: Vec<_> = (0..i64::max_value()) .map(|i| (i, input.clone() + &i.to_string()...
starts_with_five_zeros
identifier_name
test.rs
use super::FirstSets; use grammar::repr::*; use lr1::lookahead::Token::EOF; use lr1::lookahead::{Token, TokenSet}; use lr1::tls::Lr1Tls; use string_cache::DefaultAtom as Atom; use test_util::normalized_grammar; pub fn nt(t: &str) -> Symbol { Symbol::Nonterminal(NonterminalString(Atom::from(t))) } pub fn term(t: &...
fn la(t: &str) -> Token { Token::Terminal(TerminalString::quoted(Atom::from(t))) } fn first0(first: &FirstSets, symbols: &[Symbol]) -> Vec<Token> { let v = first.first0(symbols); v.iter().collect() } fn first1(first: &FirstSets, symbols: &[Symbol], lookahead: Token) -> Vec<Token> { let v = first.fir...
{ Symbol::Terminal(TerminalString::quoted(Atom::from(t))) }
identifier_body
test.rs
use super::FirstSets; use grammar::repr::*; use lr1::lookahead::Token::EOF; use lr1::lookahead::{Token, TokenSet}; use lr1::tls::Lr1Tls; use string_cache::DefaultAtom as Atom;
pub fn term(t: &str) -> Symbol { Symbol::Terminal(TerminalString::quoted(Atom::from(t))) } fn la(t: &str) -> Token { Token::Terminal(TerminalString::quoted(Atom::from(t))) } fn first0(first: &FirstSets, symbols: &[Symbol]) -> Vec<Token> { let v = first.first0(symbols); v.iter().collect() } fn first1...
use test_util::normalized_grammar; pub fn nt(t: &str) -> Symbol { Symbol::Nonterminal(NonterminalString(Atom::from(t))) }
random_line_split
test.rs
use super::FirstSets; use grammar::repr::*; use lr1::lookahead::Token::EOF; use lr1::lookahead::{Token, TokenSet}; use lr1::tls::Lr1Tls; use string_cache::DefaultAtom as Atom; use test_util::normalized_grammar; pub fn nt(t: &str) -> Symbol { Symbol::Nonterminal(NonterminalString(Atom::from(t))) } pub fn term(t: &...
(t: &str) -> Token { Token::Terminal(TerminalString::quoted(Atom::from(t))) } fn first0(first: &FirstSets, symbols: &[Symbol]) -> Vec<Token> { let v = first.first0(symbols); v.iter().collect() } fn first1(first: &FirstSets, symbols: &[Symbol], lookahead: Token) -> Vec<Token> { let v = first.first1(sym...
la
identifier_name
ordered_collection.rs
// Copyright 2014 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
<F>(&mut self, k: K, f: F) where F: FnOnce(Option<&V>) -> V { match self.entry(k) { btree_map::Entry::Occupied(mut entry) => { let new_v = f(Some(entry.get())); entry.insert(new_v); }, btree_map::Entry::Vacant(space) => { space.insert(f(None)); } } } fn pop_m...
update_value
identifier_name
ordered_collection.rs
// Copyright 2014 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
}
{ self.iter().next() }
identifier_body
ordered_collection.rs
// Copyright 2014 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
match self.entry(k) { btree_map::Entry::Occupied(mut entry) => { let new_v = f(Some(entry.get())); entry.insert(new_v); }, btree_map::Entry::Vacant(space) => { space.insert(f(None)); } } } fn pop_min_when<F>(&mut self, ready: F) -> Option<(K, V)> where F:...
} impl <K: Clone + Ord, V> OrderedCollection<K, V> for BTreeMap<K, V> { fn update_value<F>(&mut self, k: K, f: F) where F: FnOnce(Option<&V>) -> V {
random_line_split
lulzvm.rs
extern crate ctrlc; extern crate lulzvm; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate clap; use clap::{ArgGroup, ArgMatches, App};
use std::env; use std::fs::File; use std::io::{stdin, stdout, Read, Result}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; fn main() { let matches = App::new("LulzVM") .args_from_usage("[FILE] 'Bytecode executable' -d, --debug 'Enable debug messages'") ...
use lulzvm::vm::VM;
random_line_split
lulzvm.rs
extern crate ctrlc; extern crate lulzvm; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate clap; use clap::{ArgGroup, ArgMatches, App}; use lulzvm::vm::VM; use std::env; use std::fs::File; use std::io::{stdin, stdout, Read, Result}; use std::sync::Arc; use std::sync::atomic::{AtomicB...
fn do_checked_main(matches: ArgMatches) -> Result<()> { let executable_filename = matches.value_of("FILE").unwrap(); let mut executable = Vec::new(); let mut executable_file = try!(File::open(executable_filename)); let _ = try!(executable_file.read_to_end(&mut executable)); if matches.is_present...
{ let matches = App::new("LulzVM") .args_from_usage("[FILE] 'Bytecode executable' -d, --debug 'Enable debug messages'") .group(ArgGroup::with_name("required") .args(&["FILE"]) .required(true)) .get_matches(); match do_checked_main(matc...
identifier_body
lulzvm.rs
extern crate ctrlc; extern crate lulzvm; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate clap; use clap::{ArgGroup, ArgMatches, App}; use lulzvm::vm::VM; use std::env; use std::fs::File; use std::io::{stdin, stdout, Read, Result}; use std::sync::Arc; use std::sync::atomic::{AtomicB...
() { let matches = App::new("LulzVM") .args_from_usage("[FILE] 'Bytecode executable' -d, --debug 'Enable debug messages'") .group(ArgGroup::with_name("required") .args(&["FILE"]) .required(true)) .get_matches(); match do_checked_main(matche...
main
identifier_name
value.rs
use std::fmt::{Debug, Display, Formatter, Error}; use std::fmt::Result as FmtResult; use num::Float; use std::mem; use super::clip::{ClipHolder}; #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum Value { Int(i64), Float(FloatWrap), Bool(bool), String(String), Tuple(Vec<Value>), Clip(ClipHo...
} impl Display for FloatWrap { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { write!(f, "{}", self.get()) } }
{ write!(f, "{:?}", self.get()) }
identifier_body
value.rs
use std::fmt::{Debug, Display, Formatter, Error}; use std::fmt::Result as FmtResult; use num::Float; use std::mem; use super::clip::{ClipHolder}; #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum
{ Int(i64), Float(FloatWrap), Bool(bool), String(String), Tuple(Vec<Value>), Clip(ClipHolder), Nil } impl Display for Value { fn fmt<'r>(&'r self, formatter: &mut Formatter) -> FmtResult { match self { &Value::Int(i) => write!(formatter, "{}", i), &Value...
Value
identifier_name
value.rs
use std::fmt::{Debug, Display, Formatter, Error}; use std::fmt::Result as FmtResult; use num::Float; use std::mem; use super::clip::{ClipHolder}; #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum Value { Int(i64), Float(FloatWrap), Bool(bool), String(String), Tuple(Vec<Value>), Clip(ClipHo...
} if idx!= len - 1 { match write!(formatter, ", ") { Ok(()) => (), Err(e) => {return Err(e);} } } } match write!(formatter, ...
Err(e) => {return Err(e);}
random_line_split
quadratic.rs
// Copyright (c) 2015, Mikhail Vorotilov // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this // list of condit...
() { assert_eq!(find_roots_quadratic(1f32, -1e15f32, -1f32), Roots::Two([-1e-15f32, 1e15f32])); assert_eq!(find_roots_quadratic(-1f32, 1e15f32, 1f32), Roots::Two([-1e-15f32, 1e15f32])); } }
test_find_roots_quadratic_big_a1
identifier_name
quadratic.rs
// Copyright (c) 2015, Mikhail Vorotilov // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this // list of condit...
#[test] fn test_find_roots_quadratic_big_a1() { assert_eq!(find_roots_quadratic(1f32, -1e15f32, -1f32), Roots::Two([-1e-15f32, 1e15f32])); assert_eq!(find_roots_quadratic(-1f32, 1e15f32, 1f32), Roots::Two([-1e-15f32, 1e15f32])); } }
{ assert_eq!( find_roots_quadratic(1e-20f32, -1f32, -1e-30f32), Roots::Two([-1e-30f32, 1e20f32]) ); assert_eq!( find_roots_quadratic(-1e-20f32, 1f32, 1e-30f32), Roots::Two([-1e-30f32, 1e20f32]) ); assert_eq!(find_roots_quadratic(1e-...
identifier_body
quadratic.rs
// Copyright (c) 2015, Mikhail Vorotilov // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this // list of condit...
} } } } } #[cfg(test)] mod test { use super::super::super::*; #[test] fn test_find_roots_quadratic() { assert_eq!(find_roots_quadratic(0f32, 0f32, 0f32), Roots::One([0f32])); assert_eq!(find_roots_quadratic(1f32, 0f32, 1f32), Roots::No([])); ...
// Order roots if x1 < x2 { Roots::Two([x1, x2]) } else { Roots::Two([x2, x1])
random_line_split
quadratic.rs
// Copyright (c) 2015, Mikhail Vorotilov // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this // list of condit...
} else { // 2*a2 is the greatest divisor, use it (diff_sign / a2x2, same_sign / a2x2) }; // Order roots if x1 < x2 { Roots::Two([x1, x2]) } else { Roots::Two(...
{ // diff_sign is the smallest divisor, do not use it (a0x2 / same_sign, same_sign / a2x2) }
conditional_block
prefs.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use basedir::default_config_dir; use num_cpus; use opts; use resource_files::resources_dir_path; use rustc_seriali...
}
{ self.get("dom.webgl2.enabled").as_boolean().unwrap_or(false) }
identifier_body
prefs.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use basedir::default_config_dir; use num_cpus; use opts; use resource_files::resources_dir_path; use rustc_seriali...
Some(ref x) => x, None => default } } } } fn set(&mut self, value: PrefValue) { // TODO - this should error if we try to override a pref of one type // with a value of a different type match *self { ...
match *override_value {
random_line_split
prefs.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use basedir::default_config_dir; use num_cpus; use opts; use resource_files::resources_dir_path; use rustc_seriali...
(value: PrefValue) -> Pref { Pref::NoDefault(Arc::new(value)) } fn new_default(value: PrefValue) -> Pref { Pref::WithDefault(Arc::new(value), None) } fn from_json(data: Json) -> Result<Pref, ()> { let value = PrefValue::from_json(data)?; Ok(Pref::new_default(value)) ...
new
identifier_name
exponential.rs
use std::num::{sin, cos}; use extra::complex::Cmplx; use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use math_constants::e; pub fn exponential(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val)...
} } } pub fn eval_exponential(left: &nodes::Node) -> Result<~Value, ~str> { eval_monadic(exponential, left) }
let result = Cmplx::new(powed, 0.0) * complex; Ok(~AplComplex(result)) }, &AplArray(ref _depth, ref _dimensions, ref _values) => { simple_monadic_array(exponential, first)
random_line_split
exponential.rs
use std::num::{sin, cos}; use extra::complex::Cmplx; use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use math_constants::e; pub fn
(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val) => { Ok(~AplFloat(val.exp())) }, &AplInteger(val) => { Ok(~AplFloat((val as f64).exp())) }, &AplComplex(c) => { let powed = e.pow(&c.re); let left = cos(c.im...
exponential
identifier_name
exponential.rs
use std::num::{sin, cos}; use extra::complex::Cmplx; use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use math_constants::e; pub fn exponential(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val)...
, &AplInteger(val) => { Ok(~AplFloat((val as f64).exp())) }, &AplComplex(c) => { let powed = e.pow(&c.re); let left = cos(c.im); let right = sin(c.im); let complex = Cmplx::new(left, right); let result = Cmplx::new(powed, 0....
{ Ok(~AplFloat(val.exp())) }
conditional_block
exponential.rs
use std::num::{sin, cos}; use extra::complex::Cmplx; use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use math_constants::e; pub fn exponential(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val)...
{ eval_monadic(exponential, left) }
identifier_body
foo.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 ...
} for j in 0..i { writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); } writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); f.into_inner().unwrap(); drop(fs::remove_file(&ok)); let output = Command::new(&rustc) .arg(&file) ...
{ let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap()); let ok = tmpdir.join("ok"); if env::var("YOU_ARE_A_LINKER").is_ok() { if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) { let file = file.to_str().expect("non-utf8 file argument"); fs::...
identifier_body
foo.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 ...
else { exp.into_bytes() }; assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); } break } }
{ let mut out = Vec::with_capacity(exp.len() * 2); for c in exp.encode_utf16() { // encode in little endian out.push(c as u8); out.push((c >> 8) as u8); } out }
conditional_block
foo.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 ...
() { let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap()); let ok = tmpdir.join("ok"); if env::var("YOU_ARE_A_LINKER").is_ok() { if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) { let file = file.to_str().expect("non-utf8 file argument"); f...
main
identifier_name
foo.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 ...
} let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); let me_as_linker = format!("linker={}", env::current_exe().unwrap().display()); for i in (1..).map(|i| i * 100) { println!("attempt: {}", i); let file = tmpdir.join("bar.rs"); let mut f = BufWriter::new(File::create(&...
} return
random_line_split
import-glob-circular.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 ...
} mod test { use circ1::*; fn test() { f1066(); } }
mod circ2 { pub use circ1::f1; pub fn f2() { println!("f2"); } pub fn common() -> uint { return 1u; }
random_line_split
import-glob-circular.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!("f1"); } pub fn common() -> uint { return 0u; } } mod circ2 { pub use circ1::f1; pub fn f2() { println!("f2"); } pub fn common() -> uint { return 1u; } } mod test { use circ1::*; fn test() { f1066(); } }
f1
identifier_name
import-glob-circular.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 common() -> uint { return 0u; } } mod circ2 { pub use circ1::f1; pub fn f2() { println!("f2"); } pub fn common() -> uint { return 1u; } } mod test { use circ1::*; fn test() { f1066(); } }
{ println!("f1"); }
identifier_body
reverse_words_str.rs
// Implements http://rosettacode.org/wiki/Reverse_words_in_a_string #![feature(str_words)] fn rev_words(line: &str) -> String { line.words().rev().collect::<Vec<&str>>().connect(" ") } fn rev_words_on_lines(text: &str) -> String { text.lines().map(rev_words).collect::<Vec<String>>().connect("\n") } #[cfg(n...
#[test] fn test_rev_words_on_lines() { // The tests from test_rev_words should have the same results, so // we include them. let tests = [("", ""), ("a", "a"), ("a b", "b a"), ("cat dog", "dog cat"), // According to the problem, multiple ...
{ let tests = [("", ""), ("a", "a"), ("a b", "b a"), ("cat dog", "dog cat"), // According to the problem, multiple spaces can be // compressed into a single space. ("cat dog", "dog cat"), ("cat...
identifier_body
reverse_words_str.rs
// Implements http://rosettacode.org/wiki/Reverse_words_in_a_string #![feature(str_words)] fn rev_words(line: &str) -> String { line.words().rev().collect::<Vec<&str>>().connect(" ")
text.lines().map(rev_words).collect::<Vec<String>>().connect("\n") } #[cfg(not(test))] fn main() { let text = "---------- Ice and Fire ------------ fire, in end will world the say Some ice. in say Some desire of tasted I've what From fire. favor who those with hold I ... elided paragraph last... Frost Robe...
} fn rev_words_on_lines(text: &str) -> String {
random_line_split
reverse_words_str.rs
// Implements http://rosettacode.org/wiki/Reverse_words_in_a_string #![feature(str_words)] fn rev_words(line: &str) -> String { line.words().rev().collect::<Vec<&str>>().connect(" ") } fn rev_words_on_lines(text: &str) -> String { text.lines().map(rev_words).collect::<Vec<String>>().connect("\n") } #[cfg(n...
() { let tests = [("", ""), ("a", "a"), ("a b", "b a"), ("cat dog", "dog cat"), // According to the problem, multiple spaces can be // compressed into a single space. ("cat dog", "dog cat"), ("...
test_rev_words
identifier_name
htmlbrelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLBRElementBinding; use dom::bindings::codegen::InheritTypes::HTMLBRElemen...
}
{ self.htmlelement.reflector() }
identifier_body
htmlbrelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLBRElementBinding; use dom::bindings::codegen::InheritTypes::HTMLBRElemen...
(localName: DOMString, document: JSRef<Document>) -> HTMLBRElement { HTMLBRElement { htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, document) } } #[allow(unrooted_must_root)] pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLBR...
new_inherited
identifier_name
htmlbrelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLBRElementBinding; use dom::bindings::codegen::InheritTypes::HTMLBRElemen...
impl HTMLBRElementDerived for EventTarget { fn is_htmlbrelement(&self) -> bool { self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBRElementTypeId)) } } impl HTMLBRElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBRElement { HTMLBRElement { ...
}
random_line_split
car.rs
extern crate quack; use quack::*; #[derive(Copy, Clone, Debug)] pub struct Tire {pub winter: bool} #[derive(Debug, Clone)] pub struct Car {pub tires: [Tire; 4]} pub struct LeftFrontTire(pub Tire); pub struct RightFrontTire(pub Tire); pub struct LeftBackTire(pub Tire); pub struct RightBackTire(pub Tire); quack!{ ...
(&self) -> Tire {Get::<RightFrontTire>::get(self).0} fn left_back_tire(&self) -> Tire {Get::<LeftBackTire>::get(self).0} fn right_back_tire(&self) -> Tire {Get::<RightBackTire>::get(self).0} fn set_left_front_tire(&mut self, val: Tire) {self.set(LeftFrontTire(val))} fn set_right_front_tire(&mut self, v...
right_front_tire
identifier_name
car.rs
extern crate quack; use quack::*; #[derive(Copy, Clone, Debug)] pub struct Tire {pub winter: bool} #[derive(Debug, Clone)] pub struct Car {pub tires: [Tire; 4]} pub struct LeftFrontTire(pub Tire); pub struct RightFrontTire(pub Tire); pub struct LeftBackTire(pub Tire); pub struct RightBackTire(pub Tire); quack!{ ...
} // Implement trait on top of duck type object. pub trait GenericCar: GetSet<LeftFrontTire> + GetSet<RightFrontTire> + GetSet<LeftBackTire> + GetSet<RightBackTire> + Action<ShiftToSummerTires> + Action<ShiftToWinterTires> { fn left_front_tire(&self) -> Tire {Get::<LeftFrontTire>::get(self...
{ for i in 0..4 {self.tires[i].winter = false} }
identifier_body
car.rs
extern crate quack; use quack::*; #[derive(Copy, Clone, Debug)] pub struct Tire {pub winter: bool} #[derive(Debug, Clone)] pub struct Car {pub tires: [Tire; 4]} pub struct LeftFrontTire(pub Tire); pub struct RightFrontTire(pub Tire); pub struct LeftBackTire(pub Tire); pub struct RightBackTire(pub Tire); quack!{ ...
car.set_left_front_tire(Tire {winter: false}); println!("Left front tire: {:?}", car.left_front_tire()); }
random_line_split
legacy.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/. */
//! `<input size>`, and so forth. use std::sync::Arc; use selectors::tree::TNode; use selectors::matching::DeclarationBlock; use node::TElementAttributes; use properties::PropertyDeclaration; use selector_matching::Stylist; use smallvec::VecLike; /// Legacy presentational attributes that take a nonnegative integer ...
//! Legacy presentational attributes defined in the HTML5 specification: `<td width>`,
random_line_split
legacy.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/. */ //! Legacy presentational attributes defined in the HTML5 specification: `<td width>`, //! `<input size>`, and so ...
} /// A convenience function to create a declaration block from a single declaration. This is /// primarily used in `synthesize_rules_for_legacy_attributes`. #[inline] pub fn from_declaration(rule: PropertyDeclaration) -> DeclarationBlock<Vec<PropertyDeclaration>> { DeclarationBlock::from_declarations(Arc::new(ve...
let element = node.as_element(); let length = matching_rules_list.len(); element.synthesize_presentational_hints_for_legacy_attributes(matching_rules_list); if matching_rules_list.len() != length { // Never share style for elements with preshints *shareable = fa...
identifier_body
legacy.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/. */ //! Legacy presentational attributes defined in the HTML5 specification: `<td width>`, //! `<input size>`, and so ...
rule: PropertyDeclaration) -> DeclarationBlock<Vec<PropertyDeclaration>> { DeclarationBlock::from_declarations(Arc::new(vec![rule])) }
rom_declaration(
identifier_name
legacy.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/. */ //! Legacy presentational attributes defined in the HTML5 specification: `<td width>`, //! `<input size>`, and so ...
} } /// A convenience function to create a declaration block from a single declaration. This is /// primarily used in `synthesize_rules_for_legacy_attributes`. #[inline] pub fn from_declaration(rule: PropertyDeclaration) -> DeclarationBlock<Vec<PropertyDeclaration>> { DeclarationBlock::from_declarations(Arc::...
// Never share style for elements with preshints *shareable = false; }
conditional_block
watcher.rs
// Copyright 2018 Mozilla // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software...
(&mut self, _t: &Entid, _schema: &Schema) -> Result<()> { Ok(()) } }
done
identifier_name
watcher.rs
// Copyright 2018 Mozilla // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software...
pub trait TransactWatcher { fn datom(&mut self, op: OpType, e: Entid, a: Entid, v: &TypedValue); /// Only return an error if you want to interrupt the transact! /// Called with the schema _prior to_ the transact -- any attributes or /// attribute changes transacted during this transact are not reflect...
use db_traits::errors::{ Result, };
random_line_split
watcher.rs
// Copyright 2018 Mozilla // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software...
}
{ Ok(()) }
identifier_body
llp.rs
#[doc = "Register `LLP` reader"] pub struct R(crate::R<LLP_SPEC>); impl core::ops::Deref for R { type Target = crate::R<LLP_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<LLP_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<LLP_SPEC>) ...
; impl crate::RegisterSpec for LLP_SPEC { type Ux = u32; } #[doc = "`read()` method returns [llp::R](R) reader structure"] impl crate::Readable for LLP_SPEC { type Reader = R; } #[doc = "`write(|w|..)` method takes [llp::W](W) writer structure"] impl crate::Writable for LLP_SPEC { type Writer = W; } #[doc =...
LLP_SPEC
identifier_name
llp.rs
#[doc = "Register `LLP` reader"] pub struct R(crate::R<LLP_SPEC>); impl core::ops::Deref for R { type Target = crate::R<LLP_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<LLP_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<LLP_SPEC>) ...
} impl R { #[doc = "Bits 2:31 - Starting Address In Memory"] #[inline(always)] pub fn loc(&self) -> LOC_R { LOC_R::new(((self.bits >> 2) & 0x3fff_ffff) as u32) } } impl W { #[doc = "Bits 2:31 - Starting Address In Memory"] #[inline(always)] pub fn loc(&mut self) -> LOC_W { L...
{ self.w.bits = (self.w.bits & !(0x3fff_ffff << 2)) | ((value as u32 & 0x3fff_ffff) << 2); self.w }
identifier_body
llp.rs
#[doc = "Register `LLP` reader"] pub struct R(crate::R<LLP_SPEC>); impl core::ops::Deref for R { type Target = crate::R<LLP_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<LLP_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<LLP_SPEC>) ...
}
}
random_line_split
bsp_renderer.rs
/* Copyright 2013 Jesse 'Jeaye' Wilkerson See licensing in LICENSE file, or at: http://www.opensource.org/licenses/BSD-3-Clause File: client/state/game/bsp_renderer.rs Author: Jesse 'Jeaye' Wilkerson Description: A client-only state that depends on the shared game state. This st...
} ui_renderer.end(); false } fn key_action(&mut self, key: glfw::Key, action: glfw::Action, _mods: glfw::Modifiers) -> bool { (self.game_renderer.camera as @mut State).key_action(key, action, _mods) } fn mouse_moved(&mut self, x: f32, y: f32) -> bool { (self.game_renderer.camera as @mut State).mous...
{ ui_renderer.render_font( format!("{}", fps), math::Vec2f::new(self.game_renderer.camera.window_size.x as f32 - 40.0, 0.0), &self.game_renderer.fps_font); }
conditional_block
bsp_renderer.rs
/* Copyright 2013 Jesse 'Jeaye' Wilkerson See licensing in LICENSE file, or at: http://www.opensource.org/licenses/BSD-3-Clause File: client/state/game/bsp_renderer.rs Author: Jesse 'Jeaye' Wilkerson Description: A client-only state that depends on the shared game state. This st...
log_debug!("Loading bsp renderer state."); self.game_renderer.camera.show_fps = true; self.shader.bind(); self.proj_loc = self.shader.get_uniform_location("proj"); self.world_loc = self.shader.get_uniform_location("world"); } fn unload(&mut self) { log_debug!("Unloading bsp renderer sta...
impl State for BSP_Renderer { fn load(&mut self) {
random_line_split
bsp_renderer.rs
/* Copyright 2013 Jesse 'Jeaye' Wilkerson See licensing in LICENSE file, or at: http://www.opensource.org/licenses/BSD-3-Clause File: client/state/game/bsp_renderer.rs Author: Jesse 'Jeaye' Wilkerson Description: A client-only state that depends on the shared game state. This st...
}
{ (self.game_renderer.camera as @mut State).mouse_moved(x, y) }
identifier_body
bsp_renderer.rs
/* Copyright 2013 Jesse 'Jeaye' Wilkerson See licensing in LICENSE file, or at: http://www.opensource.org/licenses/BSD-3-Clause File: client/state/game/bsp_renderer.rs Author: Jesse 'Jeaye' Wilkerson Description: A client-only state that depends on the shared game state. This st...
(&mut self) { log_debug!("Unloading bsp renderer state."); /* Cleanup GL. */ check!(gl2::delete_vertex_arrays(&[self.vao])); check!(gl2::delete_buffers(&[self.vbo])); } fn get_key(&self) -> &str { &"bsp_renderer" } fn update(&mut self, delta: f32) -> bool /* dt is in terms of seconds. */ ...
unload
identifier_name
map2one.rs
use itertools::izip; use mli::{Backward, Forward, Train}; use ndarray::{Array, Array2}; use num_traits::Zero; use std::ops::Add; #[derive(Clone, Debug)] pub struct Map2One<G>(pub G); impl<G> Forward for Map2One<G> where G: Forward, { type Input = Array2<G::Input>; type Internal = Array2<G::Internal>; ...
( &self, input: &Self::Input, internal: &Self::Internal, output_delta: &Self::OutputDelta, ) -> (Self::InputDelta, Self::TrainDelta) { let both_vec: Vec<(G::InputDelta, G::TrainDelta)> = izip!(input.iter(), internal.iter(), output_delta.iter(),) .ma...
backward
identifier_name
map2one.rs
use itertools::izip; use mli::{Backward, Forward, Train}; use ndarray::{Array, Array2}; use num_traits::Zero; use std::ops::Add; #[derive(Clone, Debug)] pub struct Map2One<G>(pub G); impl<G> Forward for Map2One<G> where G: Forward, { type Input = Array2<G::Input>; type Internal = Array2<G::Internal>; ...
fn backward( &self, input: &Self::Input, internal: &Self::Internal, output_delta: &Self::OutputDelta, ) -> (Self::InputDelta, Self::TrainDelta) { let both_vec: Vec<(G::InputDelta, G::TrainDelta)> = izip!(input.iter(), internal.iter(), output_delta.iter(),) ...
type OutputDelta = Array2<G::OutputDelta>; type InputDelta = Array2<G::InputDelta>; type TrainDelta = G::TrainDelta;
random_line_split
issue-42234-unknown-receiver-type.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() {}
random_line_split
issue-42234-unknown-receiver-type.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() {}
main
identifier_name
issue-42234-unknown-receiver-type.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() {}
{ data.iter() //~ ERROR 22:5: 23:20: type annotations needed .sum::<_>() .to_string() }
identifier_body
lib.rs
#![feature(abi_x86_interrupt)] #![feature(asm)] #![feature(const_fn, unique)] #![feature(lang_items)] #![feature(naked_functions)] #![no_std] #![feature(alloc, collections)] #![feature(core_intrinsics)] extern crate bit_field; #[macro_use] extern crate bitflags; extern crate raw_cpuid; #[macro_use] extern crate lazy_s...
() {} #[cfg(not(test))] #[lang = "panic_fmt"] #[no_mangle] pub extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) ->! { println!("\n\nPANIC in {} at line {}:", file, line); println!(" {}", fmt); loop {} } #[allow(non_snake_case)] #[no_mangle] pub extern "C" fn _Unwind_Res...
eh_personality
identifier_name
lib.rs
#![feature(abi_x86_interrupt)] #![feature(asm)] #![feature(const_fn, unique)] #![feature(lang_items)] #![feature(naked_functions)] #![no_std] #![feature(alloc, collections)] #![feature(core_intrinsics)] extern crate bit_field; #[macro_use] extern crate bitflags; extern crate raw_cpuid; #[macro_use] extern crate lazy_s...
/// Enter in usermode. /// /// This functions never returns. pub unsafe fn usermode(ip: usize, sp: usize) ->! { asm!(" mov ds, ax mov es, ax mov fs, bx mov gs, ax push rax push rcx push rdx push rsi push rdi iretq" : ...
{ loop {} }
identifier_body
lib.rs
#![feature(abi_x86_interrupt)] #![feature(asm)] #![feature(const_fn, unique)] #![feature(lang_items)] #![feature(naked_functions)] #![no_std] #![feature(alloc, collections)] #![feature(core_intrinsics)] extern crate bit_field; #[macro_use] extern crate bitflags; extern crate raw_cpuid; #[macro_use]
extern crate x86_64; extern crate hole_list_allocator; extern crate alloc; extern crate collections; #[macro_use] extern crate once; // Make constants public pub use consts::*; #[macro_use] /// Console handling pub mod vga_buffer; /// Kernel message writer pub mod kernel_messaging; /// ACPI manager pub mod acpi; ...
extern crate lazy_static; extern crate multiboot2; extern crate rlibc; extern crate spin; extern crate volatile;
random_line_split
block-scoped-shadow.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ A, B } use Foo::*; //~^ ERROR `Foo` is ambiguous let _ = (A, B); fn std() {} enum std {} use std as foo; //~^ ERROR `std` is ambiguous //~| ERROR `std` is ambiguous }
Foo
identifier_name
_match.rs
} fcx.write_ty(pat.id, pat_ty); // somewhat surprising: in this case, the subtyping // relation goes the opposite way as the other // cases. Actually what we really want is not a subtyping // relation at all but rather that there exists a LUB (s...
{ let expected_ty = structurally_resolved_type(fcx, pat.span, expected); if let ty::TyRef(_, mt) = expected_ty.sty { if let ty::TySlice(_) = mt.ty.sty { pat_ty = tcx.mk_imm_ref(tcx.mk_region(ty::ReStatic), ...
conditional_block
_match.rs
scalar demand::eqtype(fcx, pat.span, expected, lhs_ty); } ast::PatEnum(..) | ast::PatIdent(..) if pat_is_resolved_const(&tcx.def_map, pat) => { let const_did = tcx.def_map.borrow().get(&pat.id).unwrap().def_id(); let const_scheme = tcx.lookup_item_type(const_did); ...
check_expr_with_lvalue_pref(fcx, discrim, LvaluePreference::from_mutbl(m)); discrim_ty = fcx.expr_ty(discrim); } else { //...but otherwise we want to use any supertype of the // discriminant. This is sort of a workaround, see note (*) in // `check_pat` for some details. ...
if let Some(m) = contains_ref_bindings {
random_line_split
_match.rs
base_def: def::DefMod(ast_util::local_def(ast::CRATE_NODE_ID)), last_private: LastMod(AllPublic), depth: path.segments.len() } } else { tcx.sess.span_bug(pat.span, &format!("unbound path {...
check_pat_enum
identifier_name
upper_half.rs
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned; use malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf}; use malachite_base_test_util::generators::unsigned_gen; fn upper_half_test_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: T::Half) where T::Half: PrimitiveUnsigned,
#[test] pub fn test_upper_half() { upper_half_test_helper(0u64, 0u32); upper_half_test_helper(1u64, 0u32); upper_half_test_helper(u16::from(u8::MAX), 0); upper_half_test_helper(u16::from(u8::MAX) + 1, 1); upper_half_test_helper(u16::MAX, u8::MAX); upper_half_test_helper(258u16, 1u8); upper...
{ assert_eq!(n.upper_half(), out); }
identifier_body
upper_half.rs
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned; use malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf}; use malachite_base_test_util::generators::unsigned_gen; fn upper_half_test_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: T::Half) where T::Half: PrimitiveUnsigned, { ass...
pub fn test_upper_half() { upper_half_test_helper(0u64, 0u32); upper_half_test_helper(1u64, 0u32); upper_half_test_helper(u16::from(u8::MAX), 0); upper_half_test_helper(u16::from(u8::MAX) + 1, 1); upper_half_test_helper(u16::MAX, u8::MAX); upper_half_test_helper(258u16, 1u8); upper_half_test...
} #[test]
random_line_split
upper_half.rs
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned; use malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf}; use malachite_base_test_util::generators::unsigned_gen; fn upper_half_test_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: T::Half) where T::Half: PrimitiveUnsigned, { ass...
() { upper_half_test_helper(0u64, 0u32); upper_half_test_helper(1u64, 0u32); upper_half_test_helper(u16::from(u8::MAX), 0); upper_half_test_helper(u16::from(u8::MAX) + 1, 1); upper_half_test_helper(u16::MAX, u8::MAX); upper_half_test_helper(258u16, 1u8); upper_half_test_helper(0xabcd1234u32,...
test_upper_half
identifier_name
main.rs
/* Periodically crawl web pages and alert the user of changes * * Copyright (C) 2016 Owen Stenson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or...
} println!("Cache path: {:?}", cache_path); let mut now = Local::now(); thread::sleep(time_to_next_minute(&now)); loop { //iterate through the jobs, executing those for which it is time for j in &jobs { println!("Starting job {}", j.url); if let Err(e) =...
{ //TODO: start threads for each tasks //TODO: replace vec with map to futures? let config = Path::new(CFG_FILE); //parse input; panic if parsing fails let (cmds, vars) = match parse::parse(config) { Ok((c,v)) => (c,v), Err(e) => panic!(e.join("\n")), }; //panic! if ...
identifier_body
main.rs
/* Periodically crawl web pages and alert the user of changes * * Copyright (C) 2016 Owen Stenson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or...
(last_run: &DateTime<Local>) -> time::Duration { //compute the amount of time program should wait before checking again //if cycling through everything took more than 1 minute, then it'll miss // the next minute (TODO?) //It's okay to wait a little too long, but do not wait too short let sec =...
time_to_next_minute
identifier_name
main.rs
/* Periodically crawl web pages and alert the user of changes * * Copyright (C) 2016 Owen Stenson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or...
loop { //iterate through the jobs, executing those for which it is time for j in &jobs { println!("Starting job {}", j.url); if let Err(e) = j.fire_if_match(cache_path, &now) { println!("Error in job {}: `{}`", j.url, e); } } print...
} println!("Cache path: {:?}", cache_path); let mut now = Local::now(); thread::sleep(time_to_next_minute(&now));
random_line_split
range_collection.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
<'c, K: 'c, V: 'c> { range: usize, collection: &'c Vec<(K, Vec<V>)>, } impl<'c, K: 'c, V: 'c> Iterator for RangeIterator<'c, K, V> where K: Add<Output = K> + FromUsize + ToUsize + Copy, { type Item = (K, &'c [V]); // The 'Iterator' trait only requires the 'next' method to be defined. The // return type is 'Op...
RangeIterator
identifier_name
range_collection.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
} if empty { self.remove(index); } } } } fn insert_item(&mut self, key: K, value: V) { assert!(!self.have_item(&key)); // todo: fix warning let lower = match self.binary_search_by(|&(k, _)| k.cmp(&key).reverse()) { Ok(index) | Err(index) => index, }; let mut to_remove: Option<us...
{}
conditional_block
range_collection.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
{ let (mut next, mut inserted) = self.split_at_mut(lower); let mut next = next.last_mut().unwrap(); let mut inserted = inserted.first_mut().unwrap(); if next.0 == key + FromUsize::from_usize(1) { inserted.1.append(&mut next.1); to_remove = Some(lower - 1); } } if let So...
{ assert!(!self.have_item(&key)); // todo: fix warning let lower = match self.binary_search_by(|&(k, _)| k.cmp(&key).reverse()) { Ok(index) | Err(index) => index, }; let mut to_remove: Option<usize> = None; if lower < self.len() && self[lower].0 + FromUsize::from_usize(self[lower].1.len()) == key { ...
identifier_body
range_collection.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
assert!(!r.have_item(&18)); assert_eq!(r.range_iter().cmp(vec![(2, &['b', 'c', 'd'][..]), (16, &['p', 'q'][..])]), Ordering::Equal); r.remove_from(&16); assert!(!r.have_item(&16)); assert_eq!(r.range_iter().cmp(vec![(2, &['b', 'c', 'd'][..])]), Ordering::Equal); r.remove_from(&3); assert_eq!(r.range_iter().cmp(v...
let mut r = ranges.clone(); r.remove_from(&20); assert_eq!(r.range_iter().cmp(vec![(2, &['b', 'c', 'd'][..]), (16, &['p', 'q', 'r'][..])]), Ordering::Equal); r.remove_from(&18);
random_line_split
mod.rs
// Copyright (C) 2019, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
else { b }; let (nbits, _) = ENCODE_TABLE[b as usize]; bits += nbits; } let mut len = bits / 8; if bits & 7!= 0 { len += 1; } Ok(len) } struct Decoder { state: usize, maybe_eos: bool, } impl Decoder { fn new() -> Decoder { Decoder { stat...
{ b.to_ascii_lowercase() }
conditional_block
mod.rs
// Copyright (C) 2019, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
(&self) -> bool { self.state == 0 || self.maybe_eos } } mod table;
is_final
identifier_name
mod.rs
// Copyright (C) 2019, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
let mut len = bits / 8; if bits & 7!= 0 { len += 1; } Ok(len) } struct Decoder { state: usize, maybe_eos: bool, } impl Decoder { fn new() -> Decoder { Decoder { state: 0, maybe_eos: false, } } // Decodes 4 bits fn decode4(&mut...
let (nbits, _) = ENCODE_TABLE[b as usize]; bits += nbits; }
random_line_split
mod.rs
// Copyright (C) 2019, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
struct Decoder { state: usize, maybe_eos: bool, } impl Decoder { fn new() -> Decoder { Decoder { state: 0, maybe_eos: false, } } // Decodes 4 bits fn decode4(&mut self, input: u8) -> Result<Option<u8>> { const MAYBE_EOS: u8 = 1; const D...
{ let mut bits: usize = 0; for &b in src { let b = if low { b.to_ascii_lowercase() } else { b }; let (nbits, _) = ENCODE_TABLE[b as usize]; bits += nbits; } let mut len = bits / 8; if bits & 7 != 0 { len += 1; } Ok(len) }
identifier_body
endian.rs
use std::marker::PhantomData; use std::fmt; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use byteorder::{ByteOrder, LittleEndian, BigEndian, NativeEndian}; use uninitialized::uninitialized; use packed::{Unaligned, Aligned, Packed}; use pod::Pod; /// A type alias for unaligned little endian primitives pub typ...
fn eq(&self, other: &EndianPrimitive<BRHS, RHS>) -> bool { self.get().eq(&other.get()) } } impl<B: ByteOrder, T: EndianConvert + Eq> Eq for EndianPrimitive<B, T> { } impl<BRHS: ByteOrder, RHS: EndianConvert, B: ByteOrder, T: EndianConvert + PartialOrd<RHS>> PartialOrd<EndianPrimitive<BRHS, RHS>> for E...
#[inline]
random_line_split
endian.rs
use std::marker::PhantomData; use std::fmt; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use byteorder::{ByteOrder, LittleEndian, BigEndian, NativeEndian}; use uninitialized::uninitialized; use packed::{Unaligned, Aligned, Packed}; use pod::Pod; /// A type alias for unaligned little endian primitives pub typ...
else { false } } } #[test] fn endian_size() { use std::mem::size_of; use std::mem::align_of; type B = NativeEndian; assert_eq!(size_of::<EndianPrimitive<B, i16>>(), 2); assert_eq!(size_of::<EndianPrimitive<B, i32>>(), 4); assert_eq!(size_of::<EndianPrimitive<B, i64>>(), 8); assert_eq...
{ true }
conditional_block
endian.rs
use std::marker::PhantomData; use std::fmt; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use byteorder::{ByteOrder, LittleEndian, BigEndian, NativeEndian}; use uninitialized::uninitialized; use packed::{Unaligned, Aligned, Packed}; use pod::Pod; /// A type alias for unaligned little endian primitives pub typ...
(&self) -> &T::Unaligned { &self.value } /// A mutable reference to the inner untransformed value #[inline] pub fn raw_mut(&mut self) -> &mut T::Unaligned { &mut self.value } } unsafe impl<B, T: EndianConvert> Pod for EndianPrimitive<B, T> { } unsafe impl<B, T: EndianConvert> Unali...
raw
identifier_name
endian.rs
use std::marker::PhantomData; use std::fmt; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use byteorder::{ByteOrder, LittleEndian, BigEndian, NativeEndian}; use uninitialized::uninitialized; use packed::{Unaligned, Aligned, Packed}; use pod::Pod; /// A type alias for unaligned little endian primitives pub typ...
} impl<B: ByteOrder, T: EndianConvert + Eq> Eq for EndianPrimitive<B, T> { } impl<BRHS: ByteOrder, RHS: EndianConvert, B: ByteOrder, T: EndianConvert + PartialOrd<RHS>> PartialOrd<EndianPrimitive<BRHS, RHS>> for EndianPrimitive<B, T> { #[inline] fn partial_cmp(&self, other: &EndianPrimitive<BRHS, RHS>) -> Op...
{ self.get().eq(&other.get()) }
identifier_body
deriving-via-extension-struct-tuple.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 ...
() { let a1 = Foo(5, 6, "abc".to_string()); let a2 = Foo(5, 6, "abc".to_string()); let b = Foo(5, 7, "def".to_string()); assert_eq!(a1, a1); assert_eq!(a2, a1); assert!(!(a1 == b)); assert!(a1!= b); assert!(!(a1!= a1)); assert!(!(a2!= a1)); }
main
identifier_name
deriving-via-extension-struct-tuple.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 ...
assert!(!(a2!= a1)); }
assert!(!(a1 == b)); assert!(a1 != b); assert!(!(a1 != a1));
random_line_split
array2d.rs
#[allow(dead_code)] use std::ops; use std::fmt; use std::vec; use std::slice; #[derive(Clone)] /// Two dimensional array pub struct Array2D<T> { data: Vec<Vec<T>>, dim: (usize, usize) } impl<T> Array2D<T> where T: Default + Clone { /// Initialize dim-sized array of zeros (default value) /// /// # ...
(self) -> Vec<Vec<T>> { self.data } } impl<T> From<Vec<Vec<T>>> for Array2D<T> { /// Performs the conversion from Vec to Array2D /// /// # Example /// ``` /// use arrays::Array2D; /// /// let vec_obj = vec![ /// vec![1, 2, 3], /// vec![4, 5, 6], /// vec![...
to_vec
identifier_name
array2d.rs
#[allow(dead_code)] use std::ops; use std::fmt; use std::vec; use std::slice; #[derive(Clone)] /// Two dimensional array pub struct Array2D<T> { data: Vec<Vec<T>>, dim: (usize, usize) } impl<T> Array2D<T> where T: Default + Clone { /// Initialize dim-sized array of zeros (default value) /// /// # ...
}
{ self.data.iter_mut() }
identifier_body
array2d.rs
#[allow(dead_code)] use std::ops; use std::fmt; use std::vec; use std::slice; #[derive(Clone)] /// Two dimensional array pub struct Array2D<T> { data: Vec<Vec<T>>, dim: (usize, usize) } impl<T> Array2D<T> where T: Default + Clone { /// Initialize dim-sized array of zeros (default value) /// /// # ...
fn into_iter(self) -> Self::IntoIter { self.data.iter() } } // TODO: rewrite it impl<'a, T> Array2D<T> { /// Returns an iterator over the slice. pub fn iter(&'a self) -> slice::Iter<'a, Vec<T>> { self.data.iter() } /// Returns an iterator that allows modifying each value. p...
random_line_split
types.rs
#[derive(Clone, Serialize)] pub struct ClanStats { pub tag: String, pub name: String, pub color: String, pub members: usize, pub description: String, pub motto: String, pub id: String, pub emblems: ClanStatsEmblems, pub blocked: bool, pub stats: HistoryClanStats, } impl ClanStats { pub fn empty() -> Self { ...
pub fb_elo10: Option<f64>, pub fb_elo8: Option<f64>, pub fb_elo6: Option<f64>, pub fb_elo: Option<f64>, pub gm_elo10: Option<f64>, pub gm_elo8: Option<f64>, pub gm_elo6: Option<f64>, pub gm_elo: Option<f64>, pub glob_rating: Option<f64>, pub glob_rating_weighted: Option<f64>, pub win_ratio: Option<f64>, pub...
pub daily_battles: Option<f64>, pub efficiency: Option<f64>,
random_line_split
types.rs
#[derive(Clone, Serialize)] pub struct ClanStats { pub tag: String, pub name: String, pub color: String, pub members: usize, pub description: String, pub motto: String, pub id: String, pub emblems: ClanStatsEmblems, pub blocked: bool, pub stats: HistoryClanStats, } impl ClanStats { pub fn empty() -> Self { ...
() -> Self { Self { v10l: 0, winratio: 0, global_weighted: 0, global: 0, gm_elo: 0, gm_elo6: 0, gm_elo8: 0, gm_elo10: 0, fb_elo: 0, fb_elo6: 0, fb_elo8: 0, fb_elo10: 0, efficiency: 0, daily_battles: 0, battles: 0, members: 0, } } } // ClanNameAndTag is a type that h...
empty
identifier_name
decodable.rs
// Copyright 2012-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-MI...
cx.field_imm(span, name, arg) }).collect(); cx.expr_struct(trait_span, outer_pat_path, fields) } } }
{ match *fields { Unnamed(ref fields) => { let path_expr = cx.expr_path(outer_pat_path); if fields.is_empty() { path_expr } else { let fields = fields.iter().enumerate().map(|(i, &span)| { getarg(cx, span, ...
identifier_body
decodable.rs
// Copyright 2012-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-MI...
let path = cx.path_ident(trait_span, substr.type_ident); let result = decode_static_fields(cx, trait_span, path, summary, ...
random_line_split
decodable.rs
// Copyright 2012-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-MI...
(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, push: &mut FnMut(Annotatable)) { expand_deriving_decodable_imp(cx, span, mitem, item, push,...
expand_deriving_rustc_decodable
identifier_name
const-err-multi.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { let _ = (A, B, C, D); }
pub const C: u8 = A as u8; //~^ ERROR const_err pub const D: i8 = 50 - A; //~^ ERROR const_err
random_line_split
const-err-multi.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let _ = (A, B, C, D); }
identifier_body
const-err-multi.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let _ = (A, B, C, D); }
main
identifier_name