file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(dead_code)] #![allow(unreachable_code)] #![allow(unused_imports)] #![allow(unused_variables)] #![deny(un...
fn layout<'a>( &'a self, containing_block: &ContainingBlock, tree_rank: usize, absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>, ) -> FlowChildren { match self.as_replaced() { Ok(replaced) => match *replaced {}, Err(ifc...
{ match self { IndependentFormattingContext::Replaced(r) => Ok(r), IndependentFormattingContext::Flow(f) => Err(NonReplacedIFC::Flow(f)), } }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(dead_code)] #![allow(unreachable_code)] #![allow(unused_imports)] #![allow(unused_variables)] #![deny(un...
{ inline_size: Length, block_size: LengthOrAuto, mode: (WritingMode, Direction), } struct DefiniteContainingBlock { size: Vec2<Length>, mode: (WritingMode, Direction), } /// https://drafts.csswg.org/css2/visuren.html#relative-positioning fn relative_adjustement( style: &ComputedValues, in...
ContainingBlock
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(dead_code)] #![allow(unreachable_code)] #![allow(unused_imports)] #![allow(unused_variables)] #![deny(un...
// https://github.com/rust-lang/rust/issues/61129 fn take<T>(x: &mut T) -> T where T: Default, { std::mem::replace(x, Default::default()) }
block: adjust(box_offsets.block_start, box_offsets.block_end), } } // FIXME: use std::mem::take when it’s stable.
random_line_split
tree_sortable.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use SortType; use ffi; use glib::object::{Cast, IsA}; use glib::translate::*; use std::mem::{...
<T, F: Fn(&T, &TreeIter, &TreeIter) -> Ordering>(this: *mut GtkTreeModel, iter: *mut GtkTreeIter, iter2: *mut GtkTreeIter, f: gpointer) -> i32 where T: IsA<TreeSortable> { let f: &F = transmute(f); f(&TreeModel::from_glib_none(this).unsafe_cast(), &from_glib_borrow(iter), ...
trampoline
identifier_name
tree_sortable.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use SortType; use ffi; use glib::object::{Cast, IsA}; use glib::translate::*; use std::mem::{...
where F: Fn(&Self, &TreeIter, &TreeIter) -> Ordering +'static { unsafe { ffi::gtk_tree_sortable_set_default_sort_func(self.as_ref().to_glib_none().0, Some(trampoline::<Self, F>), int...
fn set_default_sort_func<F>(&self, sort_func: F)
random_line_split
tree_sortable.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use SortType; use ffi; use glib::object::{Cast, IsA}; use glib::translate::*; use std::mem::{...
fn into_raw<F, T>(func: F) -> gpointer where F: Fn(&T, &TreeIter, &TreeIter) -> Ordering +'static { skip_assert_initialized!(); let func: Box<F> = Box::new(func); Box::into_raw(func) as gpointer } impl<O: IsA<TreeSortable>> TreeSortableExtManual for O { #[inline] fn get_sort_column_id(&self) ...
{ Box::<F>::from_raw(ptr as *mut _); }
identifier_body
lib.rs
time::{Duration, Instant}, }; pub mod bench; mod cli; mod console; mod event; mod formatters; mod helpers; mod options; pub mod stats; mod term; mod test_result; mod time; mod types; #[cfg(test)] mod tests; use event::{CompletedTest, TestEvent}; use helpers::concurrency::get_concurrency; use helpers::exit_code::get...
id: TestId, desc: TestDesc, timeout: Instant, } let tests_len = tests.len(); let mut filtered_tests = filter_tests(opts, tests); if!opts.bench_benchmarks { filtered_tests = convert_benchmarks_to_tests(filtered_tests); } let filtered_tests = { let mut fi...
struct TimeoutEntry {
random_line_split
lib.rs
::{Duration, Instant}, }; pub mod bench; mod cli; mod console; mod event; mod formatters; mod helpers; mod options; pub mod stats; mod term; mod test_result; mod time; mod types; #[cfg(test)] mod tests; use event::{CompletedTest, TestEvent}; use helpers::concurrency::get_concurrency; use helpers::exit_code::get_exit...
fn run_test_inner( id: TestId, desc: TestDesc, monitor_ch: Sender<CompletedTest>, testfn: Box<dyn FnOnce() + Send>, opts: TestRunOpts, ) -> Option<thread::JoinHandle<()>> { let concurrency = opts.concurrency; let name = desc.name.clone(); let run...
{ let TestDescAndFn { desc, testfn } = test; // Emscripten can catch panics but other wasm targets cannot let ignore_because_no_process_support = desc.should_panic != ShouldPanic::No && cfg!(target_arch = "wasm32") && !cfg!(target_os = "emscripten"); if force_ignore || desc.ignore || i...
identifier_body
lib.rs
::{Duration, Instant}, }; pub mod bench; mod cli; mod console; mod event; mod formatters; mod helpers; mod options; pub mod stats; mod term; mod test_result; mod time; mod types; #[cfg(test)] mod tests; use event::{CompletedTest, TestEvent}; use helpers::concurrency::get_concurrency; use helpers::exit_code::get_exit...
pending += 1; } let mut res; loop { if let Some(timeout) = calc_timeout(&timeout_queue) { res = rx.recv_timeout(timeout); for test in get_timed_out_tests(&running_tests, &mut timeout_queue) { ...
{ while pending > 0 || !remaining.is_empty() { while pending < concurrency && !remaining.is_empty() { let (id, test) = remaining.pop().unwrap(); let timeout = time::get_default_test_timeout(); let desc = test.desc.clone(); let event = ...
conditional_block
lib.rs
::{Duration, Instant}, }; pub mod bench; mod cli; mod console; mod event; mod formatters; mod helpers; mod options; pub mod stats; mod term; mod test_result; mod time; mod types; #[cfg(test)] mod tests; use event::{CompletedTest, TestEvent}; use helpers::concurrency::get_concurrency; use helpers::exit_code::get_exit...
( running_tests: &TestMap, timeout_queue: &mut VecDeque<TimeoutEntry>, ) -> Vec<TestDesc> { let now = Instant::now(); let mut timed_out = Vec::new(); while let Some(timeout_entry) = timeout_queue.front() { if now < timeout_entry.timeout { break; ...
get_timed_out_tests
identifier_name
mark_set.rs
// Copyright 2021-2022 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
() { let mut bag = MarkSet::new(); let one = Rc::new(1i8); let three = Rc::new(3i64); assert!(!bag.contains_any::<i8>()); assert!(!bag.contains_any::<i64>()); assert_eq!(bag.push(one.clone()), None); assert!(bag.contains_any::<i8>()); assert!(!bag.contains...
confirms_push_with_contains_any
identifier_name
mark_set.rs
// Copyright 2021-2022 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
/// Return `true` if and only if a mark of type `T` was pushed into this [MarkSet] and has not /// yet been removed. pub fn contains_any<T: Any>(&self) -> bool { self.map.contains_key(&TypeId::of::<T>()) } /// Return a reference to the mark of type `T` that was last pushed into this [Mark...
{ self.get::<T>() == Some(m) }
identifier_body
mark_set.rs
// Copyright 2021-2022 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
fn pops_old_items_when_new_are_pushed() { let mut bag = MarkSet::new(); let one = Rc::new(1i8); let two = Rc::new(2i8); let three = Rc::new(3i64); let four = Rc::new(4i64); assert_eq!(bag.push(one.clone()), None); assert_eq!(bag.push(two.clone()), Some(one)); ...
#[test]
random_line_split
digest.rs
use std::io::{self, Write, Read}; use std::fmt::Display; use sha2::Sha256; use sha2::Digest as DigestTrait; pub struct Digest(Sha256); impl Digest { pub fn new() -> Digest { Digest(Sha256::new()) } pub fn result_str(&mut self) -> String { return self.0.result_str(); } pub fn inpu...
}; self.0.input(&buf[..len]); } Ok(()) } } impl Write for Digest { fn write(&mut self, chunk: &[u8]) -> io::Result<usize> { self.0.input(chunk); Ok(chunk.len()) } fn flush(&mut self) -> io::Result<()> { Ok(()) } }
Err(e) => return Err(e),
random_line_split
digest.rs
use std::io::{self, Write, Read}; use std::fmt::Display; use sha2::Sha256; use sha2::Digest as DigestTrait; pub struct Digest(Sha256); impl Digest { pub fn new() -> Digest { Digest(Sha256::new()) } pub fn result_str(&mut self) -> String { return self.0.result_str(); } pub fn inpu...
fn flush(&mut self) -> io::Result<()> { Ok(()) } }
{ self.0.input(chunk); Ok(chunk.len()) }
identifier_body
digest.rs
use std::io::{self, Write, Read}; use std::fmt::Display; use sha2::Sha256; use sha2::Digest as DigestTrait; pub struct Digest(Sha256); impl Digest { pub fn new() -> Digest { Digest(Sha256::new()) } pub fn result_str(&mut self) -> String { return self.0.result_str(); } pub fn inpu...
} pub fn bool<K: AsRef<[u8]>>(&mut self, key: K, value: bool) { self.0.input(key.as_ref()); self.0.input(b"\0"); self.0.input(if value { b"0" } else { b"1" }); } pub fn sequence<K, I: IntoIterator>(&mut self, key: K, seq: I) where K: AsRef<[u8]>, I::Item: AsRef<[u8]>...
{ self.0.input(key.as_ref()); self.0.input(b"\0"); self.0.input(val.as_ref()); self.0.input(b"\0"); }
conditional_block
digest.rs
use std::io::{self, Write, Read}; use std::fmt::Display; use sha2::Sha256; use sha2::Digest as DigestTrait; pub struct
(Sha256); impl Digest { pub fn new() -> Digest { Digest(Sha256::new()) } pub fn result_str(&mut self) -> String { return self.0.result_str(); } pub fn input<V: AsRef<[u8]>>(&mut self, value: V) { self.0.input(value.as_ref()); } pub fn item<V: AsRef<[u8]>>(&mut self,...
Digest
identifier_name
counter_style_rule.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/. */ // TODO(emilio): unify this, components/style/counter_style.rs, and // components/style/gecko/rules.rs #![allow(mi...
(&self) -> CounterStyleRule { self.deep_clone_from_gecko() } }
clone_conditionally_gecko_or_servo
identifier_name
counter_style_rule.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/. */ // TODO(emilio): unify this, components/style/counter_style.rs, and // components/style/gecko/rules.rs #![allow(mi...
#[cfg(feature = "gecko")] pub fn clone_conditionally_gecko_or_servo(&self) -> CounterStyleRule { self.deep_clone_from_gecko() } }
{ self.clone() }
identifier_body
counter_style_rule.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/. */ // TODO(emilio): unify this, components/style/counter_style.rs, and // components/style/gecko/rules.rs #![allow(mi...
pub use counter_style::CounterStyleRuleData as CounterStyleRule; #[cfg(feature = "gecko")] pub use gecko::rules::CounterStyleRule; impl CounterStyleRule { #[cfg(feature = "servo")] pub fn clone_conditionally_gecko_or_servo(&self) -> CounterStyleRule { self.clone() } #[cfg(feature = "gecko")] ...
#[cfg(feature = "servo")]
random_line_split
headerbar.rs
use gtk::{Inhibit}; use gtk::Orientation::{Vertical}; use gtk::prelude::*; use relm_derive::{Msg, widget}; use relm::{Component, Widget, init}; use self::HeaderMsg::*; use self::WinMsg::*; #[derive(Msg)] pub enum HeaderMsg { Add, Remove, } #[widget] impl Widget for Header { fn model() -> () { } ...
show_close_button: true, #[name="add_button"] gtk::Button { clicked => Add, label: "Add", }, #[name="remove_button"] gtk::Button { clicked => Remove, label: "Remove", }, ...
random_line_split
headerbar.rs
use gtk::{Inhibit}; use gtk::Orientation::{Vertical}; use gtk::prelude::*; use relm_derive::{Msg, widget}; use relm::{Component, Widget, init}; use self::HeaderMsg::*; use self::WinMsg::*; #[derive(Msg)] pub enum HeaderMsg { Add, Remove, } #[widget] impl Widget for Header { fn model() -> () { } ...
() -> Model { let header = init::<Header>(()).expect("Header"); Model { header } } fn update(&mut self, event: WinMsg) { match event { Quit => gtk::main_quit(), } } view! { #[name="window"] gtk::Window { title...
model
identifier_name
lib.rs
#![crate_name="rustspec"] #![crate_type="dylib"] #![feature(plugin_registrar, rustc_private, collections, core, convert)] extern crate syntax; extern crate core; extern crate rustc; extern crate rustspec_assertions; pub use rustspec_assertions::{expect, eq, be_gt, be_ge, be_lt, be_le, contain, be_false, be_true, be_s...
let (name, block) = extract_test_node_data(parser); TestCaseNode::new(name, block, should_fail, should_be_ignored) } #[allow(unused_must_use)] fn parse_node(cx: &mut ExtCtxt, parser: &mut Parser) -> (Option<P<ast::Block>>, Vec<Box<TestNode +'static>>) { let mut nodes: Vec<Box<TestNode>> = Vec::new(); ...
{ parser.bump(); let ident = parser.parse_ident().ok().unwrap(); let token_str = ident.as_str(); should_fail = token_str == "fails"; should_be_ignored = token_str == "ignores"; }
conditional_block
lib.rs
#![crate_name="rustspec"] #![crate_type="dylib"] #![feature(plugin_registrar, rustc_private, collections, core, convert)] extern crate syntax; extern crate core; extern crate rustc; extern crate rustspec_assertions; pub use rustspec_assertions::{expect, eq, be_gt, be_ge, be_lt, be_le, contain, be_false, be_true, be_s...
(token: syntax::parse::token::Token) -> bool { token == token::OpenDelim(token::Brace) || token == token::CloseDelim(token::Brace) || token == token::OpenDelim(token::Paren) || token == token::CloseDelim(token::Paren) || token == token::Comma || token == token::Semi } #[allow(unused...
is_skippable
identifier_name
lib.rs
#![crate_name="rustspec"] #![crate_type="dylib"] #![feature(plugin_registrar, rustc_private, collections, core, convert)] extern crate syntax; extern crate core; extern crate rustc; extern crate rustspec_assertions; pub use rustspec_assertions::{expect, eq, be_gt, be_ge, be_lt, be_le, contain, be_false, be_true, be_s...
#[allow(unused_must_use)] fn parse_node(cx: &mut ExtCtxt, parser: &mut Parser) -> (Option<P<ast::Block>>, Vec<Box<TestNode +'static>>) { let mut nodes: Vec<Box<TestNode>> = Vec::new(); let mut before_block = None; while parser.token!= token::Eof { if is_skippable(parser.token.clone()) { ...
{ let mut should_fail = false; let mut should_be_ignored = false; if parser.token == token::Dot { parser.bump(); let ident = parser.parse_ident().ok().unwrap(); let token_str = ident.as_str(); should_fail = token_str == "fails"; should_be_ignored = token_str == "igno...
identifier_body
lib.rs
#![crate_name="rustspec"] #![crate_type="dylib"] #![feature(plugin_registrar, rustc_private, collections, core, convert)] extern crate syntax; extern crate core; extern crate rustc; extern crate rustspec_assertions; pub use rustspec_assertions::{expect, eq, be_gt, be_ge, be_lt, be_le, contain, be_false, be_true, be_s...
let (name, _) = parser.parse_str().ok().unwrap(); parser.bump(); let block_tokens = parser.parse_block().ok().unwrap().to_tokens(cx); let mut block_parser = tts_to_parser(cx.parse_sess(), block_tokens, cx.cfg()); let (before, children) = parse_node(cx, &mut block_parser); let node = TestContext...
#[allow(unused_must_use)] pub fn macro_scenario(cx: &mut ExtCtxt, _: Span, tts: &[ast::TokenTree]) -> Box<MacResult + 'static> { let mut parser = cx.new_parser_from_tts(tts);
random_line_split
layout_interface.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/. */ //! The high-level interface from script to layout. Using this abstract //! interface helps reduce coupling betwee...
pub struct ContentBoxResponse(pub Rect<Au>); pub struct ContentBoxesResponse(pub Vec<Rect<Au>>); pub struct NodeGeometryResponse { pub client_rect: Rect<i32>, } pub struct HitTestResponse(pub UntrustedNodeAddress); pub struct MouseOverResponse(pub Vec<UntrustedNodeAddress>); pub struct ResolvedStyleResponse(pub O...
}
random_line_split
layout_interface.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/. */ //! The high-level interface from script to layout. Using this abstract //! interface helps reduce coupling betwee...
{ pub id: PipelineId, pub url: Url, pub is_parent: bool, pub layout_pair: OpaqueScriptLayoutChannel, pub pipeline_port: IpcReceiver<LayoutControlMsg>, pub constellation_chan: ConstellationChan, pub failure: Failure, pub script_chan: Sender<ConstellationControlMsg>, pub image_cache_t...
NewLayoutTaskInfo
identifier_name
input_layers.rs
use std::borrow::Cow; use std::fmt; use std::io::BufRead; use std::result; use enum_map::{Enum, EnumMap}; use failure::Error; use tensorflow::Tensor; use crate::features::addr; use crate::features::lookup::LookupResult; use crate::features::parse_addr::parse_addressed_values; use crate::features::{BoxedLookup, Lookup...
self.realize_into(state, &mut embed_layer, &mut lookup_layers); InputVector { embed_layer, lookup_layers, } } /// Vectorize a parser state into the given slices. pub fn realize_into<S>( &self, state: &ParserState<'_>, embed_layer: &mu...
for (layer, &size) in &self.lookup_layer_sizes() { lookup_layers[layer] = vec![0; size]; }
random_line_split
input_layers.rs
use std::borrow::Cow; use std::fmt; use std::io::BufRead; use std::result; use enum_map::{Enum, EnumMap}; use failure::Error; use tensorflow::Tensor; use crate::features::addr; use crate::features::lookup::LookupResult; use crate::features::parse_addr::parse_addressed_values; use crate::features::{BoxedLookup, Lookup...
(EnumMap<Layer, BoxedLookup>); impl LayerLookups { pub fn new() -> Self { LayerLookups(EnumMap::new()) } pub fn insert<L>(&mut self, layer: Layer, lookup: L) where L: Into<Box<dyn Lookup>>, { self.0[layer] = BoxedLookup::new(lookup) } /// Get the lookup for a layer...
LayerLookups
identifier_name
input_layers.rs
use std::borrow::Cow; use std::fmt; use std::io::BufRead; use std::result; use enum_map::{Enum, EnumMap}; use failure::Error; use tensorflow::Tensor; use crate::features::addr; use crate::features::lookup::LookupResult; use crate::features::parse_addr::parse_addressed_values; use crate::features::{BoxedLookup, Lookup...
pub fn lookup_layer_sizes(&self) -> EnumMap<Layer, usize> { let mut sizes = EnumMap::new(); for layer in &self.input_layer_addrs.0 { if let Some(lookup) = self.layer_lookups.0[(&layer.layer).into()].as_ref() { match lookup.lookup_type() { LookupType...
{ &self.layer_lookups }
identifier_body
e01-pass-struct.rs
/// Exercise 11.1: Modify the example code shown in Figure 11.4 to pass the structure between the /// threads properly. /// /// The cleanest solution is - I think - if the main thread is responsible /// for both mallocing and freeing the memory, thus we don't need /// the return value (or pthread_exit), but store the c...
() { unsafe { let foo = Box::new(Foo { a: 1, b: 2, c: 3, d: 4, }); let mut tid1 = std::mem::uninitialized(); let foo_ptr = Box::into_raw(foo); pthread_create(&mut tid1, null_mut(), thr_fn1, foo_ptr as *mut c_void).check_zero().e...
main
identifier_name
e01-pass-struct.rs
/// Exercise 11.1: Modify the example code shown in Figure 11.4 to pass the structure between the
/// /// The cleanest solution is - I think - if the main thread is responsible /// for both mallocing and freeing the memory, thus we don't need /// the return value (or pthread_exit), but store the changes in to the arg /// variable directly. /// /// The solution in the book works as well of course, but leaks memory. ...
/// threads properly.
random_line_split
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main()
println!("You guessed: {}", myguess); let secret = rand::thread_rng().gen_range(1,101); match myguess.cmp(&secret) { Ordering::Less => println!("Too small!!"), Ordering::Greater => println!("Too BIG!!"), Ordering::Equal => { println!("You Win!!!"); break; } } printl...
{ loop { println!("\n"); println!("Hurry ! guess a number between 1 and 100 quick !!"); println!("Now quickly enter what you have guessed !"); let mut myguess = String::new(); io::stdin() .read_line(&mut myguess) .ok() .expect("can not read !! I am blind again !!"); let m...
identifier_body
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { loop { println!("\n"); println!("Hurry! guess a number between 1 and 100 quick!!"); println!("Now quickly enter what you have guessed!"); let mut myguess = String::new(); io::stdin() .read_line(&mut mygu...
} println!("The secret number is: {}", secret); } }
{ println!("You Win !!!"); break; }
conditional_block
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { loop { println!("\n"); println!("Hurry! guess a number between 1 and 100 quick!!"); println!("Now quickly enter what you have guessed!"); let mut myguess = String::new(); io::stdin() .read_line(&mut mygu...
match myguess.cmp(&secret) { Ordering::Less => println!("Too small!!"), Ordering::Greater => println!("Too BIG!!"), Ordering::Equal => { println!("You Win!!!"); break; } } println!("The secret number is: {}", secret); } }
let secret = rand::thread_rng().gen_range(1,101);
random_line_split
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn
() { loop { println!("\n"); println!("Hurry! guess a number between 1 and 100 quick!!"); println!("Now quickly enter what you have guessed!"); let mut myguess = String::new(); io::stdin() .read_line(&mut myguess) .ok() .expect("can not read!! I am blind again!!"); let myg...
main
identifier_name
arm_linux_androideabi.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 ...
() -> Target { let mut base = super::linux_base::opts(); base.features = "+v7".to_string(); // Many of the symbols defined in compiler-rt are also defined in libgcc. Android // linker doesn't like that by default. base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string()); // FIXME ...
target
identifier_name
arm_linux_androideabi.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 ...
Target { data_layout: "e-p:32:32:32\ -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\ -f32:32:32-f64:64:64\ -v64:64:64-v128:64:128\ -a:0:64-n32".to_string(), llvm_target: "arm-linux-androideabi".to_string(), ...
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string()); // FIXME #17437 (and #17448): Android doesn't support position dependent executables anymore. base.position_independent_executables = false;
random_line_split
arm_linux_androideabi.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 ...
options: base, } }
{ let mut base = super::linux_base::opts(); base.features = "+v7".to_string(); // Many of the symbols defined in compiler-rt are also defined in libgcc. Android // linker doesn't like that by default. base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string()); // FIXME #17437 (and #...
identifier_body
classes-simple.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 ...
cat { meows: in_x, how_hungry: in_y } } pub fn main() { let mut nyan : cat = cat(52u, 99); let mut kitty = cat(1000u, 2); assert!((nyan.how_hungry == 99)); assert!((kitty.how_hungry == 2)); }
fn cat(in_x : uint, in_y : int) -> cat {
random_line_split
classes-simple.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() { let mut nyan : cat = cat(52u, 99); let mut kitty = cat(1000u, 2); assert!((nyan.how_hungry == 99)); assert!((kitty.how_hungry == 2)); }
{ cat { meows: in_x, how_hungry: in_y } }
identifier_body
classes-simple.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut nyan : cat = cat(52u, 99); let mut kitty = cat(1000u, 2); assert!((nyan.how_hungry == 99)); assert!((kitty.how_hungry == 2)); }
main
identifier_name
main.rs
use mylib_threadpool::ThreadPool; use std::fs; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::thread; use std::time::Duration; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); for stream in listener.incoming().ta...
(mut stream: TcpStream) { let mut buffer = [0; 1024]; stream.read(&mut buffer).unwrap(); let get = b"GET / HTTP/1.1\r\n"; let sleep = b"GET /sleep HTTP/1.1\r\n"; let (status_line, filename) = if buffer.starts_with(get) { ("HTTP/1.1 200 OK\r\n\r\n", "hello.html") } else if buffer.starts...
handle_connection
identifier_name
main.rs
use mylib_threadpool::ThreadPool; use std::fs; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::thread; use std::time::Duration; fn main()
fn handle_connection(mut stream: TcpStream) { let mut buffer = [0; 1024]; stream.read(&mut buffer).unwrap(); let get = b"GET / HTTP/1.1\r\n"; let sleep = b"GET /sleep HTTP/1.1\r\n"; let (status_line, filename) = if buffer.starts_with(get) { ("HTTP/1.1 200 OK\r\n\r\n", "hello.html") }...
{ let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); for stream in listener.incoming().take(2) { let stream = stream.unwrap(); pool.execute(|| { handle_connection(stream); }); } println!("Shutting down."); }
identifier_body
main.rs
use mylib_threadpool::ThreadPool; use std::fs; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::thread; use std::time::Duration; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); for stream in listener.incoming().ta...
}; let contents = fs::read_to_string(filename).unwrap(); let response = format!("{}{}", status_line, contents); stream.write(response.as_bytes()).unwrap(); stream.flush().unwrap(); }
("HTTP/1.1 200 OK\r\n\r\n", "hello.html") } else { ("HTTP/1.1 404 NOT FOUND\r\n\r\n", "404.html")
random_line_split
main.rs
use mylib_threadpool::ThreadPool; use std::fs; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::thread; use std::time::Duration; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); for stream in listener.incoming().ta...
; let contents = fs::read_to_string(filename).unwrap(); let response = format!("{}{}", status_line, contents); stream.write(response.as_bytes()).unwrap(); stream.flush().unwrap(); }
{ ("HTTP/1.1 404 NOT FOUND\r\n\r\n", "404.html") }
conditional_block
source.rs
use std::fmt::{self, Debug, Formatter}; use url::Url; use core::source::{Source, SourceId}; use core::GitReference; use core::{Dependency, Package, PackageId, Summary}; use util::Config; use util::errors::CargoResult; use util::hex::short_hash; use sources::PathSource; use sources::git::utils::{GitRemote, GitRevision...
else { (self.remote.db_at(&db_path)?, actual_rev.unwrap()) }; // Don’t use the full hash, // to contribute less to reaching the path length limit on Windows: // https://github.com/servo/servo/pull/14397 let short_id = db.to_short_id(actual_rev.clone()).unwrap(); ...
{ self.config.shell().status( "Updating", format!("git repository `{}`", self.remote.url()), )?; trace!("updating git source `{:?}`", self.remote); self.remote .checkout(&db_path, &self.reference, self.config)? }
conditional_block
source.rs
use std::fmt::{self, Debug, Formatter}; use url::Url; use core::source::{Source, SourceId}; use core::GitReference; use core::{Dependency, Package, PackageId, Summary}; use util::Config; use util::errors::CargoResult; use util::hex::short_hash; use sources::PathSource; use sources::git::utils::{GitRemote, GitRevision...
url.set_path(&path); } // Repos generally can be accessed with or w/o '.git' let needs_chopping = url.path().ends_with(".git"); if needs_chopping { let last = { let last = url.path_segments().unwrap().next_back().unwrap(); last[..last.len() - 4].to_owned() ...
url.set_scheme("https").unwrap(); let path = url.path().to_lowercase();
random_line_split
source.rs
use std::fmt::{self, Debug, Formatter}; use url::Url; use core::source::{Source, SourceId}; use core::GitReference; use core::{Dependency, Package, PackageId, Summary}; use util::Config; use util::errors::CargoResult; use util::hex::short_hash; use sources::PathSource; use sources::git::utils::{GitRemote, GitRevision...
s.to_url().unwrap() } }
identifier_body
source.rs
use std::fmt::{self, Debug, Formatter}; use url::Url; use core::source::{Source, SourceId}; use core::GitReference; use core::{Dependency, Package, PackageId, Summary}; use util::Config; use util::errors::CargoResult; use util::hex::short_hash; use sources::PathSource; use sources::git::utils::{GitRemote, GitRevision...
(&self) -> &SourceId { &self.source_id } fn update(&mut self) -> CargoResult<()> { let lock = self.config .git_path() .open_rw(".cargo-lock-git", self.config, "the git checkouts")?; let db_path = lock.parent().join("db").join(&self.ident); ...
source_id
identifier_name
global.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/. */ //! Abstractions for global scopes. //! //! This module contains smart pointers to global scopes, to simplify writ...
let global = GetGlobalForObjectCrossCompartment(obj); let clasp = JS_GetClass(global); assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL))!= 0); match native_from_reflector_jsmanaged(global) { Ok(window) => return GlobalUnrooted::Window(window), ...
unsafe {
random_line_split
global.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/. */ //! Abstractions for global scopes. //! //! This module contains smart pointers to global scopes, to simplify writ...
/// Get next worker id. pub fn get_next_worker_id(&self) -> WorkerId { match *self { GlobalRef::Window(ref window) => window.get_next_worker_id(), GlobalRef::Worker(ref worker) => worker.get_next_worker_id() } } /// Get the URL for this global scope. pub fn...
{ match *self { GlobalRef::Window(ref window) => window.resource_task().clone(), GlobalRef::Worker(ref worker) => worker.resource_task().clone(), } }
identifier_body
global.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/. */ //! Abstractions for global scopes. //! //! This module contains smart pointers to global scopes, to simplify writ...
(&self) -> Box<ScriptChan+Send> { match *self { GlobalRef::Window(ref window) => window.script_chan(), GlobalRef::Worker(ref worker) => worker.script_chan(), } } /// Create a new sender/receiver pair that can be used to implement an on-demand /// event loop. Used for...
script_chan
identifier_name
generic-impl-more-params-with-defaults.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
; struct Vec<T, A = Heap>; impl<T, A = Heap> Vec<T, A> { fn new() -> Vec<T, A> {Vec} } fn main() { Vec::<int, Heap, bool>::new(); //~^ ERROR the impl referenced by this path needs at most 2 type parameters, // but 3 were supplied //~^^^ ERROR too many type parameters provided: expected at...
Heap
identifier_name
generic-impl-more-params-with-defaults.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 ...
// but 3 were supplied //~^^^ ERROR too many type parameters provided: expected at most 2, found 3 }
//~^ ERROR the impl referenced by this path needs at most 2 type parameters,
random_line_split
lib.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....
extern crate tiny_keccak; extern crate rlp; extern crate regex; #[macro_use] extern crate heapsize; #[macro_use] extern crate lazy_static; #[macro_use] extern crate itertools; #[macro_use] extern crate log as rlog; pub extern crate using_queue; pub extern crate table; pub mod bloom; pub mod standard; #[macro_use] pu...
extern crate target_info; extern crate ethcore_bigint as bigint; extern crate parking_lot; extern crate ansi_term;
random_line_split
pool.rs
use indy::IndyError; use indy::pool; use indy::future::Future; use serde_json::to_string; use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::fs; #[derive(Serialize, Deserialize)] pub struct PoolConfig { pub genesis_txn: String } const PROTOCOL_VERSION: usize = 2; pub fn create_and_open_po...
let mut f = fs::File::create(txn_file_path.as_path()).unwrap(); f.write_all(txn_file_data.as_bytes()).unwrap(); f.flush().unwrap(); f.sync_all().unwrap(); txn_file_path } fn _open_pool_ledger(pool_name: &str, config: Option<&str>) -> Result<i32, IndyError> { pool::open_pool_ledger(pool_name,...
{ fs::DirBuilder::new() .recursive(true) .create(txn_file_path.parent().unwrap()).unwrap(); }
conditional_block
pool.rs
use indy::IndyError; use indy::pool; use indy::future::Future; use serde_json::to_string; use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::fs; #[derive(Serialize, Deserialize)] pub struct PoolConfig { pub genesis_txn: String } const PROTOCOL_VERSION: usize = 2; pub fn create_and_open_po...
pub fn set_protocol_version(protocol_version: usize) -> Result<(), IndyError> { pool::set_protocol_version(protocol_version).wait() }
random_line_split
pool.rs
use indy::IndyError; use indy::pool; use indy::future::Future; use serde_json::to_string; use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::fs; #[derive(Serialize, Deserialize)] pub struct PoolConfig { pub genesis_txn: String } const PROTOCOL_VERSION: usize = 2; pub fn create_and_open_po...
pub fn close(pool_handle: i32) -> Result<(), IndyError> { pool::close_pool_ledger(pool_handle).wait() } fn _pool_config_json(txn_file_path: &Path) -> String { to_string(&PoolConfig { genesis_txn: txn_file_path.to_string_lossy().to_string() }).unwrap() } fn _create_pool_ledger_config(pool_name: &...
{ set_protocol_version(PROTOCOL_VERSION).unwrap(); let txn_file_path = _create_genesis_txn_file_for_test_pool(pool_name, None, None); let pool_config = _pool_config_json(txn_file_path.as_path()); _create_pool_ledger_config(pool_name, Some(pool_config.as_str()))?; _open_pool_ledger(pool_name, None) }
identifier_body
pool.rs
use indy::IndyError; use indy::pool; use indy::future::Future; use serde_json::to_string; use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::fs; #[derive(Serialize, Deserialize)] pub struct PoolConfig { pub genesis_txn: String } const PROTOCOL_VERSION: usize = 2; pub fn create_and_open_po...
(pool_name: &str, config: Option<&str>) -> Result<i32, IndyError> { pool::open_pool_ledger(pool_name, config).wait() } pub fn set_protocol_version(protocol_version: usize) -> Result<(), IndyError> { pool::set_protocol_version(protocol_version).wait() }
_open_pool_ledger
identifier_name
re.rs
String>>, #[doc(hidden)] pub prog: Program } #[doc(hidden)] pub struct ExNative { #[doc(hidden)] pub original: &'static str, #[doc(hidden)] pub names: &'static [Option<&'static str>], #[doc(hidden)] pub prog: fn(MatchKind, &str, uint, uint) -> Vec<Option<uint>> } impl Clone for ExNativ...
} impl<'t> Replacer for |&Captures|: 't -> String { fn reg_replace<'a>(&'a mut self, caps: &Captures) -> MaybeOwned<'a> { Owned((*self)(caps)) } } /// Yields all substrings delimited by a regular expression match. /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of...
{ Owned(caps.expand(*self)) }
identifier_body
re.rs
let ast = try!(parse::parse(re)); let (prog, names) = Program::new(ast); Ok(Dynamic(ExDynamic { original: re.to_string(), names: names, prog: prog, })) } /// Returns true if and only if the regex matches the string given. /// /// # Ex...
iter_pos
identifier_name
re.rs
<String>>, #[doc(hidden)] pub prog: Program } #[doc(hidden)] pub struct ExNative { #[doc(hidden)] pub original: &'static str, #[doc(hidden)] pub names: &'static [Option<&'static str>], #[doc(hidden)] pub prog: fn(MatchKind, &str, uint, uint) -> Vec<Option<uint>> } impl Clone for ExNati...
/// assert_eq!(caps.at(2), "1941"); /// assert_eq!(caps.at(0), "'Citizen Kane' (1941)"); /// # } /// ``` /// /// Note that the full match is at capture group `0`. Each subsequent /// capture group is indexed by the order of its opening `(`. /// /// We can make this example a bit clea...
/// assert_eq!(caps.at(1), "Citizen Kane");
random_line_split
mod.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
#[test] fn test_message_roundtrip() { let keys = KeyPair::random(); let ts = Utc::now(); let msg = Verified::from_value( Precommit::new( ValidatorId(123), Height(15), Round(25), crypto::hash(&[1, 2, 3]), ...
{ let keys = KeyPair::random(); let msg = SignedMessage::new(vec![], keys.public_key(), keys.secret_key()); assert_eq!(SIGNED_MESSAGE_MIN_SIZE, msg.into_bytes().len()); }
identifier_body
mod.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
() { let keys = KeyPair::random(); let ts = Utc::now(); let msg = Verified::from_value( Precommit::new( ValidatorId(123), Height(15), Round(25), crypto::hash(&[1, 2, 3]), crypto::hash(&[3, 2, 1]), ...
test_message_roundtrip
identifier_name
mod.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
//! //! 1. `Vec<u8>`: raw bytes as received from the network //! 2. `SignedMessage`: integrity and the signature of the message has been verified //! 3. `impl IntoMessage`: the message has been completely parsed //! //! Graphical representation of the message processing flow: //! //! ```text //! +---------+ ...
//! Tools for messages authenticated with the Ed25519 public-key crypto system. //! These messages are used by the P2P networking and for transaction authentication by external //! clients. //! //! Every message passes through three phases:
random_line_split
blockdev.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/. // Code to handle a single block device. use std::fs::OpenOptions; use std::path::PathBuf; use chrono::{DateTime, T...
(&self) -> Sectors { let size = self.used.size(); assert_eq!(self.bda.dev_size(), size); size } fn state(&self) -> BlockDevState { // TODO: Implement support for other BlockDevStates if self.used.used() > self.bda.size() { BlockDevState::InUse } else ...
size
identifier_name
blockdev.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/. // Code to handle a single block device. use std::fs::OpenOptions; use std::path::PathBuf; use chrono::{DateTime, T...
/// Set the user info on this blockdev. /// The user_info may be None, which unsets user info. /// Returns true if the user info was changed, otherwise false. pub fn set_user_info(&mut self, user_info: Option<&str>) -> bool { set_blockdev_user_info!(self; user_info) } } impl BlockDev for ...
{ self.bda.max_data_size() }
identifier_body
blockdev.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/. // Code to handle a single block device. use std::fs::OpenOptions; use std::path::PathBuf; use chrono::{DateTime, T...
} }
random_line_split
blockdev.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/. // Code to handle a single block device. use std::fs::OpenOptions; use std::path::PathBuf; use chrono::{DateTime, T...
} fn set_dbus_path(&mut self, path: MaybeDbusPath) { self.dbus_path = path } fn get_dbus_path(&self) -> &MaybeDbusPath { &self.dbus_path } } impl Recordable<BaseBlockDevSave> for StratBlockDev { fn record(&self) -> BaseBlockDevSave { BaseBlockDevSave { uui...
{ BlockDevState::NotInUse }
conditional_block
storage_thread.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 ipc_channel::ipc::IpcSender; use servo_url::ServoUrl; #[derive(Copy, Clone, Deserialize, Serialize, HeapSizeO...
Exit(IpcSender<()>) }
random_line_split
storage_thread.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 ipc_channel::ipc::IpcSender; use servo_url::ServoUrl; #[derive(Copy, Clone, Deserialize, Serialize, HeapSizeO...
{ /// gets the number of key/value pairs present in the associated storage data Length(IpcSender<usize>, ServoUrl, StorageType), /// gets the name of the key at the specified index in the associated storage data Key(IpcSender<Option<String>>, ServoUrl, StorageType, u32), /// Gets the available ke...
StorageThreadMsg
identifier_name
evec-internal.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let x : [int; 5] = [1,2,3,4,5]; let _y : [int; 5] = [1,2,3,4,5]; let mut z = [1,2,3,4,5]; z = x; assert_eq!(z[0], 1); assert_eq!(z[4], 5); let a : [int; 5] = [1,1,1,1,1]; let b : [int; 5] = [2,2,2,2,2]; let c : [int; 5] = [2,2,2,2,3]; log(debug, a); assert!(a < b); ...
main
identifier_name
evec-internal.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
z = x; assert_eq!(z[0], 1); assert_eq!(z[4], 5); let a : [int; 5] = [1,1,1,1,1]; let b : [int; 5] = [2,2,2,2,2]; let c : [int; 5] = [2,2,2,2,3]; log(debug, a); assert!(a < b); assert!(a <= b); assert!(a!= b); assert!(b >= a); assert!(b > a); log(debug, b); as...
random_line_split
evec-internal.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
log(debug, b); assert!(b < c); assert!(b <= c); assert!(b!= c); assert!(c >= b); assert!(c > b); assert!(a < c); assert!(a <= c); assert!(a!= c); assert!(c >= a); assert!(c > a); log(debug, c); }
{ let x : [int; 5] = [1,2,3,4,5]; let _y : [int; 5] = [1,2,3,4,5]; let mut z = [1,2,3,4,5]; z = x; assert_eq!(z[0], 1); assert_eq!(z[4], 5); let a : [int; 5] = [1,1,1,1,1]; let b : [int; 5] = [2,2,2,2,2]; let c : [int; 5] = [2,2,2,2,3]; log(debug, a); assert!(a < b); a...
identifier_body
helper.rs
// Just functions that may be useful to many modules. use std::fs::Metadata; use std::fs::FileType as StdFileType; use std::os::unix::fs::{MetadataExt, FileTypeExt, PermissionsExt}; use time::Timespec; use fuse::{FileAttr, FileType}; pub fn
(file_type : StdFileType) -> FileType { if file_type.is_dir() == true { FileType::Directory } else if file_type.is_file() == true { FileType::RegularFile } else if file_type.is_symlink() == true { FileType::Symlink } else if file_type.is_block_device() == ...
fuse_file_type
identifier_name
helper.rs
// Just functions that may be useful to many modules. use std::fs::Metadata; use std::fs::FileType as StdFileType; use std::os::unix::fs::{MetadataExt, FileTypeExt, PermissionsExt}; use time::Timespec; use fuse::{FileAttr, FileType}; pub fn fuse_file_type(file_type : StdFileType) -> FileType { if file_type.is_dir...
use std::path::Path; use fuse::Request; use libc::EACCES; use mirrorfs::MirrorFS; use std::ops::Shl; // Allows or denies access according to DAC (user/group permissions). impl MirrorFS { pub fn u_access(&self, _req: &Request, path: &Path, _mask: u32) -> Result<(), i32> { let (uid, gid) = self.usermap(_req); #...
{ FileAttr{ ino : md.ino(), size : md.size(), blocks : md.blocks(), atime : Timespec{ sec : md.atime(), nsec : md.atime_nsec() as i32, }, mtime : Timespec{ sec : md.mtime(), nsec : md.mtime_nsec() as i32, }, ctime : Timespec{ sec : md.ctime(), nsec : md.ctime_nsec() a...
identifier_body
helper.rs
// Just functions that may be useful to many modules. use std::fs::Metadata; use std::fs::FileType as StdFileType; use std::os::unix::fs::{MetadataExt, FileTypeExt, PermissionsExt}; use time::Timespec; use fuse::{FileAttr, FileType}; pub fn fuse_file_type(file_type : StdFileType) -> FileType { if file_type.is_dir...
}, Err(why) => { warn!("Could not get metadata to file {} : {:?}", path.display(), why); return Err(why.raw_os_error().unwrap()); } } } }
{ if md.permissions().mode() | _mask == md.permissions().mode() { trace!("Access request {:b} as \"other\" on path {} is ok", _mask, path.display()); return Ok(()); } else { trace!("Access request as \"other\" isn't ok! Request was {:b}, Permissions were {:b}", _mask, md.permissions().mode(...
conditional_block
helper.rs
// Just functions that may be useful to many modules. use std::fs::Metadata; use std::fs::FileType as StdFileType; use std::os::unix::fs::{MetadataExt, FileTypeExt, PermissionsExt}; use time::Timespec; use fuse::{FileAttr, FileType}; pub fn fuse_file_type(file_type : StdFileType) -> FileType { if file_type.is_dir...
} } } }
}, Err(why) => { warn!("Could not get metadata to file {} : {:?}", path.display(), why); return Err(why.raw_os_error().unwrap());
random_line_split
solution.rs
use std::io; macro_rules! read_n { ( $name : ident, $typ : ty ) => { let mut line : String = String::new(); io::stdin().read_line(&mut line); let $name : $typ = line.trim().parse::<$typ>().expect("invalid data type"); }; } fn main() { read_n!(x, u32); read_n!(n, u32); let...
if powers.len() == 0 || sum > x { return; } for i in start..powers.len() { permut(x, sum + powers[i], &mut powers, i + 1, &mut no_of_ways); } }
{ *no_of_ways += 1; return; }
conditional_block
solution.rs
use std::io; macro_rules! read_n { ( $name : ident, $typ : ty ) => { let mut line : String = String::new(); io::stdin().read_line(&mut line); let $name : $typ = line.trim().parse::<$typ>().expect("invalid data type"); }; } fn main() { read_n!(x, u32); read_n!(n, u32); let...
{ if sum == x { *no_of_ways += 1; return; } if powers.len() == 0 || sum > x { return; } for i in start..powers.len() { permut(x, sum + powers[i], &mut powers, i + 1, &mut no_of_ways); } }
identifier_body
solution.rs
use std::io; macro_rules! read_n { ( $name : ident, $typ : ty ) => { let mut line : String = String::new(); io::stdin().read_line(&mut line); let $name : $typ = line.trim().parse::<$typ>().expect("invalid data type"); }; } fn
() { read_n!(x, u32); read_n!(n, u32); let mut powers : Vec<u32> = (1..32).map(|x: u32| x.pow(n)).collect(); let mut no_of_ways: u32 = 0; permut(x, 0, &mut powers, 0, &mut no_of_ways); println!("{}", no_of_ways); } fn permut(x: u32, sum: u32, mut powers: &mut Vec<u32>, start: usize, mut no_...
main
identifier_name
solution.rs
use std::io; macro_rules! read_n { ( $name : ident, $typ : ty ) => { let mut line : String = String::new(); io::stdin().read_line(&mut line); let $name : $typ = line.trim().parse::<$typ>().expect("invalid data type"); }; } fn main() { read_n!(x, u32); read_n!(n, u32); let...
fn permut(x: u32, sum: u32, mut powers: &mut Vec<u32>, start: usize, mut no_of_ways: &mut u32) { if sum == x { *no_of_ways += 1; return; } if powers.len() == 0 || sum > x { return; } for i in start..powers.len() { permut(x, sum + powers[i], &mut powers, i + 1, &mut...
}
random_line_split
use-from-trait-xc.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:use_fr...
//
random_line_split
use-from-trait-xc.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 ...
() {}
main
identifier_name
use-from-trait-xc.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 ...
{}
identifier_body
f32.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
else { unsafe { intrinsics::copysignf32(1.0, self) } } } /// Returns `true` if `self` is positive, including `+0.0` and /// `Float::infinity()`. #[inline] fn is_positive(self) -> bool { self > 0.0 || (1.0 / self) == Float::infinity() } /// Returns `true` if `se...
{ Float::nan() }
conditional_block
f32.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
pub const DIGITS: u32 = 6; #[stable(feature = "rust1", since = "1.0.0")] pub const EPSILON: f32 = 1.19209290e-07_f32; /// Smallest finite f32 value #[stable(feature = "rust1", since = "1.0.0")] pub const MIN: f32 = -3.40282347e+38_f32; /// Smallest positive, normalized f32 value #[stable(feature = "rust1", since = "1...
random_line_split
f32.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(self) -> f32 { unsafe { intrinsics::ceilf32(self) } } /// Rounds to nearest integer. Rounds half-way cases away from zero. #[inline] fn round(self) -> f32 { unsafe { intrinsics::roundf32(self) } } /// Returns the integer part of the number (rounds towards zero). #[inline] ...
ceil
identifier_name
f32.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
/// Returns `true` if `self` is negative, including `-0.0` and /// `Float::neg_infinity()`. #[inline] fn is_negative(self) -> bool { self < 0.0 || (1.0 / self) == Float::neg_infinity() } /// Fused multiply-add. Computes `(self * a) + b` with only one rounding /// error. This produ...
{ self > 0.0 || (1.0 / self) == Float::infinity() }
identifier_body
brainfuck.rs
extern crate zaldinar_core; use std::fmt; use zaldinar_core::client::PluginRegister; use zaldinar_core::events::CommandEvent; const MAX_ITERATIONS: u32 = 134217728u32; const MAX_OUTPUT: usize = 256usize; #[derive(Debug)] pub enum Error { /// A right bracket was found with no unmatched left brackets preceding it...
next_instruction = target_position; continue; // this avoids the automatic incrementing of next_instruction below. } }, } next_instruction += 1; } if!done { event.client.send_message(event.channel(), "Reached maximum it...
random_line_split
brainfuck.rs
extern crate zaldinar_core; use std::fmt; use zaldinar_core::client::PluginRegister; use zaldinar_core::events::CommandEvent; const MAX_ITERATIONS: u32 = 134217728u32; const MAX_OUTPUT: usize = 256usize; #[derive(Debug)] pub enum Error { /// A right bracket was found with no unmatched left brackets preceding it...
(event: &CommandEvent) { let instructions = match parse_instructions(event) { Ok(instructions) => instructions, Err(e) => { event.client.send_message(event.channel(), format!("Error: {}", e)); return; } }; // Program memory, max size is 2^15 let mut memor...
brainfuck
identifier_name
brainfuck.rs
extern crate zaldinar_core; use std::fmt; use zaldinar_core::client::PluginRegister; use zaldinar_core::events::CommandEvent; const MAX_ITERATIONS: u32 = 134217728u32; const MAX_OUTPUT: usize = 256usize; #[derive(Debug)] pub enum Error { /// A right bracket was found with no unmatched left brackets preceding it...
// u32::MAX as a limit to the number of iterations to run for a single program. for _ in 0..MAX_ITERATIONS { if next_instruction >= instructions.len() { done = true; break; } match instructions[next_instruction] { Instruction::MoveRight => { ...
{ let instructions = match parse_instructions(event) { Ok(instructions) => instructions, Err(e) => { event.client.send_message(event.channel(), format!("Error: {}", e)); return; } }; // Program memory, max size is 2^15 let mut memory = [0u8; 32768]; /...
identifier_body
brainfuck.rs
extern crate zaldinar_core; use std::fmt; use zaldinar_core::client::PluginRegister; use zaldinar_core::events::CommandEvent; const MAX_ITERATIONS: u32 = 134217728u32; const MAX_OUTPUT: usize = 256usize; #[derive(Debug)] pub enum Error { /// A right bracket was found with no unmatched left brackets preceding it...
} pub fn register(register: &mut PluginRegister) { register.register_command("brainfuck", brainfuck); } fn escape_output(input: &str) -> String { let mut result = String::with_capacity(input.len()); for c in input.chars() { match c { '\t' => result.push_str("\\t"), '\r' =>...
{ event.client.send_message(event.channel(), format!("Output: {}", escape_output(&output))); }
conditional_block
task_queue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Machinery for [task-queue](https://html.spec.whatwg.org/multipage/#task-queue). use crate::dom::bindings::ce...
(&self) -> &crossbeam_channel::Receiver<T> { // This is a new iteration of the event-loop, so we reset the "business" counter. self.taken_task_counter.set(0); // We want to be notified when the script-port is ready to receive. // Hence that's the one we need to include in the select. ...
select
identifier_name
task_queue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Machinery for [task-queue](https://html.spec.whatwg.org/multipage/#task-queue). use crate::dom::bindings::ce...
_ => { // A task that will not be throttled, start counting "business" self.taken_task_counter .set(self.taken_task_counter.get() + 1); return false; }, } ...
}; match task_source { TaskSourceName::PerformanceTimeline => return true,
random_line_split
task_queue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Machinery for [task-queue](https://html.spec.whatwg.org/multipage/#task-queue). use crate::dom::bindings::ce...
/// Process incoming tasks, immediately sending priority ones downstream, /// and categorizing potential throttles. fn process_incoming_tasks(&self, first_msg: T) { let mut incoming = Vec::with_capacity(self.port.len() + 1); if!first_msg.is_wake_up() { incoming.push(first_msg);...
{ TaskQueue { port, wake_up_sender, msg_queue: DomRefCell::new(VecDeque::new()), taken_task_counter: Default::default(), throttled: Default::default(), } }
identifier_body
issue-35668.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 = (0..30).collect::<Vec<_>>(); for k in func(&a) { println!("{}", k); } }
main
identifier_name
issue-35668.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 = (0..30).collect::<Vec<_>>(); for k in func(&a) { println!("{}", k); } }
identifier_body