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
counter.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::sync::atom...
() -> Arc<Self> { Arc::new(Self::default()) } } impl Default for StdCounter { fn default() -> Self { StdCounter { value: AtomicUsize::new(0) } } } #[cfg(test)] mod test { use super::*; #[test] fn a_counting_counter() { let c = StdCounter::new(); c.add(1); ...
new
identifier_name
counter.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::sync::atom...
fn inc(&self) { self.value.fetch_add(1, Ordering::Relaxed); } fn add(&self, value: usize) { self.value.fetch_add(value, Ordering::Relaxed); } fn snapshot(&self) -> CounterSnapshot { CounterSnapshot { value: self.value.load(Ordering::Relaxed) } } } impl StdCounter { ...
{ self.value.store(0, Ordering::Relaxed); }
identifier_body
cpu.rs
use opcode::Opcode; use keypad::Keypad; use display::Display; use util; pub struct Cpu { pub memory: [u8; 4096], pub v: [u8; 16], pub i: usize, pub pc: usize, pub gfx: [u8; 64 * 32], pub delay_timer: u8, pub sound_timer: u8, pub stack: [u16; 16], pub sp: usize,
fn not_implemented(op: usize, pc: usize) { println!("Not implemented:: op: {:x}, pc: {:x}", op, pc); } impl Cpu { pub fn new() -> Cpu { let mut cpu: Cpu = Cpu { v: [0; 16], gfx: [0; 64 * 32], delay_timer: 0, sound_timer: 0, stack: [0; 16], ...
pub keypad: Keypad, pub display: Display, }
random_line_split
cpu.rs
use opcode::Opcode; use keypad::Keypad; use display::Display; use util; pub struct Cpu { pub memory: [u8; 4096], pub v: [u8; 16], pub i: usize, pub pc: usize, pub gfx: [u8; 64 * 32], pub delay_timer: u8, pub sound_timer: u8, pub stack: [u16; 16], pub sp: usize, pub keypad: Keypa...
pub fn return_from_subroutine(&mut self) { // 00EE - RTS // Return from subroutine. Pop the current value in the stack pointer // off of the stack, and set the program counter to the value popped. // self.registers['sp'] -= 1 // self.registers['pc'] = self.memory[self.regis...
{ match opcode.code { 0x00E0 => { // CLS // clear screen self.display.clear(); } 0x00EE => self.return_from_subroutine(), _ => not_implemented(opcode.code as usize, self.pc), } }
identifier_body
cpu.rs
use opcode::Opcode; use keypad::Keypad; use display::Display; use util; pub struct Cpu { pub memory: [u8; 4096], pub v: [u8; 16], pub i: usize, pub pc: usize, pub gfx: [u8; 64 * 32], pub delay_timer: u8, pub sound_timer: u8, pub stack: [u16; 16], pub sp: usize, pub keypad: Keypa...
() -> Cpu { let mut cpu: Cpu = Cpu { v: [0; 16], gfx: [0; 64 * 32], delay_timer: 0, sound_timer: 0, stack: [0; 16], pc: 0x200, // Program counter starts at 0x200 i: 0, // Reset index register sp: 0, // Reset stack p...
new
identifier_name
h5f.rs
pub use self::H5F_scope_t::*; pub use self::H5F_close_degree_t::*; pub use self::H5F_mem_t::*; pub use self::H5F_libver_t::*; use libc::{c_int, c_uint, c_void, c_char, c_double, size_t, ssize_t}; use h5::{herr_t, hsize_t, htri_t, hssize_t, H5_ih_info_t}; use h5i::hid_t; use h5ac::H5AC_cache_config_t; /* these flags ...
H5FD_MEM_GHEAP = 4, H5FD_MEM_LHEAP = 5, H5FD_MEM_OHDR = 6, H5FD_MEM_NTYPES = 7, } #[repr(C)] #[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] pub enum H5F_libver_t { H5F_LIBVER_EARLIEST = 0, H5F_LIBVER_LATEST = 1, } pub const H5F_LIBVER_18: H5F_libver_t = H5F_LIBVER_LATEST; exte...
H5FD_MEM_NOLIST = -1, H5FD_MEM_DEFAULT = 0, H5FD_MEM_SUPER = 1, H5FD_MEM_BTREE = 2, H5FD_MEM_DRAW = 3,
random_line_split
h5f.rs
pub use self::H5F_scope_t::*; pub use self::H5F_close_degree_t::*; pub use self::H5F_mem_t::*; pub use self::H5F_libver_t::*; use libc::{c_int, c_uint, c_void, c_char, c_double, size_t, ssize_t}; use h5::{herr_t, hsize_t, htri_t, hssize_t, H5_ih_info_t}; use h5i::hid_t; use h5ac::H5AC_cache_config_t; /* these flags ...
{ H5F_SCOPE_LOCAL = 0, H5F_SCOPE_GLOBAL = 1, } #[repr(C)] #[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] pub enum H5F_close_degree_t { H5F_CLOSE_DEFAULT = 0, H5F_CLOSE_WEAK = 1, H5F_CLOSE_SEMI = 2, H5F_CLOSE_STRONG = 3, } #[repr(C)] #[derive(Copy, Clone)] pub struct H5F_info_t {...
H5F_scope_t
identifier_name
h5f.rs
pub use self::H5F_scope_t::*; pub use self::H5F_close_degree_t::*; pub use self::H5F_mem_t::*; pub use self::H5F_libver_t::*; use libc::{c_int, c_uint, c_void, c_char, c_double, size_t, ssize_t}; use h5::{herr_t, hsize_t, htri_t, hssize_t, H5_ih_info_t}; use h5i::hid_t; use h5ac::H5AC_cache_config_t; /* these flags ...
} #[repr(C)] #[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] pub enum H5F_mem_t { H5FD_MEM_NOLIST = -1, H5FD_MEM_DEFAULT = 0, H5FD_MEM_SUPER = 1, H5FD_MEM_BTREE = 2, H5FD_MEM_DRAW = 3, H5FD_MEM_GHEAP = 4, H5FD_MEM_LHEAP = 5, H5FD_MEM_OHDR = 6, H5FD_MEM_NTYPES =...
{ unsafe { ::std::mem::zeroed() } }
identifier_body
main.rs
extern crate capnp; extern crate capnp_rpc; use std::error::Error; use std::io; use capnp_rpc::{RpcSystem,twoparty,rpc_twoparty_capnp}; use capnp_rpc::capability::{InitRequest,LocalClient,WaitForContent}; use gj::{EventLoop,Promise,TaskReaper,TaskSet}; use gj::io::tcp; use freestack::identity3; pub fn accept_loop(...
let store = Rc::new(RefCell::new( kvstore::etcd::Etcd::new(etcd_url) .expect("Error connecting to etcd"))); let identity3_server = identity3::bootstrap_interface(store); EventLoop::top_level(move |wait_scope| { use std::net::ToSocketAddrs; let addr = try!(bind_addr.to_soc...
println!("Starting up"); let bind_addr = "localhost:1234"; let etcd_url = "http://localhost:2379";
random_line_split
main.rs
extern crate capnp; extern crate capnp_rpc; use std::error::Error; use std::io; use capnp_rpc::{RpcSystem,twoparty,rpc_twoparty_capnp}; use capnp_rpc::capability::{InitRequest,LocalClient,WaitForContent}; use gj::{EventLoop,Promise,TaskReaper,TaskSet}; use gj::io::tcp; use freestack::identity3; pub fn accept_loop(...
; impl TaskReaper<(), Box<Error>> for Reaper { fn task_failed(&mut self, error: Box<Error>) { // FIXME: log instead println!("Task failed: {}", error); } } fn main() { println!("Starting up"); let bind_addr = "localhost:1234"; let etcd_url = "http://localhost:2379"; let store ...
Reaper
identifier_name
rectangle.rs
use crate::factory::IFactory; use crate::geometry::IGeometry; use crate::resource::IResource; use std::mem::MaybeUninit; use com_wrapper::ComWrapper; use dcommon::Error; use math2d::Rectf; use winapi::shared::winerror::SUCCEEDED; use winapi::um::d2d1::{ID2D1Geometry, ID2D1RectangleGeometry, ID2D1Resource}; use wio::c...
impl RectangleGeometry { pub fn create(factory: &dyn IFactory, rectangle: &Rectf) -> Result<RectangleGeometry, Error> { unsafe { let mut ptr = std::ptr::null_mut(); let hr = factory .raw_f() .CreateRectangleGeometry(rectangle as *const _ as *const _, &m...
}
random_line_split
rectangle.rs
use crate::factory::IFactory; use crate::geometry::IGeometry; use crate::resource::IResource; use std::mem::MaybeUninit; use com_wrapper::ComWrapper; use dcommon::Error; use math2d::Rectf; use winapi::shared::winerror::SUCCEEDED; use winapi::um::d2d1::{ID2D1Geometry, ID2D1RectangleGeometry, ID2D1Resource}; use wio::c...
{ ptr: ComPtr<ID2D1RectangleGeometry>, } impl RectangleGeometry { pub fn create(factory: &dyn IFactory, rectangle: &Rectf) -> Result<RectangleGeometry, Error> { unsafe { let mut ptr = std::ptr::null_mut(); let hr = factory .raw_f() .CreateRectangle...
RectangleGeometry
identifier_name
rectangle.rs
use crate::factory::IFactory; use crate::geometry::IGeometry; use crate::resource::IResource; use std::mem::MaybeUninit; use com_wrapper::ComWrapper; use dcommon::Error; use math2d::Rectf; use winapi::shared::winerror::SUCCEEDED; use winapi::um::d2d1::{ID2D1Geometry, ID2D1RectangleGeometry, ID2D1Resource}; use wio::c...
} unsafe impl super::GeometryType for RectangleGeometry {}
{ &self.ptr }
identifier_body
rectangle.rs
use crate::factory::IFactory; use crate::geometry::IGeometry; use crate::resource::IResource; use std::mem::MaybeUninit; use com_wrapper::ComWrapper; use dcommon::Error; use math2d::Rectf; use winapi::shared::winerror::SUCCEEDED; use winapi::um::d2d1::{ID2D1Geometry, ID2D1RectangleGeometry, ID2D1Resource}; use wio::c...
} } pub fn rect(&self) -> Rectf { unsafe { let mut rect = MaybeUninit::uninit(); self.ptr.GetRect(rect.as_mut_ptr()); rect.assume_init().into() } } } unsafe impl IResource for RectangleGeometry { unsafe fn raw_resource(&self) -> &ID2D1Resour...
{ Err(hr.into()) }
conditional_block
pipe.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 ...
pub fn raw(&self) -> libc::HANDLE { self.inner.raw() } pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { self.inner.read(buf) } pub fn write(&self, buf: &[u8]) -> io::Result<usize> { self.inner.write(buf) } }
{ self.inner }
identifier_body
pipe.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 ...
(&self, buf: &[u8]) -> io::Result<usize> { self.inner.write(buf) } }
write
identifier_name
pipe.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 ...
})); let reader = Handle::new(reader); let writer = Handle::new(writer); Ok((AnonPipe { inner: reader }, AnonPipe { inner: writer })) } impl AnonPipe { pub fn handle(&self) -> &Handle { &self.inner } pub fn into_handle(self) -> Handle { self.inner } pub fn raw(&self) -> libc::HANDLE { self...
c::CreatePipe(&mut reader, &mut writer, 0 as *mut _, 0)
random_line_split
msgsend-pipes-shared.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 ...
enum request { get_count, bytes(uint), stop } fn server(requests: &Receiver<request>, responses: &Sender<uint>) { let mut count = 0u; let mut done = false; while!done { match requests.recv_opt() { Ok(get_count) => { responses.send(count.clone()); } Ok(bytes(b)) => ...
{}
identifier_body
msgsend-pipes-shared.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 ...
else if args.len() <= 1u { vec!("".to_string(), "10000".to_string(), "4".to_string()) } else { args.move_iter().map(|x| x.to_string()).collect() }; println!("{}", args); run(args.as_slice()); }
{ vec!("".to_string(), "1000000".to_string(), "10000".to_string()) }
conditional_block
msgsend-pipes-shared.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 ...
Ok(get_count) => { responses.send(count.clone()); } Ok(bytes(b)) => { //println!("server: received {:?} bytes", b); count += b; } Err(..) => { done = true; } _ => { } } } responses.send(count); //println!("server exiting"); } ...
random_line_split
msgsend-pipes-shared.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) {} enum request { get_count, bytes(uint), stop } fn server(requests: &Receiver<request>, responses: &Sender<uint>) { let mut count = 0u; let mut done = false; while!done { match requests.recv_opt() { Ok(get_count) => { responses.send(count.clone()); } Ok(...
move_out
identifier_name
contain.rs
use matchers::matcher::Matcher; pub struct Contain<T: PartialEq> { value: T, file_line: (&'static str, u32) } impl <T: PartialEq> Matcher<Vec<T>> for Contain<T> { fn assert_check(&self, expected: Vec<T>) -> bool { expected.contains(&self.value) } #[allow(unused_variables)] fn msg(&self, e...
} pub fn contain<T: PartialEq>(value: T, file_line: (&'static str, u32)) -> Box<Contain<T>> { Box::new(Contain { value: value, file_line: file_line }) } #[macro_export] macro_rules! contain( ($value:expr) => ( contain($value.clone(), (file!(), expand_line!())) ); );
{ self.file_line }
identifier_body
contain.rs
use matchers::matcher::Matcher; pub struct Contain<T: PartialEq> {
file_line: (&'static str, u32) } impl <T: PartialEq> Matcher<Vec<T>> for Contain<T> { fn assert_check(&self, expected: Vec<T>) -> bool { expected.contains(&self.value) } #[allow(unused_variables)] fn msg(&self, expected: Vec<T>) -> String { format!("Expected {} to contain {} but it did...
value: T,
random_line_split
contain.rs
use matchers::matcher::Matcher; pub struct Contain<T: PartialEq> { value: T, file_line: (&'static str, u32) } impl <T: PartialEq> Matcher<Vec<T>> for Contain<T> { fn assert_check(&self, expected: Vec<T>) -> bool { expected.contains(&self.value) } #[allow(unused_variables)] fn msg(&self, e...
(&self) -> (&'static str, u32) { self.file_line } } pub fn contain<T: PartialEq>(value: T, file_line: (&'static str, u32)) -> Box<Contain<T>> { Box::new(Contain { value: value, file_line: file_line }) } #[macro_export] macro_rules! contain( ($value:expr) => ( contain($value.clone(), (file!...
get_file_line
identifier_name
mod.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 ...
} impl<'tcx> ObligationCause<'tcx> { pub fn new(span: Span, body_id: ast::NodeId, code: ObligationCauseCode<'tcx>) -> ObligationCause<'tcx> { ObligationCause { span: span, body_id: body_id, code: code } } pub fn misc(span: Span, body_id: ast::NodeId) -...
{ Obligation { cause: self.cause.clone(), recursion_depth: self.recursion_depth, predicate: value } }
identifier_body
mod.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 ...
pub use self::util::Supertraits; pub use self::util::supertrait_def_ids; pub use self::util::SupertraitDefIds; pub use self::util::transitive_bounds; pub use self::util::upcast; mod coherence; mod error_reporting; mod fulfill; mod project; mod object_safety; mod select; mod util; /// An `Obligation` represents some t...
pub use self::util::elaborate_predicates; pub use self::util::get_vtable_index_of_object_method; pub use self::util::trait_ref_for_builtin_bound; pub use self::util::predicate_for_trait_def; pub use self::util::supertraits;
random_line_split
mod.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,T>(infcx: &InferCtxt<'a,'tcx>, cause: ObligationCause<'tcx>, value: &T) -> Result<T, Vec<FulfillmentError<'tcx>>> where T : TypeFoldable<'tcx> + HasTypeFlags { debug!("normalize_param_env(value={:?})",...
fully_normalize
identifier_name
test_utils.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Internal module containing convenience utility functions mainly for testing use crate::traits::Uniform; use serde::{Deserialize, Serialize}; /// A deterministic seed for PRNGs related to keys pub const TEST_SEED: [u8; 32] = [0u8; ...
let name = crate::_serde_name::trace_name::<TestDiemCrypto>() .expect("The `CryptoHasher` macro only applies to structs and enums.") .as_bytes(); crate::hash::DefaultHasher::prefixed_hash(&name) }) } fn update(&mut self, bytes: &[u8]) { self....
TEST_DIEM_CRYPTO_SEED.get_or_init(|| {
random_line_split
test_utils.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Internal module containing convenience utility functions mainly for testing use crate::traits::Uniform; use serde::{Deserialize, Serialize}; /// A deterministic seed for PRNGs related to keys pub const TEST_SEED: [u8; 32] = [0u8; ...
} #[cfg(any(test, feature = "fuzzing"))] impl crate::hash::CryptoHash for TestDiemCrypto { type Hasher = TestDiemCryptoHasher; fn hash(&self) -> crate::hash::HashValue { use crate::hash::CryptoHasher; let mut state = Self::Hasher::default(); bcs::serialize_into(&mut state, &self) ...
{ Ok(()) }
identifier_body
test_utils.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Internal module containing convenience utility functions mainly for testing use crate::traits::Uniform; use serde::{Deserialize, Serialize}; /// A deterministic seed for PRNGs related to keys pub const TEST_SEED: [u8; 32] = [0u8; ...
(pub String); // the following block is macro expanded from derive(CryptoHasher, BCSCryptoHash) /// Cryptographic hasher for an BCS-serializable #item #[cfg(any(test, feature = "fuzzing"))] pub struct TestDiemCryptoHasher(crate::hash::DefaultHasher); #[cfg(any(test, feature = "fuzzing"))] impl ::core::clone::Clone fo...
TestDiemCrypto
identifier_name
overloaded_deref_with_ref_pattern.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 ...
}; // Check that mutable ref binding in let picks DerefMut let mut y = DerefMutOk(1); let ref mut z = *y; // Check that immutable ref binding in match picks Deref let mut b = DerefOk(2); match *b { ref n => n, }; // Check that immutable ref binding in let picks Deref l...
ref mut n => n,
random_line_split
overloaded_deref_with_ref_pattern.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 ...
// Check that mixed mutable/immutable ref binding in match picks DerefMut let mut b = DerefMutOk((0, 9)); match *b { (ref mut n, ref m) => (n, m), }; let mut b = DerefMutOk((0, 9)); match *b { (ref n, ref mut m) => (n, m), }; // Check that mixed mutable/immutable ref b...
{ // Check that mutable ref binding in match picks DerefMut let mut b = DerefMutOk(0); match *b { ref mut n => n, }; // Check that mutable ref binding in let picks DerefMut let mut y = DerefMutOk(1); let ref mut z = *y; // Check that immutable ref binding in match picks Deref ...
identifier_body
overloaded_deref_with_ref_pattern.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 ...
(&self) -> &Self::Target { panic!() } } impl<T> DerefMut for DerefMutOk<T> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } fn main() { // Check that mutable ref binding in match picks DerefMut let mut b = DerefMutOk(0); match *b { ref mut n => n, };...
deref
identifier_name
graphical.rs
/******************************************************************************* * * kit/kernel/terminal/vga.rs * * vim:ft=rust:ts=4:sw=4:et:tw=80 * * Copyright (C) 2015-2021, Devyn Cairns * Redistribution of this file is permitted under the terms of the simplified * BSD license. See LICENSE for more informatio...
fn scroll(&mut self) { if self.fb.double_buffer_enabled() { let (x0, y0) = self.position_xy(1, 0); let (x1, y1) = self.position_xy(0, 0); // Move the contents of everything but the first row up one row self.fb.copy_within(x0, y0, x1, y1, sel...
{ self.render(ch, self.row, self.col, (self.native_fg, self.native_bg)); }
identifier_body
graphical.rs
/******************************************************************************* * * kit/kernel/terminal/vga.rs * * vim:ft=rust:ts=4:sw=4:et:tw=80 * * Copyright (C) 2015-2021, Devyn Cairns * Redistribution of this file is permitted under the terms of the simplified * BSD license. See LICENSE for more informatio...
let codepoint = read_u16(&unicode_table_buf[pos..]) as u32; pos += 2; if codepoint == PSF1_SEPARATOR { // End of sequences for this index break; } else if codepoint == PSF1_STARTSEQ && mod...
{ break 'eof; }
conditional_block
graphical.rs
/******************************************************************************* * * kit/kernel/terminal/vga.rs * * vim:ft=rust:ts=4:sw=4:et:tw=80 * * Copyright (C) 2015-2021, Devyn Cairns * Redistribution of this file is permitted under the terms of the simplified * BSD license. See LICENSE for more informatio...
fg: Color::White, bg: Color::Black, native_fg: 0, native_bg: 0, char_buf: CharStream::default(), fb, font, }; g.rows = g.fb.height()/g.font_h; g.cols = g.fb.width()/g.font_w; g.update_colors(); ...
cols: 0, font_w: font.char_width() + 1, font_h: font.char_height(),
random_line_split
graphical.rs
/******************************************************************************* * * kit/kernel/terminal/vga.rs * * vim:ft=rust:ts=4:sw=4:et:tw=80 * * Copyright (C) 2015-2021, Devyn Cairns * Redistribution of this file is permitted under the terms of the simplified * BSD license. See LICENSE for more informatio...
(&mut self, byte: u8, fg: Color, bg: Color, row: usize, col: usize) -> fmt::Result { // I think we should get rid of this method, it doesn't handle unicode properly self.render( char::fr...
put_raw_byte
identifier_name
hashset.rs
use containers::array::Array; use containers::list::List; use containers::reference::Ref; use containers::vector::Vector; use memory::page::Page; use memory::region::Region; #[derive(Copy, Clone)] pub struct HashSet<T: Hash<T> + Copy> { slots: Vector<Ref<List<Slot<T>>>>, } impl<T: Hash<T> + Copy> HashSet<T> { ...
false } } #[derive(Copy, Clone)] struct Slot<T: Copy> { value: T, hash_code: usize, } pub struct HashPrimeHelper {} // https://planetmath.org/goodhashtableprimes static HASH_PRIMES: &'static [usize] = &[ 3, 5, 11, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317, 196613...
}
random_line_split
hashset.rs
use containers::array::Array; use containers::list::List; use containers::reference::Ref; use containers::vector::Vector; use memory::page::Page; use memory::region::Region; #[derive(Copy, Clone)] pub struct HashSet<T: Hash<T> + Copy> { slots: Vector<Ref<List<Slot<T>>>>, } impl<T: Hash<T> + Copy> HashSet<T> { ...
(_pr: &Region, _rp: *mut Page, vector: Ref<Vector<T>>) -> Ref<HashSet<T>> { let _r = Region::create(_pr); let hash_size = HashPrimeHelper::get_prime(vector.length); let mut array: Ref<Array<Ref<List<Slot<T>>>>> = Ref::new(_r.page, Array::new()); for _ in 0..hash_size { array....
from_vector
identifier_name
hashset.rs
use containers::array::Array; use containers::list::List; use containers::reference::Ref; use containers::vector::Vector; use memory::page::Page; use memory::region::Region; #[derive(Copy, Clone)] pub struct HashSet<T: Hash<T> + Copy> { slots: Vector<Ref<List<Slot<T>>>>, } impl<T: Hash<T> + Copy> HashSet<T> { ...
fn is_prime(candidate: usize) -> bool { if (candidate & 1)!= 0 { let limit = (candidate as f64).sqrt() as usize; let mut divisor: usize = 3; while divisor <= limit { divisor += 2; if (candidate % divisor) == 0 { return...
{ for i in HASH_PRIMES { if *i >= size { return *i; } } let mut i = size | 1; while i < std::usize::MAX { if HashPrimeHelper::is_prime(i) { return i; } i += 2; } size }
identifier_body
hashset.rs
use containers::array::Array; use containers::list::List; use containers::reference::Ref; use containers::vector::Vector; use memory::page::Page; use memory::region::Region; #[derive(Copy, Clone)] pub struct HashSet<T: Hash<T> + Copy> { slots: Vector<Ref<List<Slot<T>>>>, } impl<T: Hash<T> + Copy> HashSet<T> { ...
} return true; } candidate == 2 } } pub trait Equal<T:?Sized = Self> { fn equals(&self, other: &T) -> bool; } pub trait Hash<T:?Sized = Self>: Equal<T> { fn hash(&self) -> usize; } // FNV-1a hash pub fn hash(data: *const u8, length: usize) -> usize { let byte...
{ return false; }
conditional_block
numeric-method-autoexport.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
pub fn main() { // ints // num assert_eq!(15i.add(6), 21); assert_eq!(15i8.add(6i8), 21i8); assert_eq!(15i16.add(6i16), 21i16); assert_eq!(15i32.add(6i32), 21i32); assert_eq!(15i64.add(6i64), 21i64); // uints // num assert_eq!(15u.add(6u), 21u); assert_eq!(15u8.add(6u8), 21u8); ...
random_line_split
numeric-method-autoexport.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { // ints // num assert_eq!(15i.add(6), 21); assert_eq!(15i8.add(6i8), 21i8); assert_eq!(15i16.add(6i16), 21i16); assert_eq!(15i32.add(6i32), 21i32); assert_eq!(15i64.add(6i64), 21i64); // uints // num assert_eq!(15u.add(6u), 21u); assert_eq!(15u8.add(6u8), 21u8); assert_eq!(...
main
identifier_name
numeric-method-autoexport.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
assert_eq!(10f64.to_int().unwrap(), 10); }
{ // ints // num assert_eq!(15i.add(6), 21); assert_eq!(15i8.add(6i8), 21i8); assert_eq!(15i16.add(6i16), 21i16); assert_eq!(15i32.add(6i32), 21i32); assert_eq!(15i64.add(6i64), 21i64); // uints // num assert_eq!(15u.add(6u), 21u); assert_eq!(15u8.add(6u8), 21u8); assert_eq!(15u...
identifier_body
explicit-self-generic.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 ...
impl<K,V> Copy for HashMap<K,V> {} fn linear_map<K,V>() -> HashMap<K,V> { HashMap::HashMap_(LM{ resize_at: 32, size: 0}) } impl<K,V> HashMap<K,V> { pub fn len(&mut self) -> uint { match *self { HashMap::HashMap_(l) => l.size } } } pub fn main() { let mut m...
impl Copy for LM {} enum HashMap<K,V> { HashMap_(LM) }
random_line_split
explicit-self-generic.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 ...
(&mut self) -> uint { match *self { HashMap::HashMap_(l) => l.size } } } pub fn main() { let mut m = box linear_map::<(),()>(); assert_eq!(m.len(), 0); }
len
identifier_name
explicit-self-generic.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub fn main() { let mut m = box linear_map::<(),()>(); assert_eq!(m.len(), 0); }
{ match *self { HashMap::HashMap_(l) => l.size } }
identifier_body
mod.rs
// Copyright 2015 Pierre Talbot (IRCAM) // 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...
pub type CStoreFD<VStore> = store::Store<VStore, events::FDEvent, reactors::IndexedDeps, schedulers::RelaxedFifo>;
random_line_split
fs.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...
fn local_dapps(dapps_path: &Path) -> Vec<LocalDapp> { let files = fs::read_dir(dapps_path); if let Err(e) = files { warn!(target: "dapps", "Unable to load local dapps from: {}. Reason: {:?}", dapps_path.display(), e); return vec![]; } let files = files.expect("Check is done earlier"); files.map(|dir| { let...
random_line_split
fs.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...
(name: String, path: PathBuf) -> LocalDapp { // try to get manifest file let info = read_manifest(&name, path.clone()); LocalDapp { id: name, path: path, info: info, } } /// Returns endpoints for Local Dapps found for given filesystem path. /// Scans the directory and collects `LocalPageEndpoints`. pub fn lo...
local_dapp
identifier_name
fs.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...
let files = files.expect("Check is done earlier"); files.map(|dir| { let entry = dir?; let file_type = entry.file_type()?; // skip files if file_type.is_file() { return Err(io::Error::new(io::ErrorKind::NotFound, "Not a file")); } // take directory name and path entry.file_name().into_str...
{ warn!(target: "dapps", "Unable to load local dapps from: {}. Reason: {:?}", dapps_path.display(), e); return vec![]; }
conditional_block
fs.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...
fn local_dapps(dapps_path: &Path) -> Vec<LocalDapp> { let files = fs::read_dir(dapps_path); if let Err(e) = files { warn!(target: "dapps", "Unable to load local dapps from: {}. Reason: {:?}", dapps_path.display(), e); return vec![]; } let files = files.expect("Check is done earlier"); files.map(|dir| { ...
{ let mut pages = Endpoints::new(); for dapp in local_dapps(dapps_path.as_ref()) { pages.insert( dapp.id, Box::new(LocalPageEndpoint::new(dapp.path, dapp.info, PageCache::Disabled, signer_address.clone())) ); } pages }
identifier_body
sha2.rs
self) -> (Self, Self); } impl ToBits for u64 { fn to_bits(self) -> (u64, u64) { return (self >> 61, self << 3); } } /// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric /// overflow. fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T { ...
{ buffer: [u8,..64], buffer_idx: uint, } impl FixedBuffer64 { /// Create a new FixedBuffer64 fn new() -> FixedBuffer64 { return FixedBuffer64 { buffer: [0u8,..64], buffer_idx: 0 }; } } impl FixedBuffer for FixedBuffer64 { fn input(&mut self, input: &[u8...
FixedBuffer64
identifier_name
sha2.rs
self) -> (Self, Self); } impl ToBits for u64 { fn to_bits(self) -> (u64, u64) { return (self >> 61, self << 3); } } /// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric /// overflow. fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T { ...
} // While we have at least a full buffer size chunk's worth of data, process that data // without copying it into the buffer while input.len() - i >= size { func(input.slice(i, i + size)); i += size; } // Copy any input data into the buffer. At...
{ copy_memory( self.buffer.mut_slice(self.buffer_idx, self.buffer_idx + input.len()), input); self.buffer_idx += input.len(); return; }
conditional_block
sha2.rs
(self) -> (Self, Self); } impl ToBits for u64 { fn to_bits(self) -> (u64, u64) { return (self >> 61, self << 3); } } /// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric /// overflow. fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T { ...
/// Get the number of bytes remaining in the buffer until it is full. fn remaining(&self) -> uint; /// Get the size of the buffer fn size(&self) -> uint; } /// A FixedBuffer of 64 bytes useful for implementing Sha256 which has a 64 byte blocksize. struct FixedBuffer64 { buffer: [u8,..64], buf...
fn full_buffer<'s>(&'s mut self) -> &'s [u8]; /// Get the current position of the buffer. fn position(&self) -> uint;
random_line_split
sha2.rs
self) -> (Self, Self); } impl ToBits for u64 { fn to_bits(self) -> (u64, u64) { return (self >> 61, self << 3); } } /// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric /// overflow. fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T { ...
fn sigma0(x: u32) -> u32 { ((x >> 7) | (x << 25)) ^ ((x >> 18) | (x << 14)) ^ (x >> 3) } fn sigma1(x: u32) -> u32 { ((x >> 17) | (x << 15)) ^ ((x >> 19) | (x << 13)) ^ (x >> 10) } let mut a = self.h0; let mut b = self.h1; let mut c = se...
{ ((x >> 6) | (x << 26)) ^ ((x >> 11) | (x << 21)) ^ ((x >> 25) | (x << 7)) }
identifier_body
config.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> { fold_item(self, item) } } pub fn strip_items<F>(krate: ast::Crate, in_cfg: F) -> ast::Crate where F: FnMut(&[ast::Attribute]) -> bool, { let mut ctxt = Context { in_cfg: in_cfg, }; ctxt.fold_crate(krate)...
{ fold::noop_fold_mac(mac, self) }
identifier_body
config.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
<F>(cx: &mut Context<F>, ast::ForeignMod {abi, items}: ast::ForeignMod) -> ast::ForeignMod where F: FnMut(&[ast::Attribute]) -> bool { ast::ForeignMod { abi: abi, items: items.into_iter() .filter_map(|a| filter_foreign_item(cx, a))...
fold_foreign_mod
identifier_name
config.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
_ => true } } fn fold_block<F>(cx: &mut Context<F>, b: P<ast::Block>) -> P<ast::Block> where F: FnMut(&[ast::Attribute]) -> bool { b.map(|ast::Block {id, stmts, expr, rules, span}| { let resulting_stmts: Vec<P<ast::Stmt>> = stmts.into_iter().filter(|a| retain_stmt(cx, &**a)).co...
{ match decl.node { ast::DeclItem(ref item) => { item_in_cfg(cx, &**item) } _ => true } }
conditional_block
config.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
node: ast::Variant_ { id: id, name: name, attrs: attrs, kind: match kind { ast::TupleVariantKind(..) => kind, ...
random_line_split
tests.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 range_ends_with_escape() { let re = regex!(r"([\[-\x{5d}])"); let ms = re.find_iter("[]").collect::<Vec<_>>(); assert_eq!(ms, vec![(0, 1), (1, 2)]); } #[test] fn empty_match_find_iter() { let re = regex!(r".*?"); let ms: Vec<_> = re.find_iter("abc").collect(); assert_eq!(ms, vec![(0, 0), (1,...
#[test]
random_line_split
tests.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 re = regex!(r"([\[-\x{5d}])"); let ms = re.find_iter("[]").collect::<Vec<_>>(); assert_eq!(ms, vec![(0, 1), (1, 2)]); } #[test] fn empty_match_find_iter() { let re = regex!(r".*?"); let ms: Vec<_> = re.find_iter("abc").collect(); assert_eq!(ms, vec![(0, 0), (1, 1), (2, 2), (3, 3)]); } ...
range_ends_with_escape
identifier_name
tests.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] fn range_ends_with_escape() { let re = regex!(r"([\[-\x{5d}])"); let ms = re.find_iter("[]").collect::<Vec<_>>(); assert_eq!(ms, vec![(0, 1), (1, 2)]); } #[test] fn empty_match_find_iter() { let re = regex!(r".*?"); let ms: Vec<_> = re.find_iter("abc").collect(); assert_eq!(ms, vec![(...
{ let re = regex!(r"([[-z])"); let ms = re.find_iter("[]").collect::<Vec<_>>(); assert_eq!(ms, vec![(0, 1), (1, 2)]); }
identifier_body
visit_ast.rs
//! The Rust AST Visitor. Extracts useful information and massages it into a form //! usable for `clean`. use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::Node; use rustc_middle::middle::privacy::AccessLevel; u...
(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> { // If the root is re-exported, terminate all recursion. let mut stack = FxHashSet::default(); stack.insert(hir::CRATE_HIR_ID); RustdocVisitor { cx, view_item_stack: stack, inlining: fal...
new
identifier_name
visit_ast.rs
//! The Rust AST Visitor. Extracts useful information and massages it into a form //! usable for `clean`. use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::Node; use rustc_middle::middle::privacy::AccessLevel; u...
// should be inlined even if it is also documented at the top level. let def_id = item.def_id.to_def_id(); let is_macro_2_0 =!macro_def.macro_rules; let nonexported =!self.cx.tcx.has_attr(def_id, sym::macro_export); if is_macro_2_0 || ...
// 2. This macro isn't marked with `#[macro_export]`, and thus isn't covered // by the case above. // 3. We're inlining, since a reexport where inlining has been requested
random_line_split
visit_ast.rs
//! The Rust AST Visitor. Extracts useful information and massages it into a form //! usable for `clean`. use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::Node; use rustc_middle::middle::privacy::AccessLevel; u...
let attrs = self.cx.tcx.hir().attrs(item.hir_id()); // If there was a private module in the current path then don't bother inlining // anything as it will probably be stripped anyway. if is_pub && self.inside_public_path { let please...
{ return; }
conditional_block
visit_ast.rs
//! The Rust AST Visitor. Extracts useful information and massages it into a form //! usable for `clean`. use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::Node; use rustc_middle::middle::privacy::AccessLevel; u...
// Also, is there some reason that this doesn't use the 'visit' // framework from syntax?. crate struct RustdocVisitor<'a, 'tcx> { cx: &'a mut core::DocContext<'tcx>, view_item_stack: FxHashSet<hir::HirId>, inlining: bool, /// Are the current module and all of its parents public? inside_public_pa...
{ while let Some(id) = tcx.hir().get_enclosing_scope(node) { node = id; if tcx.hir().attrs(node).lists(sym::doc).has_word(sym::hidden) { return true; } } false }
identifier_body
lib.rs
mod front_of_house; mod back_of_house; pub use crate::front_of_house::{hosting,serving}; pub use crate::back_of_house::{kitchen,special_services}; pub use crate::back_of_house::Appetizer::{Soup,Salad,NoApp}; pub use crate::back_of_house::Toast::{White,Wheat,Rye,SourDough}; pub use crate::back_of_house::Breakfast; pub...
() { println!(); hosting::add_to_waitlist("Dr. Strange"); hosting::seat_at_table(); serving::take_order(Rye, Soup); serving::serve_order(); special_services::fix_incorrect_order(); serving::take_payment(); println!(); hosting::add_to_waitlist("Mr. Bogus"); hosting::seat_at...
eat_at_restaurant
identifier_name
lib.rs
mod front_of_house; mod back_of_house; pub use crate::front_of_house::{hosting,serving}; pub use crate::back_of_house::{kitchen,special_services}; pub use crate::back_of_house::Appetizer::{Soup,Salad,NoApp}; pub use crate::back_of_house::Toast::{White,Wheat,Rye,SourDough}; pub use crate::back_of_house::Breakfast; pub...
hosting::seat_at_table(); serving::take_order(White, NoApp); serving::serve_order(); serving::take_payment(); special_services::call_bouncer(); println!(); hosting::add_to_waitlist("Miss Nami"); hosting::seat_at_table(); serving::take_order(SourDough, Salad); serving::serve...
serving::take_payment(); println!(); hosting::add_to_waitlist("Mr. Bogus");
random_line_split
lib.rs
mod front_of_house; mod back_of_house; pub use crate::front_of_house::{hosting,serving}; pub use crate::back_of_house::{kitchen,special_services}; pub use crate::back_of_house::Appetizer::{Soup,Salad,NoApp}; pub use crate::back_of_house::Toast::{White,Wheat,Rye,SourDough}; pub use crate::back_of_house::Breakfast; pub...
hosting::add_to_waitlist("Miss Nami"); hosting::seat_at_table(); serving::take_order(SourDough, Salad); serving::serve_order(); serving::take_payment(); }
{ println!(); hosting::add_to_waitlist("Dr. Strange"); hosting::seat_at_table(); serving::take_order(Rye, Soup); serving::serve_order(); special_services::fix_incorrect_order(); serving::take_payment(); println!(); hosting::add_to_waitlist("Mr. Bogus"); hosting::seat_at_ta...
identifier_body
kill.rs
use anyhow::Result; use pretty_assertions::assert_eq; use rstest::rstest; use pueue_lib::network::message::*; use pueue_lib::state::GroupStatus; use pueue_lib::task::*; use crate::fixtures::*; use crate::helper::*; #[rstest] #[case( Message::Kill(KillMessage { tasks: TaskSelection::All, children:...
( #[case] kill_message: Message, #[case] group_should_pause: bool, ) -> Result<()> { let daemon = daemon().await?; let shared = &daemon.settings.shared; // Add multiple tasks and start them immediately for _ in 0..3 { assert_success(add_task(shared, "sleep 60", true).await?); } ...
test_kill_tasks
identifier_name
kill.rs
use anyhow::Result; use pretty_assertions::assert_eq; use rstest::rstest; use pueue_lib::network::message::*; use pueue_lib::state::GroupStatus; use pueue_lib::task::*; use crate::fixtures::*; use crate::helper::*; #[rstest] #[case( Message::Kill(KillMessage { tasks: TaskSelection::All, children:...
/// /// If a whole group or everything is killed, the respective groups should also be paused! /// This is security measure to prevent unwanted task execution in an emergency. async fn test_kill_tasks( #[case] kill_message: Message, #[case] group_should_pause: bool, ) -> Result<()> { let daemon = daemon().a...
/// We test different ways of killing those tasks. /// - Via the --all flag, which just kills everything. /// - Via the --group flag, which just kills everything in the default group. /// - Via specific ids.
random_line_split
kill.rs
use anyhow::Result; use pretty_assertions::assert_eq; use rstest::rstest; use pueue_lib::network::message::*; use pueue_lib::state::GroupStatus; use pueue_lib::task::*; use crate::fixtures::*; use crate::helper::*; #[rstest] #[case( Message::Kill(KillMessage { tasks: TaskSelection::All, children:...
}) .await?; } // Groups should be paused in specific modes. if group_should_pause { let state = get_state(shared).await?; assert_eq!( state.groups.get(PUEUE_DEFAULT_GROUP).unwrap().status, GroupStatus::Paused ); } Ok(()) }
{ let daemon = daemon().await?; let shared = &daemon.settings.shared; // Add multiple tasks and start them immediately for _ in 0..3 { assert_success(add_task(shared, "sleep 60", true).await?); } // Wait until all tasks are running for id in 0..3 { wait_for_task_condition(sh...
identifier_body
kill.rs
use anyhow::Result; use pretty_assertions::assert_eq; use rstest::rstest; use pueue_lib::network::message::*; use pueue_lib::state::GroupStatus; use pueue_lib::task::*; use crate::fixtures::*; use crate::helper::*; #[rstest] #[case( Message::Kill(KillMessage { tasks: TaskSelection::All, children:...
Ok(()) }
{ let state = get_state(shared).await?; assert_eq!( state.groups.get(PUEUE_DEFAULT_GROUP).unwrap().status, GroupStatus::Paused ); }
conditional_block
tests.rs
use super::*; fn create_graph() -> VecGraph<usize>
#[test] fn num_nodes() { let graph = create_graph(); assert_eq!(graph.num_nodes(), 7); } #[test] fn successors() { let graph = create_graph(); assert_eq!(graph.successors(0), &[1]); assert_eq!(graph.successors(1), &[2, 3]); assert_eq!(graph.successors(2), &[]); assert_eq!(graph.successors...
{ // Create a simple graph // // 5 // | // V // 0 --> 1 --> 2 // | // v // 3 --> 4 // // 6 VecGraph::new(7, vec![(0, 1), (1, 2), (1, 3), (3, 4), (5, 1)]) }
identifier_body
tests.rs
use super::*; fn
() -> VecGraph<usize> { // Create a simple graph // // 5 // | // V // 0 --> 1 --> 2 // | // v // 3 --> 4 // // 6 VecGraph::new(7, vec![(0, 1), (1, 2), (1, 3), (3, 4), (5, 1)]) } #[test] fn num_nodes() { let...
create_graph
identifier_name
tests.rs
use super::*; fn create_graph() -> VecGraph<usize> { // Create a simple graph // // 5 // | // V // 0 --> 1 --> 2 // | // v // 3 --> 4 // // 6 VecGraph::new(7, vec![(0, 1), (1, 2), (1, 3), (3, 4), (5, 1)]) } #[...
assert_eq!(graph.successors(4), &[]); assert_eq!(graph.successors(5), &[1]); assert_eq!(graph.successors(6), &[]); } #[test] fn dfs() { let graph = create_graph(); let dfs: Vec<_> = graph.depth_first_search(0).collect(); assert_eq!(dfs, vec![0, 1, 3, 4, 2]); }
random_line_split
mod.rs
//! //! Metapackage to extend an interface to ai //! // // Ai behaviors are inherited from specific objects that have the AI trait // // How many times should AI randomly try stuff // Since there will probably be a lot of AI, and since each one might be doing stuff randomly, // the larger this gets, the more it imp...
(&self) -> Box<dyn AI> { self.box_clone() } }
clone
identifier_name
mod.rs
//! // // Ai behaviors are inherited from specific objects that have the AI trait // // How many times should AI randomly try stuff // Since there will probably be a lot of AI, and since each one might be doing stuff randomly, // the larger this gets, the more it impacts performance in the absolute worst case pub c...
//! //! Metapackage to extend an interface to ai
random_line_split
mod.rs
//! //! Metapackage to extend an interface to ai //! // // Ai behaviors are inherited from specific objects that have the AI trait // // How many times should AI randomly try stuff // Since there will probably be a lot of AI, and since each one might be doing stuff randomly, // the larger this gets, the more it imp...
/// /// Allow boxed trait objects to be cloned /// fn box_clone(&self) -> Box<dyn AI>; } /// /// Allow cloning of boxed trait objects via box_clone() /// /// https://users.rust-lang.org/t/solved-is-it-possible-to-clone-a-boxed-trait-object/1714 /// /// The downside is that all things that impl AI need to ...
{ // Check for below map (< 0) and above map (> map.width() - 1) x < 0 || y < 0 || y >= (map.height() - 1) as isize || x >= (map.width() - 1) as isize }
identifier_body
raw_block.rs
use Renderable; use Block; use context::Context; use LiquidOptions; use tags::RawBlock; use lexer::Token; use lexer::Element; use lexer::Element::{Expression, Tag, Raw}; #[cfg(test)] use std::default::Default;
struct RawT{ content : String } impl Renderable for RawT{ fn render(&self, _context: &mut Context) -> Option<String>{ Some(self.content.to_string()) } } impl Block for RawBlock{ fn initialize(&self, _tag_name: &str, _arguments: &[Token], tokens: Vec<Element>, _options : &LiquidOptions) -> Res...
random_line_split
raw_block.rs
use Renderable; use Block; use context::Context; use LiquidOptions; use tags::RawBlock; use lexer::Token; use lexer::Element; use lexer::Element::{Expression, Tag, Raw}; #[cfg(test)] use std::default::Default; struct RawT{ content : String } impl Renderable for RawT{ fn render(&self, _context: &mut Context) ...
(&self, _tag_name: &str, _arguments: &[Token], tokens: Vec<Element>, _options : &LiquidOptions) -> Result<Box<Renderable>, String>{ let content = tokens.iter().fold("".to_string(), |a, b| match b { &Expression(_, ref text) => ...
initialize
identifier_name
error.rs
//! Contains the different error codes that were in psm.h in the C version. pub enum Error { Ok, NoProgress, ParamError, NoMemory, NotIinitalized, BadApiVersion, NoAffinity, InternalError, ShmemSegmentError, OptReadOnly, Timeout, TooManyEps, Finalized, EpClosed, ...
{ "Unknown Error" }
identifier_body
error.rs
//! Contains the different error codes that were in psm.h in the C version. pub enum
{ Ok, NoProgress, ParamError, NoMemory, NotIinitalized, BadApiVersion, NoAffinity, InternalError, ShmemSegmentError, OptReadOnly, Timeout, TooManyEps, Finalized, EpClosed, NoDevice, UnitNotFound, DeviceFailure, CloseTimeout, NoPortsAvailable, ...
Error
identifier_name
error.rs
//! Contains the different error codes that were in psm.h in the C version. pub enum Error { Ok, NoProgress, ParamError, NoMemory, NotIinitalized, BadApiVersion, NoAffinity, InternalError, ShmemSegmentError, OptReadOnly, Timeout, TooManyEps, Finalized, EpClosed, ...
MqTruncation, AmInvalidReply, AlreadyInitialized, UnknownError } pub fn error_to_string(error: Error) -> &'static str { "Unknown Error" }
MqNoCompletions,
random_line_split
tmux.rs
use std::os::unix::fs::PermissionsExt; use std::os::unix::process::CommandExt; use std::path::{Path, PathBuf}; use std::process::{Command, Output}; use std::{env, fs, io}; use nix::unistd::Uid; use nmk::bin_name::{TMUX, ZSH}; use nmk::env_name::NMK_TMUX_VERSION; use nmk::tmux::config::Context; use nmk::tmux::version:...
else { "screen" }; Context { support_256_color: use_8bit_color, detach_on_destroy: cmd_opt.detach_on_destroy, default_term: default_term.to_owned(), default_shell: which::which(ZSH).expect("zsh not found"), } }
{ "screen-256color" }
conditional_block
tmux.rs
use std::os::unix::fs::PermissionsExt; use std::os::unix::process::CommandExt; use std::path::{Path, PathBuf}; use std::process::{Command, Output}; use std::{env, fs, io}; use nix::unistd::Uid; use nmk::bin_name::{TMUX, ZSH}; use nmk::env_name::NMK_TMUX_VERSION; use nmk::tmux::config::Context;
use crate::cmdline::CmdOpt; use crate::utils::print_usage_time; pub struct Tmux { pub bin: PathBuf, pub version: Version, } fn find_version() -> Result<Version, TmuxVersionError> { if let Ok(s) = std::env::var(NMK_TMUX_VERSION) { log::debug!("Using tmux version from environment variable"); ...
use nmk::tmux::version::{TmuxVersionError, Version};
random_line_split
tmux.rs
use std::os::unix::fs::PermissionsExt; use std::os::unix::process::CommandExt; use std::path::{Path, PathBuf}; use std::process::{Command, Output}; use std::{env, fs, io}; use nix::unistd::Uid; use nmk::bin_name::{TMUX, ZSH}; use nmk::env_name::NMK_TMUX_VERSION; use nmk::tmux::config::Context; use nmk::tmux::version:...
() -> io::Result<PathBuf> { let tmp_dir = env::temp_dir(); let nmk_tmp_dir = tmp_dir.join(format!("nmk-{}", Uid::current())); if!nmk_tmp_dir.exists() { fs::create_dir(&nmk_tmp_dir)?; let mut permissions = nmk_tmp_dir.metadata()?.permissions(); permissions.set_mode(0o700); fs:...
create_nmk_tmp_dir
identifier_name
infinite_iter.rs
use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use clippy_utils::{get_trait_def_id, higher, is_qpath_def_path, paths}; use rustc_hir::{BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_to...
{ Infinite, MaybeInfinite, Finite, } use self::Finiteness::{Finite, Infinite, MaybeInfinite}; impl Finiteness { #[must_use] fn and(self, b: Self) -> Self { match (self, b) { (Finite, _) | (_, Finite) => Finite, (MaybeInfinite, _) | (_, MaybeInfinite) => MaybeInfini...
Finiteness
identifier_name
infinite_iter.rs
use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use clippy_utils::{get_trait_def_id, higher, is_qpath_def_path, paths}; use rustc_hir::{BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_to...
else if method.ident.name == sym!(collect) { let ty = cx.typeck_results().expr_ty(expr); if INFINITE_COLLECTORS .iter() .any(|diag_item| is_type_diagnostic_item(cx, ty, *diag_item)) { return is_infinite(cx, &args[...
{ let not_double_ended = get_trait_def_id(cx, &paths::DOUBLE_ENDED_ITERATOR).map_or(false, |id| { !implements_trait(cx, cx.typeck_results().expr_ty(&args[0]), id, &[]) }); if not_double_ended { return is_infinite(cx, &args[0]); ...
conditional_block
infinite_iter.rs
use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use clippy_utils::{get_trait_def_id, higher, is_qpath_def_path, paths}; use rustc_hir::{BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_to...
("product", 1), ]; /// the paths of types that are known to be infinitely allocating const INFINITE_COLLECTORS: &[Symbol] = &[ sym::BinaryHeap, sym::BTreeMap, sym::BTreeSet, sym::hashmap_type, sym::hashset_type, sym::LinkedList, sym::vec_type, sym::vecdeque_type, ]; fn complete_inf...
("min_by_key", 2), ("sum", 1),
random_line_split
main.rs
#![feature(box_syntax)] extern crate e2d2; extern crate fnv; extern crate getopts; extern crate rand; extern crate time; use self::nf::*; use e2d2::config::{basic_opts, read_matches}; use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::*; use std::env; use std::fmt::Display; use std::process; use std::...
let args: Vec<String> = env::args().collect(); let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(f) => panic!(f.to_string()), }; let mut configuration = read_matches(&matches, &opts); configuration.pool_size = 512; // Travis allocates at most 512 hugepages. match ini...
random_line_split
main.rs
#![feature(box_syntax)] extern crate e2d2; extern crate fnv; extern crate getopts; extern crate rand; extern crate time; use self::nf::*; use e2d2::config::{basic_opts, read_matches}; use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::*; use std::env; use std::fmt::Display; use std::process; use std::...
<T, S>(ports: Vec<T>, sched: &mut S) where T: PacketRx + PacketTx + Display + Clone +'static, S: Scheduler + Sized, { println!("Receiving started"); let pipelines: Vec<_> = ports .iter() .map(|port| tcp_nf(ReceiveBatch::new(port.clone())).send(port.clone())) .collect(); println...
test
identifier_name
main.rs
#![feature(box_syntax)] extern crate e2d2; extern crate fnv; extern crate getopts; extern crate rand; extern crate time; use self::nf::*; use e2d2::config::{basic_opts, read_matches}; use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::*; use std::env; use std::fmt::Display; use std::process; use std::...
fn main() { let opts = basic_opts(); let args: Vec<String> = env::args().collect(); let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(f) => panic!(f.to_string()), }; let mut configuration = read_matches(&matches, &opts); configuration.pool_size = 512; // Travis allo...
{ println!("Receiving started"); let pipelines: Vec<_> = ports .iter() .map(|port| tcp_nf(ReceiveBatch::new(port.clone())).send(port.clone())) .collect(); println!("Running {} pipelines", pipelines.len()); for pipeline in pipelines { sched.add_task(pipeline).unwrap(); ...
identifier_body
main.rs
#![feature(box_syntax)] extern crate e2d2; extern crate fnv; extern crate getopts; extern crate rand; extern crate time; use self::nf::*; use e2d2::config::{basic_opts, read_matches}; use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::*; use std::env; use std::fmt::Display; use std::process; use std::...
} }
{ println!("Error: {}", e); if let Some(backtrace) = e.backtrace() { println!("Backtrace: {:?}", backtrace); } process::exit(1); }
conditional_block
take_until.rs
use consumer::*; use std::cell::Cell; use std::rc::Rc; use stream::*; /// Emit items until it receive an item from another stream. /// /// This struct is created by the /// [`take_until()`](./trait.Stream.html#method.take_until) method on /// [Stream](./trait.Stream.html). See its documentation for more. #[must_use = ...
(&mut self, item: T) -> bool { !self.is_closed.get() && self.consumer.emit(item) } } impl<S, T> Stream for TakeUntil<S, T> where S: Stream, T: Stream { type Item = S::Item; fn consume<C>(self, consumer: C) where C: Consumer<Self::Item> { let is_closed = Rc::new(Cel...
emit
identifier_name
take_until.rs
use consumer::*; use std::cell::Cell; use std::rc::Rc; use stream::*; /// Emit items until it receive an item from another stream. /// /// This struct is created by the /// [`take_until()`](./trait.Stream.html#method.take_until) method on /// [Stream](./trait.Stream.html). See its documentation for more. #[must_use = ...
} impl<S, T> Stream for TakeUntil<S, T> where S: Stream, T: Stream { type Item = S::Item; fn consume<C>(self, consumer: C) where C: Consumer<Self::Item> { let is_closed = Rc::new(Cell::new(false)); self.trigger.consume(TriggerConsumer { is_closed: is_closed.clone() ...
{ !self.is_closed.get() && self.consumer.emit(item) }
identifier_body
take_until.rs
use consumer::*; use std::cell::Cell; use std::rc::Rc; use stream::*; /// Emit items until it receive an item from another stream.
pub struct TakeUntil<S, T> { stream: S, trigger: T, } struct TakeUntilState<C> { consumer: C, is_closed: Rc<Cell<bool>>, } struct TriggerConsumer { is_closed: Rc<Cell<bool>>, } impl<T> Consumer<T> for TriggerConsumer { fn emit(&mut self, _: T) -> bool { self.is_closed.set(true); ...
/// /// This struct is created by the /// [`take_until()`](./trait.Stream.html#method.take_until) method on /// [Stream](./trait.Stream.html). See its documentation for more. #[must_use = "stream adaptors are lazy and do nothing unless consumed"]
random_line_split
orgs.rs
use clap::{App, Arg, ArgMatches, SubCommand}; use config; use git_hub::{GitHubResponse, orgs}; use serde_json; use serde_json::Error; pub fn SUBCOMMAND<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("orgs") .about("List, Get, Edit your GitHub Organizations") .version(version!()) ...
() -> () { let response = GitHubResponse { status: StatusCode::Forbidden, headers: Headers::new(), body: None }; assert_eq!(build_output(&response, false), FORBIDDEN); } #[test] fn test_build_output_unauthorized...
test_build_output_forbidden
identifier_name
orgs.rs
use clap::{App, Arg, ArgMatches, SubCommand}; use config; use git_hub::{GitHubResponse, orgs}; use serde_json; use serde_json::Error; pub fn SUBCOMMAND<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("orgs") .about("List, Get, Edit your GitHub Organizations") .version(version!()) ...
mod list { use clap::ArgMatches; use config::load_config; use evidence::json_ops; use git_hub::{GitHubResponse, orgs}; use hyper::status::StatusCode; use git_hub::orgs::OrgSummary; #[cfg(windows)] pub const NL: &'static str = "\r\n"; #[cfg(not(windows))] pub const NL: &'static str = "\n"; pub fn handle(ma...
(_, _) => unreachable!() } }
random_line_split