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
addressbook_send.rs
// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
() -> TypedReader<Builder<HeapAllocator>, address_book::Owned> { let mut message = Builder::new_default(); { let address_book = message.init_root::<address_book::Builder>(); let mut people = address_book.init_people(2); { let mut alice = people.rebor...
build_address_book
identifier_name
addressbook_send.rs
// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
{ let book = addressbook::build_address_book(); let (tx_book, rx_book) = mpsc::channel::<TypedReader<Builder<HeapAllocator>, addressbook_capnp::address_book::Owned>>(); let (tx_id, rx_id) = mpsc::channel::<u32>(); thread::spawn(move || { let addressbook_reader = rx_book.recv().unwrap(); ...
identifier_body
htmllielement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLLIElementBinding; use dom::bindings::js::Root; use dom::document::Docume...
{ htmlelement: HTMLElement, } impl HTMLLIElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLLIElement { HTMLLIElement { htmlelement: HTMLElement::new_inherited(localName, prefix, document) } } #[allow(unrooted_must_root)...
HTMLLIElement
identifier_name
htmllielement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLLIElementBinding; use dom::bindings::js::Root; use dom::document::Docume...
Node::reflect_node(box element, document, HTMLLIElementBinding::Wrap) } }
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> Root<HTMLLIElement> { let element = HTMLLIElement::new_inherited(localName, prefix, document);
random_line_split
htmllielement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLLIElementBinding; use dom::bindings::js::Root; use dom::document::Docume...
}
{ let element = HTMLLIElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLLIElementBinding::Wrap) }
identifier_body
trait-bounds-in-arc.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// option. This file may not be copied, modified, or distributed // except according to those terms. // Tests that a heterogeneous list of existential types can be put inside an Arc // and shared between tasks as long as all types fulfill Send. // ignore-pretty #![allow(unknown_features)] #![feature(box_syntax)] #![...
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
trait-bounds-in-arc.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...
(&self) -> bool { self.bark_decibels < 70 || self.tricks_known > 20 } } impl Pet for Goldfyshe { fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) } fn num_legs(&self) -> uint { 0 } fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } } pub fn main() { let catte...
of_good_pedigree
identifier_name
trait-bounds-in-arc.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...
let (tx1, rx1) = channel(); let arc1 = arc.clone(); let _t1 = Thread::spawn(move|| { check_legs(arc1); tx1.send(()); }); let (tx2, rx2) = channel(); let arc2 = arc.clone(); let _t2 = Thread::spawn(move|| { check_names(arc2); tx2.send(()); }); let (tx3, rx3) = channel(); let arc3 = arc.cl...
{ let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_string() }; let dogge1 = Dogge { bark_decibels: 100, tricks_known: 42, name: "alan_turing".to_string(), }; let dogge2 = Dogge { bark_decibels: 55, tricks_known: 11, name: "albert_einstein".to_...
identifier_body
check_txn_status.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use txn_types::{Key, Lock, TimeStamp, WriteType}; use crate::storage::{ mvcc::txn::MissingLockAction, mvcc::{ metrics::MVCC_CHECK_TXN_STATUS_COUNTER_VEC, ErrorInner, LockType, MvccTxn, ReleasedLock, Result, TxnCommitRecord, ...
<S: Snapshot>( txn: &mut MvccTxn<S>, primary_key: Key, mismatch_lock: Option<Lock>, action: MissingLockAction, resolving_pessimistic_lock: bool, ) -> Result<TxnStatus> { MVCC_CHECK_TXN_STATUS_COUNTER_VEC.get_commit_info.inc(); match txn .reader .get_txn_commit_record(&primary_...
check_txn_status_missing_lock
identifier_name
check_txn_status.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use txn_types::{Key, Lock, TimeStamp, WriteType}; use crate::storage::{ mvcc::txn::MissingLockAction, mvcc::{ metrics::MVCC_CHECK_TXN_STATUS_COUNTER_VEC, ErrorInner, LockType, MvccTxn, ReleasedLock, Result, TxnCommitRecord, ...
txn.put_lock(primary_key, &lock); MVCC_CHECK_TXN_STATUS_COUNTER_VEC.update_ts.inc(); } // As long as the primary lock's min_commit_ts > caller_start_ts, locks belong to the same transaction // can't block reading. Return MinCommitTsPushed result to the client to let it bypass locks. let...
if lock.min_commit_ts < current_ts { lock.min_commit_ts = current_ts; }
random_line_split
check_txn_status.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use txn_types::{Key, Lock, TimeStamp, WriteType}; use crate::storage::{ mvcc::txn::MissingLockAction, mvcc::{ metrics::MVCC_CHECK_TXN_STATUS_COUNTER_VEC, ErrorInner, LockType, MvccTxn, ReleasedLock, Result, TxnCommitRecord, ...
} .into()); } if resolving_pessimistic_lock { return Ok(TxnStatus::LockNotExistDoNothing); } let ts = txn.start_ts; // collapse previous rollback if exist. if txn.collapse_rollback { ...
{ MVCC_CHECK_TXN_STATUS_COUNTER_VEC.get_commit_info.inc(); match txn .reader .get_txn_commit_record(&primary_key, txn.start_ts)? { TxnCommitRecord::SingleRecord { commit_ts, write } => { if write.write_type == WriteType::Rollback { Ok(TxnStatus::RolledBac...
identifier_body
check_txn_status.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use txn_types::{Key, Lock, TimeStamp, WriteType}; use crate::storage::{ mvcc::txn::MissingLockAction, mvcc::{ metrics::MVCC_CHECK_TXN_STATUS_COUNTER_VEC, ErrorInner, LockType, MvccTxn, ReleasedLock, Result, TxnCommitRecord, ...
let ts = txn.start_ts; // collapse previous rollback if exist. if txn.collapse_rollback { txn.collapse_prev_rollback(primary_key.clone())?; } if let (Some(l), None) = (mismatch_lock, overlapped_write.as_ref()) { txn.mark_rol...
{ return Ok(TxnStatus::LockNotExistDoNothing); }
conditional_block
scene.rs
//! The Scene system is basically for transitioning between //! *completely* different states that have entirely different game //! loops and but which all share a state. It operates as a stack, with new //! scenes getting pushed to the stack (while the old ones stay in //! memory unchanged). Apparently this is basic...
} #[cfg(test)] mod tests { use super::*; struct Thing { scenes: Vec<SceneStack<u32, u32>>, } #[test] fn test1() { let x = Thing { scenes: vec![] }; } }
{ let current_scene = &mut **self .scenes .last_mut() .expect("Tried to do input for empty scene stack"); current_scene.input(&mut self.world, event, started); }
identifier_body
scene.rs
//! The Scene system is basically for transitioning between //! *completely* different states that have entirely different game //! loops and but which all share a state. It operates as a stack, with new //! scenes getting pushed to the stack (while the old ones stay in //! memory unchanged). Apparently this is basic...
} } // These functions must be on the SceneStack because otherwise // if you try to get the current scene and the world to call // update() on the current scene it causes a double-borrow. :/ pub fn update(&mut self, ctx: &mut ggez::Context) { let next_scene = { let cur...
{ let old_scene = self.pop(); self.push(s); Some(old_scene) }
conditional_block
scene.rs
//! The Scene system is basically for transitioning between //! *completely* different states that have entirely different game //! loops and but which all share a state. It operates as a stack, with new //! scenes getting pushed to the stack (while the old ones stay in //! memory unchanged). Apparently this is basic...
pub fn push<S>(scene: S) -> Self where S: Scene<C, Ev> +'static, { SceneSwitch::Push(Box::new(scene)) } } /// A stack of `Scene`'s, together with a context object. pub struct SceneStack<C, Ev> { pub world: C, scenes: Vec<Box<Scene<C, Ev>>>, } impl<C, Ev> SceneStack<C, Ev> { ...
{ SceneSwitch::Replace(Box::new(scene)) } /// Same as `replace()` but returns SceneSwitch::Push
random_line_split
scene.rs
//! The Scene system is basically for transitioning between //! *completely* different states that have entirely different game //! loops and but which all share a state. It operates as a stack, with new //! scenes getting pushed to the stack (while the old ones stay in //! memory unchanged). Apparently this is basic...
(&mut self, next_scene: SceneSwitch<C, Ev>) -> Option<Box<Scene<C, Ev>>> { match next_scene { SceneSwitch::None => None, SceneSwitch::Pop => { let s = self.pop(); Some(s) } SceneSwitch::Push(s) => { self.push(s); ...
switch
identifier_name
treiber.rs
//! Treiber stacks. use std::sync::atomic::{self, AtomicPtr}; use std::marker::PhantomData; use std::ptr; use {Guard, add_garbage_box}; /// A Treiber stack. /// /// Treiber stacks are one way to implement concurrent LIFO stack. /// /// Treiber stacks builds on linked lists. They are lock-free and non-blocking. It can...
for i in j { i.join().unwrap(); } assert_eq!(*stack.pop().unwrap(), 16 * 1000 * 1001 / 2); } #[test] fn sum() { let stack = Arc::new(Treiber::<i64>::new()); let mut j = Vec::new(); for _ in 0..1000 { stack.push(10); } ...
{ let stack = Arc::new(Treiber::<u64>::new()); stack.push(0); let mut j = Vec::new(); // 16 times, we add the numbers from 0 to 1000 to the only element in the stack. for _ in 0..16 { let s = stack.clone(); j.push(thread::spawn(move || { f...
identifier_body
treiber.rs
//! Treiber stacks. use std::sync::atomic::{self, AtomicPtr}; use std::marker::PhantomData; use std::ptr; use {Guard, add_garbage_box}; /// A Treiber stack. /// /// Treiber stacks are one way to implement concurrent LIFO stack. /// /// Treiber stacks builds on linked lists. They are lock-free and non-blocking. It can...
stack.push(200); stack.push(44); assert_eq!(*stack.pop().unwrap(), 44); assert_eq!(*stack.pop().unwrap(), 200); assert_eq!(*stack.pop().unwrap(), 1); assert!(stack.pop().is_none()); ::gc(); } #[test] fn simple2() { let stack = Treiber::new()...
#[test] fn simple1() { let stack = Treiber::new(); stack.push(1);
random_line_split
treiber.rs
//! Treiber stacks. use std::sync::atomic::{self, AtomicPtr}; use std::marker::PhantomData; use std::ptr; use {Guard, add_garbage_box}; /// A Treiber stack. /// /// Treiber stacks are one way to implement concurrent LIFO stack. /// /// Treiber stacks builds on linked lists. They are lock-free and non-blocking. It can...
() { let stack = Arc::new(Treiber::new()); let mut j = Vec::new(); for _ in 0..16 { let s = stack.clone(); j.push(thread::spawn(move || { for _ in 0..1_000_000 { s.push(23); assert_eq!(*s.pop().unwrap(), 23); ...
push_pop
identifier_name
treiber.rs
//! Treiber stacks. use std::sync::atomic::{self, AtomicPtr}; use std::marker::PhantomData; use std::ptr; use {Guard, add_garbage_box}; /// A Treiber stack. /// /// Treiber stacks are one way to implement concurrent LIFO stack. /// /// Treiber stacks builds on linked lists. They are lock-free and non-blocking. It can...
} break; } } } })); } for i in j { i.join().unwrap(); } let mut sum = 0; while let Some(x) = stack.pop() { sum += *x; ...
{ s.push(*a + 1); s.push(*b - 1); break; }
conditional_block
main.rs
fn main() { use std::env; // these seem to return the same things for (key, value) in env::vars_os() { println!("{:?}: {:?}", key, value); } for (key, value) in env::vars() { println!("{:?}: {:?}", key, value); } let key = "OS"; match env::var_os(key) { Some(val) =...
} match env::var("SWARMIP") { Ok(val) => println!("{:?}", val), Err(e) => println!("couldn't interpret {}", e), } let data = env::var_os("OS"); println!("{:?}", data); match env::var("SWARMIP") { Ok(mediakraken_ip) => { println!("{:?}", mediakraken_ip); }, ...
match env::var("PATH") { Ok(val) => println!("{:?}", val), Err(e) => println!("couldn't interpret {}", e),
random_line_split
main.rs
fn
() { use std::env; // these seem to return the same things for (key, value) in env::vars_os() { println!("{:?}: {:?}", key, value); } for (key, value) in env::vars() { println!("{:?}: {:?}", key, value); } let key = "OS"; match env::var_os(key) { Some(val) => print...
main
identifier_name
main.rs
fn main()
Err(e) => println!("couldn't interpret {}", e), } match env::var("SWARMIP") { Ok(val) => println!("{:?}", val), Err(e) => println!("couldn't interpret {}", e), } let data = env::var_os("OS"); println!("{:?}", data); match env::var("SWARMIP") { Ok(mediakraken_ip) =>...
{ use std::env; // these seem to return the same things for (key, value) in env::vars_os() { println!("{:?}: {:?}", key, value); } for (key, value) in env::vars() { println!("{:?}: {:?}", key, value); } let key = "OS"; match env::var_os(key) { Some(val) => println!...
identifier_body
workernavigator.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::WorkerNavigatorBinding; use dom::bindings::codegen::Bindings::WorkerNavigato...
self.permissions.or_init(|| Permissions::new(&self.global())) } }
random_line_split
workernavigator.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::WorkerNavigatorBinding; use dom::bindings::codegen::Bindings::WorkerNavigato...
(&self) -> DOMString { navigatorinfo::AppCodeName() } // https://html.spec.whatwg.org/multipage/#dom-navigator-platform fn Platform(&self) -> DOMString { navigatorinfo::Platform() } // https://html.spec.whatwg.org/multipage/#dom-navigator-useragent fn UserAgent(&self) -> DOMStr...
AppCodeName
identifier_name
mem.rs
// mem.rs // AltOSRust // // Created by Daniel Seitz on 12/6/16 /* #[no_mangle] pub unsafe extern fn __aeabi_memclr4(dest: *mut u32, mut n: isize) { while n > 0 { n -= 1; *dest.offset(n) = 0; } } #[no_mangle] // TODO: Implement this, right now we don't do any reallocations, so it should never get called, ...
for i in 0..10 { assert_eq!(block[i], 0x0); } } }
random_line_split
mem.rs
// mem.rs // AltOSRust // // Created by Daniel Seitz on 12/6/16 /* #[no_mangle] pub unsafe extern fn __aeabi_memclr4(dest: *mut u32, mut n: isize) { while n > 0 { n -= 1; *dest.offset(n) = 0; } } #[no_mangle] // TODO: Implement this, right now we don't do any reallocations, so it should never get called, ...
() { let mut block: [u32; 10] = [0xAAAAAAAA; 10]; for i in 0..10 { assert_eq!(block[i], 0xAAAAAAAA); } unsafe { __aeabi_memclr4(block.as_mut_ptr(), 10) }; for i in 0..10 { assert_eq!(block[i], 0x0); } } }
memclr
identifier_name
mem.rs
// mem.rs // AltOSRust // // Created by Daniel Seitz on 12/6/16 /* #[no_mangle] pub unsafe extern fn __aeabi_memclr4(dest: *mut u32, mut n: isize) { while n > 0 { n -= 1; *dest.offset(n) = 0; } } #[no_mangle] // TODO: Implement this, right now we don't do any reallocations, so it should never get called, ...
}
{ let mut block: [u32; 10] = [0xAAAAAAAA; 10]; for i in 0..10 { assert_eq!(block[i], 0xAAAAAAAA); } unsafe { __aeabi_memclr4(block.as_mut_ptr(), 10) }; for i in 0..10 { assert_eq!(block[i], 0x0); } }
identifier_body
struct_with_packing.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case,
non_camel_case_types, non_upper_case_globals )] #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct a { pub b: ::std::os::raw::c_char, pub c: ::std::os::raw::c_short, } #[test] fn bindgen_test_layout_a() { assert_eq!( ::std::mem::size_of::<a>(), ...
random_line_split
struct_with_packing.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct
{ pub b: ::std::os::raw::c_char, pub c: ::std::os::raw::c_short, } #[test] fn bindgen_test_layout_a() { assert_eq!( ::std::mem::size_of::<a>(), 3usize, concat!("Size of: ", stringify!(a)) ); assert_eq!( ::std::mem::align_of::<a>(), 1usize, concat!("Al...
a
identifier_name
logf32.rs
#![feature(core, core_intrinsics, core_float)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::logf32; use core::num::Float; use core::f32; use core::f32::consts::E; // pub fn logf32(x: f32) -> f32; #[test] fn logf32_test1() { let x: f32 = f32::nan(); let result: f32...
#[test] fn logf32_test4() { let x: f32 = 1.0; let result: f32 = unsafe { logf32(x) }; assert_eq!(result, 0.0); } #[test] fn logf32_test5() { let x: f32 = E; let result: f32 = unsafe { logf32(x) }; assert_eq!(result, 0.99999994); } }
{ let x: f32 = f32::neg_infinity(); let result: f32 = unsafe { logf32(x) }; assert_eq!(result.is_nan(), true); }
identifier_body
logf32.rs
#![feature(core, core_intrinsics, core_float)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::logf32; use core::num::Float; use core::f32; use core::f32::consts::E; // pub fn logf32(x: f32) -> f32; #[test] fn logf32_test1() { let x: f32 = f32::nan(); let result: f32...
() { let x: f32 = E; let result: f32 = unsafe { logf32(x) }; assert_eq!(result, 0.99999994); } }
logf32_test5
identifier_name
logf32.rs
#![feature(core, core_intrinsics, core_float)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::logf32; use core::num::Float; use core::f32; use core::f32::consts::E; // pub fn logf32(x: f32) -> f32; #[test] fn logf32_test1() { let x: f32 = f32::nan(); let result: f32...
#[test] fn logf32_test3() { let x: f32 = f32::neg_infinity(); let result: f32 = unsafe { logf32(x) }; assert_eq!(result.is_nan(), true); } #[test] fn logf32_test4() { let x: f32 = 1.0; let result: f32 = unsafe { logf32(x) }; assert_eq!(result, 0.0); } #[test] fn logf32_test5()...
let x: f32 = f32::infinity(); let result: f32 = unsafe { logf32(x) }; assert_eq!(result, f32::infinity()); }
random_line_split
synom.rs
// Copyright 2018 Syn 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 distributed // except according ...
(self, s: &str) -> Result<Self::Output, ParseError> { match s.parse() { Ok(tts) => self.parse2(tts), Err(_) => Err(ParseError::new("error while lexing input string")), } } } impl<F, T> Parser for F where F: FnOnce(Cursor) -> PResult<T>, { type Output = T; fn par...
parse_str
identifier_name
synom.rs
// Copyright 2018 Syn 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 distributed // except according ...
} /// Extension traits that are made available within the `call!` parser. /// /// *This module is available if Syn is built with the `"parsing"` feature.* pub mod ext { use super::*; use proc_macro2::Ident; /// Additional parsing methods for `Ident`. /// /// This trait is sealed and cannot be impl...
Err(ParseError::new("failed to parse anything")) } else { Err(ParseError::new("failed to parse all tokens")) } }
random_line_split
synom.rs
// Copyright 2018 Syn 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 distributed // except according ...
} impl<F, T> Parser for F where F: FnOnce(Cursor) -> PResult<T>, { type Output = T; fn parse2(self, tokens: TokenStream) -> Result<T, ParseError> { let buf = TokenBuffer::new2(tokens); let (t, rest) = self(buf.begin())?; if rest.eof() { Ok(t) } else if rest == ...
{ match s.parse() { Ok(tts) => self.parse2(tts), Err(_) => Err(ParseError::new("error while lexing input string")), } }
identifier_body
chunk.rs
use std::cell::RefCell; use std::collections::HashMap; use crate::array::*; use crate::shader::Vertex; use gfx; #[derive(Copy, Clone)] pub struct BlockState { pub value: u16, } pub const EMPTY_BLOCK: BlockState = BlockState { value: 0 }; #[derive(Copy, Clone)] pub struct BiomeId { pub value: u8, } #[derive...
pub const SIZE: usize = 16; /// A chunk of SIZE x SIZE x SIZE blocks, in YZX order. #[derive(Copy, Clone)] pub struct Chunk { pub blocks: [[[BlockState; SIZE]; SIZE]; SIZE], pub light_levels: [[[LightLevel; SIZE]; SIZE]; SIZE], } // TODO: Change to const pointer. pub const EMPTY_CHUNK: &Chunk = &Chunk { ...
random_line_split
chunk.rs
use std::cell::RefCell; use std::collections::HashMap; use crate::array::*; use crate::shader::Vertex; use gfx; #[derive(Copy, Clone)] pub struct BlockState { pub value: u16, } pub const EMPTY_BLOCK: BlockState = BlockState { value: 0 }; #[derive(Copy, Clone)] pub struct BiomeId { pub value: u8, } #[derive...
(self) -> u8 { self.value & 0xf } pub fn sky_light(self) -> u8 { self.value >> 4 } } pub const SIZE: usize = 16; /// A chunk of SIZE x SIZE x SIZE blocks, in YZX order. #[derive(Copy, Clone)] pub struct Chunk { pub blocks: [[[BlockState; SIZE]; SIZE]; SIZE], pub light_levels: [[[Li...
block_light
identifier_name
get_capabilities.rs
//! `GET /_matrix/client/*/capabilities` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3capabilities use ruma_common::api::ruma_api; use crate::capabilities::Capabilities; ruma_api! { metadata: { descript...
(capabilities: Capabilities) -> Self { Self { capabilities } } } impl From<Capabilities> for Response { fn from(capabilities: Capabilities) -> Self { Self::new(capabilities) } } }
new
identifier_name
get_capabilities.rs
//! `GET /_matrix/client/*/capabilities` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3capabilities use ruma_common::api::ruma_api; use crate::capabilities::Capabilities; ruma_api! { metadata: { descript...
} impl Response { /// Creates a new `Response` with the given capabilities. pub fn new(capabilities: Capabilities) -> Self { Self { capabilities } } } impl From<Capabilities> for Response { fn from(capabilities: Capabilities) -> Self { Self::new...
{ Self {} }
identifier_body
get_capabilities.rs
//! `GET /_matrix/client/*/capabilities` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3capabilities use ruma_common::api::ruma_api; use crate::capabilities::Capabilities; ruma_api! { metadata: { descript...
} impl Request { /// Creates an empty `Request`. pub fn new() -> Self { Self {} } } impl Response { /// Creates a new `Response` with the given capabilities. pub fn new(capabilities: Capabilities) -> Self { Self { capabilities } }...
error: crate::Error
random_line_split
state_manager.rs
use status::*; use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; #[derive(Clone)] pub struct StateManager { current_state: Status, prev_state: Status, is_web_requesting: bool, is_bg_requesting: bool, tx_state: Sender<(Status,Status)>, to_print_scre...
} pub fn get_state(&self) -> Status { self.current_state } pub fn is_to_print_screen(&self) -> bool { (*self.to_print_screen.clone()).load(Ordering::Relaxed) } pub fn set_to_print_screen(&mut self, value: bool) { (*self.to_print_screen).store(value, Ordering::Relaxed)...
{ let prev_state_tmp = self.prev_state.clone(); let current_state_tmp = self.current_state.clone(); self.prev_state = self.current_state; self.current_state = value; self.tx_state.send((prev_state_tmp, current_state_tmp)); }
conditional_block
state_manager.rs
use status::*; use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; #[derive(Clone)] pub struct StateManager { current_state: Status, prev_state: Status, is_web_requesting: bool, is_bg_requesting: bool, tx_state: Sender<(Status,Status)>, to_print_scre...
self.current_state } pub fn is_to_print_screen(&self) -> bool { (*self.to_print_screen.clone()).load(Ordering::Relaxed) } pub fn set_to_print_screen(&mut self, value: bool) { (*self.to_print_screen).store(value, Ordering::Relaxed) } }
random_line_split
state_manager.rs
use status::*; use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; #[derive(Clone)] pub struct StateManager { current_state: Status, prev_state: Status, is_web_requesting: bool, is_bg_requesting: bool, tx_state: Sender<(Status,Status)>, to_print_scre...
pub fn is_bg_request (&self) -> bool { self.is_bg_requesting } pub fn set_bg_request(&mut self, value: bool) { self.is_bg_requesting = value; } pub fn update_state(&mut self, value: Status) { if self.current_state!= value { let prev_state_tmp = self.prev_state....
{ self.is_web_requesting = value; }
identifier_body
state_manager.rs
use status::*; use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; #[derive(Clone)] pub struct StateManager { current_state: Status, prev_state: Status, is_web_requesting: bool, is_bg_requesting: bool, tx_state: Sender<(Status,Status)>, to_print_scre...
(&self) -> Status { self.current_state } pub fn is_to_print_screen(&self) -> bool { (*self.to_print_screen.clone()).load(Ordering::Relaxed) } pub fn set_to_print_screen(&mut self, value: bool) { (*self.to_print_screen).store(value, Ordering::Relaxed) } }
get_state
identifier_name
vec.rs
/* Precached - A Linux process monitor and pre-caching daemon Copyright (C) 2017-2020 the precached developers This file is part of precached. Precached 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 Softwar...
}
{ self.iter().any(|e| e == p) }
identifier_body
vec.rs
/* Precached - A Linux process monitor and pre-caching daemon Copyright (C) 2017-2020 the precached developers This file is part of precached. Precached 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 Softwar...
(&self, p: &T) -> bool { self.iter().any(|e| e == p) } }
contains
identifier_name
vec.rs
/* Precached - A Linux process monitor and pre-caching daemon Copyright (C) 2017-2020 the precached developers This file is part of precached. Precached 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 Softwar...
You should have received a copy of the GNU General Public License along with Precached. If not, see <http://www.gnu.org/licenses/>. */ use rayon::prelude::*; use std::cmp::PartialEq; pub trait Contains<T> { fn contains(&self, p: &T) -> bool; } impl<T: PartialEq> Contains<T> for Vec<T> { fn contains(...
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(box_syntax)] #![feature(step_by)] #![deny(unsafe_code)] extern crate cookie as cookie_rs; extern crat...
raw_status: raw_status, body: body, } } } #[derive(Clone, Deserialize, Serialize)] pub struct CustomResponseMediator { pub response_chan: IpcSender<Option<CustomResponse>>, pub load_url: ServoUrl, } /// [Policies](https://w3c.github.io/webappsec-referrer-policy/#referrer-po...
impl CustomResponse { pub fn new(headers: Headers, raw_status: RawStatus, body: Vec<u8>) -> CustomResponse { CustomResponse { headers: headers,
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(box_syntax)] #![feature(step_by)] #![deny(unsafe_code)] extern crate cookie as cookie_rs; extern crat...
(mut slice: &[u8]) -> &[u8] { const HTTP_WS_BYTES: &'static [u8] = b"\x09\x0A\x0D\x20"; loop { match slice.split_first() { Some((first, remainder)) if HTTP_WS_BYTES.contains(first) => slice = remainder, _ => break, } } loop { match slice.split_last() { ...
trim_http_whitespace
identifier_name
handler.rs
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
else { outer_result } } }
{ Err(inner_result.err().or(outer_result.err()).unwrap()) }
conditional_block
handler.rs
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at //
// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the Licen...
// https://www.apache.org/licenses/LICENSE-2.0
random_line_split
handler.rs
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
<SD, F> { pub(super) inner: SD, pub(super) handler: F, } impl<SD, F, IC, R> SendDesc<IC, R> for Handler<SD, F> where SD: SendDesc<IC, ()> + Send, IC: InboundContext, R: Send, F: FnMut( Result<&dyn InboundContext<SocketAddr = IC::SocketAddr>, Error>, ) -> Result<ResponseStatu...
Handler
identifier_name
dissimilaroriginwindow.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding; use dom::bindings::codegen::Bindings::Dissimi...
} impl DissimilarOriginWindowMethods for DissimilarOriginWindow { // https://html.spec.whatwg.org/multipage/#dom-window fn Window(&self) -> DomRoot<WindowProxy> { DomRoot::from_ref(&*self.window_proxy) } // https://html.spec.whatwg.org/multipage/#dom-self fn Self_(&self) -> DomRoot<Window...
{ self.upcast::<GlobalScope>().origin() }
identifier_body
dissimilaroriginwindow.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding; use dom::bindings::codegen::Bindings::Dissimi...
(&self) { // TODO: Implement x-origin blur } // https://html.spec.whatwg.org/multipage/#dom-focus fn Focus(&self) { // TODO: Implement x-origin focus } // https://html.spec.whatwg.org/multipage/#dom-location fn Location(&self) -> DomRoot<DissimilarOriginLocation> { self...
Blur
identifier_name
dissimilaroriginwindow.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding; use dom::bindings::codegen::Bindings::Dissimi...
// https://html.spec.whatwg.org/multipage/#dom-focus fn Focus(&self) { // TODO: Implement x-origin focus } // https://html.spec.whatwg.org/multipage/#dom-location fn Location(&self) -> DomRoot<DissimilarOriginLocation> { self.location.or_init(|| DissimilarOriginLocation::new(self)) ...
fn Blur(&self) { // TODO: Implement x-origin blur }
random_line_split
api.rs
use std::collections::BTreeMap; use anyhow::Result; use lazy_static::lazy_static; use super::WindowsEmulator; pub enum CallingConvention { Stdcall, Cdecl, } pub struct ArgumentDescriptor { pub ty: String, pub name: String, } pub struct FunctionDescriptor { pub calling_convention: CallingConve...
m }; pub static ref HOOKS: BTreeMap<String, Hook> = { let mut m = BTreeMap::new(); m.insert( String::from("kernel32.dll!GetVersionExA"), Box::new( move |emu: &mut dyn WindowsEmulator, desc: &FunctionDescriptor| -> Result<()> { ...
name: String::from("lpVersionInformation"), } ] } );
random_line_split
api.rs
use std::collections::BTreeMap; use anyhow::Result; use lazy_static::lazy_static; use super::WindowsEmulator; pub enum CallingConvention { Stdcall, Cdecl, } pub struct ArgumentDescriptor { pub ty: String, pub name: String, } pub struct
{ pub calling_convention: CallingConvention, pub return_type: String, pub arguments: Vec<ArgumentDescriptor>, } type Hook = Box<dyn Fn(&mut dyn WindowsEmulator, &FunctionDescriptor) -> Result<()> + Send + Sync>; lazy_static! { pub static ref API: BTreeMap<String, FunctionDescriptor> =...
FunctionDescriptor
identifier_name
borrowck-rvalues-mutable.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) -> usize { let v = self.value; self.value += 1; v } } pub fn main() { let v = Counter::new(22).get_and_inc(); assert_eq!(v, 22); let v = Counter::new(22).inc().inc().get(); assert_eq!(v, 24);; }
get_and_inc
identifier_name
borrowck-rvalues-mutable.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 get(&self) -> usize { self.value } fn get_and_inc(&mut self) -> usize { let v = self.value; self.value += 1; v } } pub fn main() { let v = Counter::new(22).get_and_inc(); assert_eq!(v, 22); let v = Counter::new(22).inc().inc().get(); assert_eq!(v, ...
{ self.value += 1; self }
identifier_body
borrowck-rvalues-mutable.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let v = Counter::new(22).inc().inc().get(); assert_eq!(v, 24);; }
random_line_split
format.rs
#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct Format(pub ChannelFormat, pub NumericFormat); #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum ChannelFormat { R4G4, R4G4B4A4, R5G6B5, B5G6R5, R5G5B5A1, R8, R8G8, R8G8B8A8, B8G8R8A8,
R11G11B10, R10G10B10A2, R16, R16G16, R16G16B16A16, R32, R32G32, R32G32B32, R32G32B32A32, R16G8, R32G8, R9G9B9E5 } #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum NumericFormat { UnsignedNormalizedInteger, SignedNormalizedInteger, UnsignedInteger, Si...
R10G11B11,
random_line_split
format.rs
#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct Format(pub ChannelFormat, pub NumericFormat); #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum ChannelFormat { R4G4, R4G4B4A4, R5G6B5, B5G6R5, R5G5B5A1, R8, R8G8, R8G8B8A8, B8G8R8A8, R10G11B11, R11G11B10, R10G1...
{ UnsignedNormalizedInteger, SignedNormalizedInteger, UnsignedInteger, SignedInteger, Float }
NumericFormat
identifier_name
cleanup.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 ...
dbg.write_uint(stats.n_unique_boxes); dbg.write_str("\n bytes_freed: "); dbg.write_uint(stats.n_bytes_freed); dbg.write_str("\n"); } } /// Bindings to the runtime pub mod rustrt { use libc::c_void; #[link_name = "rustrt"] pub extern { #[rust_stack] // F...
dbg.write_str("annihilator stats:"); dbg.write_str("\n total_boxes: "); dbg.write_uint(stats.n_total_boxes); dbg.write_str("\n unique_boxes: ");
random_line_split
cleanup.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 ...
} /// Bindings to the runtime pub mod rustrt { use libc::c_void; #[link_name = "rustrt"] pub extern { #[rust_stack] // FIXME (#4386): Unable to make following method private. pub unsafe fn rust_get_task() -> *c_void; } }
{ // We do logging here w/o allocation. let dbg = libc::STDERR_FILENO as io::fd_t; dbg.write_str("annihilator stats:"); dbg.write_str("\n total_boxes: "); dbg.write_uint(stats.n_total_boxes); dbg.write_str("\n unique_boxes: "); dbg.write_uint(stats.n_unique_boxe...
conditional_block
cleanup.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 ...
() { use unstable::lang::local_free; use io::WriterUtil; use io; use libc; use sys; use managed; let mut stats = AnnihilateStats { n_total_boxes: 0, n_unique_boxes: 0, n_bytes_freed: 0 }; // Pass 1: Make all boxes immortal. for each_live_alloc |box, uniq...
annihilate
identifier_name
stylearc.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...
// FIXME(bholley): Use the updated comment when [2] is merged. // // This load is needed to prevent reordering of use of the data and // deletion of the data. Because it is marked `Release`, the decreasing // of the reference count synchronizes with this `Acquire` load. This ...
{ return; }
conditional_block
stylearc.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...
#[inline] pub fn ptr_eq(this: &Self, other: &Self) -> bool { this.ptr == other.ptr } } impl<T:?Sized> Clone for Arc<T> { #[inline] fn clone(&self) -> Self { // Using a relaxed ordering is alright here, as knowledge of the // original reference prevents other threads from ...
{ let _ = Box::from_raw(self.ptr); }
identifier_body
stylearc.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...
(data: T) -> Self { let x = Box::new(ArcInner { count: atomic::AtomicUsize::new(1), data: data, }); Arc { ptr: Box::into_raw(x) } } pub fn into_raw(this: Self) -> *const T { let ptr = unsafe { &((*this.ptr).data) as *const _ }; mem::forget(this); ...
new
identifier_name
stylearc.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...
impl<T:?Sized + fmt::Debug> fmt::Debug for Arc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } impl<T:?Sized> fmt::Pointer for Arc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.ptr, f) } } impl<T: Default...
random_line_split
closures.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
{ // closures are anonymous functions. let sum = |i: f64, j: f64| -> f64 { i + j }; let print_hi = || println!("Hi"); let i = 4.0; let j = 3.0; println!("{}", sum(i, j)); print_hi(); }
identifier_body
closures.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
print_hi(); }
println!("{}", sum(i, j));
random_line_split
closures.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
() { // closures are anonymous functions. let sum = |i: f64, j: f64| -> f64 { i + j }; let print_hi = || println!("Hi"); let i = 4.0; let j = 3.0; println!("{}", sum(i, j)); print_hi(); }
main
identifier_name
tokeniser.rs
//! The _Tokeniser_ class. #![experimental] use std::char::is_whitespace; use escape_scheme::EscapeScheme; /// A tokeniser object. /// /// A Tokeniser can be fed characters from an iterator, string, or individually. /// It is an _immutable_ object: actions on a Tokeniser consume the Tokeniser, /// and produce a fre...
/// Drops the current working string, if it is empty. fn drop_empty_current_string(&mut self) { if self.vec.last().map(|s| s.is_empty()).unwrap_or(false) { self.vec.pop(); } } }
self.escape = self.escape_map.find(&c).map(|a| a.clone()); self.in_word = true; }
identifier_body
tokeniser.rs
//! The _Tokeniser_ class. #![experimental] use std::char::is_whitespace; use escape_scheme::EscapeScheme; /// A tokeniser object. /// /// A Tokeniser can be fed characters from an iterator, string, or individually. /// It is an _immutable_ object: actions on a Tokeniser consume the Tokeniser, /// and produce a fre...
// -> Begin escape (and word if not in one already) ( c, Tokeniser { escape: None, quote: None, escape_map: ref e,.. } ) if e.contains_key(&c) => new.start_escaping(c), // Escape leader, in escape-permittin...
// ESCAPE LEADER // Escape leader, not in quotes
random_line_split
tokeniser.rs
//! The _Tokeniser_ class. #![experimental] use std::char::is_whitespace; use escape_scheme::EscapeScheme; /// A tokeniser object. /// /// A Tokeniser can be fed characters from an iterator, string, or individually. /// It is an _immutable_ object: actions on a Tokeniser consume the Tokeniser, /// and produce a fre...
f, chr: char) -> Tokeniser<Q, E, S> { let mut new = self.clone(); match (chr, self) { // ERROR // Found an error // -> Ignore input ( _, Tokeniser { error: Some(_),.. } ) => (), // ESCAPE SEQUENCES // Currently escaping ...
char(sel
identifier_name
vec.rs
//! Vector primitive. use prelude::*; use core::{mem, ops, ptr, slice}; use leak::Leak; /// A low-level vector primitive. /// /// This does not perform allocation nor reallaction, thus these have to be done manually. /// Moreover, no destructors are called, making it possible to leak memory. pub struct Vec<T: Leak>...
(&mut self) -> Option<T> { if self.len == 0 { None } else { unsafe { // LAST AUDIT: 2016-08-21 (Ticki). // Decrement the length. This won't underflow due to the conditional above. self.len -= 1; // We use `ptr::rea...
pop
identifier_name
vec.rs
//! Vector primitive. use prelude::*; use core::{mem, ops, ptr, slice}; use leak::Leak; /// A low-level vector primitive. /// /// This does not perform allocation nor reallaction, thus these have to be done manually. /// Moreover, no destructors are called, making it possible to leak memory. pub struct Vec<T: Leak>...
else { // Place the element in the end of the vector. unsafe { // LAST AUDIT: 2016-08-21 (Ticki). // By the invariants of this type (the size is bounded by the address space), this // conversion isn't overflowing. ptr::write((self...
{ Err(()) }
conditional_block
vec.rs
//! Vector primitive. use prelude::*; use core::{mem, ops, ptr, slice}; use leak::Leak; /// A low-level vector primitive. /// /// This does not perform allocation nor reallaction, thus these have to be done manually. /// Moreover, no destructors are called, making it possible to leak memory. pub struct Vec<T: Leak>...
// LAST AUDIT: 2016-08-21 (Ticki). // Due to the invariants of `Block`, this copy is safe (the pointer is valid and // unaliased). ptr::copy_nonoverlapping(old.ptr.get(), self.ptr.get(), old.len); } Block::from(old) } /// Get the capacity of th...
{ log!(INTERNAL, "Refilling vector..."); // Calculate the new capacity. let new_cap = block.size() / mem::size_of::<T>(); // Make some assertions. assert!( self.len <= new_cap, "Block not large enough to cover the vector." ); assert!(bloc...
identifier_body
vec.rs
//! Vector primitive. use prelude::*; use core::{mem, ops, ptr, slice}; use leak::Leak; /// A low-level vector primitive. /// /// This does not perform allocation nor reallaction, thus these have to be done manually. /// Moreover, no destructors are called, making it possible to leak memory. pub struct Vec<T: Leak>...
// By the invariants of this type (the size is bounded by the address space), this // conversion isn't overflowing. ptr::write((self.ptr.get()).offset(self.len as isize), elem); } // Increment the length. self.len += 1; Ok(...
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
} fn create_constellation(opts: opts::Opts, compositor_proxy: Box<CompositorProxy + Send>, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan, devtools_chan: Option<Sender<devtools_traits::Devtool...
{ self.compositor.title_for_main_frame() }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
() { ChildSandbox::new(content_process_sandbox_profile()).activate() .expect("Failed to activate sandbox!"); } #[cfg(target_os = "windows")] fn create_sandbox() { panic!("Sandboxing is not supported on Windows."); }
create_sandbox
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
//! of Servo's internal subsystems, including the `ScriptThread` and the //! `LayoutThread`, as well maintains the navigation context. //! //! The `Browser` is fed events from a generic type that implements the //! `WindowMethods` trait. #[cfg(not(target_os = "windows"))] extern crate gaol; #[macro_use] extern crate g...
//! `Constellation`, which does the heavy lifting of coordinating all
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
} // The compositor coordinates with the client window to create the final // rendered page and display it somewhere. let compositor = IOCompositor::create(window, InitialCompositorState { sender: compositor_proxy, receiver: compositor_receiver, cons...
{ webdriver(port, constellation_chan.clone()); }
conditional_block
size.rs
use std::{io, mem}; use super::cvt; use super::libc::{c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ}; #[repr(C)] struct TermSize {
y: c_ushort, } /// Get the size of the terminal. pub fn terminal_size() -> io::Result<(u16, u16)> { unsafe { let mut size: TermSize = mem::zeroed(); cvt(ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size as *mut _))?; Ok((size.col as u16, size.row as u16)) } } /// Get the size of the...
row: c_ushort, col: c_ushort, x: c_ushort,
random_line_split
size.rs
use std::{io, mem}; use super::cvt; use super::libc::{c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ}; #[repr(C)] struct TermSize { row: c_ushort, col: c_ushort, x: c_ushort, y: c_ushort, } /// Get the size of the terminal. pub fn terminal_size() -> io::Result<(u16, u16)>
/// Get the size of the terminal, in pixels pub fn terminal_size_pixels() -> io::Result<(u16, u16)> { unsafe { let mut size: TermSize = mem::zeroed(); cvt(ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size as *mut _))?; Ok((size.x as u16, size.y as u16)) } }
{ unsafe { let mut size: TermSize = mem::zeroed(); cvt(ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size as *mut _))?; Ok((size.col as u16, size.row as u16)) } }
identifier_body
size.rs
use std::{io, mem}; use super::cvt; use super::libc::{c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ}; #[repr(C)] struct
{ row: c_ushort, col: c_ushort, x: c_ushort, y: c_ushort, } /// Get the size of the terminal. pub fn terminal_size() -> io::Result<(u16, u16)> { unsafe { let mut size: TermSize = mem::zeroed(); cvt(ioctl(STDOUT_FILENO, TIOCGWINSZ.into(), &mut size as *mut _))?; Ok((size.col ...
TermSize
identifier_name
smallintmap.rs
use std::collections::SmallIntMap; struct Tenant<'a> { name: &'a str, phone: &'a str, } fn main()
apartments.pop(&1); match apartments.find_mut(&3) { Some(henrietta) => henrietta.name = "David and Henrietta Smith", _ => println!("Oh no! Where did David and Henrietta go?"), } apartments.insert(0, Tenant { name: "Phillip Davis", phone: "5555-7869", }); for (ke...
{ // Start with 5 apartments let mut apartments = SmallIntMap::with_capacity(5); // The compiler infers 1 as uint apartments.insert(1, Tenant { name: "John Smith", phone: "555-1234", }); apartments.insert(3, Tenant { name: "Henrietta George", phone: "555-2314", ...
identifier_body
smallintmap.rs
use std::collections::SmallIntMap; struct Tenant<'a> { name: &'a str, phone: &'a str, } fn main() { // Start with 5 apartments let mut apartments = SmallIntMap::with_capacity(5); // The compiler infers 1 as uint apartments.insert(1, Tenant { name: "John Smith", phone: "555-123...
name: "David Rogers", phone: "555-5467", }); apartments.pop(&1); match apartments.find_mut(&3) { Some(henrietta) => henrietta.name = "David and Henrietta Smith", _ => println!("Oh no! Where did David and Henrietta go?"), } apartments.insert(0, Tenant { name:...
}); apartments.insert(5, Tenant {
random_line_split
smallintmap.rs
use std::collections::SmallIntMap; struct Tenant<'a> { name: &'a str, phone: &'a str, } fn
() { // Start with 5 apartments let mut apartments = SmallIntMap::with_capacity(5); // The compiler infers 1 as uint apartments.insert(1, Tenant { name: "John Smith", phone: "555-1234", }); apartments.insert(3, Tenant { name: "Henrietta George", phone: "555-2314...
main
identifier_name
server.rs
use container::{Container, ControlDispatcher}; use config::Config; use lssa::control::Control; use lssa::manager::AppManager; use futures; use futures::Future; use futures::Stream; use futures::Sink; //use futures::{StreamExt, FutureExt}; pub struct Server { container: Container } impl Server { pub fn new(co...
(container: Container) -> futures::sync::mpsc::Sender<Control> { let (tx, rx) = futures::sync::mpsc::channel(4096); ::std::thread::spawn(move || { ::tokio::executor::current_thread::block_on_all( futures::future::ok(()).map(move |_| { let mut manager = App...
launch_manager
identifier_name
server.rs
use container::{Container, ControlDispatcher}; use config::Config; use lssa::control::Control; use lssa::manager::AppManager; use futures; use futures::Future; use futures::Stream; use futures::Sink; //use futures::{StreamExt, FutureExt}; pub struct Server { container: Container } impl Server { pub fn new(co...
tx } pub fn run_apps(&self) -> impl Future<Item = (), Error = ()> { let (tx, rx) = futures::sync::mpsc::channel::<Control>(4096); self.container.set_control_dispatcher(ControlDispatcher::new(tx)); let container = self.container.clone(); let mut control_sender = Self::la...
random_line_split
server.rs
use container::{Container, ControlDispatcher}; use config::Config; use lssa::control::Control; use lssa::manager::AppManager; use futures; use futures::Future; use futures::Stream; use futures::Sink; //use futures::{StreamExt, FutureExt}; pub struct Server { container: Container } impl Server { pub fn new(co...
fn launch_manager(container: Container) -> futures::sync::mpsc::Sender<Control> { let (tx, rx) = futures::sync::mpsc::channel(4096); ::std::thread::spawn(move || { ::tokio::executor::current_thread::block_on_all( futures::future::ok(()).map(move |_| { ...
{ Server { container: Container::new(config) } }
identifier_body
surface_state.rs
//! TODO Documentation use std::marker::PhantomData; use crate::libc::c_int; use wlroots_sys::{wl_output_transform, wl_resource, wlr_surface_state}; use crate::{render::PixmanRegion, surface::Surface}; #[derive(Debug)] #[repr(u32)] /// Represents a change in the pending state. /// /// When a particular bit is set, ...
State { state, phantom: PhantomData } } /// Gets the state of the sub surface. /// /// # Panics /// If the invalid state is in an undefined state, this will panic. pub fn committed(&self) -> InvalidState { use self::InvalidState::*; unsafe...
/// # Safety /// Since we rely on the surface providing a valid surface state, /// this function is marked unsafe. pub(crate) unsafe fn new(state: wlr_surface_state) -> State<'surface> {
random_line_split
surface_state.rs
//! TODO Documentation use std::marker::PhantomData; use crate::libc::c_int; use wlroots_sys::{wl_output_transform, wl_resource, wlr_surface_state}; use crate::{render::PixmanRegion, surface::Surface}; #[derive(Debug)] #[repr(u32)] /// Represents a change in the pending state. /// /// When a particular bit is set, ...
} } } /// Get the position of the surface relative to the previous position. /// /// Return value is in (dx, dy) format. pub fn position(&self) -> (i32, i32) { unsafe { (self.state.dx, self.state.dy) } } /// Get the size of the sub surface. /// /// Retu...
{ wlr_log!(WLR_ERROR, "Invalid invalid state {}", invalid); panic!("Invalid invalid state in wlr_surface_state") }
conditional_block
surface_state.rs
//! TODO Documentation use std::marker::PhantomData; use crate::libc::c_int; use wlroots_sys::{wl_output_transform, wl_resource, wlr_surface_state}; use crate::{render::PixmanRegion, surface::Surface}; #[derive(Debug)] #[repr(u32)] /// Represents a change in the pending state. /// /// When a particular bit is set, ...
(&self) -> i32 { unsafe { self.state.scale } } /// Get the output transform applied to the surface. pub fn transform(&self) -> wl_output_transform { unsafe { self.state.transform } } /// Gets the buffer of the surface. pub unsafe fn buffer(&self) -> *mut wl_resource { s...
scale
identifier_name
build.rs
use std::env; use std::process::Command; use std::str::{self, FromStr}; // The rustc-cfg strings below are *not* public API. Please let us know by // opening a GitHub issue if your build environment requires some way to enable // these cfgs other than by executing our build script. fn main() { let minor = match ru...
}; let version = match str::from_utf8(&output.stdout) { Ok(version) => version, Err(_) => return None, }; let mut pieces = version.split('.'); if pieces.next()!= Some("rustc 1") { return None; } let next = match pieces.next() { Some(next) => next, N...
random_line_split
build.rs
use std::env; use std::process::Command; use std::str::{self, FromStr}; // The rustc-cfg strings below are *not* public API. Please let us know by // opening a GitHub issue if your build environment requires some way to enable // these cfgs other than by executing our build script. fn
() { let minor = match rustc_minor_version() { Some(minor) => minor, None => return, }; let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; // CString::into_boxed_c_str stabilized in Rust 1.20: ...
main
identifier_name
build.rs
use std::env; use std::process::Command; use std::str::{self, FromStr}; // The rustc-cfg strings below are *not* public API. Please let us know by // opening a GitHub issue if your build environment requires some way to enable // these cfgs other than by executing our build script. fn main()
} // Duration available in core since Rust 1.25: // https://blog.rust-lang.org/2018/03/29/Rust-1.25.html#library-stabilizations if minor >= 25 { println!("cargo:rustc-cfg=core_duration"); } // 128-bit integers stabilized in Rust 1.26: // https://blog.rust-lang.org/2018/05/10/Rust-1...
{ let minor = match rustc_minor_version() { Some(minor) => minor, None => return, }; let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; // CString::into_boxed_c_str stabilized in Rust 1.20: /...
identifier_body
msg_pong.rs
use std; use ::serialize::{self, Serializable}; use super::PingMessage; use super::BIP0031_VERSION; #[derive(Debug,Default,Clone)] pub struct PongMessage { pub nonce: u64, } impl PongMessage { pub fn new(ping:&PingMessage) -> PongMessage { PongMessage{ nonce: ping.nonce } } } impl super::Message for Po...
fn deserialize(&mut self, io:&mut std::io::Read, ser:&serialize::SerializeParam) -> serialize::Result { if BIP0031_VERSION < ser.version { self.nonce.deserialize(io, ser) } else { Ok(0usize) } } }
{ if BIP0031_VERSION < ser.version { self.nonce.serialize(io, ser) } else { Ok(0usize) } }
identifier_body