file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
mod.rs
use std::net::SocketAddr; use filter::FilterDecision; use message::initiate::InitiateMessage; use message::protocol::Protocol; use message::extensions::Extensions; use filter::filters::Filters; use bip_util::bt::{PeerId, InfoHash}; use futures::stream::Stream; use futures::sink::Sink; use futures::future::{self, Into...
R:'static, C:'static { handle.spawn(future::loop_fn((stream, handler, sink, context), |(stream, mut handler, sink, context)| { // We will terminate the loop if, the stream gives us an error, the stream gives us None, the handler gives // us an error, or the sink gives us an error...
F: IntoFuture<Item=Option<R>> + 'static,
random_line_split
reseeding.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self) -> u32 { self.reseed_if_necessary(); self.bytes_generated += 4; self.rng.next_u32() } fn next_u64(&mut self) -> u64 { self.reseed_if_necessary(); self.bytes_generated += 8; self.rng.next_u64() } fn fill_bytes(&mut self, dest: &mut [u8]) { ...
next_u32
identifier_name
reseeding.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn from_seed(seed: u32) -> Counter { Counter { i: seed } } } type MyRng = ReseedingRng<Counter, ReseedWithDefault>; #[test] fn test_reseeding() { let mut rs = ReseedingRng::new(Counter {i:0}, 400, ReseedWithDefault); let mut i = 0; for _ in 0..1000 ...
{ self.i = seed; }
identifier_body
reseeding.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(rs.next_u32(), i % 100); i += 1; } } #[test] fn test_rng_seeded() { let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); assert!(order::equals(ra.gen_ascii_c...
random_line_split
reseeding.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } impl<R: Rng, Rsdr: Reseeder<R>> Rng for ReseedingRng<R, Rsdr> { fn next_u32(&mut self) -> u32 { self.reseed_if_necessary(); self.bytes_generated += 4; self.rng.next_u32() } fn next_u64(&mut self) -> u64 { self.reseed_if_necessary(); self.bytes_generated +=...
{ self.reseeder.reseed(&mut self.rng); self.bytes_generated = 0; }
conditional_block
crypto_auth.rs
// crypto_auth.h pub const crypto_auth_BYTES: usize = crypto_auth_hmacsha512256_BYTES; pub const crypto_auth_KEYBYTES: usize = crypto_auth_hmacsha512256_KEYBYTES;
extern { pub fn crypto_auth_bytes() -> size_t; pub fn crypto_auth_keybytes() -> size_t; pub fn crypto_auth_primitive() -> *const c_char; pub fn crypto_auth(a: *mut [u8; crypto_auth_BYTES], m: *const u8, mlen: c_ulonglong, k: *const [u8...
pub const crypto_auth_PRIMITIVE: &'static str = "hmacsha512256";
random_line_split
crypto_auth.rs
// crypto_auth.h pub const crypto_auth_BYTES: usize = crypto_auth_hmacsha512256_BYTES; pub const crypto_auth_KEYBYTES: usize = crypto_auth_hmacsha512256_KEYBYTES; pub const crypto_auth_PRIMITIVE: &'static str = "hmacsha512256"; extern { pub fn crypto_auth_bytes() -> size_t; pub fn crypto_auth_keybytes() -> s...
{ unsafe { let s = crypto_auth_primitive(); let s = std::ffi::CStr::from_ptr(s).to_bytes(); assert!(s == crypto_auth_PRIMITIVE.as_bytes()); } }
identifier_body
crypto_auth.rs
// crypto_auth.h pub const crypto_auth_BYTES: usize = crypto_auth_hmacsha512256_BYTES; pub const crypto_auth_KEYBYTES: usize = crypto_auth_hmacsha512256_KEYBYTES; pub const crypto_auth_PRIMITIVE: &'static str = "hmacsha512256"; extern { pub fn crypto_auth_bytes() -> size_t; pub fn crypto_auth_keybytes() -> s...
() { assert!(unsafe { crypto_auth_bytes() as usize } == crypto_auth_BYTES) } #[test] fn test_crypto_auth_keybytes() { assert!(unsafe { crypto_auth_keybytes() as usize } == crypto_auth_KEYBYTES) } #[test] fn test_crypto_auth_primitive() { unsafe { let s = crypto_auth_primitive(); ...
test_crypto_auth_bytes
identifier_name
close-over-big-then-small-data.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 f<A:Clone +'static>(a: A, b: u16) -> @Invokable<A> { @Invoker { a: a, b: b, } as @Invokable<A> } pub fn main() { let (a, b) = f(22_u64, 44u16).f(); info!("a=%? b=%?", a, b); assert_eq!(a, 22u64); assert_eq!(b, 44u16); }
{ (self.a.clone(), self.b) }
identifier_body
close-over-big-then-small-data.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:Clone +'static>(a: A, b: u16) -> @Invokable<A> { @Invoker { a: a, b: b, } as @Invokable<A> } pub fn main() { let (a, b) = f(22_u64, 44u16).f(); info!("a=%? b=%?", a, b); assert_eq!(a, 22u64); assert_eq!(b, 44u16); }
f
identifier_name
close-over-big-then-small-data.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 ...
assert_eq!(a, 22u64); assert_eq!(b, 44u16); }
random_line_split
closure.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 ...
} } fn deduce_expectations_from_expected_type<'a,'tcx>( fcx: &FnCtxt<'a,'tcx>, expected_ty: Ty<'tcx>) -> (Option<ty::FnSig<'tcx>>,Option<ty::ClosureKind>) { debug!("deduce_expectations_from_expected_type(expected_ty={:?})", expected_ty); match expected_ty.sty { ty::TyTrait(...
{ }
conditional_block
closure.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 ...
<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, expr: &ast::Expr, opt_kind: Option<ty::ClosureKind>, decl: &'tcx ast::FnDecl, body: &'tcx ast::Block, expected_sig: Option<ty::FnSig<'tcx>>) { let expr_d...
check_closure
identifier_name
closure.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 ...
ty::Predicate::RegionOutlives(..) => None, ty::Predicate::TypeOutlives(..) => None, }; opt_trait_ref .and_then(|trait_ref| self_type_matches_expected_vid(fcx, trait_ref, expected_vid)) .and_then(|trait_ref| fcx.tcx().lang_items.fn_tra...
let opt_trait_ref = match obligation.predicate { ty::Predicate::Projection(ref data) => Some(data.to_poly_trait_ref()), ty::Predicate::Trait(ref data) => Some(data.to_poly_trait_ref()), ty::Predicate::Equate(..) => None,
random_line_split
closure.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 ...
fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, expr: &ast::Expr, opt_kind: Option<ty::ClosureKind>, decl: &'tcx ast::FnDecl, body: &'tcx ast::Block, expected_sig: Option<ty::FnSig<'tcx>>...
{ debug!("check_expr_closure(expr={:?},expected={:?})", expr, expected); // It's always helpful for inference if we know the kind of // closure sooner rather than later, so first examine the expected // type, and see if can glean a closure kind from there. let (expected_sig,ex...
identifier_body
mesh_manager.rs
//! A resource manager to load meshes. use crate::loader::mtl::MtlMaterial; use crate::loader::obj; use crate::resource::Mesh; use ncollide3d::procedural; use ncollide3d::procedural::TriMesh; use std::cell::RefCell; use std::collections::HashMap; use std::io::Result as IoResult; use std::path::Path; use std::rc::Rc; ...
// FIXME: is this the right place to put this? /// Loads the meshes described by an obj file. pub fn load_obj( path: &Path, mtl_dir: &Path, geometry_name: &str, ) -> IoResult<Vec<(String, Rc<RefCell<Mesh>>, Option<MtlMaterial>)>> { obj::parse_file(path, mtl_dir, geometr...
{ let _ = self.meshes.remove(&name.to_string()); }
identifier_body
mesh_manager.rs
//! A resource manager to load meshes. use crate::loader::mtl::MtlMaterial; use crate::loader::obj; use crate::resource::Mesh; use ncollide3d::procedural; use ncollide3d::procedural::TriMesh; use std::cell::RefCell; use std::collections::HashMap; use std::io::Result as IoResult; use std::path::Path; use std::rc::Rc; ...
pub struct MeshManager { meshes: HashMap<String, Rc<RefCell<Mesh>>>, } impl MeshManager { /// Creates a new mesh manager. pub fn new() -> MeshManager { let mut res = MeshManager { meshes: HashMap::new(), }; let _ = res.add_trimesh(procedural::unit_sphere(50, 50, true), ...
/// /// Upon construction, it contains: /// /// It keeps a cache of already-loaded meshes. Note that this is only a cache, nothing more. /// Thus, its usage is not required to load meshes.
random_line_split
mesh_manager.rs
//! A resource manager to load meshes. use crate::loader::mtl::MtlMaterial; use crate::loader::obj; use crate::resource::Mesh; use ncollide3d::procedural; use ncollide3d::procedural::TriMesh; use std::cell::RefCell; use std::collections::HashMap; use std::io::Result as IoResult; use std::path::Path; use std::rc::Rc; ...
{ meshes: HashMap<String, Rc<RefCell<Mesh>>>, } impl MeshManager { /// Creates a new mesh manager. pub fn new() -> MeshManager { let mut res = MeshManager { meshes: HashMap::new(), }; let _ = res.add_trimesh(procedural::unit_sphere(50, 50, true), false, "sphere"); ...
MeshManager
identifier_name
transmute-type-parameters.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
f: T, } unsafe fn i<T>(x: Bad<T>) { let _: int = transmute(x); //~ ERROR cannot transmute } enum Worse<T> { A(T), B, } unsafe fn j<T>(x: Worse<T>) { let _: int = transmute(x); //~ ERROR cannot transmute } unsafe fn k<T>(x: Option<T>) { let _: int = transmute(x); //~ ERROR cannot transmute...
struct Bad<T> {
random_line_split
transmute-type-parameters.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
unsafe fn k<T>(x: Option<T>) { let _: int = transmute(x); //~ ERROR cannot transmute } fn main() {}
{ let _: int = transmute(x); //~ ERROR cannot transmute }
identifier_body
transmute-type-parameters.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 ...
<T>(x: (T, int)) { let _: int = transmute(x); //~ ERROR cannot transmute } unsafe fn h<T>(x: [T,..10]) { let _: int = transmute(x); //~ ERROR cannot transmute } struct Bad<T> { f: T, } unsafe fn i<T>(x: Bad<T>) { let _: int = transmute(x); //~ ERROR cannot transmute } enum Worse<T> { A(T), ...
g
identifier_name
x86stdcall2.rs
// run-pass #![allow(non_camel_case_types)] pub type HANDLE = usize; pub type DWORD = u32; pub type SIZE_T = u32; pub type LPVOID = usize; pub type BOOL = u8; #[cfg(windows)] mod kernel32 { use super::{HANDLE, DWORD, SIZE_T, LPVOID, BOOL}; extern "system" { pub fn GetProcessHeap() -> HANDLE; ...
{ }
identifier_body
x86stdcall2.rs
// run-pass #![allow(non_camel_case_types)] pub type HANDLE = usize; pub type DWORD = u32; pub type SIZE_T = u32; pub type LPVOID = usize; pub type BOOL = u8; #[cfg(windows)] mod kernel32 { use super::{HANDLE, DWORD, SIZE_T, LPVOID, BOOL}; extern "system" { pub fn GetProcessHeap() -> HANDLE; ...
() { let heap = unsafe { kernel32::GetProcessHeap() }; let mem = unsafe { kernel32::HeapAlloc(heap, 0, 100) }; assert!(mem!= 0); let res = unsafe { kernel32::HeapFree(heap, 0, mem) }; assert!(res!= 0); } #[cfg(not(windows))] pub fn main() { }
main
identifier_name
x86stdcall2.rs
// run-pass #![allow(non_camel_case_types)] pub type HANDLE = usize; pub type DWORD = u32; pub type SIZE_T = u32; pub type LPVOID = usize; pub type BOOL = u8; #[cfg(windows)] mod kernel32 { use super::{HANDLE, DWORD, SIZE_T, LPVOID, BOOL}; extern "system" { pub fn GetProcessHeap() -> HANDLE; ...
pub fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL; } } #[cfg(windows)] pub fn main() { let heap = unsafe { kernel32::GetProcessHeap() }; let mem = unsafe { kernel32::HeapAlloc(heap, 0, 100) }; assert!(mem!= 0); let res = unsafe { kernel32::HeapFree(heap, 0, mem) }; ...
random_line_split
tasks.rs
use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; #[allow(non_camel_case_types)] enum
{ WAITING, RUNNING_NO_TASKS, RUNNING_GOT_TASKS, } pub struct Tasks { state: AtomicUsize } impl Tasks { pub fn new() -> Tasks { Tasks { state: AtomicUsize::new(State::WAITING as usize) } } /** * recheck queue? */ pub fn fetch_task(&self) -> bool { let old_sta...
State
identifier_name
tasks.rs
use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; #[allow(non_camel_case_types)] enum State { WAITING, RUNNING_NO_TASKS, RUNNING_GOT_TASKS, } pub struct Tasks { state: AtomicUsize } impl Tasks { pub fn new() -> Tasks { Tasks { state: AtomicUsize::new(State::WAITING as u...
return false; } else { panic!(format!("unknown old state: {}", old_state)); } } /** * schedule task execution? */ pub fn add_task(&self) -> bool { // fast track for high-load applications // atomic get is cheaper than atomic swap // ...
let old_state: usize = self.state.fetch_sub(1, Ordering::Relaxed); if old_state == State::RUNNING_GOT_TASKS as usize { return true; } else if old_state == State::RUNNING_NO_TASKS as usize {
random_line_split
tasks.rs
use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; #[allow(non_camel_case_types)] enum State { WAITING, RUNNING_NO_TASKS, RUNNING_GOT_TASKS, } pub struct Tasks { state: AtomicUsize } impl Tasks { pub fn new() -> Tasks { Tasks { state: AtomicUsize::new(State::WAITING as u...
/** * schedule task execution? */ pub fn add_task(&self) -> bool { // fast track for high-load applications // atomic get is cheaper than atomic swap // for both this thread and fetching thread if self.state.load(Ordering::Relaxed) == State::RUNNING_GOT_TASKS as usize...
{ let old_state: usize = self.state.fetch_sub(1, Ordering::Relaxed); if old_state == State::RUNNING_GOT_TASKS as usize { return true; } else if old_state == State::RUNNING_NO_TASKS as usize { return false; } else { panic!(format!("unknown old state: {}...
identifier_body
account.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
a.commit_storage(&Default::default(), &mut db).unwrap(); assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2"); } #[test] fn commit_remove_commit_storage() { let mut a = Account::new_contract(69.into(), 0.into()); let mut db = MemoryDB::new(); let ...
let mut a = Account::new_contract(69.into(), 0.into()); let mut db = MemoryDB::new(); let mut db = AccountDBMut::new(&mut db, &Address::new()); a.set_storage(0.into(), 0x1234.into()); assert_eq!(a.storage_root(), None);
random_line_split
account.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
fn empty_storage_cache() -> RefCell<LruCache<H256, H256>> { RefCell::new(LruCache::new(STORAGE_CACHE_ITEMS)) } /// General constructor. pub fn from_pod(pod: PodAccount) -> Account { Account { balance: pod.balance, nonce: pod.nonce, storage_root: SHA3_NULL_RLP, storage_cache: Self::empty_storage_c...
{ Account { balance: balance, nonce: nonce, storage_root: SHA3_NULL_RLP, storage_cache: Self::empty_storage_cache(), storage_changes: storage, code_hash: code.sha3(), code_size: Some(code.len()), code_cache: Arc::new(code), code_filth: Filth::Dirty, address_hash: Cell::new(None), } }
identifier_body
account.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
, (false, _) => {}, } } /// Export to RLP. pub fn rlp(&self) -> Bytes { let mut stream = RlpStream::new_list(4); stream.append(&self.nonce); stream.append(&self.balance); stream.append(&self.storage_root); stream.append(&self.code_hash); stream.out() } /// Clone basic account data pub fn clone_...
{ db.emplace(self.code_hash.clone(), DBValue::from_slice(&*self.code_cache)); self.code_size = Some(self.code_cache.len()); self.code_filth = Filth::Clean; }
conditional_block
account.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
(&self) -> &U256 { &self.nonce } /// return the code hash associated with this account. pub fn code_hash(&self) -> H256 { self.code_hash.clone() } /// return the code hash associated with this account. pub fn address_hash(&self, address: &Address) -> H256 { let hash = self.address_hash.get(); hash.unwrap_o...
nonce
identifier_name
modbus_server.rs
use crate::prelude::*; use libmodbus_sys as ffi; /// The server is waiting for request from clients and must answer when it is concerned by the request. The libmodbus /// offers the following functions to handle requests: /// /// * Receive /// - [`receive()`](struct.Modbus.html#method.receive) /// * Reply /// ...
( &self, request: &[u8], request_len: i32, modbus_mapping: &ModbusMapping, ) -> Result<i32, Error> { unsafe { let len = ffi::modbus_reply( self.ctx, request.as_ptr(), request_len, modbus_mapping.modbu...
reply
identifier_name
modbus_server.rs
use crate::prelude::*; use libmodbus_sys as ffi; /// The server is waiting for request from clients and must answer when it is concerned by the request. The libmodbus /// offers the following functions to handle requests: /// /// * Receive /// - [`receive()`](struct.Modbus.html#method.receive) /// * Reply /// ...
match len { -1 => Err(Error::Server { msg: "receive".to_owned(), source: ::std::io::Error::last_os_error(), }), len => Ok(len), } } } /// `modbus_reply` - send a reponse to the received reque...
unsafe { let len = ffi::modbus_receive(self.ctx, request.as_mut_ptr());
random_line_split
modbus_server.rs
use crate::prelude::*; use libmodbus_sys as ffi; /// The server is waiting for request from clients and must answer when it is concerned by the request. The libmodbus /// offers the following functions to handle requests: /// /// * Receive /// - [`receive()`](struct.Modbus.html#method.receive) /// * Reply /// ...
/// `modbus_reply` - send a reponse to the received request /// /// The [`reply()`](#method.reply) function shall send a response to received request. The request req given in /// argument is analyzed, a response is then built and sent by using the information of the modbus context ctx. /// If the...
{ assert!(request.len() <= Modbus::MAX_ADU_LENGTH as usize); unsafe { let len = ffi::modbus_receive(self.ctx, request.as_mut_ptr()); match len { -1 => Err(Error::Server { msg: "receive".to_owned(), source: ::std::io::Error:...
identifier_body
filter.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
} /// Filter Address pub type FilterAddress = VariadicValue<H160>; /// Topic pub type Topic = VariadicValue<H256>; /// Filter #[derive(Debug, PartialEq, Clone, Deserialize, Eq, Hash)] #[serde(deny_unknown_fields)] pub struct Filter { /// From Block #[serde(rename="fromBlock")] pub from_block: Option<BlockNumber>,...
{ let v: Value = Deserialize::deserialize(deserializer)?; if v.is_null() { return Ok(VariadicValue::Null); } from_value(v.clone()).map(VariadicValue::Single) .or_else(|_| from_value(v).map(VariadicValue::Multiple)) .map_err(|err| D::Error::custom(format!("Invalid variadic value type: {}", err))) }
identifier_body
filter.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
{ /// New logs. Logs(Vec<Log>), /// New hashes (block or transactions) Hashes(Vec<H256>), /// Empty result, Empty, } impl Serialize for FilterChanges { fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error> where S: Serializer { match *self { FilterChanges::Logs(ref logs) => logs.serialize(s), FilterC...
FilterChanges
identifier_name
filter.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
iter.next().unwrap_or(None), iter.next().unwrap_or(None), iter.next().unwrap_or(None), iter.next().unwrap_or(None) ] }, limit: self.limit, } } } /// Results of the filter_changes RPC. #[derive(Debug, PartialEq)] pub enum FilterChanges { /// New logs. Logs(Vec<Log>), /// New hashes (...
vec![
random_line_split
app_chooser_widget.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
pub fn get_show_default(&mut self) -> bool { unsafe { to_bool(ffi::gtk_app_chooser_widget_get_show_default(GTK_APP_CHOOSER_WIDGET(self.pointer))) } } pub fn set_show_recommended(&self, setting: bool) { unsafe { ffi::gtk_app_chooser_widget_set_show_recommended(GTK_APP_C...
{ unsafe { ffi::gtk_app_chooser_widget_set_show_default(GTK_APP_CHOOSER_WIDGET(self.pointer), to_gboolean(setting)) } }
identifier_body
app_chooser_widget.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
struct_Widget!(AppChooserWidget); impl AppChooserWidget { pub fn new(content_type: &str) -> Option<AppChooserWidget> { let tmp_pointer = unsafe { ffi::gtk_app_chooser_widget_new(content_type.borrow_to_glib().0) }; check_pointer!(tmp_pointer, AppChooserWidget) } pub fn s...
use glib::translate::{FromGlibPtr, ToGlibPtr}; use glib::{to_bool, to_gboolean};
random_line_split
app_chooser_widget.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
(&mut self) -> bool { unsafe { to_bool(ffi::gtk_app_chooser_widget_get_show_recommended(GTK_APP_CHOOSER_WIDGET(self.pointer))) } } pub fn set_show_fallback(&self, setting: bool) { unsafe { ffi::gtk_app_chooser_widget_set_show_fallback(GTK_APP_CHOOSER_WIDGET(self.pointer), to...
get_show_recommended
identifier_name
auth.rs
//============================================================================= // // WARNING: This file is AUTO-GENERATED // // Do not make changes directly to this file. // // If you would like to make a change to the library, please update the schema // definitions at https://github.com/slack-rs/s...
/// Checks authentication & identity. /// /// Wraps https://api.slack.com/methods/auth.test pub async fn test<R>(client: &R, token: &str) -> Result<TestResponse, TestError<R::Error>> where R: SlackWebRequestSender, { let params = &[("token", token)]; let url = crate::get_slack_url_for_method("auth.test")...
{ let params = vec![ Some(("token", token)), request .test .map(|test| ("test", if test { "1" } else { "0" })), ]; let params = params.into_iter().filter_map(|x| x).collect::<Vec<_>>(); let url = crate::get_slack_url_for_method("auth.revoke"); client ....
identifier_body
auth.rs
//============================================================================= // // WARNING: This file is AUTO-GENERATED // // Do not make changes directly to this file. // // If you would like to make a change to the library, please update the schema // definitions at https://github.com/slack-rs/s...
{ let params = &[("token", token)]; let url = crate::get_slack_url_for_method("auth.test"); client .send(&url, &params[..]) .await .map_err(TestError::Client) .and_then(|result| { serde_json::from_str::<TestResponse>(&result) .map_err(|e| TestError::Mal...
where R: SlackWebRequestSender,
random_line_split
auth.rs
//============================================================================= // // WARNING: This file is AUTO-GENERATED // // Do not make changes directly to this file. // // If you would like to make a change to the library, please update the schema // definitions at https://github.com/slack-rs/s...
<R>(client: &R, token: &str) -> Result<TestResponse, TestError<R::Error>> where R: SlackWebRequestSender, { let params = &[("token", token)]; let url = crate::get_slack_url_for_method("auth.test"); client .send(&url, &params[..]) .await .map_err(TestError::Client) .and_then(|...
test
identifier_name
send-resource.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 ...
(&self) {} } fn test(f: int) -> test { test { f: f } } pub fn main() { let (p, c) = stream(); do task::spawn() { let (pp, cc) = stream(); c.send(cc); let _r = pp.recv(); } p.recv().send(test(42)); }
drop
identifier_name
send-resource.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 ...
}
p.recv().send(test(42));
random_line_split
send-resource.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(f: int) -> test { test { f: f } } pub fn main() { let (p, c) = stream(); do task::spawn() { let (pp, cc) = stream(); c.send(cc); let _r = pp.recv(); } p.recv().send(test(42)); }
{}
identifier_body
random.rs
extern crate conway; extern crate rand; use rand::Rng; use std::{thread, time}; use conway::universe::*; fn
() { let player0 = PlayerBuilder::new(Region::new(100, 70, 34, 16)); // used for the glider gun and predefined patterns let player1 = PlayerBuilder::new(Region::new(0, 0, 80, 80)); let players = vec![player0, player1]; let bigbang = BigBang::new() .width(1280) .height(800) .serve...
main
identifier_name
random.rs
extern crate conway; extern crate rand; use rand::Rng; use std::{thread, time}; use conway::universe::*; fn main() { let player0 = PlayerBuilder::new(Region::new(100, 70, 34, 16)); // used for the glider gun and predefined patterns let player1 = PlayerBuilder::new(Region::new(0, 0, 80, 80)); let players...
rand_word >>= 1; } } uni.next(); thread::sleep(step_time); } }
{ let _ = uni.toggle(col, row, 0); }
conditional_block
random.rs
extern crate conway; extern crate rand; use rand::Rng; use std::{thread, time}; use conway::universe::*; fn main() { let player0 = PlayerBuilder::new(Region::new(100, 70, 34, 16)); // used for the glider gun and predefined patterns let player1 = PlayerBuilder::new(Region::new(0, 0, 80, 80));
.server_mode(true) .history(16) .fog_radius(6) .add_players(players) .birth(); let mut uni = bigbang.unwrap(); let step_time = time::Duration::from_millis(30); let mut rng = rand::thread_rng(); loop { println!("\x1b[H\x1b[2J{}", uni); println!("Gen: {...
let players = vec![player0, player1]; let bigbang = BigBang::new() .width(1280) .height(800)
random_line_split
random.rs
extern crate conway; extern crate rand; use rand::Rng; use std::{thread, time}; use conway::universe::*; fn main()
println!("Gen: {}", uni.latest_gen()); let mut rand_word: u64 = rng.gen::<u8>() as u64; for col in 60..64 { for row in 15..17 { if rand_word & 1 == 1 { let _ = uni.toggle(col, row, 0); } rand_word >>= 1; ...
{ let player0 = PlayerBuilder::new(Region::new(100, 70, 34, 16)); // used for the glider gun and predefined patterns let player1 = PlayerBuilder::new(Region::new(0, 0, 80, 80)); let players = vec![player0, player1]; let bigbang = BigBang::new() .width(1280) .height(800) .serve...
identifier_body
addps.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn addps_1() {
fn addps_2() { run_test(&Instruction { mnemonic: Mnemonic::ADDPS, operand1: Some(Direct(XMM0)), operand2: Some(IndirectScaledIndexed(ECX, EDX, Four, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[1...
run_test(&Instruction { mnemonic: Mnemonic::ADDPS, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 88, 238], OperandSize::Dword) }
random_line_split
addps.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn addps_1() { run_test(&Instruction { mnemonic: Mnemonic::ADDPS, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM6...
fn addps_3() { run_test(&Instruction { mnemonic: Mnemonic::ADDPS, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM1)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 88, 209], OperandSize::Qword) } fn addps_4() { run...
{ run_test(&Instruction { mnemonic: Mnemonic::ADDPS, operand1: Some(Direct(XMM0)), operand2: Some(IndirectScaledIndexed(ECX, EDX, Four, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 88, 4, 145]...
identifier_body
addps.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn
() { run_test(&Instruction { mnemonic: Mnemonic::ADDPS, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 88, 238], OperandSize::Dword) } fn addps_2() { run_test(&Instr...
addps_1
identifier_name
blobstore.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. */
use clap::{Parser, Subcommand}; use mononoke_app::args::RepoBlobstoreArgs; use mononoke_app::MononokeApp; use fetch::BlobstoreFetchArgs; use upload::BlobstoreUploadArgs; /// Directly access blobstore keys #[derive(Parser)] pub struct CommandArgs { #[clap(flatten)] repo_blobstore_args: RepoBlobstoreArgs, ...
mod fetch; mod upload; use anyhow::{Context, Result};
random_line_split
blobstore.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. */ mod fetch; mod upload; use anyhow::{Context, Result}; use clap::{Parser, Subcommand}; use mononoke_app::args::RepoBlobstoreArgs; use monon...
{ /// Fetch a blob from the blobstore Fetch(BlobstoreFetchArgs), /// Upload a blob to the blobstore Upload(BlobstoreUploadArgs), } pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> { let ctx = app.new_context(); let blobstore = app .open_blobstore(&args.repo_blobstore...
BlobstoreSubcommand
identifier_name
blobstore.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. */ mod fetch; mod upload; use anyhow::{Context, Result}; use clap::{Parser, Subcommand}; use mononoke_app::args::RepoBlobstoreArgs; use monon...
{ let ctx = app.new_context(); let blobstore = app .open_blobstore(&args.repo_blobstore_args) .await .context("Failed to open blobstore")?; match args.subcommand { BlobstoreSubcommand::Fetch(fetch_args) => { fetch::fetch(&ctx, &blobstore, fetch_args).await? ...
identifier_body
blobstore.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. */ mod fetch; mod upload; use anyhow::{Context, Result}; use clap::{Parser, Subcommand}; use mononoke_app::args::RepoBlobstoreArgs; use monon...
} Ok(()) }
{ upload::upload(&ctx, &blobstore, upload_args).await? }
conditional_block
dropck_direct_cycle_with_drop.rs
// A simple example of an unsound mixing of cyclic structure and Drop. // // Each `D` has a name and an optional reference to another `D` // sibling, but also implements a drop method that prints out its own // name as well as the name of its sibling. // // By setting up a cyclic structure, the drop code cannot possibl...
{ g(); }
identifier_body
dropck_direct_cycle_with_drop.rs
// A simple example of an unsound mixing of cyclic structure and Drop. // // Each `D` has a name and an optional reference to another `D` // sibling, but also implements a drop method that prints out its own // name as well as the name of its sibling. // // By setting up a cyclic structure, the drop code cannot possibl...
fn g() { let (d1, d2) = (D::new(format!("d1")), D::new(format!("d2"))); d1.p.set(Some(&d2)); //~^ ERROR `d2` does not live long enough d2.p.set(Some(&d1)); //~^ ERROR `d1` does not live long enough } fn main() { g(); }
random_line_split
dropck_direct_cycle_with_drop.rs
// A simple example of an unsound mixing of cyclic structure and Drop. // // Each `D` has a name and an optional reference to another `D` // sibling, but also implements a drop method that prints out its own // name as well as the name of its sibling. // // By setting up a cyclic structure, the drop code cannot possibl...
(&mut self) { println!("dropping {} whose sibling is {:?}", self.name, self.p.get().map(|d| &d.name)); } } fn g() { let (d1, d2) = (D::new(format!("d1")), D::new(format!("d2"))); d1.p.set(Some(&d2)); //~^ ERROR `d2` does not live long enough d2.p.set(Some(&d1)); //~^ ER...
drop
identifier_name
lib.rs
// (c) 2016-2017 Productize SPRL <joost@productize.be> //! Kicad file format parser and generator library #![warn(missing_docs)] #[macro_use] extern crate log; extern crate shellexpand; extern crate symbolic_expressions; // extern crate strum; // #[macro_use] // extern crate strum_macros; use std::fmt; use std::path...
}, } match layout::parse(&data) { Ok(layout) => return Ok(KicadFile::Layout(layout)), Err(x) => if expected == Expected::Layout { return Err(x); }, } match symbol_lib::parse_str(&data) { Ok(sl) => return Ok(KicadFile::SymbolLib(sl)), Err(x) => ...
Ok(sch) => return Ok(KicadFile::Schematic(sch)), Err(x) => if expected == Expected::Schematic { return Err(x);
random_line_split
lib.rs
// (c) 2016-2017 Productize SPRL <joost@productize.be> //! Kicad file format parser and generator library #![warn(missing_docs)] #[macro_use] extern crate log; extern crate shellexpand; extern crate symbolic_expressions; // extern crate strum; // #[macro_use] // extern crate strum_macros; use std::fmt; use std::path...
{ /// smaller x pub x1: f64, /// smaller y pub y1: f64, /// bigger x pub x2: f64, /// bigger y pub y2: f64, /// item is bounded pub is_bounded: bool, } impl Default for Bound { fn default() -> Bound { Bound { x1: 0.0, y1: 0.0, x2:...
Bound
identifier_name
lib.rs
// (c) 2016-2017 Productize SPRL <joost@productize.be> //! Kicad file format parser and generator library #![warn(missing_docs)] #[macro_use] extern crate log; extern crate shellexpand; extern crate symbolic_expressions; // extern crate strum; // #[macro_use] // extern crate strum_macros; use std::fmt; use std::path...
/// read a file, expecting it to be a Kicad project file pub fn read_project(name: &Path) -> Result<project::Project, KicadError> { match read_kicad_file(name, Expected::Project)? { KicadFile::Project(mo) => Ok(mo), x => str_error(format!("unexpected {} in {}", x, name.display())), } } /// re...
{ match read_kicad_file(name, Expected::SymbolLib)? { KicadFile::SymbolLib(mo) => Ok(mo), x => str_error(format!("unexpected {} in {}", x, name.display())), } }
identifier_body
get_transactions_with_currency.rs
use api::client::{TellerClient, ApiServiceResult, Transaction}; use chrono::{Date, UTC}; #[derive(Debug)] pub struct TransactionsWithCurrrency { pub transactions: Vec<Transaction>, pub currency: String, } impl TransactionsWithCurrrency { pub fn new<S: Into<String>>(transactions: Vec<Transaction>, ...
} #[cfg(test)] mod tests { use api::client::{TellerClient, generate_utc_date_from_date_str}; use super::GetTransactionsWithCurrency; use hyper; mock_connector_in_order!(GetTransactionsFollowedByGetAccount { include_str!("../mocks/get-transactions.http") include_str!("../mocks/get-acc...
{ let transactions = try!(self.get_transactions(&account_id, &from, &to)); let account = try!(self.get_account(&account_id)); let currency = account.currency; Ok(TransactionsWithCurrrency::new(transactions, currency)) }
identifier_body
get_transactions_with_currency.rs
use api::client::{TellerClient, ApiServiceResult, Transaction}; use chrono::{Date, UTC}; #[derive(Debug)] pub struct TransactionsWithCurrrency { pub transactions: Vec<Transaction>, pub currency: String, } impl TransactionsWithCurrrency { pub fn
<S: Into<String>>(transactions: Vec<Transaction>, currency: S) -> TransactionsWithCurrrency { TransactionsWithCurrrency { transactions: transactions, currency: currency.into(), } } } pub trait GetTransactionsWit...
new
identifier_name
get_transactions_with_currency.rs
use api::client::{TellerClient, ApiServiceResult, Transaction}; use chrono::{Date, UTC}; #[derive(Debug)] pub struct TransactionsWithCurrrency { pub transactions: Vec<Transaction>, pub currency: String, } impl TransactionsWithCurrrency { pub fn new<S: Into<String>>(transactions: Vec<Transaction>, ...
-> ApiServiceResult<TransactionsWithCurrrency> { let transactions = try!(self.get_transactions(&account_id, &from, &to)); let account = try!(self.get_account(&account_id)); let currency = account.currency; Ok(TransactionsWithCurrrency::new(transact...
to: &Date<UTC>)
random_line_split
clientrect.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::utils::WrapperCache; pub struct ClientRect { wrapper: WrapperCache, top: f32, bott...
pub fn Bottom(&self) -> f32 { self.bottom } pub fn Left(&self) -> f32 { self.left } pub fn Right(&self) -> f32 { self.right } pub fn Width(&self) -> f32 { f32::abs(self.right - self.left) } pub fn Height(&self) -> f32 { f32::abs(self.bott...
{ self.top }
identifier_body
clientrect.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::utils::WrapperCache; pub struct ClientRect { wrapper: WrapperCache, top: f32, bott...
(&self) -> f32 { f32::abs(self.right - self.left) } pub fn Height(&self) -> f32 { f32::abs(self.bottom - self.top) } }
Width
identifier_name
clientrect.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::utils::WrapperCache; pub struct ClientRect { wrapper: WrapperCache, top: f32, bott...
rect.init_wrapper(); rect } pub fn Top(&self) -> f32 { self.top } pub fn Bottom(&self) -> f32 { self.bottom } pub fn Left(&self) -> f32 { self.left } pub fn Right(&self) -> f32 { self.right } pub fn Width(&self) -> f32 { ...
random_line_split
difference.rs
// Copyright (c) 2018 The predicates-rs Project Developers. // // 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 distr...
(_, Some(b'@')) => { *line = format!("{}", palette.description.paint(&line)); } _ => (), } } lines } #[cfg(not(feature = "color"))] fn colorize_diff(lines: Vec<String>, _palette: crate::Palette) -> Vec<String> { lines }
{ let (prefix, body) = line.split_at(1); *line = format!("{}{}", palette.var.paint(prefix), body); }
conditional_block
difference.rs
// Copyright (c) 2018 The predicates-rs Project Developers. // // 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 distr...
{ orig: borrow::Cow<'static, str>, } impl Predicate<str> for DifferencePredicate { fn eval(&self, edit: &str) -> bool { edit == self.orig } fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<reflection::Case<'a>> { let result = variable!= self.orig; if result...
DifferencePredicate
identifier_name
difference.rs
// Copyright (c) 2018 The predicates-rs Project Developers. // // 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 distr...
} /// Creates a new `Predicate` that diffs two strings. /// /// # Examples /// /// ``` /// use predicates::prelude::*; /// /// let predicate_fn = predicate::str::diff("Hello World"); /// assert_eq!(true, predicate_fn.eval("Hello World")); /// assert!(predicate_fn.find_case(false, "Hello World").is_none()); /// assert...
{ let palette = crate::Palette::current(); write!( f, "{} {} {}", palette.description.paint("diff"), palette.expected.paint("original"), palette.var.paint("var"), ) }
identifier_body
one_byte_xor.rs
use std::slice; use common::{err, ascii, charfreq, util}; pub struct Guess { pub plain: Vec<u8>, pub key: u8, pub distance: f32 } pub fn guess_key(cipher: &Vec<u8>, opt_options: Option<&GuessOptions>) -> Result<Guess, err::Error> { let mut guess_dist = Vec::new(); let default_optio...
(&self, input: &Vec<u8>) -> Result<f32, err::Error> { (self.distance_fn)(rts!(&input).as_ref()) } fn weighted_distance(&self, input: &Vec<u8>, weight: f32) -> Result<f32, err::Error> { Ok((self.weight_fn)(try!(self.distance(&input)), weight)) } } pub fn xor(input: &Vec<u8>, key: u8) -> Vec...
distance
identifier_name
one_byte_xor.rs
use std::slice; use common::{err, ascii, charfreq, util}; pub struct Guess { pub plain: Vec<u8>, pub key: u8, pub distance: f32 } pub fn guess_key(cipher: &Vec<u8>, opt_options: Option<&GuessOptions>) -> Result<Guess, err::Error> { let mut guess_dist = Vec::new(); let default_optio...
for key in options.keys() { let dist: f32; if options.weights_available() { dist = try!(options.weighted_distance(&xor(&cipher, key), *(weight_it.next().unwrap()))); } else { dist = try!(options.distance(&xor(&cipher, key))); } guess_dist...
random_line_split
one_byte_xor.rs
use std::slice; use common::{err, ascii, charfreq, util}; pub struct Guess { pub plain: Vec<u8>, pub key: u8, pub distance: f32 } pub fn guess_key(cipher: &Vec<u8>, opt_options: Option<&GuessOptions>) -> Result<Guess, err::Error> { let mut guess_dist = Vec::new(); let default_optio...
pub fn set_distance_fn(&mut self, distance_fn: FnDistance) { self.distance_fn = distance_fn; } pub fn set_weight_fn(&mut self, weight_fn: FnWeight) { self.weight_fn = weight_fn; } fn keys(&self) -> Vec<u8> { if self.start.is_some() { return (self.start.unwrap...
{ ctry!(start >= end, "invalid range, start value must be less than end value"); ctry!(self.candidates.is_some(), "range is redundant, candidates are already set"); self.start = Some(start); self.end = Some(end); Ok(()) }
identifier_body
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use dom::binding...
&self.resource_threads } }
random_line_split
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use dom::binding...
(&mut self, load: LoadType) { debug!("Adding blocking load {:?} ({}).", load, self.blocking_loads.len()); self.blocking_loads.push(load); } /// Initiate a new fetch. pub fn fetch_async(&mut self, load: LoadType, request: RequestInit, ...
add_blocking_load
identifier_name
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use dom::binding...
*blocker = None; } /// Return the url associated with this load. pub fn url(&self) -> Option<&ServoUrl> { self.load.as_ref().map(LoadType::url) } } impl Drop for LoadBlocker { fn drop(&mut self) { if!thread::panicking() { debug_assert!(self.load.is_none()); ...
{ this.doc.finish_load(this.load.take().unwrap()); }
conditional_block
mod.rs
use std::error::Error; /// Derives `std::fmt::Display` for structs/enums. /// Derived implementation outputs empty string. /// Useful, as a way to formally satisfy `Display` trait bound. /// /// ## Syntax: /// /// For regular structs/enums: /// /// ``` /// enum MyEnum { /// ... /// } /// /// derive_display!(MyEnum)...
/// derive_display!(MyGenericStruct, T, U); /// ``` macro_rules! derive_display { (@fmt) => { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(f, "") } }; ($type:ident) => { impl ::std::fmt::Display for $type { derive_display!(@f...
/// ``` /// struct MyGenericStruct<T, U> { /// ... /// } ///
random_line_split
mod.rs
use std::error::Error; /// Derives `std::fmt::Display` for structs/enums. /// Derived implementation outputs empty string. /// Useful, as a way to formally satisfy `Display` trait bound. /// /// ## Syntax: /// /// For regular structs/enums: /// /// ``` /// enum MyEnum { /// ... /// } /// /// derive_display!(MyEnum)...
;
SimpleErr
identifier_name
mod.rs
// A battle in the game mod ai; mod commands; mod drawer; pub mod map; mod messages; mod networking; mod paths; mod responses; mod ui; pub mod units; use *; use self::drawer::*; use self::map::*; use self::networking::*; use self::paths::*; use self::ui::*; use self::units::*; use super::error::*; use context::*; u...
} } #[test] fn battle_operations() { let skirmish_settings = SkirmishSettings::default(); let settings = Settings::default(); let mut battle = Battle::new_from_settings(&skirmish_settings, settings).unwrap(); { let map = &battle.client.map; assert_eq!(map.side, Side::PlayerA); ...
{ self.client.end_turn(); }
conditional_block
mod.rs
// A battle in the game mod ai; mod commands; mod drawer; pub mod map; mod messages; mod networking; mod paths; mod responses; mod ui; pub mod units; use *; use self::drawer::*; use self::map::*; use self::networking::*; use self::paths::*; use self::ui::*; use self::units::*; use super::error::*; use context::*; u...
(&mut self, x: usize, y: usize) { match self.client.map.units.at(x, y) { Some(unit) => { self.path = None; if unit.side == self.client.side { self.selected = Some(unit.id); } else if let Some(selected) = self.selected { ...
perform_actions
identifier_name
mod.rs
// A battle in the game mod ai; mod commands; mod drawer; pub mod map; mod messages; mod networking; mod paths; mod responses; mod ui; pub mod units; use *; use self::drawer::*; use self::map::*; use self::networking::*; use self::paths::*; use self::ui::*; use self::units::*; use super::error::*; use context::*; u...
assert!(map .units .iter() .filter(|unit| unit.side == Side::PlayerA) .all(|unit| unit.tag == skirmish_settings.player_a_unit_type)); } // The first unit should be a player unit at (0, 0) let unit = battle.client.map.units.get_mut(0).unwrap(); asser...
random_line_split
lib.rs
// DO NOT EDIT! // This file was generated automatically from'src/mako/api/lib.rs.mako' // DO NOT EDIT! //! This documentation was generated from *Ad Exchange Seller* crate version *0.1.8+20150617*, where *20150617* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplate...
//! //! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of //! the doit() methods, or handed as possibly intermediate results to either the //! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../yup-oauth2/trait.AuthenticatorDelegat...
//! Ok(res) => println!("Success: {:?}", res), //! } //! # } //! ``` //! ## Handling Errors
random_line_split
foreign_keys.rs
#![allow(clippy::expect_fun_call)] // My calls are so fun use super::data_structures::ForeignKeyConstraint; use super::inference::get_primary_keys; use super::table_data::TableName; use crate::database::InferConnection; pub fn remove_unsafe_foreign_keys_for_codegen( database_url: &str, foreign_keys: &[Foreign...
.filter(|fk| safe_tables.contains(&fk.child_table)) .filter(|fk| { let pk_columns = get_primary_keys(&conn, &fk.parent_table).expect(&format!( "Error loading primary keys for `{}`", fk.parent_table )); pk_columns.len() == 1 && pk_columns[...
{ let conn = InferConnection::establish(database_url) .expect(&format!("Could not connect to `{}`", database_url)); let duplicates = foreign_keys .iter() .map(ForeignKeyConstraint::ordered_tables) .filter(|tables| { let dup_count = foreign_keys .iter(...
identifier_body
foreign_keys.rs
#![allow(clippy::expect_fun_call)] // My calls are so fun use super::data_structures::ForeignKeyConstraint; use super::inference::get_primary_keys; use super::table_data::TableName; use crate::database::InferConnection; pub fn
( database_url: &str, foreign_keys: &[ForeignKeyConstraint], safe_tables: &[TableName], ) -> Vec<ForeignKeyConstraint> { let conn = InferConnection::establish(database_url) .expect(&format!("Could not connect to `{}`", database_url)); let duplicates = foreign_keys .iter() .map(...
remove_unsafe_foreign_keys_for_codegen
identifier_name
foreign_keys.rs
#![allow(clippy::expect_fun_call)] // My calls are so fun
pub fn remove_unsafe_foreign_keys_for_codegen( database_url: &str, foreign_keys: &[ForeignKeyConstraint], safe_tables: &[TableName], ) -> Vec<ForeignKeyConstraint> { let conn = InferConnection::establish(database_url) .expect(&format!("Could not connect to `{}`", database_url)); let duplica...
use super::data_structures::ForeignKeyConstraint; use super::inference::get_primary_keys; use super::table_data::TableName; use crate::database::InferConnection;
random_line_split
parser.rs
use std::io::{Read, BufReader, Cursor}; use FromCursor; use compression::Compression; use frame::frame_response::ResponseBody; use super::*; use types::{from_bytes, from_u16_bytes, UUID_LEN, CStringList}; use types::data_serialization_types::decode_timeuuid; use error; pub fn parse_frame(r: &mut Read, compressor: &Co...
let mut body_bytes = Vec::with_capacity(length); unsafe { body_bytes.set_len(length); } try!(cursor.read_exact(&mut body_bytes)); let full_body = if flags.iter().any(|flag| flag == &Flag::Compression) { try!(compressor.decode(body_bytes)) } else { try!(Compression::Non...
let length = from_bytes(length_bytes.to_vec().as_slice()) as usize;
random_line_split
parser.rs
use std::io::{Read, BufReader, Cursor}; use FromCursor; use compression::Compression; use frame::frame_response::ResponseBody; use super::*; use types::{from_bytes, from_u16_bytes, UUID_LEN, CStringList}; use types::data_serialization_types::decode_timeuuid; use error; pub fn parse_frame(r: &mut Read, compressor: &Co...
(frame: Frame) -> error::Result<Frame> { match frame.opcode { Opcode::Error => { frame.get_body().and_then(|err| match err { ResponseBody::Error(err) => { Err(error::Error::Server(err)) ...
convert_frame_into_result
identifier_name
parser.rs
use std::io::{Read, BufReader, Cursor}; use FromCursor; use compression::Compression; use frame::frame_response::ResponseBody; use super::*; use types::{from_bytes, from_u16_bytes, UUID_LEN, CStringList}; use types::data_serialization_types::decode_timeuuid; use error; pub fn parse_frame(r: &mut Read, compressor: &Co...
{ match frame.opcode { Opcode::Error => { frame.get_body().and_then(|err| match err { ResponseBody::Error(err) => { Err(error::Error::Server(err)) } ...
identifier_body
commands.rs
<R: AsyncReadExt + Unpin>( mut server: R, ) -> Result<ServerStartup> { // This is an async equivalent of ServerConnection::read_one_response let mut bytes = [0u8; 4]; server.read_exact(&mut bytes[..]).await?; let len = BigEndian::read_u32(&bytes); let mut data = vec![0; len as usize]; serve...
read_server_startup_status
identifier_name
commands.rs
let tempdir = tempfile::Builder::new().prefix("sccache").tempdir()?; let socket_path = tempdir.path().join("sock"); let runtime = Runtime::new()?; let exe_path = env::current_exe()?; let workdir = exe_path.parent().expect("executable path has no parent?!"); let _child = process::Command::new(&exe_p...
}) } #[cfg(not(windows))] fn redirect_stderr(f: File) { use libc::dup2; use std::os::unix::io::IntoRawFd; // Ignore errors here. unsafe { dup2(f.into_raw_fd(), 2); } } #[cfg(windows)] fn redirect_stderr(f: File) { use std::os::windows::io::IntoRawHandle; use winapi::um::process...
runtime.block_on(async move { match tokio::time::timeout(timeout, startup).await { Ok(result) => result, Err(_elapsed) => Ok(ServerStartup::TimedOut), }
random_line_split
commands.rs
tempdir = tempfile::Builder::new().prefix("sccache").tempdir()?; let socket_path = tempdir.path().join("sock"); let runtime = Runtime::new()?; let exe_path = env::current_exe()?; let workdir = exe_path.parent().expect("executable path has no parent?!"); let _child = process::Command::new(&exe_path)...
/// If `SCCACHE_ERROR_LOG` is set, redirect stderr to it. fn redirect_error_log() -> Result<()> { let name = match env::var("SCCACHE_ERROR_LOG") { Ok(filename) if!filename.is_empty() => filename, _ => return Ok(()), }; let f = OpenOptions::new().create(true).append(true).open(name)?; r...
{ use std::os::windows::io::IntoRawHandle; use winapi::um::processenv::SetStdHandle; use winapi::um::winbase::STD_ERROR_HANDLE; // Ignore errors here. unsafe { SetStdHandle(STD_ERROR_HANDLE, f.into_raw_handle()); } }
identifier_body
commands.rs
tempdir = tempfile::Builder::new().prefix("sccache").tempdir()?; let socket_path = tempdir.path().join("sock"); let runtime = Runtime::new()?; let exe_path = env::current_exe()?; let workdir = exe_path.parent().expect("executable path has no parent?!"); let _child = process::Command::new(&exe_path)...
else { bail!("Unexpected response from server") } } /// Return the signal that caused a process to exit from `status`. #[cfg(unix)] #[allow(dead_code)] fn status_signal(status: process::ExitStatus) -> Option<i32> { status.signal() } /// Not implemented for non-Unix. #[cfg(not(unix))] #[allow(dead_cod...
{ Ok(response) }
conditional_block
psrldq.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*;
use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn psrldq_1() { run_test(&Instruction { mnemonic: Mnemonic::PSRLDQ, operand1: Some(Direct(XMM3)), operand2: Some(Literal8(24)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, br...
random_line_split
psrldq.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn psrldq_1() { run_test(&Instruction { mnemonic: Mnemonic::PSRLDQ, operand1: Some(Direct(XMM3)), operand2: Some(Literal8(...
() { run_test(&Instruction { mnemonic: Mnemonic::PSRLDQ, operand1: Some(Direct(XMM6)), operand2: Some(Literal8(34)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 115, 222, 34], OperandSize::Qword) }
psrldq_2
identifier_name
psrldq.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn psrldq_1() { run_test(&Instruction { mnemonic: Mnemonic::PSRLDQ, operand1: Some(Direct(XMM3)), operand2: Some(Literal8(...
{ run_test(&Instruction { mnemonic: Mnemonic::PSRLDQ, operand1: Some(Direct(XMM6)), operand2: Some(Literal8(34)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 115, 222, 34], OperandSize::Qword) }
identifier_body
shadowed-argument.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...
fn a_function(x: bool, y: bool) { zzz(); // #break sentinel(); let x = 10; zzz(); // #break sentinel(); let x = 10.5f64; let y = 20; zzz(); // #break sentinel(); } fn main() { a_function(false, true); } fn zzz() {()} fn sentinel() {()}
// lldb-command:continue #![omit_gdb_pretty_printer_section]
random_line_split
shadowed-argument.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...
(x: bool, y: bool) { zzz(); // #break sentinel(); let x = 10; zzz(); // #break sentinel(); let x = 10.5f64; let y = 20; zzz(); // #break sentinel(); } fn main() { a_function(false, true); } fn zzz() {()} fn sentinel() {()}
a_function
identifier_name
shadowed-argument.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...
fn sentinel() {()}
{()}
identifier_body