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
std_unstable.rs
use std::time::Duration; pub(crate) trait AsMillis_ { fn as_millis_(self) -> u128; } impl AsMillis_ for Duration { fn as_millis_(self) -> u128 { 1000 * u128::from(self.as_secs()) + u128::from(self.subsec_millis()) } } pub(crate) trait RemoveItem_ { type Item; fn remove_item_(&mut self, it...
) { assert_eq!(left.transpose_(), right); } test(None, Ok(None)); test(Some(Ok(())), Ok(Some(()))); test(Some(Err(())), Err(())); } }
fn test_transpose_() { fn test( left: Option<std::result::Result<(), ()>>, right: std::result::Result<Option<()>, ()>,
random_line_split
std_unstable.rs
use std::time::Duration; pub(crate) trait AsMillis_ { fn as_millis_(self) -> u128; } impl AsMillis_ for Duration { fn as_millis_(self) -> u128 { 1000 * u128::from(self.as_secs()) + u128::from(self.subsec_millis()) } } pub(crate) trait RemoveItem_ { type Item; fn remove_item_(&mut self, it...
() { fn test( left: Option<std::result::Result<(), ()>>, right: std::result::Result<Option<()>, ()>, ) { assert_eq!(left.transpose_(), right); } test(None, Ok(None)); test(Some(Ok(())), Ok(Some(()))); test(Some(Err(())), Err(())); ...
test_transpose_
identifier_name
std_unstable.rs
use std::time::Duration; pub(crate) trait AsMillis_ { fn as_millis_(self) -> u128; } impl AsMillis_ for Duration { fn as_millis_(self) -> u128 { 1000 * u128::from(self.as_secs()) + u128::from(self.subsec_millis()) } } pub(crate) trait RemoveItem_ { type Item; fn remove_item_(&mut self, it...
test(None, Ok(None)); test(Some(Ok(())), Ok(Some(()))); test(Some(Err(())), Err(())); } }
{ assert_eq!(left.transpose_(), right); }
identifier_body
mod.rs
//! Representation of Cranelift IR functions. mod builder; pub mod condcodes; pub mod dfg; pub mod entities; mod extfunc; mod extname; pub mod function; mod globalvalue; mod heap; pub mod immediates; pub mod instructions; pub mod jumptable; pub mod layout; mod libcall; mod memflags; mod progpoint; mod sourceloc; pub m...
pub use crate::ir::instructions::{ InstructionData, Opcode, ValueList, ValueListPool, VariableArgs, }; pub use crate::ir::jumptable::JumpTableData; pub use crate::ir::layout::Layout; pub use crate::ir::libcall::{get_libcall_funcref, get_probestack_funcref, LibCall}; pub use crate::ir::memflags::MemFlags; pub use cr...
pub use crate::ir::function::Function; pub use crate::ir::globalvalue::GlobalValueData; pub use crate::ir::heap::{HeapData, HeapStyle};
random_line_split
mod.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /// The minimum schema version we can open. pub(super) const SCHEMA_MIN_VERSION: u8 = 11; /// The version new files are initially created with. pub(super) const SCHEMA_STARTING_VERSION: u8 =...
self.upgrade_tags_to_schema17()?; self.db.execute_batch("update col set ver = 17")?; } // fixme: on the next schema upgrade, change _collapsed to _expanded // in DeckCommon and invert existing values, so that we can avoid // serializing the values in the default c...
{ if ver < 14 { self.db .execute_batch(include_str!("schema14_upgrade.sql"))?; self.upgrade_deck_conf_to_schema14()?; self.upgrade_tags_to_schema14()?; self.upgrade_config_to_schema14()?; } if ver < 15 { self.db ...
identifier_body
mod.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /// The minimum schema version we can open. pub(super) const SCHEMA_MIN_VERSION: u8 = 11; /// The version new files are initially created with. pub(super) const SCHEMA_STARTING_VERSION: u8 =...
(&self, ver: u8, server: bool) -> Result<()> { if ver < 14 { self.db .execute_batch(include_str!("schema14_upgrade.sql"))?; self.upgrade_deck_conf_to_schema14()?; self.upgrade_tags_to_schema14()?; self.upgrade_config_to_schema14()?; } ...
upgrade_to_latest_schema
identifier_name
mod.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /// The minimum schema version we can open. pub(super) const SCHEMA_MIN_VERSION: u8 = 11; /// The version new files are initially created with. pub(super) const SCHEMA_STARTING_VERSION: u8 =...
// fixme: on the next schema upgrade, change _collapsed to _expanded // in DeckCommon and invert existing values, so that we can avoid // serializing the values in the default case, and use // DeckCommon::default() in new_normal() and new_filtered() Ok(()) } pub(super)...
{ self.upgrade_tags_to_schema17()?; self.db.execute_batch("update col set ver = 17")?; }
conditional_block
mod.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /// The minimum schema version we can open. pub(super) const SCHEMA_MIN_VERSION: u8 = 11; /// The version new files are initially created with. pub(super) const SCHEMA_STARTING_VERSION: u8 =...
if ver < 17 { self.upgrade_tags_to_schema17()?; self.db.execute_batch("update col set ver = 17")?; } // fixme: on the next schema upgrade, change _collapsed to _expanded // in DeckCommon and invert existing values, so that we can avoid // serializing the v...
random_line_split
resolve-inconsistent-binding-mode.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 ...
//~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } } fn matcher4(x: opts) { match x { a(ref mut i) | b(ref i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } } fn matcher5(x: opts) { ...
{}
conditional_block
resolve-inconsistent-binding-mode.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 matcher2(x: opts) { match x { a(ref i) | b(i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } } fn matcher3(x: opts) { match x { a(ref mut i) | b(ref const i) => {} //~ ERROR variable `i` is bound with different mode in pattern #...
a(ref i) | b(i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } }
random_line_split
resolve-inconsistent-binding-mode.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 ...
(x: opts) { match x { a(ref i) | b(i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } } fn matcher3(x: opts) { match x { a(ref mut i) | b(ref const i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pa...
matcher2
identifier_name
vm.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
pub fn sgate_sel(&self) -> Option<CapSel> { None } pub fn setup(&self) { } pub fn map_pages(&self, _vpe: &VPEDesc, _virt: goff, _phys: GlobAddr, _pages: usize, _attr: MapFlags) -> Result<(), Error> { Err(Error::new(Code::NotSup)) } pub fn unmap_pages(...
{ None }
identifier_body
vm.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
(&self, _vpe: &VPEDesc, _virt: goff, _phys: GlobAddr, _pages: usize, _attr: MapFlags) -> Result<(), Error> { Err(Error::new(Code::NotSup)) } pub fn unmap_pages(&self, _vpe: &VPEDesc, _virt: goff, _pages: usize) -> Result<(), Error> { Err(Error::new(Code::NotSup)) } }
map_pages
identifier_name
vm.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
pub fn unmap_pages(&self, _vpe: &VPEDesc, _virt: goff, _pages: usize) -> Result<(), Error> { Err(Error::new(Code::NotSup)) } }
random_line_split
overloaded-autoderef.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 ...
() { assert_eq!(Rc::new(5u).to_uint(), Some(5)); assert_eq!((~&~&Rc::new(~~&~5u)).to_uint(), Some(5)); let point = Rc::new(Point {x: 2, y: 4}); assert_eq!(point.x, 2); assert_eq!(point.y, 4); let i = Rc::new(RefCell::new(2)); let i_value = *i.borrow(); *i.borrow_mut() = 5; assert_eq...
main
identifier_name
overloaded-autoderef.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 fn main() { assert_eq!(Rc::new(5u).to_uint(), Some(5)); assert_eq!((~&~&Rc::new(~~&~5u)).to_uint(), Some(5)); let point = Rc::new(Point {x: 2, y: 4}); assert_eq!(point.x, 2); assert_eq!(point.y, 4); let i = Rc::new(RefCell::new(2)); let i_value = *i.borrow(); *i.borrow_mut() = 5;...
#[deriving(Eq, Show)] struct Point { x: int, y: int
random_line_split
os.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<'a> Iterator for SplitPaths<'a> { type Item = PathBuf; fn next(&mut self) -> Option<PathBuf> { // On Windows, the PATH environment variable is semicolon separated. // Double quotes are used as a way of introducing literal semicolons // (since c:\some;dir is a valid Windows path). ...
{ SplitPaths { data: unparsed.encode_wide(), must_yield: true, } }
identifier_body
os.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 ...
(&mut self) -> Option<OsString> { self.range.next().map(|i| unsafe { let ptr = *self.cur.offset(i); let mut len = 0; while *ptr.offset(len)!= 0 { len += 1; } // Push it onto the list. let ptr = ptr as *const u16; let buf = slice::from_raw_...
next
identifier_name
os.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 ...
Env { base: ch, cur: ch } } } pub struct SplitPaths<'a> { data: EncodeWide<'a>, must_yield: bool, } pub fn split_paths(unparsed: &OsStr) -> SplitPaths { SplitPaths { data: unparsed.encode_wide(), must_yield: true, } } impl<'a> Iterator for SplitPaths<'a> { type Item =...
{ panic!("failure getting env string from OS: {}", io::Error::last_os_error()); }
conditional_block
os.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 v = super::to_utf16_os(n); unsafe { if libc::SetEnvironmentVariableW(v.as_ptr(), ptr::null()) == 0 { panic!("failed to unset env: {}", io::Error::last_os_error()); } } } pub struct Args { range: Range<isize>, cur: *mut *mut u16, } impl Iterator for Args { type I...
} } } pub fn unsetenv(n: &OsStr) {
random_line_split
compositor_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::CompositingReason; use eucli...
fn try_recv_compositor_msg(&mut self) -> Option<Msg> { self.try_recv().ok() } fn recv_compositor_msg(&mut self) -> Msg { self.recv().unwrap() } } pub trait RenderListener { fn recomposite(&mut self, reason: CompositingReason); } impl RenderListener for Box<CompositorProxy +'static>...
fn recv_compositor_msg(&mut self) -> Msg; } /// A convenience implementation of `CompositorReceiver` for a plain old Rust `Receiver`. impl CompositorReceiver for Receiver<Msg> {
random_line_split
compositor_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::CompositingReason; use eucli...
(&mut self) -> Msg { self.recv().unwrap() } } pub trait RenderListener { fn recomposite(&mut self, reason: CompositingReason); } impl RenderListener for Box<CompositorProxy +'static> { fn recomposite(&mut self, reason: CompositingReason) { self.send(Msg::Recomposite(reason)); } } /// ...
recv_compositor_msg
identifier_name
compositor_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::CompositingReason; use eucli...
Msg::HeadParsed => write!(f, "HeadParsed"), Msg::CollectMemoryReports(..) => write!(f, "CollectMemoryReports"), Msg::Status(..) => write!(f, "Status"), Msg::GetClientWindow(..) => write!(f, "GetClientWindow"), Msg::MoveTo(..) => write!(f, "MoveTo"), ...
{ match *self { Msg::Exit => write!(f, "Exit"), Msg::ShutdownComplete => write!(f, "ShutdownComplete"), Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"), Msg::ChangeRunningAnimationsState(..) => write!(f, "ChangeRunningAnimationsState"), ...
identifier_body
pubsub-macros.rs
use jsonrpc_core; use jsonrpc_pubsub; use serde_json; #[macro_use] extern crate jsonrpc_derive; use jsonrpc_core::futures::channel::mpsc; use jsonrpc_pubsub::typed::Subscriber; use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId}; use std::sync::Arc; pub enum MyError {} impl From<MyError> for ...
} type Result<T> = ::std::result::Result<T, MyError>; #[rpc] pub trait Rpc { type Metadata; /// Hello subscription. #[pubsub(subscription = "hello", subscribe, name = "hello_subscribe", alias("hello_alias"))] fn subscribe(&self, a: Self::Metadata, b: Subscriber<String>, c: u32, d: Option<u64>); /// Hello subs...
{ unreachable!() }
identifier_body
pubsub-macros.rs
use jsonrpc_core; use jsonrpc_pubsub; use serde_json; #[macro_use] extern crate jsonrpc_derive; use jsonrpc_core::futures::channel::mpsc; use jsonrpc_pubsub::typed::Subscriber; use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId}; use std::sync::Arc; pub enum MyError {} impl From<MyError> for ...
let mut io = PubSubHandler::default(); let rpc = RpcImpl::default(); io.extend_with(rpc.to_delegate()); // when let meta = Metadata; let req = r#"{"jsonrpc":"2.0","id":1,"method":"hello_alias","params":[1]}"#; let res = io.handle_request_sync(req, meta); let expected = r#"{ "jsonrpc": "2.0", "result": 5, ...
#[test] fn test_subscribe_with_alias() {
random_line_split
pubsub-macros.rs
use jsonrpc_core; use jsonrpc_pubsub; use serde_json; #[macro_use] extern crate jsonrpc_derive; use jsonrpc_core::futures::channel::mpsc; use jsonrpc_pubsub::typed::Subscriber; use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId}; use std::sync::Arc; pub enum MyError {} impl From<MyError> for ...
(&self, a: u64, b: u64) -> Result<u64> { Ok(a + b) } fn notify(&self, a: u64) { println!("Received `notify` with value: {}", a); } } #[derive(Clone, Default)] struct Metadata; impl jsonrpc_core::Metadata for Metadata {} impl PubSubMetadata for Metadata { fn session(&self) -> Option<Arc<Session>> { let (tx, ...
add
identifier_name
rec-extend.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 origin: Point = Point {x: 0, y: 0}; let right: Point = Point {x: origin.x + 10,.. origin}; let up: Point = Point {y: origin.y + 10,.. origin}; assert_eq!(origin.x, 0); assert_eq!(origin.y, 0); assert_eq!(right.x, 10); assert_eq!(right.y, 0); assert_eq!(up.x, 0); assert_eq!(up.y...
identifier_body
rec-extend.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(origin.x, 0); assert_eq!(origin.y, 0); assert_eq!(right.x, 10); assert_eq!(right.y, 0); assert_eq!(up.x, 0); assert_eq!(up.y, 10); }
pub fn main() { let origin: Point = Point {x: 0, y: 0}; let right: Point = Point {x: origin.x + 10,.. origin}; let up: Point = Point {y: origin.y + 10,.. origin};
random_line_split
rec-extend.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 origin: Point = Point {x: 0, y: 0}; let right: Point = Point {x: origin.x + 10,.. origin}; let up: Point = Point {y: origin.y + 10,.. origin}; assert_eq!(origin.x, 0); assert_eq!(origin.y, 0); assert_eq!(right.x, 10); assert_eq!(right.y, 0); assert_eq!(up.x, 0); assert_eq!(u...
main
identifier_name
binary_frame_reader.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 bincode::deserialize; use byteorder::{LittleEndian, ReadBytesExt}; use clap; use std::any::TypeId; use std::fs...
// (a) SetRootPipeline // (b) SetDisplayList // (c) GenerateFrame that occurs *after* (a) and (b) match msg { ApiMsg::UpdateDocument(_, ref txn) => { if txn.generate_frame { ...
// need to find:
random_line_split
binary_frame_reader.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 bincode::deserialize; use byteorder::{LittleEndian, ReadBytesExt}; use clap; use std::any::TypeId; use std::fs...
else if self.play_through { if!self.frame_exists(self.frame_num + 1) { process::exit(0); } self.next_frame(); self.do_frame(wrench); } else { wrench.refresh(); } self.frame_num } // note that we don't loop her...
{ wrench.begin_frame(); let frame_items = self.frame_data.clone(); for item in frame_items { match item { Item::Message(msg) => if !self.should_skip_upload_msg(&msg) { wrench.api.send_message(msg); }, ...
conditional_block
binary_frame_reader.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 bincode::deserialize; use byteorder::{LittleEndian, ReadBytesExt}; use clap; use std::any::TypeId; use std::fs...
(&self, frame: u32) -> bool { !self.eof || (frame as usize) < self.frame_offsets.len() } } impl WrenchThing for BinaryFrameReader { fn do_frame(&mut self, wrench: &mut Wrench) -> u32 { // save where the frame begins as we read through the file if self.frame_num as usize >= self.frame_off...
frame_exists
identifier_name
binary_frame_reader.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 bincode::deserialize; use byteorder::{LittleEndian, ReadBytesExt}; use clap; use std::any::TypeId; use std::fs...
// a frame exists if we either haven't hit eof yet, or if // we have, then if we've seen its offset. fn frame_exists(&self, frame: u32) -> bool { !self.eof || (frame as usize) < self.frame_offsets.len() } } impl WrenchThing for BinaryFrameReader { fn do_frame(&mut self, wrench: &mut Wrench...
{ if !self.skip_uploads { return false; } match *msg { ApiMsg::UpdateResources(..) => true, _ => false, } }
identifier_body
fulfill.rs
tcx>> } /// The fulfillment context is used to drive trait resolution. It /// consists of a list of obligations that must be (eventually) /// satisfied. The job is to track which are satisfied, which yielded /// errors, and which are still pending. At any point, users can call /// `select_where_possible`, and the ful...
loop { let count = self.predicates.len(); debug!("select_where_possible({} obligations) iteration", count); let mut new_obligations = Vec::new(); // If we are only attempting obligations we haven't seen yet, // then set `skip` to ...
only_new_obligations); let mut errors = Vec::new();
random_line_split
fulfill.rs
} /// The fulfillment context is used to drive trait resolution. It /// consists of a list of obligations that must be (eventually) /// satisfied. The job is to track which are satisfied, which yielded /// errors, and which are still pending. At any point, users can call /// `select_where_possible`, and the fulfilme...
Err(_) => { errors.push( FulfillmentError::new( obligation.clone(), CodeSelectionError(Unimplemented))); } } true } ty::Predicate::TypeOutlives(r...
{ }
conditional_block
fulfill.rs
} /// The fulfillment context is used to drive trait resolution. It /// consists of a list of obligations that must be (eventually) /// satisfied. The job is to track which are satisfied, which yielded /// errors, and which are still pending. At any point, users can call /// `select_where_possible`, and the fulfilme...
<'a>(&mut self, infcx: &InferCtxt<'a,'tcx>, typer: &ty::ClosureTyper<'tcx>) -> Result<(),Vec<FulfillmentError<'tcx>>> { let mut selcx = SelectionContext::new(infcx, typer); self.select(&mut...
select_where_possible
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/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
{ let a: &T = &**a; let b: &T = &**b; (a as *const T) == (b as *const T) }
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/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
#[allow(non_camel_case_types)] pub mod values; pub mod viewport; pub mod workqueue; use std::sync::Arc; /// The CSS properties supported by the style system. // Generated from the properties.mako.rs template by build.rs #[macro_use] #[allow(unsafe_code)] pub mod properties { include!(concat!(env!("OUT_DIR"), "/pr...
pub mod timer; pub mod traversal; #[macro_use]
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/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
<T:'static>(a: &Arc<T>, b: &Arc<T>) -> bool { let a: &T = &**a; let b: &T = &**b; (a as *const T) == (b as *const T) }
arc_ptr_eq
identifier_name
main.rs
use std::cell::Cell; use std::rt::io::{Reader, Writer, Listener}; use std::rt::io::net::tcp::*; use std::rt::io::net::ip::*; fn allocate_buffer(buffer_size: uint) -> ~[u8] { let mut buffer: ~[u8] = std::vec::with_capacity(buffer_size); unsafe { std::vec::raw::set_len(&mut buffer, buffer_size); } return bu...
}, }; } } } }
loop { match stream.read(dest_buffer) { Some(x) => stream.write(dest_buffer.slice_to(x)), None => { break
random_line_split
main.rs
use std::cell::Cell; use std::rt::io::{Reader, Writer, Listener}; use std::rt::io::net::tcp::*; use std::rt::io::net::ip::*; fn allocate_buffer(buffer_size: uint) -> ~[u8] { let mut buffer: ~[u8] = std::vec::with_capacity(buffer_size); unsafe { std::vec::raw::set_len(&mut buffer, buffer_size); } return bu...
() { let listen_address = Ipv4(127, 0, 0, 1, 8000); let mut listener = match TcpListener::bind(listen_address) { Some(x) => x, None => { fail!("Unable to bind to " + listen_address.to_str()); } }; loop { let stream = Cell::new(listener.accept().unwrap());...
main
identifier_name
main.rs
use std::cell::Cell; use std::rt::io::{Reader, Writer, Listener}; use std::rt::io::net::tcp::*; use std::rt::io::net::ip::*; fn allocate_buffer(buffer_size: uint) -> ~[u8]
fn main() { let listen_address = Ipv4(127, 0, 0, 1, 8000); let mut listener = match TcpListener::bind(listen_address) { Some(x) => x, None => { fail!("Unable to bind to " + listen_address.to_str()); } }; loop { let stream = Cell::new(listener.accept()....
{ let mut buffer: ~[u8] = std::vec::with_capacity(buffer_size); unsafe { std::vec::raw::set_len(&mut buffer, buffer_size); } return buffer }
identifier_body
main.rs
use std::cell::Cell; use std::rt::io::{Reader, Writer, Listener}; use std::rt::io::net::tcp::*; use std::rt::io::net::ip::*; fn allocate_buffer(buffer_size: uint) -> ~[u8] { let mut buffer: ~[u8] = std::vec::with_capacity(buffer_size); unsafe { std::vec::raw::set_len(&mut buffer, buffer_size); } return bu...
}; loop { let stream = Cell::new(listener.accept().unwrap()); do spawn { let mut dest_buffer = allocate_buffer(512); let mut stream = stream.take(); loop { match stream.read(dest_buffer) { Some(x) => stream.write(dest_bu...
{ fail!("Unable to bind to " + listen_address.to_str()); }
conditional_block
lib.rs
//! # MongoDB Rust Driver //! //! A driver written in pure Rust, providing a native interface to MongoDB. //! //! ## Connecting to MongoDB //! //! The Client is an entry-point to interacting with a MongoDB instance. //! //! ```no_run //! # use mongodb::{Client, ClientOptions, ThreadedClient}; //! # use mongodb::common:...
//! client.add_completion_hook(log_query_duration).unwrap(); //! ``` //! //! ## Topology Monitoring //! //! Each server within a MongoDB server set is monitored asynchronously for changes in status, and //! the driver's view of the current topology is updated in response to this. This allows the //! driver to be aware ...
//! _ => println!("Failed to execute command."), //! } //! } //! //! let mut client = Client::connect("localhost", 27017).unwrap();
random_line_split
lib.rs
//! # MongoDB Rust Driver //! //! A driver written in pure Rust, providing a native interface to MongoDB. //! //! ## Connecting to MongoDB //! //! The Client is an entry-point to interacting with a MongoDB instance. //! //! ```no_run //! # use mongodb::{Client, ClientOptions, ThreadedClient}; //! # use mongodb::common:...
{ /// Indicates how a server should be selected for read operations. pub read_preference: ReadPreference, /// Describes the guarantees provided by MongoDB when reporting the success of a write /// operation. pub write_concern: WriteConcern, req_id: Arc<AtomicIsize>, topology: Topology, ...
ClientInner
identifier_name
lib.rs
//! # MongoDB Rust Driver //! //! A driver written in pure Rust, providing a native interface to MongoDB. //! //! ## Connecting to MongoDB //! //! The Client is an entry-point to interacting with a MongoDB instance. //! //! ```no_run //! # use mongodb::{Client, ClientOptions, ThreadedClient}; //! # use mongodb::common:...
#[cfg(feature = "ssl")] /// Creates a new options struct with a specified SSL certificate pub fn with_unauthenticated_ssl(ca_file: &str, verify_peer: bool) -> ClientOptions { let mut options = ClientOptions::new(); options.stream_connector = StreamConnector::with_unauthenticated_ssl(ca_fil...
{ let mut options = ClientOptions::new(); options.stream_connector = StreamConnector::with_ssl(ca_file, certificate_file, key_file, verify_peer); options }
identifier_body
pref_util.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use serde_json::Value; use std::collections::HashMap; use std::fmt; use std::str::FromStr; use std::sync::{Arc, R...
}
{ *self.user_prefs.write().unwrap() = self.default_prefs.clone(); }
identifier_body
pref_util.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use serde_json::Value; use std::collections::HashMap; use std::fmt; use std::str::FromStr; use std::sync::{Arc, R...
Some(other.into()) } } } )+ } } impl_pref_from! { f64 => PrefValue::Float, i64 => PrefValue::Int, String => PrefValue::Str, &str => PrefValue::Str, bool => PrefValue::Bool, } impl_from_pref! { PrefValue::Float ...
fn from(other: PrefValue) -> Self { if let PrefValue::Missing = other { None } else {
random_line_split
pref_util.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use serde_json::Value; use std::collections::HashMap; use std::fmt; use std::str::FromStr; use std::sync::{Arc, R...
<V>(&self, key: &str, val: V) -> Result<(), PrefError> where V: Into<PrefValue>, { let mut prefs = self.user_prefs.write().unwrap(); self.set_inner(key, &mut prefs, val) } pub fn set_all<M>(&self, values: M) -> Result<(), PrefError> where M: IntoIterator<Item = (Stri...
set
identifier_name
mod.rs
//------------------------------------------------------------------------------- // URL: //------------------------------------------------------------------------------- use std::path::Path; use time; use reader; pub const ID: i32 = 8; pub const DIR: &str = "array/dutchflag"; //--------------------------------...
if element == 0 { elements[mid] = elements[low]; elements[low] = element; low += 1; mid += 1; } else if element == 1 { mid += 1; } else { elements[mid] = elements[high]; elements[high] = element; high -= 1; } } }
let mut mid = 0; let mut high = elements.len() - 1; while mid <= high { let element = elements[mid];
random_line_split
mod.rs
//------------------------------------------------------------------------------- // URL: //------------------------------------------------------------------------------- use std::path::Path; use time; use reader; pub const ID: i32 = 8; pub const DIR: &str = "array/dutchflag"; //--------------------------------...
high -= 1; } } }
{ let mut low = 0; let mut mid = 0; let mut high = elements.len() - 1; while mid <= high { let element = elements[mid]; if element == 0 { elements[mid] = elements[low]; elements[low] = element; low += 1; mid += 1; } else if element == 1 { mid += 1; } else { ...
identifier_body
mod.rs
//------------------------------------------------------------------------------- // URL: //------------------------------------------------------------------------------- use std::path::Path; use time; use reader; pub const ID: i32 = 8; pub const DIR: &str = "array/dutchflag"; //--------------------------------...
(elements: &mut Vec<i64>) { let mut low = 0; let mut mid = 0; let mut high = elements.len() - 1; while mid <= high { let element = elements[mid]; if element == 0 { elements[mid] = elements[low]; elements[low] = element; low += 1; mid += 1; } else if element == 1 { ...
first_algorithm
identifier_name
mod.rs
//------------------------------------------------------------------------------- // URL: //------------------------------------------------------------------------------- use std::path::Path; use time; use reader; pub const ID: i32 = 8; pub const DIR: &str = "array/dutchflag"; //--------------------------------...
} }
{ elements[mid] = elements[high]; elements[high] = element; high -= 1; }
conditional_block
write_all.rs
use std::path::Path; use clap::{App, SubCommand, Arg, ArgMatches}; use futures::prelude::*; use attaca::Repository; use attaca::trace::Trace; use errors::*; use trace::Progress; const HELP_STR: &'static str = r#" This test will first hashsplit and marshal a file; then, it will attempt to connect to a remote and se...
matches, Progress::new(Some("_debug".to_string())), ) } }
repository,
random_line_split
write_all.rs
use std::path::Path; use clap::{App, SubCommand, Arg, ArgMatches}; use futures::prelude::*; use attaca::Repository; use attaca::trace::Trace; use errors::*; use trace::Progress; const HELP_STR: &'static str = r#" This test will first hashsplit and marshal a file; then, it will attempt to connect to a remote and se...
pub fn go<P: AsRef<Path>>( repository: &mut Repository, conf_dir: P, matches: &ArgMatches, ) -> Result<()> { let conf = conf_dir.as_ref().join("ceph.conf"); let keyring = conf_dir.as_ref().join("ceph.client.admin.keyring"); // HACK: Ignore errors if adding the remote fails (it will fail if t...
{ let path = matches.value_of("INPUT").unwrap(); let context = repository.remote("_debug", trace)?; let chunk_stream = context.split_file(path); let hash_future = context.write_file(chunk_stream); let write_future = context.close(); write_future.join(hash_future).wait()?; Ok(()) }
identifier_body
write_all.rs
use std::path::Path; use clap::{App, SubCommand, Arg, ArgMatches}; use futures::prelude::*; use attaca::Repository; use attaca::trace::Trace; use errors::*; use trace::Progress; const HELP_STR: &'static str = r#" This test will first hashsplit and marshal a file; then, it will attempt to connect to a remote and se...
}
{ run( repository, matches, Progress::new(Some("_debug".to_string())), ) }
conditional_block
write_all.rs
use std::path::Path; use clap::{App, SubCommand, Arg, ArgMatches}; use futures::prelude::*; use attaca::Repository; use attaca::trace::Trace; use errors::*; use trace::Progress; const HELP_STR: &'static str = r#" This test will first hashsplit and marshal a file; then, it will attempt to connect to a remote and se...
<T: Trace>(repository: &mut Repository, matches: &ArgMatches, trace: T) -> Result<()> { let path = matches.value_of("INPUT").unwrap(); let context = repository.remote("_debug", trace)?; let chunk_stream = context.split_file(path); let hash_future = context.write_file(chunk_stream); let write_future...
run
identifier_name
match_args.rs
use std::os; fn increase(number: i32) { println!("{}", number + 1); } fn
(number: i32) { println!("{}", number - 1); } fn help() { println!("usage: match_args <string> Check whether given string is the answer. match_args {{increase|decrease}} <integer> Increase or decrease given integer by one."); } fn main() { let args = os::args(); match args.as_slice() { ...
decrease
identifier_name
match_args.rs
use std::os; fn increase(number: i32) { println!("{}", number + 1); } fn decrease(number: i32) { println!("{}", number - 1); } fn help() { println!("usage: match_args <string> Check whether given string is the answer. match_args {{increase|decrease}} <integer> Increase or decrease given integer b...
}; // parse the command match cmd.as_slice() { "increase" => increase(number), "decrease" => decrease(number), _ => { println!("error: invalid command"); help(); }, } ...
return; },
random_line_split
match_args.rs
use std::os; fn increase(number: i32) { println!("{}", number + 1); } fn decrease(number: i32) { println!("{}", number - 1); } fn help()
fn main() { let args = os::args(); match args.as_slice() { // no arguments passed [ref name] => { println!("My name is '{}'. Try passing some arguments!", name); }, // one argument passed [_, ref string] => { if string.as_slice() == "42" { ...
{ println!("usage: match_args <string> Check whether given string is the answer. match_args {{increase|decrease}} <integer> Increase or decrease given integer by one."); }
identifier_body
worklet.rs
global_type: global_type, } } pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> { debug!("Creating worklet {:?}.", global_type); reflect_dom_object(box Worklet::new_inherited(window, global_type), window, Wrap) } pub fn worklet_id(&self) -> W...
// Steps 6-12 in parallel. let pending_tasks_struct = PendingTasksStruct::new(); let global = self.window.upcast::<GlobalScope>(); let pool = ScriptThread::worklet_thread_pool(); pool.fetch_and_invoke_a_worklet_script(global.pipeline_id(), ...
random_line_split
worklet.rs
_type: global_type, } } pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> { debug!("Creating worklet {:?}.", global_type); reflect_dom_object(box Worklet::new_inherited(window, global_type), window, Wrap) } pub fn worklet_id(&self) -> WorkletI...
// To finish swapping roles, perform the atomic swap. // The other end should have already started the swap, so this shouldn't block. WorkletData::FinishSwapRoles(swapper) => { let _ = swapper.swap(&mut self.role); } //...
{ let (our_swapper, their_swapper) = swapper(); sender.send(WorkletData::FinishSwapRoles(their_swapper)).unwrap(); let _ = our_swapper.swap(&mut self.role); }
conditional_block
worklet.rs
_type: global_type, } } pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> { debug!("Creating worklet {:?}.", global_type); reflect_dom_object(box Worklet::new_inherited(window, global_type), window, Wrap) } pub fn
(&self) -> WorkletId { self.worklet_id } #[allow(dead_code)] pub fn worklet_global_scope_type(&self) -> WorkletGlobalScopeType { self.global_type } } impl WorkletMethods for Worklet { #[allow(unrooted_must_root)] /// https://drafts.css-houdini.org/worklets/#dom-worklet-addmodul...
worklet_id
identifier_name
worklet.rs
_type: global_type, } } pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> { debug!("Creating worklet {:?}.", global_type); reflect_dom_object(box Worklet::new_inherited(window, global_type), window, Wrap) } pub fn worklet_id(&self) -> WorkletI...
} /// https://drafts.css-houdini.org/worklets/#pending-tasks-struct #[derive(Clone, Debug)] struct PendingTasksStruct(Arc<AtomicIsize>); impl PendingTasksStruct { fn new() -> PendingTasksStruct { PendingTasksStruct(Arc::new(AtomicIsize::new(WORKLET_THREAD_POOL_SIZE as isize))) } fn set_counter_t...
{ WorkletId(servo_rand::random()) }
identifier_body
led.rs
//! Easy use of LEDs. use peripheral; /// All the LEDs. pub static LEDS: [Led; 4] = [Led { i: 12 }, Led { i: 13 }, Led { i: 14 }, Led { i: 15 }];
/// A single LED. pub struct Led { i: u8, } impl Led { /// Turns the LED on. pub fn on(&self) { let bsrr = &peripheral::gpiod().bsrr; match self.i { 12 => bsrr.write(|w| w.bs12(true)), 13 => bsrr.write(|w| w.bs13(true)), 14 => bsrr.write(|w| w.bs14(true))...
random_line_split
led.rs
//! Easy use of LEDs. use peripheral; /// All the LEDs. pub static LEDS: [Led; 4] = [Led { i: 12 }, Led { i: 13 }, Led { i: 14 }, Led { i: 15 }]; /// A single LED. pub struct Led { i: u8, } impl Led { /// Turns the LED on...
/// Turns the LED off. pub fn off(&self) { let bsrr = &peripheral::gpiod().bsrr; match self.i { 12 => bsrr.write(|w| w.br12(true)), 13 => bsrr.write(|w| w.br13(true)), 14 => bsrr.write(|w| w.br14(true)), 15 => bsrr.write(|w| w.br15(true)), ...
{ let bsrr = &peripheral::gpiod().bsrr; match self.i { 12 => bsrr.write(|w| w.bs12(true)), 13 => bsrr.write(|w| w.bs13(true)), 14 => bsrr.write(|w| w.bs14(true)), 15 => bsrr.write(|w| w.bs15(true)), _ => {} } }
identifier_body
led.rs
//! Easy use of LEDs. use peripheral; /// All the LEDs. pub static LEDS: [Led; 4] = [Led { i: 12 }, Led { i: 13 }, Led { i: 14 }, Led { i: 15 }]; /// A single LED. pub struct Led { i: u8, } impl Led { /// Turns the LED on...
() { let gpiod = peripheral::gpiod_mut(); let rcc = peripheral::rcc_mut(); // RCC: Enable GPIOD rcc.ahb1enr.modify(|_, w| w.gpioden(true)); // GPIOD: Configure pins 12-15 as outputs gpiod.moder.modify(|_, w| { w.moder12(0b01) .moder13(0b01) .moder14(0b01) ...
init
identifier_name
worklet.rs
Reflector::new(), window: Dom::from_ref(window), worklet_id: WorkletId::new(), global_type: global_type, } } pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> { debug!("Creating worklet {:?}.", global_type); reflect...
(Uuid); malloc_size_of_is_0!(WorkletId); impl WorkletId { fn new() -> WorkletId { WorkletId(servo_rand::random_uuid()) } } /// <https://drafts.css-houdini.org/worklets/#pending-tasks-struct> #[derive(Clone, Debug)] struct PendingTasksStruct(Arc<AtomicIsize>); impl PendingTasksStruct { fn new() -...
WorkletId
identifier_name
worklet.rs
is important to avoid /// deadlock by making sure the primary worklet thread doesn't end up /// blocking waiting on layout. In particular, since the constellation /// can block waiting on layout, this means the primary worklet thread /// can't block waiting on the constellation. In general, the primary /// worklet thr...
random_line_split
list.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("List", inherited=True) %> ${hel...
% endif ${helpers.predefined_type( "list-style-image", "url::ImageUrlOrNone", engines="gecko servo-2013", initial_value="computed::url::ImageUrlOrNone::none()", initial_specified_value="specified::url::ImageUrlOrNone::none()", animation_value_type="discrete", spec="https://drafts.csswg.org...
{helpers.predefined_type( "list-style-type", "ListStyleType", "computed::ListStyleType::disc()", engines="gecko", initial_specified_value="specified::ListStyleType::disc()", animation_value_type="discrete", boxed=True, spec="https://drafts.csswg.org/css-li...
conditional_block
list.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("List", inherited=True) %> ${hel...
)} // TODO(pcwalton): Implement the full set of counter styles per CSS-COUNTER-STYLES [1] 6.1: // // decimal-leading-zero, armenian, upper-armenian, lower-armenian, georgian, lower-roman, // upper-roman // // [1]: http://dev.w3.org/csswg/css-counter-styles/ % if engine in ["servo-2013", "servo-2020"]: ${he...
engines="gecko servo-2013 servo-2020", servo_2020_pref="layout.2020.unimplemented", animation_value_type="discrete", spec="https://drafts.csswg.org/css-lists/#propdef-list-style-position", servo_restyle_damage="rebuild_and_reflow",
random_line_split
events.rs
#[macro_use(with_assets)] extern crate Lattice; use Lattice::window::{Window}; use Lattice::view::{View, Text}; use std::rc::Rc; use std::cell::{RefCell,Cell}; use std::sync::Mutex; #[macro_use] extern crate lazy_static; lazy_static! { static ref text_clicked: Mutex<Cell<bool>> = Mutex::new(Cell::new(false)); ...
else {[0.0, 0.0, 0.0, 0.0]})) .hovered(move |e| { let lh = left_hovered.lock().unwrap().set(true); }) .color([0.4, 0.4, 1.0, 1.0]) .scale(2.0, "em") .width(25.0, "%") .translate_x(150.0, "px") .translat...
{[0.8,0.8,0.8,0.8]}
conditional_block
events.rs
#[macro_use(with_assets)] extern crate Lattice; use Lattice::window::{Window}; use Lattice::view::{View, Text}; use std::rc::Rc; use std::cell::{RefCell,Cell}; use std::sync::Mutex; #[macro_use] extern crate lazy_static; lazy_static! { static ref text_clicked: Mutex<Cell<bool>> = Mutex::new(Cell::new(false)); ...
.translate_y(150.0, "px")); lh.set(false); v.append(Text::new("assets/Macondo-Regular.ttf", "click text") .shadow((if tc.get() {[-3,-3,3,3]} else {[0,0,0,0]}), (if tc.get() {[0.8,0.8,0.8,1.0]} else {[0.0,0.0,0.0,0.0]})) .clicked(move |e| { ...
{ let mut w = Window::new("Premadeath").set_fullscreen(true); with_assets!(w); w.start(|events| { let mut v = View::new(); let lh = left_hovered.lock().unwrap(); let tc = text_clicked.lock().unwrap(); v.append(Text::new("assets/Macondo-Regular.ttf", "hover text") ...
identifier_body
events.rs
#[macro_use(with_assets)] extern crate Lattice; use Lattice::window::{Window}; use Lattice::view::{View, Text}; use std::rc::Rc; use std::cell::{RefCell,Cell}; use std::sync::Mutex; #[macro_use] extern crate lazy_static; lazy_static! { static ref text_clicked: Mutex<Cell<bool>> = Mutex::new(Cell::new(false)); ...
() { let mut w = Window::new("Premadeath").set_fullscreen(true); with_assets!(w); w.start(|events| { let mut v = View::new(); let lh = left_hovered.lock().unwrap(); let tc = text_clicked.lock().unwrap(); v.append(Text::new("assets/Macondo-Regular.ttf", "hover text") ...
main
identifier_name
events.rs
#[macro_use(with_assets)] extern crate Lattice; use Lattice::window::{Window}; use Lattice::view::{View, Text}; use std::rc::Rc; use std::cell::{RefCell,Cell}; use std::sync::Mutex; #[macro_use] extern crate lazy_static; lazy_static! { static ref text_clicked: Mutex<Cell<bool>> = Mutex::new(Cell::new(false)); ...
tc.set(true); }) .color([1.0, 0.4, 0.4, 1.0]) .scale(3.0, "em") .width(40.0, "%") .align("right") .translate_x(50.0, "%") .translate_y(30.0, "%")); v }); }
(if tc.get() {[0.8,0.8,0.8,1.0]} else {[0.0,0.0,0.0,0.0]})) .clicked(move |e| { let tc = text_clicked.lock().unwrap();
random_line_split
esr_from.rs
/* This file is a part of cargo-esr. Copyright (C) 2017 Mohammad AlSaleh <CE.Mohammad.AlSaleh at gmail.com> https://github.com/rust-alt/cargo-esr 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 ca...
// url=id by default fn url_from_id(id: &str) -> String { String::from(id) } fn url_from_id_and_token(id: &str, token: &str) -> String { let url = Self::url_from_id(id); if url.find('?').is_some() { url + "&access_token=" + token } else { url + "?...
pub trait EsrFrom: Sized + Sync + Send + DeserializeOwned {
random_line_split
esr_from.rs
/* This file is a part of cargo-esr. Copyright (C) 2017 Mohammad AlSaleh <CE.Mohammad.AlSaleh at gmail.com> https://github.com/rust-alt/cargo-esr 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 ca...
#[derive(Deserialize, Debug, Clone)] pub struct Meta { pub total: usize, } #[async_trait] pub trait EsrFromMulti: EsrFrom + Sync + Send +'static { type Inner: Clone; async fn from_url_multi(url: &str, multi_page: bool) -> Result<Self> { let mut initial_self = Self::from_url(url).await?; ...
{ static RET: OnceCell<HttpClient> = OnceCell::new(); let init = || HttpClientBuilder::new() //.connect_timeout(Duration::from_secs(5)) .max_connections(32) .redirect_policy(RedirectPolicy::Limit(5)) .auto_referer() .default_header("User-Agent", "cargo-esr/0.1") ....
identifier_body
esr_from.rs
/* This file is a part of cargo-esr. Copyright (C) 2017 Mohammad AlSaleh <CE.Mohammad.AlSaleh at gmail.com> https://github.com/rust-alt/cargo-esr 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 ca...
} async fn bytes_from_url(url: &str) -> Result<Vec<u8>> { let client = get_static_client()?; log::debug!("Getting data from '{}'", url); // Creating an outgoing request. let mut response = client.get_async(url).await?; let mut buf = Vec::with_capacity(64*1024); ...
{ url + "?access_token=" + token }
conditional_block
esr_from.rs
/* This file is a part of cargo-esr. Copyright (C) 2017 Mohammad AlSaleh <CE.Mohammad.AlSaleh at gmail.com> https://github.com/rust-alt/cargo-esr 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 ca...
(id: &str, token: &str) -> Result<Vec<u8>> { Self::bytes_from_url(&*Self::url_from_id_and_token(id, token)).await } fn from_bytes(bytes: &[u8]) -> Result<Self> { // Deserialize let info = serde_json::from_slice(bytes)?; Ok(info) } async fn from_url(url: &str) -> Result<...
bytes_from_id_with_token
identifier_name
list.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("List", inherited=True) %> ${help...
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { let mut first = true; for pair in &self.0 { if!first { try!(dest.write_str(" ")); } first = false; try!(Token::QuotedString(Cow::from...
impl ToCss for SpecifiedValue {
random_line_split
list.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("List", inherited=True) %> ${help...
} #[inline] pub fn get_initial_value() -> computed_value::T { computed_value::T(vec![ ("\u{201c}".to_owned(), "\u{201d}".to_owned()), ("\u{2018}".to_owned(), "\u{2019}".to_owned()), ]) } pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<Specifie...
{ let mut first = true; for pair in &self.0 { if !first { try!(dest.write_str(" ")); } first = false; try!(Token::QuotedString(Cow::from(&*pair.0)).to_css(dest)); try!(dest.write_str(" ")); ...
identifier_body
list.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("List", inherited=True) %> ${help...
(pub Vec<(String,String)>); } impl ComputedValueAsSpecified for SpecifiedValue {} no_viewport_percentage!(SpecifiedValue); impl ToCss for SpecifiedValue { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { let mut first = true; for pair in &self.0 { ...
T
identifier_name
comments.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...
if rdr.curr_is('\n') { trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col); curr_line = String::new(); rdr.bump(); } else { ...
{ rdr.fatal("unterminated block comment"); }
conditional_block
comments.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 gather_comments_and_literals(span_diagnostic: &diagnostic::SpanHandler, path: String, srdr: &mut Read) -> (Vec<Comment>, Vec<Literal>) { let mut src = Vec::new(); srdr.read_to_end(&mut src).unwrap(); ...
pub pos: BytePos, } // it appears this function is called only from pprust... that's // probably not a good thing.
random_line_split
comments.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
}
{ let stripped = strip_doc_comment_decoration("/// test"); assert_eq!(stripped, " test"); let stripped = strip_doc_comment_decoration("///! test"); assert_eq!(stripped, " test"); let stripped = strip_doc_comment_decoration("// test"); assert_eq!(stripped, " test"); ...
identifier_body
comments.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let comment = "/**\n let a: *i32;\n *a = 5;\n*/"; let stripped = strip_doc_comment_decoration(comment); assert_eq!(stripped, " let a: *i32;\n *a = 5;"); } #[test] fn test_block_doc_comment_4() { let comment = "/*******************\n test\n *********************/"; l...
test_block_doc_comment_3
identifier_name
race.rs
use gen::{Generator, GenResult, Yields, Returns}; use gen::either::GenEither; use cat::sum::Either; use cat::{Iso, Inj}; pub struct GenRace<F, L>(GenEither<(F, L), (F, L)>); impl<F, L> Yields for GenRace<F, L> where F: Yields { type Yield = F::Yield; } impl<F, L> Returns for GenRace<F, L> where F: Retur...
GenEither::Latter((f, l)) => { match l.next().inj() { Either::Left(s) => { let (y, l) = s.inj(); GenResult::Yield(y, GenRace(GenEither::Former((f, l)))) } Either::Right(l) => GenResul...
{ match f.next().inj() { Either::Left(s) => { let (y, f) = s.inj(); GenResult::Yield(y, GenRace(GenEither::Latter((f, l)))) } Either::Right(f) => GenResult::Return(GenEither::Former((f, l))), ...
conditional_block
race.rs
use gen::{Generator, GenResult, Yields, Returns}; use gen::either::GenEither; use cat::sum::Either; use cat::{Iso, Inj}; pub struct GenRace<F, L>(GenEither<(F, L), (F, L)>); impl<F, L> Yields for GenRace<F, L> where F: Yields { type Yield = F::Yield; } impl<F, L> Returns for GenRace<F, L> where F: Retur...
(self) -> GenResult<Self> { match self.0 { GenEither::Former((f, l)) => { match f.next().inj() { Either::Left(s) => { let (y, f) = s.inj(); GenResult::Yield(y, GenRace(GenEither::Latter((f, l)))) ...
next
identifier_name
race.rs
use gen::{Generator, GenResult, Yields, Returns}; use gen::either::GenEither; use cat::sum::Either; use cat::{Iso, Inj}; pub struct GenRace<F, L>(GenEither<(F, L), (F, L)>); impl<F, L> Yields for GenRace<F, L> where F: Yields { type Yield = F::Yield; } impl<F, L> Returns for GenRace<F, L> where F: Retur...
} } } pub trait Race { fn race<L>(self, l: L) -> GenRace<Self, L> where Self: Sized { GenRace(GenEither::Former((self, l))) } } impl<C> Race for C {} #[cfg(test)] mod tests { use gen::iter::wrap::Wrap; use gen::map::ret::MapReturn; use gen::comb::race::Race; use gen...
{ match self.0 { GenEither::Former((f, l)) => { match f.next().inj() { Either::Left(s) => { let (y, f) = s.inj(); GenResult::Yield(y, GenRace(GenEither::Latter((f, l)))) } Eith...
identifier_body
race.rs
use gen::{Generator, GenResult, Yields, Returns}; use gen::either::GenEither; use cat::sum::Either; use cat::{Iso, Inj}; pub struct GenRace<F, L>(GenEither<(F, L), (F, L)>); impl<F, L> Yields for GenRace<F, L> where F: Yields { type Yield = F::Yield;
impl<F, L> Returns for GenRace<F, L> where F: Returns, L: Returns { type Return = GenEither<(F::Return, L), (F, L::Return)>; } impl<F, L> Generator for GenRace<F, L> where F: Generator, L: Generator<Yield = F::Yield>, L::Transition: Iso<Either<(F::Yield, L), L::Return>>, { ...
}
random_line_split
subst.rs
regions: NonerasedRegions(VecPerParamSpace::empty()), } } pub fn trans_empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let regions_is_noop = match self.regions { ...
(&self) -> bool { self.all_vecs(|v| v.is_empty()) } pub fn map<U, P>(&self, pred: P) -> VecPerParamSpace<U> where P: FnMut(&T) -> U { let result = self.iter().map(pred).collect(); VecPerParamSpace::new_internal(result, self.type_limit, ...
is_empty
identifier_name
subst.rs
regions: NonerasedRegions(VecPerParamSpace::empty()), } } pub fn trans_empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let regions_is_noop = match self.regions { ...
tcx: &ty::ctxt<'tcx>, substs: &Substs<'tcx>, span: Option<Span>) -> T { let mut folder = SubstFolder { tcx: tcx, substs: substs, span: span, ...
} impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T { fn subst_spanned(&self,
random_line_split
subst.rs
regions: NonerasedRegions(VecPerParamSpace::empty()), } } pub fn trans_empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let regions_is_noop = match self.regions { ...
fn exit_region_binder(&mut self) { self.region_binders_passed -= 1; } fn fold_region(&mut self, r: ty::Region) -> ty::Region { // Note: This routine only handles regions that are bound on // type declarations and other outer declarations, not those // bound in *fn types*. ...
{ self.region_binders_passed += 1; }
identifier_body
enum_same_crate_empty_match.rs
#![deny(unreachable_patterns)] #[non_exhaustive] pub enum NonExhaustiveEnum { Unit, //~^ not covered Tuple(u32), //~^ not covered Struct { field: u32 } //~^ not covered } pub enum NormalEnum { Unit, //~^ not covered Tuple(u32), //~^ not covered Struct { field: u32 }
pub enum EmptyNonExhaustiveEnum {} fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) { match x {} match x { _ => {} //~ ERROR unreachable pattern } } fn main() { match NonExhaustiveEnum::Unit {} //~^ ERROR `Unit`, `Tuple(_)` and `Struct {.. }` not covered [E0004] match NormalEnum::Uni...
//~^ not covered } #[non_exhaustive]
random_line_split
enum_same_crate_empty_match.rs
#![deny(unreachable_patterns)] #[non_exhaustive] pub enum NonExhaustiveEnum { Unit, //~^ not covered Tuple(u32), //~^ not covered Struct { field: u32 } //~^ not covered } pub enum NormalEnum { Unit, //~^ not covered Tuple(u32), //~^ not covered Struct { field: u32 } //~...
{} fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) { match x {} match x { _ => {} //~ ERROR unreachable pattern } } fn main() { match NonExhaustiveEnum::Unit {} //~^ ERROR `Unit`, `Tuple(_)` and `Struct {.. }` not covered [E0004] match NormalEnum::Unit {} //~^ ERROR `Unit`, `Tu...
EmptyNonExhaustiveEnum
identifier_name
radio.rs
use crate::direction::Direction; use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent}; use crate::theme::ColorStyle; use crate::view::View; use crate::Cursive; use crate::Vec2; use crate::{Printer, With}; use std::cell::RefCell; use std::rc::Rc; struct SharedState<T> { selection: usize, values:...
else { printer.with_color(ColorStyle::secondary(), |printer| { self.draw_internal(printer) }); } } fn on_event(&mut self, event: Event) -> EventResult { if!self.enabled { return EventResult::Ignored; } match event { ...
{ printer.with_selection(printer.focused, |printer| { self.draw_internal(printer) }); }
conditional_block
radio.rs
use crate::direction::Direction; use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent}; use crate::theme::ColorStyle; use crate::view::View; use crate::Cursive; use crate::Vec2; use crate::{Printer, With}; use std::cell::RefCell; use std::rc::Rc; struct SharedState<T> { selection: usize, values:...
/// pub struct RadioButton<T> { state: Rc<RefCell<SharedState<T>>>, id: usize, enabled: bool, label: String, } impl<T:'static> RadioButton<T> { impl_enabled!(self.enabled); fn new( state: Rc<RefCell<SharedState<T>>>, id: usize, label: String, ) -> Self { Rad...
/// time. /// /// `RadioButton`s are not created directly, but through /// [`RadioGroup::button`].
random_line_split
radio.rs
use crate::direction::Direction; use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent}; use crate::theme::ColorStyle; use crate::view::View; use crate::Cursive; use crate::Vec2; use crate::{Printer, With}; use std::cell::RefCell; use std::rc::Rc; struct SharedState<T> { selection: usize, values:...
/// Returns `true` if this button is selected. pub fn is_selected(&self) -> bool { self.state.borrow().selection == self.id } /// Selects this button, un-selecting any other in the same group. pub fn select(&mut self) -> EventResult { let mut state = self.state.borrow_mut(); ...
{ RadioButton { state, id, enabled: true, label, } }
identifier_body
radio.rs
use crate::direction::Direction; use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent}; use crate::theme::ColorStyle; use crate::view::View; use crate::Cursive; use crate::Vec2; use crate::{Printer, With}; use std::cell::RefCell; use std::rc::Rc; struct SharedState<T> { selection: usize, values:...
(&self) -> Rc<T> { Rc::clone(&self.values[self.selection]) } } /// Group to coordinate multiple radio buttons. /// /// A `RadioGroup` is used to create and manage [`RadioButton`]s. /// /// A `RadioGroup` can be cloned; it will keep pointing to the same group. #[derive(Clone)] pub struct RadioGroup<T> { ...
selection
identifier_name
momentum_indicators.rs
extern crate tars; use tars::momentum_indicators::rsi::rsi; use tars::helpers::round_array; // Some randomly generated data to test against TA-Lib (see generate_data.py & correct_values.py)
const OPEN: &[f64] = &[1984.03, 1959.83, 2041.42, 2019.04, 1969.53, 2082.75, 2209.52, 2200.9, 2364.04, 2543.32, 2423.95, 2483.28, 2604.88, 2393.81, 2231.27, 2420.82, 2544.0, 2766.67, 2919.62, 2763.25]; const HIGH: &[f64] = &[2174.72, 2129.49, 2158.92, 2050.2, 2042.12, 2151....
random_line_split