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
util.rs
// Copyright 2014 Travis Watkins // // 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 w...
<F: Float>(f00: F, f10: F, f01: F, f11: F, u: F, v: F) -> F { lerp(lerp(f00, f10, u), lerp(f01, f11, u), v) } #[inline] pub fn trilerp<F: Float>(f000: F, f100: F, f010: F, f110: F, f001: F, f101: F, f011: F, f111: F, u: F, v: F, w: F) -> F { lerp(bilerp(f000, f100, f010, f110, u, v), bilerp(f...
bilerp
identifier_name
util.rs
// Copyright 2014 Travis Watkins // // 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 w...
{ let six = cast(6.0_f32).unwrap(); let fifteen = cast(15.0_f32).unwrap(); let ten = cast(10.0_f32).unwrap(); t * t * t * (t * (t * six - fifteen) + ten) }
identifier_body
util.rs
// Copyright 2014 Travis Watkins // // 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 w...
} #[inline] pub fn scurve3<F: Float>(t: F) -> F { let three : F = cast(3.0_f32).unwrap(); let two = cast(2.0_f32).unwrap(); t * t * (three - (t * two)) } #[inline] pub fn scurve5<F: Float>(t: F) -> F { let six = cast(6.0_f32).unwrap(); let fifteen = cast(15.0_f32).unwrap(); let ten = cast(10....
random_line_split
homing.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
//! In order to solve this problem, this module implements the notion of a //! "homing operation" which will transplant a task from its currently running //! scheduler back onto the original I/O loop. This is accomplished entirely at //! the librustuv layer with very little cooperation from the scheduler (which //! we ...
//! and then attempt to use it on another. //!
random_line_split
homing.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ queue: Queue, id: uint, } impl HomeHandle { pub fn new(id: uint, pool: &mut QueuePool) -> HomeHandle { HomeHandle { queue: pool.queue(), id: id } } fn send(&mut self, task: BlockedTask) { self.queue.push(task); } } impl Clone for HomeHandle { fn clone(&self) -> HomeHand...
HomeHandle
identifier_name
interning.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use std::collections::HashMap; use std::hash; use core::{Key, Value, FNV}; use externs; /// /// A struct that encapsulates interning of python `Value`s as comparable `Key`s. /// /// To...
key } pub fn get(&self, k: &Key) -> &Value { self .reverse .get(&k) .unwrap_or_else(|| panic!("Previously memoized object disappeared for {:?}", k)) } } struct InternKey(i64, Value); impl Eq for InternKey {} impl PartialEq for InternKey { fn eq(&self, other: &InternKey) -> bool { ...
{ self.reverse.insert(key, v); self.id_generator += 1; }
conditional_block
interning.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use std::collections::HashMap; use std::hash; use core::{Key, Value, FNV}; use externs; /// /// A struct that encapsulates interning of python `Value`s as comparable `Key`s. /// /// To...
pub fn insert(&mut self, v: Value) -> Key { let ident = externs::identify(&v); let type_id = ident.type_id; let mut inserted = false; let id_generator = self.id_generator; let key = self .forward .entry(InternKey(ident.hash, v.clone())) .or_insert_with(|| { inserted = true...
{ Interns::default() }
identifier_body
interning.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use std::collections::HashMap; use std::hash; use core::{Key, Value, FNV}; use externs; /// /// A struct that encapsulates interning of python `Value`s as comparable `Key`s. /// /// To...
<H: hash::Hasher>(&self, state: &mut H) { self.0.hash(state); } }
hash
identifier_name
interning.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use std::collections::HashMap; use std::hash; use core::{Key, Value, FNV}; use externs; /// /// A struct that encapsulates interning of python `Value`s as comparable `Key`s. /// /// To...
impl Eq for InternKey {} impl PartialEq for InternKey { fn eq(&self, other: &InternKey) -> bool { externs::equals(&self.1, &other.1) } } impl hash::Hash for InternKey { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.0.hash(state); } }
} struct InternKey(i64, Value);
random_line_split
shootout-mandelbrot.rs
// xfail-test reading from os::args()[1] - bogus! use std::cast::transmute; use std::from_str::FromStr; use std::libc::{STDOUT_FILENO, c_int, fdopen, fputc}; use std::os; static ITER: uint = 50; static LIMIT: f64 = 2.0; #[fixed_stack_segment] fn main() { unsafe { let w: i32 = FromStr::from_str(os::args()...
} } } }
{ byte_acc <<= 8 - w%8; fputc(byte_acc as c_int, stdout); byte_acc = 0; bit_num = 0; }
conditional_block
shootout-mandelbrot.rs
// xfail-test reading from os::args()[1] - bogus! use std::cast::transmute; use std::from_str::FromStr; use std::libc::{STDOUT_FILENO, c_int, fdopen, fputc}; use std::os; static ITER: uint = 50; static LIMIT: f64 = 2.0; #[fixed_stack_segment] fn
() { unsafe { let w: i32 = FromStr::from_str(os::args()[1]).unwrap(); let h = w; let mut byte_acc: i8 = 0; let mut bit_num: i32 = 0; printfln!("P4\n%d %d", w as int, h as int); let mode = "w"; let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));...
main
identifier_name
shootout-mandelbrot.rs
// xfail-test reading from os::args()[1] - bogus! use std::cast::transmute; use std::from_str::FromStr; use std::libc::{STDOUT_FILENO, c_int, fdopen, fputc}; use std::os; static ITER: uint = 50; static LIMIT: f64 = 2.0; #[fixed_stack_segment] fn main()
let Ci = 2.0 * (y as f64) / (h as f64) - 1.0; for _ in range(0i32, ITER as i32) { if Tr + Ti > LIMIT * LIMIT { break; } Zi = 2.0*Zr*Zi + Ci; Zr = Tr - Ti + Cr; Tr...
{ unsafe { let w: i32 = FromStr::from_str(os::args()[1]).unwrap(); let h = w; let mut byte_acc: i8 = 0; let mut bit_num: i32 = 0; printfln!("P4\n%d %d", w as int, h as int); let mode = "w"; let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0])); ...
identifier_body
shootout-mandelbrot.rs
// xfail-test reading from os::args()[1] - bogus! use std::cast::transmute; use std::from_str::FromStr; use std::libc::{STDOUT_FILENO, c_int, fdopen, fputc}; use std::os; static ITER: uint = 50; static LIMIT: f64 = 2.0; #[fixed_stack_segment] fn main() { unsafe { let w: i32 = FromStr::from_str(os::args()...
let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0])); for y in range(0i32, h) { let y = y as f64; for x in range(0i32, w) { let mut Zr = 0f64; let mut Zi = 0f64; let mut Tr = 0f64; let mut Ti = 0f64; ...
let mode = "w";
random_line_split
tcp-accept-stress.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. #![feature(phase)] ...
//
random_line_split
tcp-accept-stress.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 ...
() { test(); let (tx, rx) = channel(); TaskBuilder::new().native().spawn(proc() { tx.send(test()); }); rx.recv(); } fn test() { let mut l = TcpListener::bind("127.0.0.1", 0).unwrap(); let addr = l.socket_name().unwrap(); let mut a = l.listen().unwrap(); let cnt = Arc::new(a...
main
identifier_name
tcp-accept-stress.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 ...
Err(ref e) if e.kind == EndOfFile => break, Err(e) => fail!("{}", e), } } tx.send(()); }); } for _ in range(0, N) { let tx = tx.clone(); spawn(proc() { for _ in range(0, M) { let ...
{ let mut l = TcpListener::bind("127.0.0.1", 0).unwrap(); let addr = l.socket_name().unwrap(); let mut a = l.listen().unwrap(); let cnt = Arc::new(atomic::AtomicUint::new(0)); let (tx, rx) = channel(); for _ in range(0, N) { let a = a.clone(); let cnt = cnt.clone(); let ...
identifier_body
unwind-match.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
, _ => fail!("non-exhaustive match failure") }; assert_eq!(res, ~"happy"); } fn main() { test_box(); test_str(); }
{ ~"happy" }
conditional_block
unwind-match.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { test_box(); test_str(); }
main
identifier_name
unwind-match.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test_str() { let res = match false { true => { ~"happy" }, _ => fail!("non-exhaustive match failure") }; assert_eq!(res, ~"happy"); } fn main() { test_box(); test_str(); }
{ @0; }
identifier_body
main.rs
extern crate hlua; use hlua::Lua; extern crate rustyline; use rustyline::error::ReadlineError; use std::rc::Rc; use std::io; use std::io::BufRead; mod snail; use snail::*; use std::io::prelude::*; use std::error::Error; use std::fs; use std::fs::File; use std::fs::metadata; use std::env; use std::path::Path; use...
} fn execute_path(path_str: &str) { let meta = metadata(path_str).unwrap(); if meta.is_file() { match file(path_str) { Some(n) => execute(n), None => (), } } else { println!("{}: can't execute folder", path_str) } } fn file(path: &str) -> Option<Rc<S...
}
random_line_split
main.rs
extern crate hlua; use hlua::Lua; extern crate rustyline; use rustyline::error::ReadlineError; use std::rc::Rc; use std::io; use std::io::BufRead; mod snail; use snail::*; use std::io::prelude::*; use std::error::Error; use std::fs; use std::fs::File; use std::fs::metadata; use std::env; use std::path::Path; use...
Err(why) => println!("{}", why.description()) } } fn execute(data: Rc<String>) { let mut lua = Lua::new(); fn print(a: String) { println!("{}", a) } fn trim(a: String) -> String { a.trim().to_owned() } fn read() -> String { let mut line = Stri...
{ let path = Path::new(path); println!("building: {}", path.display()); let split_name = path.file_name().unwrap().to_str().unwrap().split("."); let split: Vec<&str> = split_name.collect(); let parent_path = match path.parent() { Some(p) => match p.file_name() { Some(path) ...
identifier_body
main.rs
extern crate hlua; use hlua::Lua; extern crate rustyline; use rustyline::error::ReadlineError; use std::rc::Rc; use std::io; use std::io::BufRead; mod snail; use snail::*; use std::io::prelude::*; use std::error::Error; use std::fs; use std::fs::File; use std::fs::metadata; use std::env; use std::path::Path; use...
(path: &str) { let meta = metadata(path).unwrap(); if meta.is_file() { match file(path) { Some(n) => write(path, n), None => (), } } else { let paths = fs::read_dir(path).unwrap(); for path in paths { let path = format!("{}", path....
write_path
identifier_name
logistic.rs
use la::Matrix; use opt::GradientDescent; pub struct LogisticRegression { theta : Matrix<f64>, threshold : f64 } impl LogisticRegression { pub fn train<F : FnMut(f64) -> ()>(x : &Matrix<f64>, y : &Matrix<bool>, learning_rate : f64, max_iterations : usize, mut iter_notify_f_opt : Option<F>) -> LogisticRegression...
} } } LogisticRegression { theta : theta, threshold : 0.5 } } pub fn get_theta<'a>(&'a self) -> &'a Matrix<f64> { &self.theta } pub fn get_threshold(&self) -> f64 { self.threshold } #[inline] pub fn set_threshold(&mut self, threshold : f64) { self.th...
{ }
conditional_block
logistic.rs
use la::Matrix; use opt::GradientDescent; pub struct LogisticRegression { theta : Matrix<f64>,
} impl LogisticRegression { pub fn train<F : FnMut(f64) -> ()>(x : &Matrix<f64>, y : &Matrix<bool>, learning_rate : f64, max_iterations : usize, mut iter_notify_f_opt : Option<F>) -> LogisticRegression { let extx = Matrix::one_vector(x.rows()).cr(x); let numy = y.map(&|b : &bool| -> f64 { if *b { 1.0 } else ...
threshold : f64
random_line_split
logistic.rs
use la::Matrix; use opt::GradientDescent; pub struct LogisticRegression { theta : Matrix<f64>, threshold : f64 } impl LogisticRegression { pub fn train<F : FnMut(f64) -> ()>(x : &Matrix<f64>, y : &Matrix<bool>, learning_rate : f64, max_iterations : usize, mut iter_notify_f_opt : Option<F>) -> LogisticRegression...
#[inline] pub fn set_threshold(&mut self, threshold : f64) { self.threshold = threshold; } // h(x) = 1 / (1 + e^(- theta^T * [1; x])) pub fn p(&self, x : &Matrix<f64>) -> f64 { assert!(x.cols() == 1); assert!((x.rows() + 1) == self.theta.get_data().len()); // sum = theta^T * x let mut ...
{ self.threshold }
identifier_body
logistic.rs
use la::Matrix; use opt::GradientDescent; pub struct LogisticRegression { theta : Matrix<f64>, threshold : f64 } impl LogisticRegression { pub fn train<F : FnMut(f64) -> ()>(x : &Matrix<f64>, y : &Matrix<bool>, learning_rate : f64, max_iterations : usize, mut iter_notify_f_opt : Option<F>) -> LogisticRegression...
(&self, x : &Matrix<f64>) -> bool { self.predict(x) } }
hypothesis
identifier_name
error.rs
#![ warn( missing_docs ) ] #![ warn( missing_debug_implementations ) ] /// Alias for std::error::Error. pub use std::error::Error as ErrorAdapter; /// /// Macro to generate error. /// /// # Sample /// ``` /// # use werror::*; /// err!( "No attr" ); /// ``` /// #[ macro_export ] macro_rules! err { ( $msg : expr )...
{ /// Constructor expecting message with description. pub fn new< Msg : Into< String > >( msg : Msg ) -> Error { Error { msg : msg.into() } } /// Message with description getter. pub fn msg( &self ) -> &String { &self.msg } } impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt...
{ msg : String, } impl Error
random_line_split
error.rs
#![ warn( missing_docs ) ] #![ warn( missing_debug_implementations ) ] /// Alias for std::error::Error. pub use std::error::Error as ErrorAdapter; /// /// Macro to generate error. /// /// # Sample /// ``` /// # use werror::*; /// err!( "No attr" ); /// ``` /// #[ macro_export ] macro_rules! err { ( $msg : expr )...
< Msg : Into< String > >( msg : Msg ) -> Error { Error { msg : msg.into() } } /// Message with description getter. pub fn msg( &self ) -> &String { &self.msg } } impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!( f, "{}", self.msg ...
new
identifier_name
error.rs
#![ warn( missing_docs ) ] #![ warn( missing_debug_implementations ) ] /// Alias for std::error::Error. pub use std::error::Error as ErrorAdapter; /// /// Macro to generate error. /// /// # Sample /// ``` /// # use werror::*; /// err!( "No attr" ); /// ``` /// #[ macro_export ] macro_rules! err { ( $msg : expr )...
} impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!( f, "{}", self.msg ) } } impl std::error::Error for Error { fn description( &self ) -> &str { &self.msg } }
{ &self.msg }
identifier_body
fake_adapter.rs
//! An adapter to a non-existing device, whose state is entirely controlled programmatically. //! Used for testing. use adapter::*; use api::{ Error, User }; use selector::*; use services::*; use values::*; use transformable_channels::mpsc::*; use std::cell::RefCell; use std::collections::HashMap ; use std::collecti...
{ ValueSent(Id<Setter>, Value) } fn dup<T>(t: T) -> (T, T) where T: Clone { (t.clone(), t) } struct TestWatchGuard(Arc<AtomicBool>); impl AdapterWatchGuard for TestWatchGuard {} impl Drop for TestWatchGuard { fn drop(&mut self) { self.0.store(true, Ordering::Relaxed) } } type SyncMap<K, V> =...
Effect
identifier_name
fake_adapter.rs
//! An adapter to a non-existing device, whose state is entirely controlled programmatically. //! Used for testing. use adapter::*; use api::{ Error, User }; use selector::*; use services::*; use values::*; use transformable_channels::mpsc::*; use std::cell::RefCell; use std::collections::HashMap ; use std::collecti...
} tx.send(()).unwrap(); } }); result } pub fn take_rx(&self) -> Receiver<Effect> { self.rx_effect.lock().unwrap().take().unwrap() } pub fn get_tweak(&self) -> Arc<Fn(Tweak) + Sync + Send> { self.tweak.clone() } } static ...
{ senders_thread.lock().unwrap().insert(id, err); }
conditional_block
fake_adapter.rs
//! An adapter to a non-existing device, whose state is entirely controlled programmatically. //! Used for testing. use adapter::*; use api::{ Error, User }; use selector::*; use services::*; use values::*; use transformable_channels::mpsc::*; use std::cell::RefCell; use std::collections::HashMap ; use std::collecti...
} type SyncMap<K, V> = Arc<Mutex<HashMap<K, V>>>; struct WatcherState { filter: Option<Range>, on_event: Box<ExtSender<WatchEvent>>, is_met: RefCell<bool>, /* is_met*/ is_dropped: Arc<AtomicBool>, /* is_dropped */ } pub struct FakeAdapter { id: Id<AdapterId>, name: String, tweak: Arc<Fn(T...
{ self.0.store(true, Ordering::Relaxed) }
identifier_body
fake_adapter.rs
//! An adapter to a non-existing device, whose state is entirely controlled programmatically. //! Used for testing. use adapter::*; use api::{ Error, User }; use selector::*; use services::*; use values::*; use transformable_channels::mpsc::*; use std::cell::RefCell; use std::collections::HashMap ; use std::collecti...
value: value.clone() }).unwrap(); } _ => {} } *watch...
id: id.clone(),
random_line_split
lib.rs
// ================================================================= // // * WARNING * //
// // Changes made to this file will be overwritten. If changes are // required to the generated code, the service_crategen project // must be updated to generate the changes. // // ================================================================= #![doc( html_logo_url = "https://raw.githubusercontent.com/rusoto...
// This file is generated!
random_line_split
main.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
Transaction options: --code CODE Contract code as hex (without 0x) --input DATA Input data as hex (without 0x) --gas GAS Supplied gas as hex (without 0x) General options: -h, --help Display this message and exit. "#; fn main() { let args: Args = Docopt::new(USAGE).and_t...
random_line_split
main.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { writeln!(f, "Gas used: {:?}", self.gas_used)?; writeln!(f, "Output: {:?}", self.output)?; writeln!(f, "Time: {}.{:.9}s", self.time.as_secs(), self.time.subsec_nanos())?; Ok(()) } } /// Execution failed pub struct Failure { /// Internal error error:...
fmt
identifier_name
userscripts.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::inheritance::Castable; use dom::globalscope::GlobalScope; use dom::htmlheadelement::HTMLHeadEle...
let script_text = String::from_utf8_lossy(&contents); win.upcast::<GlobalScope>() .evaluate_js_on_global_with_result(&script_text, rval.handle_mut()); } } }
{ let node = head.upcast::<Node>(); let doc = node.owner_doc(); let win = doc.window(); let cx = win.get_cx(); rooted!(in(cx) let mut rval = UndefinedValue()); let path = PathBuf::from(path_str); let mut files = read_dir(&path) .expect("Bad path passe...
conditional_block
userscripts.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::inheritance::Castable; use dom::globalscope::GlobalScope; use dom::htmlheadelement::HTMLHeadEle...
(head: &HTMLHeadElement) { if let Some(ref path_str) = opts::get().userscripts { let node = head.upcast::<Node>(); let doc = node.owner_doc(); let win = doc.window(); let cx = win.get_cx(); rooted!(in(cx) let mut rval = UndefinedValue()); let path = PathBuf::from(pat...
load_script
identifier_name
userscripts.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::inheritance::Castable; use dom::globalscope::GlobalScope; use dom::htmlheadelement::HTMLHeadEle...
f.read_to_end(&mut contents).unwrap(); let script_text = String::from_utf8_lossy(&contents); win.upcast::<GlobalScope>() .evaluate_js_on_global_with_result(&script_text, rval.handle_mut()); } } }
{ if let Some(ref path_str) = opts::get().userscripts { let node = head.upcast::<Node>(); let doc = node.owner_doc(); let win = doc.window(); let cx = win.get_cx(); rooted!(in(cx) let mut rval = UndefinedValue()); let path = PathBuf::from(path_str); let mut f...
identifier_body
userscripts.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::inheritance::Castable; use dom::globalscope::GlobalScope; use dom::htmlheadelement::HTMLHeadEle...
files.sort(); for file in files { let mut f = File::open(&file).unwrap(); let mut contents = vec![]; f.read_to_end(&mut contents).unwrap(); let script_text = String::from_utf8_lossy(&contents); win.upcast::<GlobalScope>() .evalu...
.filter_map(|e| e.ok()) .map(|e| e.path()) .collect::<Vec<_>>();
random_line_split
lib.rs
// Copyright (C) 2020 Christian Amsüss // // This file is subject to the terms and conditions of the GNU Lesser // General Public License v2.1. See the file LICENSE in the top level // directory for more details. #![no_std] use riot_wrappers::{riot_main, println}; use riot_wrappers::{gcoap, thread, ztimer, gnrc}; use...
) { extern "C" { fn do_vfs_init(); } unsafe { do_vfs_init() }; let handler = coap_message_demos::full_application_tree(None) .below(&["ps"], riot_coap_handler_demos::ps::ps_tree()) .below(&["vfs"], riot_coap_handler_demos::vfs::vfs("/const")) .with_wkc() ; let ...
ain(
identifier_name
lib.rs
// Copyright (C) 2020 Christian Amsüss // // This file is subject to the terms and conditions of the GNU Lesser // General Public License v2.1. See the file LICENSE in the top level // directory for more details. #![no_std] use riot_wrappers::{riot_main, println}; use riot_wrappers::{gcoap, thread, ztimer, gnrc}; use...
let sectimer = ztimer::ZTimer::sec(); sectimer.sleep_ticks(2); for netif in gnrc::Netif::all() { println!("Active interface from PID {:?} ({:?})", netif.pid(), netif.pid().get_name().unwrap_or("unnamed")); match netif.ipv6_addrs() { Ok(addrs) => { ...
extern "C" { fn do_vfs_init(); } unsafe { do_vfs_init() }; let handler = coap_message_demos::full_application_tree(None) .below(&["ps"], riot_coap_handler_demos::ps::ps_tree()) .below(&["vfs"], riot_coap_handler_demos::vfs::vfs("/const")) .with_wkc() ; let ...
identifier_body
lib.rs
// Copyright (C) 2020 Christian Amsüss // // This file is subject to the terms and conditions of the GNU Lesser // General Public License v2.1. See the file LICENSE in the top level // directory for more details. #![no_std] use riot_wrappers::{riot_main, println}; use riot_wrappers::{gcoap, thread, ztimer, gnrc}; use...
_ => { println!(" Does not support IPv6."); } } } // Sending main thread to sleep; can't return or the Gcoap handler would need to be // deregistered (which it can't). loop { thread::sleep(); } }) }
for a in addrs.addresses() { println!(" Address {:?}", a); } }
conditional_block
lib.rs
// Copyright (C) 2020 Christian Amsüss
// This file is subject to the terms and conditions of the GNU Lesser // General Public License v2.1. See the file LICENSE in the top level // directory for more details. #![no_std] use riot_wrappers::{riot_main, println}; use riot_wrappers::{gcoap, thread, ztimer, gnrc}; use coap_handler_implementations::{ReportingH...
//
random_line_split
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
; }
{ // child // check working directory (don't try to compare with `cwd` here!) assert!(my_cwd.ends_with_path(&Path::new(child_dir))); // check arguments assert_eq!(my_args.get(1).as_slice(), arg); // check environment variable assert!(my_env.c...
conditional_block
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// make a separate directory for the child drop(fs::mkdir(&cwd, io::UserRWX).is_ok()); assert!(fs::copy(&my_path, &child_path).is_ok()); // run child let p = Command::new(&child_path) .arg(arg) .cwd(&cwd) .env_...
let child_filename = child_filestem.with_extension(my_ext); let child_path = cwd.join(child_filename.clone());
random_line_split
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let my_args = os::args(); let my_cwd = os::getcwd(); let my_env = os::env(); let my_path = Path::new(os::self_exe_name().unwrap()); let my_dir = my_path.dir_path(); let my_ext = my_path.extension_str().unwrap_or(""); // some non-ASCII characters let blah = "\u03c0\u042f\u...
main
identifier_name
process-spawn-with-unicode-params.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
if my_args.len() == 1 { // parent let child_filestem = Path::new(child_name); let child_filename = child_filestem.with_extension(my_ext); let child_path = cwd.join(child_filename.clone()); // make a separate directory for the child drop(fs::mkdir(&cwd, io::U...
{ let my_args = os::args(); let my_cwd = os::getcwd(); let my_env = os::env(); let my_path = Path::new(os::self_exe_name().unwrap()); let my_dir = my_path.dir_path(); let my_ext = my_path.extension_str().unwrap_or(""); // some non-ASCII characters let blah = "\u03c0\u042f\u97f...
identifier_body
neuron.rs
/* This file is part of Mulp. Mulp 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. Mulp is distributed in the hope that it will be useful, ...
self.a = a; } /// Load (output - target) precedly computed /// only for the output layer. /// Load error and compute ponderated errors. /// pub fn load_error(&mut self, error: f64) { self.error = error; // and then back propagate accross weights // pond...
random_line_split
neuron.rs
/* This file is part of Mulp. Mulp 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. Mulp is distributed in the hope that it will be useful, ...
// PROPAGATION // // Should be differentiable // class C2 // input vector is the output of the precedent layer pub fn compute_net(&mut self, input: &[f64]) { self.net = dot_product(input, self.w.as_slice()); } fn phi(&self, x: f64) -> f64 { return logistic_...
{ let mut it = self.w.iter_mut(); loop { match it.next() { Some(w) => { *w = task_rng.gen_range(-born, born); } None => { break } } } }
identifier_body
neuron.rs
/* This file is part of Mulp. Mulp 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. Mulp is distributed in the hope that it will be useful, ...
(&mut self, input: &[f64], nu: f64, mu: f64) { for i in range (0u, self.nb_input) { self.w[i] += nu*self.error*input[i] + mu*self.momentum[i]; self.momentum[i] = nu*self.error*input[i] + mu*self.momentum[i]; // or // self.w[i] += nu*self...
actualize_weights
identifier_name
deriving-span-Ord-enum-struct-variant.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 ...
; #[deriving(Eq, Ord)] enum Enum { A { x: Error //~ ERROR //~^ ERROR //~^^ ERROR //~^^^ ERROR //~^^^^ ERROR //~^^^^^ ERROR //~^^^^^^ ERROR //~^^^^^^^ ERROR } } fn main() {}
Error
identifier_name
deriving-span-Ord-enum-struct-variant.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 ...
//~^ ERROR //~^^ ERROR //~^^^ ERROR //~^^^^ ERROR //~^^^^^ ERROR //~^^^^^^ ERROR //~^^^^^^^ ERROR } } fn main() {}
#[deriving(Eq, Ord)] enum Enum { A { x: Error //~ ERROR
random_line_split
deriving-span-Ord-enum-struct-variant.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
main.rs
use std::io; use std::cmp::min; type Matrix = Vec<Vec<u64>>; fn readline () -> String { let mut input_str = String::new(); io::stdin().read_line(&mut input_str).ok().expect("read error"); input_str } fn read_matrix (n: usize) -> Matrix { (0..n).map(|_| must_parse_arr(&readline())).collect() } fn m...
fn calc_circle_size (rows: usize, cols: usize, circle_pos: usize) -> usize { 2 * rows - 4 * circle_pos + 2 * cols - 4 * circle_pos - 4 } fn read_circle(m: &Matrix, rows: usize, cols: usize, circle_pos: usize) -> Vec<u64> { let mut circle: Vec<u64> = Vec::with_capacity(calc_circle_size(rows, cols, circle_pos)...
{ CircleIter { counter: 0, circle_size: calc_circle_size(rows, cols, circle_pos), circle_pos: circle_pos, circle_rows: rows - 2 * circle_pos, circle_cols: cols - 2 * circle_pos, first_row: circle_pos, first_col: circle_pos, last_col: cols - circle_po...
identifier_body
main.rs
use std::io; use std::cmp::min; type Matrix = Vec<Vec<u64>>; fn readline () -> String { let mut input_str = String::new(); io::stdin().read_line(&mut input_str).ok().expect("read error"); input_str } fn read_matrix (n: usize) -> Matrix { (0..n).map(|_| must_parse_arr(&readline())).collect() } fn m...
else { let temp = self.counter + 3 - 2 * self.circle_rows - self.circle_cols; (self.first_row, self.last_col - temp, self.counter) }; self.counter += 1; Some(pos) } } fn iter_circle (rows: usize, cols: usize, circle_pos: usize) -> CircleIter { CircleIter { ...
{ let temp = self.counter + 2 - self.circle_rows - self.circle_cols; (self.last_row - temp, self.last_col, self.counter) }
conditional_block
main.rs
use std::io;
type Matrix = Vec<Vec<u64>>; fn readline () -> String { let mut input_str = String::new(); io::stdin().read_line(&mut input_str).ok().expect("read error"); input_str } fn read_matrix (n: usize) -> Matrix { (0..n).map(|_| must_parse_arr(&readline())).collect() } fn must_parse<T> (num_str: &str) -> ...
use std::cmp::min;
random_line_split
main.rs
use std::io; use std::cmp::min; type Matrix = Vec<Vec<u64>>; fn readline () -> String { let mut input_str = String::new(); io::stdin().read_line(&mut input_str).ok().expect("read error"); input_str } fn
(n: usize) -> Matrix { (0..n).map(|_| must_parse_arr(&readline())).collect() } fn must_parse<T> (num_str: &str) -> T where T: std::str::FromStr { num_str.trim().parse().ok().expect("parse error") } fn must_parse_arr<T> (s: &str) -> Vec<T> where T: std::str::FromStr { s.split_whitespace().map(|item| must_...
read_matrix
identifier_name
tcp.rs
use std::fmt; use std::io; use std::net::{SocketAddr, TcpListener as StdTcpListener}; use std::time::Duration; use tokio::net::TcpListener; use tokio::time::Sleep; use tracing::{debug, error, trace}; use crate::common::{task, Future, Pin, Poll}; #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/5...
} if let Err(e) = socket.set_nodelay(self.tcp_nodelay) { trace!("error trying to set TCP nodelay: {}", e); } return Poll::Ready(Ok(AddrStream::new(socket, addr))); } Err(e) => { ...
{ trace!("error trying to set TCP keepalive: {}", e); }
conditional_block
tcp.rs
use std::fmt; use std::io; use std::net::{SocketAddr, TcpListener as StdTcpListener}; use std::time::Duration; use tokio::net::TcpListener; use tokio::time::Sleep; use tracing::{debug, error, trace}; use crate::common::{task, Future, Pin, Poll}; #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/5...
#[inline] fn is_write_vectored(&self) -> bool { // Note that since `self.inner` is a `TcpStream`, this could // *probably* be hard-coded to return `true`...but it seems more // correct to ask it anyway (maybe we're on some platform without // scatter-gat...
{ self.project().inner.poll_shutdown(cx) }
identifier_body
tcp.rs
use std::fmt; use std::io; use std::net::{SocketAddr, TcpListener as StdTcpListener}; use std::time::Duration; use tokio::net::TcpListener; use tokio::time::Sleep; use tracing::{debug, error, trace}; use crate::common::{task, Future, Pin, Poll}; #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/5...
impl fmt::Debug for AddrIncoming { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AddrIncoming") .field("addr", &self.addr) .field("sleep_on_errors", &self.sleep_on_errors) .field("tcp_keepalive_timeout", &self.tcp_keepalive_timeout) .f...
matches!(e.kind(), io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionAborted | io::ErrorKind::ConnectionReset) }
random_line_split
tcp.rs
use std::fmt; use std::io; use std::net::{SocketAddr, TcpListener as StdTcpListener}; use std::time::Duration; use tokio::net::TcpListener; use tokio::time::Sleep; use tracing::{debug, error, trace}; use crate::common::{task, Future, Pin, Poll}; #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/5...
(tcp: TcpStream, addr: SocketAddr) -> AddrStream { AddrStream { inner: tcp, remote_addr: addr, } } /// Returns the remote (peer) address of this connection. #[inline] pub fn remote_addr(&self) -> SocketAddr { self.remot...
new
identifier_name
issue-17546.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn newer() -> NoResult<foo::MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::NoResult` used as a type unimplemented!() } fn main() { let _ = new(); }
//~^ ERROR: found value `foo::MyEnum::Result` used as a type unimplemented!() }
random_line_split
issue-17546.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() -> NoResult<MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::NoResult` used as a type unimplemented!() } } mod bar { use foo::MyEnum::Result; use foo; fn new() -> Result<foo::MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::Result` used as a type unimpl...
new
identifier_name
issue-17546.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} mod bar { use foo::MyEnum::Result; use foo; fn new() -> Result<foo::MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::Result` used as a type unimplemented!() } } fn new() -> Result<foo::MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::Result` used as a type uni...
{ //~^ ERROR: found value `foo::MyEnum::NoResult` used as a type unimplemented!() }
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 http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
(&self, record: &LogRecord) { self.0.log(record); self.1.log(record); } } pub fn set_logger(constellation_chan: IpcSender<ScriptMsg>) { log::set_logger(|max_log_level| { let env_logger = EnvLogger::new(); let con_logger = FromScriptLogger::new(constellation_chan); let fi...
log
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 http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
} pub fn set_logger(constellation_chan: IpcSender<ScriptMsg>) { log::set_logger(|max_log_level| { let env_logger = EnvLogger::new(); let con_logger = FromScriptLogger::new(constellation_chan); let filter = max(env_logger.filter(), con_logger.filter()); let logger = BothLogger(env_l...
{ self.0.log(record); self.1.log(record); }
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 http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
else { webrender_traits::RendererKind::Native }; webrender::Renderer::new(webrender::RendererOptions { device_pixel_ratio: device_pixel_ratio, resource_path: resource_path, enable_aa: opts.enable_text_antialiasing, ...
{ webrender_traits::RendererKind::OSMesa }
conditional_block
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 http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
use std::path::PathBuf; use std::rc::Rc; use std::sync::mpsc::Sender; use url::Url; use util::opts; use util::prefs::PREFS; use util::resource_files::resources_dir_path; pub use gleam::gl; /// The in-process interface to Servo. /// /// It does everything necessary to render the web, primarily /// orchestrating the in...
use profile_traits::mem; use profile_traits::time; use script_traits::{ConstellationMsg, SWManagerSenders, ScriptMsg}; use std::borrow::Cow; use std::cmp::max;
random_line_split
rand_gen.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
impl RandGen<Int64Type> for Int64Type { fn gen(_: i32) -> i64 { thread_rng().gen::<i64>() } } impl RandGen<Int96Type> for Int96Type { fn gen(_: i32) -> Int96 { let mut rng = thread_rng(); let mut result = Int96::new(); result.set_data(rng.gen::<u32>(), rng.gen::<u32>(), rng...
impl RandGen<Int32Type> for Int32Type { fn gen(_: i32) -> i32 { thread_rng().gen::<i32>() } }
random_line_split
rand_gen.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
} impl RandGen<Int32Type> for Int32Type { fn gen(_: i32) -> i32 { thread_rng().gen::<i32>() } } impl RandGen<Int64Type> for Int64Type { fn gen(_: i32) -> i64 { thread_rng().gen::<i64>() } } impl RandGen<Int96Type> for Int96Type { fn gen(_: i32) -> Int96 { let mut rng = th...
{ thread_rng().gen::<bool>() }
identifier_body
rand_gen.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
else { len as usize }; let value = random_bytes(value_len); ByteArray::from(value) } } pub fn random_bytes(n: usize) -> Vec<u8> { let mut result = vec![]; let mut rng = thread_rng(); for _ in 0..n { result.push(rng.gen_range(0, 255)); } result } pub...
{ rng.gen_range(0, 128) }
conditional_block
rand_gen.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
(_: i32) -> f32 { thread_rng().gen::<f32>() } } impl RandGen<DoubleType> for DoubleType { fn gen(_: i32) -> f64 { thread_rng().gen::<f64>() } } impl RandGen<ByteArrayType> for ByteArrayType { fn gen(_: i32) -> ByteArray { let mut rng = thread_rng(); let mut result = Byt...
gen
identifier_name
test2.rs
use std::error::Error; use std::thread; use std::time::Duration; use blurz::bluetooth_adapter::BluetoothAdapter as Adapter; use blurz::bluetooth_device::BluetoothDevice as Device; use blurz::bluetooth_discovery_session::BluetoothDiscoverySession as DiscoverySession; use blurz::bluetooth_gatt_characteristic::Bluetooth...
extern crate blurz; static BATTERY_SERVICE_UUID: &'static str = "0000180f-0000-1000-8000-00805f9b34fb"; static COLOR_PICKER_SERVICE_UUID: &'static str = "00001812-0000-1000-8000-00805f9b34fb";
random_line_split
test2.rs
extern crate blurz; static BATTERY_SERVICE_UUID: &'static str = "0000180f-0000-1000-8000-00805f9b34fb"; static COLOR_PICKER_SERVICE_UUID: &'static str = "00001812-0000-1000-8000-00805f9b34fb"; use std::error::Error; use std::thread; use std::time::Duration; use blurz::bluetooth_adapter::BluetoothAdapter as Adapter; ...
{ match test2() { Ok(_) => (), Err(e) => println!("{:?}", e), } }
identifier_body
test2.rs
extern crate blurz; static BATTERY_SERVICE_UUID: &'static str = "0000180f-0000-1000-8000-00805f9b34fb"; static COLOR_PICKER_SERVICE_UUID: &'static str = "00001812-0000-1000-8000-00805f9b34fb"; use std::error::Error; use std::thread; use std::time::Duration; use blurz::bluetooth_adapter::BluetoothAdapter as Adapter; ...
() { match test2() { Ok(_) => (), Err(e) => println!("{:?}", e), } }
main
identifier_name
test2.rs
extern crate blurz; static BATTERY_SERVICE_UUID: &'static str = "0000180f-0000-1000-8000-00805f9b34fb"; static COLOR_PICKER_SERVICE_UUID: &'static str = "00001812-0000-1000-8000-00805f9b34fb"; use std::error::Error; use std::thread; use std::time::Duration; use blurz::bluetooth_adapter::BluetoothAdapter as Adapter; ...
let services = try!(device.get_gatt_services()); for service in services { let s = Service::new(bt_session, service.clone()); println!("{:?}", s); let characteristics = try!(s.get_gatt_characteristics()); for characteristic in characteristics { let c = Characteristic...
{ return Err(Box::from("No connectable device found")); }
conditional_block
htmlobjectelement.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::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLObjectElementB...
// https://html.spec.whatwg.org/multipage/#dom-fae-form fn GetForm(&self) -> Option<Root<HTMLFormElement>> { self.form_owner() } } impl Validatable for HTMLObjectElement { fn is_instance_validatable(&self) -> bool { true } fn validate(&self, validate_flags: ValidationFlags) -> b...
random_line_split
htmlobjectelement.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::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLObjectElementB...
} impl VirtualMethods for HTMLObjectElement { fn super_type(&self) -> Option<&VirtualMethods> { Some(self.upcast::<HTMLElement>() as &VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { self.super_type().unwrap().attribute_mutated(attr, mutation); ...
{ if validate_flags.is_empty() {} // Need more flag check for different validation types later true }
identifier_body
htmlobjectelement.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::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLObjectElementB...
(&self) -> Root<ValidityState> { let window = window_from_node(self); ValidityState::new(&window, self.upcast()) } // https://html.spec.whatwg.org/multipage/#dom-object-type make_getter!(Type, "type"); // https://html.spec.whatwg.org/multipage/#dom-object-type make_setter!(SetType,...
Validity
identifier_name
constants.rs
use time::Timespec; pub const DEFAULT_BLOCKS_COUNT: u64 = 1; pub const DEFAULT_CREATE_TIME: Timespec = Timespec { sec: 1381237736, nsec: 0, }; pub const PROJECTS_DIRNAME: &'static str = "projects"; pub const PROJECTS_JSON_FILENAME: &'static str = "projects.json"; pub const PROJECT_LDM_DIR: &'static str = "l...
(val: u8) -> ReservedFile { match val { 0 => ReservedFile::Root, 2 => ReservedFile::FeatureFlagsJson, 3 => ReservedFile::PermissionsJson, 4 => ReservedFile::ProjectJson, 5 => ReservedFile::RolesJson, _ => ReservedFile::KeepMe, } ...
from
identifier_name
constants.rs
use time::Timespec; pub const DEFAULT_BLOCKS_COUNT: u64 = 1; pub const DEFAULT_CREATE_TIME: Timespec = Timespec { sec: 1381237736, nsec: 0, }; pub const PROJECTS_DIRNAME: &'static str = "projects"; pub const PROJECTS_JSON_FILENAME: &'static str = "projects.json"; pub const PROJECT_LDM_DIR: &'static str = "l...
}
{ match val { 0 => ReservedFile::Root, 2 => ReservedFile::FeatureFlagsJson, 3 => ReservedFile::PermissionsJson, 4 => ReservedFile::ProjectJson, 5 => ReservedFile::RolesJson, _ => ReservedFile::KeepMe, } }
identifier_body
constants.rs
use time::Timespec; pub const DEFAULT_BLOCKS_COUNT: u64 = 1; pub const DEFAULT_CREATE_TIME: Timespec = Timespec { sec: 1381237736, nsec: 0, }; pub const PROJECTS_DIRNAME: &'static str = "projects"; pub const PROJECTS_JSON_FILENAME: &'static str = "projects.json"; pub const PROJECT_LDM_DIR: &'static str = "l...
impl Into<u8> for Category { fn into(self) -> u8 { self as u8 } } #[derive(Debug, Clone)] pub enum ReservedFile { Root = 0, FeatureFlagsJson = 2, PermissionsJson, ProjectJson, RolesJson, // Keep me - see https://github.com/osxfuse/osxfuse/issues/286 KeepMe = 255, } impl F...
Schedules, Templates, Uploads, Users, }
random_line_split
issue-19190-2.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
; impl Deref for Bar { type Target = String; fn deref(&self) -> &String { loop {} } } // @has issue_19190_2/struct.Bar.html // @!has - '//*[@id="method.new"]' 'fn new() -> String' // @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
Bar
identifier_name
issue-19190-2.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// @has issue_19190_2/struct.Bar.html // @!has - '//*[@id="method.new"]' 'fn new() -> String' // @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
fn deref(&self) -> &String { loop {} } }
random_line_split
issue-19190-2.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} // @has issue_19190_2/struct.Bar.html // @!has - '//*[@id="method.new"]' 'fn new() -> String' // @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
{ loop {} }
identifier_body
tcp.rs
#![feature(test)] extern crate peel_ip;
use test::Bencher; use peel_ip::prelude::*; static PACKET: &'static [u8] = &[0xca, 0x45, 0x01, 0xbb, 0x98, 0x66, 0x5f, 0x0a, 0x44, 0x9d, 0x7f, 0x05, 0x80, 0x18, 0x20, 0x00, 0x0f, 0x1c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x00, 0x02, 0x2c, 0x2e, 0x63, 0...
extern crate test;
random_line_split
tcp.rs
#![feature(test)] extern crate peel_ip; extern crate test; use test::Bencher; use peel_ip::prelude::*; static PACKET: &'static [u8] = &[0xca, 0x45, 0x01, 0xbb, 0x98, 0x66, 0x5f, 0x0a, 0x44, 0x9d, 0x7f, 0x05, 0x80, 0x18, 0x20, 0x00, 0x0f, 0x1c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x00,...
(bencher: &mut Bencher) { let mut parser = TcpParser; bencher.iter(|| { parser.parse(PACKET, None, None).unwrap(); }); bencher.bytes = PACKET.len() as u64; } #[bench] fn tcp_big_packet(bencher: &mut Bencher) { let mut parser = TcpParser; let mut input = Vec::from(PACKET); input.exte...
tcp_small_packet
identifier_name
tcp.rs
#![feature(test)] extern crate peel_ip; extern crate test; use test::Bencher; use peel_ip::prelude::*; static PACKET: &'static [u8] = &[0xca, 0x45, 0x01, 0xbb, 0x98, 0x66, 0x5f, 0x0a, 0x44, 0x9d, 0x7f, 0x05, 0x80, 0x18, 0x20, 0x00, 0x0f, 0x1c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x00,...
{ let mut parser = TcpParser; let mut input = Vec::from(PACKET); input.extend_from_slice(&[0xff; 1450]); bencher.iter(|| { parser.parse(&input, None, None).unwrap(); }); bencher.bytes = input.len() as u64; }
identifier_body
regions-copy-closure.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a> { cl: ||: 'a, } fn box_it<'r>(x: ||: 'r) -> closure_box<'r> { closure_box {cl: x} } pub fn main() { let mut i = 3i; assert_eq!(i, 3); { let cl = || i += 1; let cl_box = box_it(cl); (cl_box.cl)(); } assert_eq!(i, 4); }
closure_box
identifier_name
regions-copy-closure.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 cl_box = box_it(cl); (cl_box.cl)(); } assert_eq!(i, 4); }
let mut i = 3i; assert_eq!(i, 3); { let cl = || i += 1;
random_line_split
main.rs
use std::env; use std::process; extern crate concurrent_prime_sieve; use concurrent_prime_sieve::filter::prime_filter; mod draw_spiral; fn help() ->!{ println!("Can only use up to 2 environment variables. E.G."); println!(">>>cargo run <size> <write_to_path>"); process::exit(0); } fn
(env_args: &Vec<String>, default_size: usize) -> usize { match env_args[1].trim().parse(){ Ok(n) => n, Err(_) => default_size, } } fn get_env(default_size: usize) -> (String, usize){ let env_args: Vec<String> = env::args().collect(); let (path, size) = match env_args.len(){ 1 => ...
get_size_from_env
identifier_name
main.rs
use std::env; use std::process; extern crate concurrent_prime_sieve; use concurrent_prime_sieve::filter::prime_filter; mod draw_spiral; fn help() ->!{ println!("Can only use up to 2 environment variables. E.G."); println!(">>>cargo run <size> <write_to_path>"); process::exit(0); } fn get_size_from_env(env_a...
fn main() { let (path, size) = get_env(200); // println!("{}", path); let num_primes = size*size + 1; let is_prime_iter = prime_filter(num_primes); draw_spiral::prime_filter_to_spiral_png(size, is_prime_iter, path); // for (i, j) in is_prime_iter.iter().enumerate(){ // println!("{} is p...
{ let env_args: Vec<String> = env::args().collect(); let (path, size) = match env_args.len(){ 1 => ("", default_size), 2 => ("", get_size_from_env(&env_args, default_size)), 3 => (env_args[2].as_str(), get_size_from_env(&env_args, default_size)), _ => help(), }; (String::...
identifier_body
main.rs
use std::env; use std::process; extern crate concurrent_prime_sieve; use concurrent_prime_sieve::filter::prime_filter; mod draw_spiral; fn help() ->!{ println!("Can only use up to 2 environment variables. E.G."); println!(">>>cargo run <size> <write_to_path>"); process::exit(0); } fn get_size_from_env(env_a...
let (path, size) = get_env(200); // println!("{}", path); let num_primes = size*size + 1; let is_prime_iter = prime_filter(num_primes); draw_spiral::prime_filter_to_spiral_png(size, is_prime_iter, path); // for (i, j) in is_prime_iter.iter().enumerate(){ // println!("{} is prime: {}", i,...
_ => help(), }; (String::from(path), size) } fn main() {
random_line_split
lib.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ //! Python bindings for native blackbox logging. use std::ops::Deref; use blackbox::event::Event; use blackbox::init; use blackbox::log; ...
( py: Python, session_ids: Vec<u64>, pattern: &str, ) -> PyResult<Vec<(u64, f64, String, String)>> { let pattern: serde_json::Value = serde_json::from_str(pattern).map_pyerr(py)?; let blackbox = blackbox::SINGLETON.lock(); let blackbox = blackbox.deref(); let mut result = Vec::new(); for...
events_by_session_ids
identifier_name
lib.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ //! Python bindings for native blackbox logging. use std::ops::Deref; use blackbox::event::Event; use blackbox::init; use blackbox::log; ...
use cpython::*; use cpython_ext::PyNone; use cpython_ext::PyPath; use cpython_ext::ResultPyErrExt; pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> { let name = [package, "blackbox"].join("."); let m = PyModule::new(py, &name)?; m.add( py, "init", py_fn!( ...
random_line_split
lib.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ //! Python bindings for native blackbox logging. use std::ops::Deref; use blackbox::event::Event; use blackbox::init; use blackbox::log; ...
/// Log a JSON-serialized event. The JSON string must be deserializable /// to the Rust Event type, defined in blackbox/src/event.rs. fn log_json(py: Python, json: String) -> PyResult<PyNone> { let event = Event::from_json(&json).map_pyerr(py)?; log(&event); Ok(PyNone) } /// Write buffered changes to dis...
{ let blackbox = BlackboxOptions::new() .max_bytes_per_log(size) .max_log_count(count) .open(path) .map_pyerr(py)?; init(blackbox); Ok(PyNone) }
identifier_body
build.rs
extern crate string_cache_shared; use string_cache_shared::{STATIC_ATOM_SET, ALL_NS, pack_static}; use std::ascii::AsciiExt; use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; fn main() { let path = Path::new(env!("OUT_DIR")).join("ns_atom_macros_without_plugin.rs"); let mut file = BufW...
if suffix.is_empty() { writeln!(file, r"({:?}) => {{ $crate::Namespace({}) }};", prefix1, atom(url)).unwrap(); writeln!(file, r"( {} ) => {{ $crate::Namespace({}) }};", prefix1, atom(url)).unwrap(); } else { let prefix2 = prefix1.clone(); generate_combination(prefix1 + &*suffix[....
fn generate_combination(prefix1: String, suffix: &str, url: &str, file: &mut BufWriter<File>) {
random_line_split
build.rs
extern crate string_cache_shared; use string_cache_shared::{STATIC_ATOM_SET, ALL_NS, pack_static}; use std::ascii::AsciiExt; use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; fn main() { let path = Path::new(env!("OUT_DIR")).join("ns_atom_macros_without_plugin.rs"); let mut file = BufW...
(s: &str) -> String { let data = pack_static(STATIC_ATOM_SET.get_index(s).unwrap() as u32); format!("$crate::Atom {{ data: 0x{:x} }}", data) } fn is_ident(s: &str) -> bool { let mut chars = s.chars(); !s.is_empty() && match chars.next().unwrap() { 'a'...'z' | 'A'...'Z' | '_' => true, _ =...
atom
identifier_name
build.rs
extern crate string_cache_shared; use string_cache_shared::{STATIC_ATOM_SET, ALL_NS, pack_static}; use std::ascii::AsciiExt; use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; fn main() { let path = Path::new(env!("OUT_DIR")).join("ns_atom_macros_without_plugin.rs"); let mut file = BufW...
{ let mut chars = s.chars(); !s.is_empty() && match chars.next().unwrap() { 'a'...'z' | 'A'...'Z' | '_' => true, _ => false } && chars.all(|c| match c { 'a'...'z' | 'A'...'Z' | '_' | '0'...'9' => true, _ => false }) }
identifier_body