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
TestClz.rs
/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by app...
} int2 __attribute__((kernel)) testClzInt2Int2(int2 inValue) { return clz(inValue); } int3 __attribute__((kernel)) testClzInt3Int3(int3 inValue) { return clz(inValue); } int4 __attribute__((kernel)) testClzInt4Int4(int4 inValue) { return clz(inValue); } uint __attribute__((kernel)) testClzUintUint(uint ...
return clz(inValue); } int __attribute__((kernel)) testClzIntInt(int inValue) { return clz(inValue);
random_line_split
type_variable.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 ...
* dir, vid1)` where `vid1` is some other variable id. */ let old_value = { let value_ptr = &mut self.values.get_mut(vid.index).value; mem::replace(value_ptr, Known(ty)) }; let relations = match old_value { Bounded(b) => b, Known...
* Instantiates `vid` with the type `ty` and then pushes an * entry onto `stack` for each of the relations of `vid` to * other variables. The relations will have the form `(ty,
random_line_split
type_variable.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 replace_if_possible(&self, t: Ty<'tcx>) -> Ty<'tcx> { match t.sty { ty::ty_infer(ty::TyVar(v)) => { match self.probe(v) { None => t, Some(u) => u } } _ => t, } } pub fn snaps...
{ match self.values.get(vid.index).value { Bounded(..) => None, Known(t) => Some(t) } }
identifier_body
type_variable.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) -> Snapshot { Snapshot { snapshot: self.values.start_snapshot() } } pub fn rollback_to(&mut self, s: Snapshot) { self.values.rollback_to(s.snapshot); } pub fn commit(&mut self, s: Snapshot) { self.values.commit(s.snapshot); } } impl<'tcx> sv::SnapshotVecDelegat...
snapshot
identifier_name
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
unreachable!(); } fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> { Some(self.owner as @mut Reflectable) } }
&mut self.reflector_ } fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
random_line_split
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
Text_xml => { AbstractDocument::as_abstract(cx, @mut Document::new(self.owner, XML)) } _ => { fail!("unsupported document type") } }; let root = @HTMLHtmlElement { htmlelement: HTMLElement::new(HTMLHtmlElementT...
{ HTMLDocument::new(self.owner) }
conditional_block
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
pub fn new(owner: @mut Window) -> @mut DOMParser { reflect_dom_object(@mut DOMParser::new_inherited(owner), owner, DOMParserBinding::Wrap) } pub fn Constructor(owner: @mut Window) -> Fallible<@mut DOMParser> { Ok(DOMParser::new(owner)) } pub fn ParseFro...
{ DOMParser { owner: owner, reflector_: Reflector::new() } }
identifier_body
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
(&self, _cx: *JSContext) -> Option<@mut Reflectable> { Some(self.owner as @mut Reflectable) } }
GetParentObject
identifier_name
coercion.rs
mut things (when the expected is &mut T and you have &mut T). See //! the various `src/test/run-pass/coerce-reborrow-*.rs` tests for //! examples of where this is useful. //! //! ## Subtle note //! //! When deciding what type coercions to consider, we do not attempt to //! resolve any type variables we may encounter....
(&self, a: Ty<'tcx>, b: Ty<'tcx>, mutbl_b: ast::Mutability) -> CoerceResult<'tcx> { debug!("coerce_unsafe_ptr(a={}, b={})", a.repr(self.tcx()), b.repr(self.tcx())); let mt_a...
coerce_unsafe_ptr
identifier_name
coercion.rs
//! of mut things (when the expected is &mut T and you have &mut T). See //! the various `src/test/run-pass/coerce-reborrow-*.rs` tests for //! examples of where this is useful. //! //! ## Subtle note //! //! When deciding what type coercions to consider, we do not attempt to //! resolve any type variables we may enco...
self.coerce_unsized(a, b) }); if unsize.is_ok() { return unsize; } // Examine the supertype and consider auto-borrowing. // // Note: does not attempt to resolve type variables we encounter. // See above for details. match b.sty { ...
a.repr(self.tcx()), b.repr(self.tcx())); // Consider coercing the subtype to a DST let unsize = self.unpack_actual_value(a, |a| {
random_line_split
coercion.rs
mut things (when the expected is &mut T and you have &mut T). See //! the various `src/test/run-pass/coerce-reborrow-*.rs` tests for //! examples of where this is useful. //! //! ## Subtle note //! //! When deciding what type coercions to consider, we do not attempt to //! resolve any type variables we may encounter....
let (source, reborrow) = match (&source.sty, &target.sty) { (&ty::ty_rptr(_, mt_a), &ty::ty_rptr(_, mt_b)) => { try!(coerce_mutbls(mt_a.mutbl, mt_b.mutbl)); let coercion = Coercion(self.origin.span()); let r_borrow = self.fcx.infcx().next_region_var(c...
{ debug!("coerce_unsized(source={}, target={})", source.repr(self.tcx()), target.repr(self.tcx())); let traits = (self.tcx().lang_items.unsize_trait(), self.tcx().lang_items.coerce_unsized_trait()); let (unsize_did, coerce_unsized_did) = if le...
identifier_body
resolve.rs
use std::collections::{HashMap, HashSet}; use core::{Package, PackageId, SourceId}; use core::registry::PackageRegistry; use core::resolver::{self, Resolve, Method}; use ops; use util::CargoResult; /// Resolve all dependencies for the specified `package` using the previous /// lockfile as a guide if present. /// /// ...
let mut resolved = try!(resolver::resolve(&summary, &method, registry)); match previous { Some(r) => resolved.copy_metadata(r), None => {} } return Ok(resolved); fn keep<'a>(p: &&'a PackageId, to_avoid_packages: Option<&HashSet<&'a PackageId>>, to_avo...
random_line_split
resolve.rs
use std::collections::{HashMap, HashSet}; use core::{Package, PackageId, SourceId}; use core::registry::PackageRegistry; use core::resolver::{self, Resolve, Method}; use ops; use util::CargoResult; /// Resolve all dependencies for the specified `package` using the previous /// lockfile as a guide if present. /// /// ...
} } None => {} } let summary = package.summary().clone(); let summary = match previous { Some(r) => { // In the case where a previous instance of resolve is available, we // want to lock as many packages as possible to the previous version ...
{ try!(registry.add_sources(&[package.package_id().source_id() .clone()])); // Here we place an artificial limitation that all non-registry sources // cannot be locked at more than one revision. This means that if a git // repository provides more than one packag...
identifier_body
resolve.rs
use std::collections::{HashMap, HashSet}; use core::{Package, PackageId, SourceId}; use core::registry::PackageRegistry; use core::resolver::{self, Resolve, Method}; use ops; use util::CargoResult; /// Resolve all dependencies for the specified `package` using the previous /// lockfile as a guide if present. /// /// ...
<'a>(registry: &mut PackageRegistry, package: &Package, method: Method, previous: Option<&'a Resolve>, to_avoid: Option<&HashSet<&'a PackageId>>) -> CargoR...
resolve_with_previous
identifier_name
assign-to-method.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 ...
{ meows : usize, how_hungry : isize, } impl cat { pub fn speak(&self) { self.meows += 1_usize; } } fn cat(in_x : usize, in_y : isize) -> cat { cat { meows: in_x, how_hungry: in_y } } fn main() { let nyan : cat = cat(52_usize, 99); nyan.speak = || println!("meow"); //~ ERROR atte...
cat
identifier_name
assign-to-method.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 ...
meows : usize, how_hungry : isize, } impl cat { pub fn speak(&self) { self.meows += 1_usize; } } fn cat(in_x : usize, in_y : isize) -> cat { cat { meows: in_x, how_hungry: in_y } } fn main() { let nyan : cat = cat(52_usize, 99); nyan.speak = || println!("meow"); //~ ERROR attempt...
struct cat {
random_line_split
assign-to-method.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 nyan : cat = cat(52_usize, 99); nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method }
identifier_body
network_usage.rs
use futures::{Future, Stream}; use std::sync::Arc; use tokio_timer::Timer; use tokio_core::reactor::Handle; use component::Component; use error::{Error, Result}; use std::time::Duration; use utils; #[derive(Clone, PartialEq, Copy)] pub enum Scale { Binary, Decimal, } impl Scale { fn base(&self) -> u16 { ...
Scale::Binary => 1024, } } } #[derive(Clone, Copy)] pub enum Direction { Incoming, Outgoing, } pub struct NetworkUsage { pub interface: String, pub direction: Direction, pub scale: Scale, pub percision: u8, pub refresh_frequency: Duration, pub sample_duration: D...
random_line_split
network_usage.rs
use futures::{Future, Stream}; use std::sync::Arc; use tokio_timer::Timer; use tokio_core::reactor::Handle; use component::Component; use error::{Error, Result}; use std::time::Duration; use utils; #[derive(Clone, PartialEq, Copy)] pub enum Scale { Binary, Decimal, } impl Scale { fn base(&self) -> u16 { ...
{ pub interface: String, pub direction: Direction, pub scale: Scale, pub percision: u8, pub refresh_frequency: Duration, pub sample_duration: Duration, } impl Default for NetworkUsage { fn default() -> NetworkUsage { NetworkUsage { interface: "eth0".to_string(), ...
NetworkUsage
identifier_name
network_usage.rs
use futures::{Future, Stream}; use std::sync::Arc; use tokio_timer::Timer; use tokio_core::reactor::Handle; use component::Component; use error::{Error, Result}; use std::time::Duration; use utils; #[derive(Clone, PartialEq, Copy)] pub enum Scale { Binary, Decimal, } impl Scale { fn base(&self) -> u16 { ...
} fn get_prefix(scale: Scale, power: u8) -> &'static str { match (scale, power) { (Scale::Decimal, 0) | (Scale::Binary, 0) => "B/s", (Scale::Decimal, 1) => "kb/s", (Scale::Decimal, 2) => "Mb/s", (Scale::Decimal, 3) => "Gb/s", (Scale::Decimal, 4) => "Tb/s", (Scale::B...
{ NetworkUsage { interface: "eth0".to_string(), direction: Direction::Incoming, scale: Scale::Binary, percision: 3, refresh_frequency: Duration::from_secs(10), sample_duration: Duration::from_secs(1), } }
identifier_body
float_context.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 geom::point::Point2D; use geom::size::Size2D; use geom::rect::Rect; use gfx::geometry::{Au, max, min}; use std...
#[inline(always)] pub fn last_float_pos(&mut self) -> Point2D<Au> { do self.with_base |base| { base.last_float_pos() } } #[inline(always)] pub fn clearance(&self, clear: ClearType) -> Au { do self.with_base |base| { base.clearance(clear) } ...
{ do self.with_base |base| { base.place_between_floats(info) } }
identifier_body
float_context.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 geom::point::Point2D; use geom::size::Size2D; use geom::rect::Rect; use gfx::geometry::{Au, max, min}; use std...
(&self, bounds: &Rect<Au>) -> bool { for float in self.float_data.iter() { match *float{ None => (), Some(data) => { if data.bounds.translate(&self.offset).intersects(bounds) { return true; } ...
collides_with_float
identifier_name
float_context.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 geom::point::Point2D; use geom::size::Size2D; use geom::rect::Rect; use gfx::geometry::{Au, max, min}; use std...
"Non-terminating float placement"); // Place here if there is enough room if (rect.size.width >= info.width) { let height = self.max_height_for_bounds(rect.origin.x, ...
Size2D(info.max_width, Au(max_value))) }, Some(rect) => { assert!(rect.origin.y + rect.size.height != float_y,
random_line_split
counter.rs
//! A wrapper which counts the number of records pushed past and updates a shared count map. use std::rc::Rc;
use std::cell::RefCell; use progress::CountMap; use dataflow::channels::Content; use Push; /// A wrapper which updates shared `counts` based on the number of records pushed. pub struct Counter<T, D, P: Push<(T, Content<D>)>> { pushee: P, counts: Rc<RefCell<CountMap<T>>>, phantom: ::std::marker::PhantomDat...
random_line_split
counter.rs
//! A wrapper which counts the number of records pushed past and updates a shared count map. use std::rc::Rc; use std::cell::RefCell; use progress::CountMap; use dataflow::channels::Content; use Push; /// A wrapper which updates shared `counts` based on the number of records pushed. pub struct Counter<T, D, P: Push<...
// only propagate `None` if dirty (indicates flush) if message.is_some() || self.counts.borrow().len() > 0 { self.pushee.push(message); } } } impl<T, D, P: Push<(T, Content<D>)>> Counter<T, D, P> where T : Eq+Clone+'static { /// Allocates a new `Counter` from a...
{ self.counts.borrow_mut().update(time, data.len() as i64); }
conditional_block
counter.rs
//! A wrapper which counts the number of records pushed past and updates a shared count map. use std::rc::Rc; use std::cell::RefCell; use progress::CountMap; use dataflow::channels::Content; use Push; /// A wrapper which updates shared `counts` based on the number of records pushed. pub struct Counter<T, D, P: Push<...
(pushee: P, counts: Rc<RefCell<CountMap<T>>>) -> Counter<T, D, P> { Counter { pushee: pushee, counts: counts, phantom: ::std::marker::PhantomData, } } /// Extracts shared counts into `updates`. /// /// It is unclear why this method exists at the same t...
new
identifier_name
counter.rs
//! A wrapper which counts the number of records pushed past and updates a shared count map. use std::rc::Rc; use std::cell::RefCell; use progress::CountMap; use dataflow::channels::Content; use Push; /// A wrapper which updates shared `counts` based on the number of records pushed. pub struct Counter<T, D, P: Push<...
}
{ while let Some((ref time, delta)) = self.counts.borrow_mut().pop() { updates.update(time, delta); } }
identifier_body
echo.rs
#[macro_use] extern crate log; #[macro_use] extern crate rux; extern crate num_cpus; extern crate env_logger; use rux::{RawFd, Reset}; use rux::buf::ByteBuffer; use rux::handler::*; use rux::mux::*; use rux::epoll::*; use rux::sys::socket::*; use rux::prop::server::*; use rux::daemon::*; const BUF_SIZE: usize = 2048;...
EPOLL_BUF_CAP, EPOLL_LOOP_MS, MAX_CONN); let config = ServerConfig::tcp(("127.0.0.1", 9999)) .unwrap() .max_conn(MAX_CONN) .io_threads(1) //.io_threads(::std::cmp::max(1, ::num_cpus::get() / 2)) .epoll_config(EpollConfig { loop_ms: EPOLL_LOOP_MS, buffer_capacity: E...
::env_logger::init().unwrap(); info!("BUF_SIZE: {}; EPOLL_BUF_CAP: {}; EPOLL_LOOP_MS: {}; MAX_CONN: {}", BUF_SIZE,
random_line_split
echo.rs
#[macro_use] extern crate log; #[macro_use] extern crate rux; extern crate num_cpus; extern crate env_logger; use rux::{RawFd, Reset}; use rux::buf::ByteBuffer; use rux::handler::*; use rux::mux::*; use rux::epoll::*; use rux::sys::socket::*; use rux::prop::server::*; use rux::daemon::*; const BUF_SIZE: usize = 2048;...
(&mut self, _: EpollFd) { } } impl Reset for EchoHandler { fn reset(&mut self) {} } #[derive(Clone, Debug)] struct EchoFactory; impl<'a> HandlerFactory<'a, EchoHandler, ByteBuffer> for EchoFactory { fn new_resource(&self) -> ByteBuffer { ByteBuffer::with_capacity(BUF_SIZE) } fn new_handler(&mut self...
with_epfd
identifier_name
echo.rs
#[macro_use] extern crate log; #[macro_use] extern crate rux; extern crate num_cpus; extern crate env_logger; use rux::{RawFd, Reset}; use rux::buf::ByteBuffer; use rux::handler::*; use rux::mux::*; use rux::epoll::*; use rux::sys::socket::*; use rux::prop::server::*; use rux::daemon::*; const BUF_SIZE: usize = 2048;...
MuxCmd::Keep } fn on_next(&mut self, event: MuxEvent<'a, ByteBuffer>) { let fd = event.fd; let events = event.events; let buffer = event.resource; if events.contains(EPOLLHUP) { trace!("socket's fd {}: EPOLLHUP", fd); self.closed = true; return; } if events.contai...
{ return MuxCmd::Close; }
conditional_block
echo.rs
#[macro_use] extern crate log; #[macro_use] extern crate rux; extern crate num_cpus; extern crate env_logger; use rux::{RawFd, Reset}; use rux::buf::ByteBuffer; use rux::handler::*; use rux::mux::*; use rux::epoll::*; use rux::sys::socket::*; use rux::prop::server::*; use rux::daemon::*; const BUF_SIZE: usize = 2048;...
fn with_epfd(&mut self, _: EpollFd) { } } impl Reset for EchoHandler { fn reset(&mut self) {} } #[derive(Clone, Debug)] struct EchoFactory; impl<'a> HandlerFactory<'a, EchoHandler, ByteBuffer> for EchoFactory { fn new_resource(&self) -> ByteBuffer { ByteBuffer::with_capacity(BUF_SIZE) } fn new_h...
{ EPOLLIN | EPOLLOUT | EPOLLET }
identifier_body
batch.rs
//! # `batch` - batches of files to marshal. //! //! A `Batch` represents a collection of files which are being marshalled and a stream of hashed //! output objects. For a single `Batch`, there should correspond a set of valid marshalled files //! and a stream of valid hashed objects produced from marshalling/hashing t...
pub fn marshal_subtree<P: AsRef<Path>>( &mut self, path: P, ) -> Box<Future<Item = ObjectHash, Error = Error> + Send> { let result = self.load_subtree(path) .map(|tree| { let tree_total = tree.total(); self.len += tree_total; ...
{ let tree = DataTree::load(chunked.to_vec().into_iter().map(SmallRecord::from)); let tree_total = tree.total(); self.len += tree_total; let marshal = tree.marshal(Hasher::with_trace( self.marshal_tx.clone(), self.trace.on_marshal(tree_total), )); ...
identifier_body
batch.rs
//! # `batch` - batches of files to marshal. //! //! A `Batch` represents a collection of files which are being marshalled and a stream of hashed //! output objects. For a single `Batch`, there should correspond a set of valid marshalled files //! and a stream of valid hashed objects produced from marshalling/hashing t...
} Ok(dir_tree) } /// Marshal a chunked file into a tree of objects, returning the marshalled objects along with /// the hash of the root object. pub fn marshal_file( &mut self, chunked: Chunked, ) -> Box<Future<Item = ObjectHash, Error = Error> + Send> { le...
{ dir_tree.insert(entry_path, self.load_file(&path)?); }
conditional_block
batch.rs
//! # `batch` - batches of files to marshal. //! //! A `Batch` represents a collection of files which are being marshalled and a stream of hashed //! output objects. For a single `Batch`, there should correspond a set of valid marshalled files //! and a stream of valid hashed objects produced from marshalling/hashing t...
let entry_path = path.strip_prefix(path_ref).unwrap(); if path.is_dir() { dir_tree.insert(entry_path, self.load_subtree(&path)?); } else { dir_tree.insert(entry_path, self.load_file(&path)?); } } Ok(dir_tree) } //...
let path = entry.path();
random_line_split
batch.rs
//! # `batch` - batches of files to marshal. //! //! A `Batch` represents a collection of files which are being marshalled and a stream of hashed //! output objects. For a single `Batch`, there should correspond a set of valid marshalled files //! and a stream of valid hashed objects produced from marshalling/hashing t...
<P: AsRef<Path>>(&mut self, path: P) -> Result<Chunked> { let slice = self.read_path(path)?; let mut trace = self.trace.on_split(slice.len() as u64); let chunked = split::chunk_with_trace(slice, &mut trace); Ok(chunked) } pub fn load_file<P: AsRef<Path>>(&mut self, path: P) -> ...
chunk_file
identifier_name
htmldivelement.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::HTMLDivElementBinding::{self, HTMLDivElementMethods}; use dom::bindings::js:...
}
random_line_split
htmldivelement.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::HTMLDivElementBinding::{self, HTMLDivElementMethods}; use dom::bindings::js:...
(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLDivElement> { Node::reflect_node(box HTMLDivElement::new_inherited(local_name, prefix, document), document, HTMLDivElementBinding::Wrap) } }...
new
identifier_name
config.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0. //! Storage configuration. use crate::server::ttl::TTLCheckerTask; use crate::server::CONFIG_ROCKSDB_GAUGE; use configuration::{ConfigChange, ConfigManager, ConfigValue, Configuration, Result as CfgResult}; use engine_rocks::raw::{Cache, LRUCacheOptio...
}, "" => {} other => { warn!( "Memory allocator {} is not supported, continue with default allocator", other ); } } }; None } }
{ warn!( "Create jemalloc nodump allocator for block cache failed: {}, continue with default allocator", e ); }
conditional_block
config.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0. //! Storage configuration. use crate::server::ttl::TTLCheckerTask; use crate::server::CONFIG_ROCKSDB_GAUGE; use configuration::{ConfigChange, ConfigManager, ConfigValue, Configuration, Result as CfgResult}; use engine_rocks::raw::{Cache, LRUCacheOptio...
"TiKV has optimized latch since v4.0, so it is not necessary to set large schedule \ concurrency. To save memory, change it from {:?} to {:?}", self.scheduler_concurrency, MAX_SCHED_CONCURRENCY ); self.scheduler_concurrency = MAX_SCHED_CONCURRENCY;...
if self.data_dir != DEFAULT_DATA_DIR { self.data_dir = config::canonicalize_path(&self.data_dir)? } if self.scheduler_concurrency > MAX_SCHED_CONCURRENCY { warn!(
random_line_split
config.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0. //! Storage configuration. use crate::server::ttl::TTLCheckerTask; use crate::server::CONFIG_ROCKSDB_GAUGE; use configuration::{ConfigChange, ConfigManager, ConfigValue, Configuration, Result as CfgResult}; use engine_rocks::raw::{Cache, LRUCacheOptio...
() -> Config { let cpu_num = SysQuota::new().cpu_cores_quota(); Config { data_dir: DEFAULT_DATA_DIR.to_owned(), gc_ratio_threshold: DEFAULT_GC_RATIO_THRESHOLD, max_key_size: DEFAULT_MAX_KEY_SIZE, scheduler_concurrency: DEFAULT_SCHED_CONCURRENCY, ...
default
identifier_name
main.rs
#![cfg_attr(all(test, feature = "nightly"), feature(test))] // we only need test feature when testing #[macro_use] extern crate log; extern crate syntex_syntax; extern crate toml; extern crate env_logger; #[macro_use] extern crate clap; extern crate racer; #[cfg(not(test))] use racer::core; #[cfg(not(test))] use ra...
Config {fqn: m.value_of("fqn").map(ToOwned::to_owned),..Default::default() } } } #[cfg(not(test))] fn build_cli<'a, 'b, 'c, 'd, 'e, 'f>() -> App<'a, 'b, 'c, 'd, 'e, 'f> { // we use the more verbose "Builder Pattern" to create the CLI because it's a littel faster // than the less verbose "Usage Str...
{ let cfg = Config { charnum: value_t_or_exit!(m.value_of("charnum"), usize), fn_name: m.value_of("path").map(PathBuf::from), substitute_file: m.value_of("substitute_file").map(PathBuf::from), ..Default::default() }; ...
conditional_block
main.rs
#![cfg_attr(all(test, feature = "nightly"), feature(test))] // we only need test feature when testing #[macro_use] extern crate log; extern crate syntex_syntax; extern crate toml; extern crate env_logger; #[macro_use] extern crate clap; extern crate racer; #[cfg(not(test))] use racer::core; #[cfg(not(test))] use ra...
(cfg: &Config, print_type: CompletePrinter) { let fn_path = &*cfg.fn_name.as_ref().unwrap(); let substitute_file = cfg.substitute_file.as_ref().unwrap_or(fn_path); let cache = core::FileCache::new(); let session = core::Session::from_path(&cache, fn_path, substitute_file); let src = session.load_fi...
run_the_complete_fn
identifier_name
main.rs
#![cfg_attr(all(test, feature = "nightly"), feature(test))] // we only need test feature when testing #[macro_use] extern crate log; extern crate syntex_syntax; extern crate toml; extern crate env_logger; #[macro_use] extern crate clap; extern crate racer; #[cfg(not(test))] use racer::core; #[cfg(not(test))] use ra...
#[cfg(not(test))] fn run(m: ArgMatches, interface: Interface) { use CompletePrinter::{Normal, WithSnippets}; // match raw subcommand, and get it's sub-matches "m" if let (name, Some(sub_m)) = m.subcommand() { let mut cfg = Config::from(sub_m); cfg.interface = interface; match name ...
{ // make sure we get a stack trace ifwe panic ::std::env::set_var("RUST_BACKTRACE","1"); env_logger::init().unwrap(); check_rust_src_env_var(); let matches = build_cli().get_matches(); let interface = match matches.value_of("interface") { Some("text") => Interface::Text, ...
identifier_body
main.rs
#![cfg_attr(all(test, feature = "nightly"), feature(test))] // we only need test feature when testing #[macro_use] extern crate log; extern crate syntex_syntax; extern crate toml; extern crate env_logger; #[macro_use] extern crate clap; extern crate racer; #[cfg(not(test))] use racer::core; #[cfg(not(test))] use ra...
} #[cfg(not(test))] impl Default for Interface { fn default() -> Self { Interface::Text } } #[cfg(not(test))] #[derive(Default)] struct Config { fqn: Option<String>, linenum: usize, charnum: usize, fn_name: Option<PathBuf>, substitute_file: Option<PathBuf>, interface: Interface, } #[cfg(n...
random_line_split
mod.rs
//! Provides dedicated `system` pipelines inside OrbTk. //! //! System pipelines are modules, that handle specific tasks when //! iteratively walking the widget tree. Because each widget //! implements the `state` trait, all system modules are accessible. //! Pipelines are connected in a logical order. E.g. the `InitSy...
mod init_system; mod layout_system; mod post_layout_state_system; mod render_system;
mod cleanup_system; mod event_state_system;
random_line_split
session.rs
//! This exposes `Session`, the struct stored in the `Alloy`. use std::sync::Arc; use super::SessionStore; /// A session which provides basic CRUD operations.
key: K, store: Arc<Box<SessionStore<K, V> +'static + Send + Sync>> } impl<K, V> Session<K, V> { /// Create a new session pub fn new(key: K, store: Box<SessionStore<K, V> +'static + Send + Sync>) -> Session<K, V> { Session { key: key, store: Arc::new(store) } ...
pub struct Session<K, V> {
random_line_split
session.rs
//! This exposes `Session`, the struct stored in the `Alloy`. use std::sync::Arc; use super::SessionStore; /// A session which provides basic CRUD operations. pub struct Session<K, V> { key: K, store: Arc<Box<SessionStore<K, V> +'static + Send + Sync>> } impl<K, V> Session<K, V> { /// Create a new sessio...
(&self, value: V) -> Option<V> { self.store.swap(&self.key, value) } /// Insert value, if not yet set, or update the current value of this session. /// /// Returns an owned copy of the set (current) value of this session. /// /// This is analagous to the `insert_or_update_with` method of...
swap
identifier_name
session.rs
//! This exposes `Session`, the struct stored in the `Alloy`. use std::sync::Arc; use super::SessionStore; /// A session which provides basic CRUD operations. pub struct Session<K, V> { key: K, store: Arc<Box<SessionStore<K, V> +'static + Send + Sync>> } impl<K, V> Session<K, V> { /// Create a new sessio...
/// Swap the given value with the current value of this session. /// /// Returns the value being replaced. /// Returns `None` if this session was not yet set. pub fn swap(&self, value: V) -> Option<V> { self.store.swap(&self.key, value) } /// Insert value, if not yet set, or update ...
{ self.store.find(&self.key) }
identifier_body
poly.rs
// Copyright (C) 2020 Inderjit Gill <email@indy.io> // This file is part of Seni // Seni is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any l...
( render_list: &mut RenderList, matrix: &Matrix, coords: &[(f32, f32)], colours: &[Rgb], uvm: &UvMapping, ) -> Result<()> { let num_vertices = coords.len(); if colours.len()!= num_vertices { error!("render_poly: coords and colours length mismatch"); return Err(Error::Geometry...
render
identifier_name
poly.rs
// Copyright (C) 2020 Inderjit Gill <email@indy.io> // This file is part of Seni // Seni is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any l...
rpg.add_vertex(matrix, x, y, &colours[i], uvm.map[4], uvm.map[5]) } Ok(()) }
{ let num_vertices = coords.len(); if colours.len() != num_vertices { error!("render_poly: coords and colours length mismatch"); return Err(Error::Geometry); } else if num_vertices < 3 { return Ok(()); } let (x, y) = coords[0]; render_list.prepare_to_add_triangle_strip(m...
identifier_body
poly.rs
// Copyright (C) 2020 Inderjit Gill <email@indy.io> // This file is part of Seni // Seni is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any l...
use crate::render_list::RenderList; use crate::rgb::Rgb; use crate::uvmapper::UvMapping; use log::error; pub fn render( render_list: &mut RenderList, matrix: &Matrix, coords: &[(f32, f32)], colours: &[Rgb], uvm: &UvMapping, ) -> Result<()> { let num_vertices = coords.len(); if colours.len()...
use crate::error::{Error, Result}; use crate::matrix::Matrix;
random_line_split
sph_hamsi_test.rs
extern crate sphlib; extern crate libc; use sphlib::{sph_hamsi, utils}; #[test] fn will_be_224_hash() { let dest = sph_hamsi::hamsi224_init_load_close(""); let actual = utils::to_hex_hash(&dest); assert_eq!("b9f6eb1a9b990373f9d2cb125584333c69a3d41ae291845f05da221f", actual.to_string()); } #[test] fn wi...
#[test] fn will_be_384_hash() { let dest = sph_hamsi::hamsi384_init_load_close(""); let actual = utils::to_hex_hash(&dest); assert_eq!("3943cd34e3b96b197a8bf4bac7aa982d18530dd12f41136b26d7e88759255f21153f4a4bd02e523612b8427f9dd96c8d", actual.to_string()); } #[test] fn will_be_512_hash() { let dest ...
{ let dest = sph_hamsi::hamsi256_init_load_close(""); let actual = utils::to_hex_hash(&dest); assert_eq!("750e9ec469f4db626bee7e0c10ddaa1bd01fe194b94efbabebd24764dc2b13e9", actual.to_string()); }
identifier_body
sph_hamsi_test.rs
extern crate sphlib; extern crate libc; use sphlib::{sph_hamsi, utils}; #[test] fn
() { let dest = sph_hamsi::hamsi224_init_load_close(""); let actual = utils::to_hex_hash(&dest); assert_eq!("b9f6eb1a9b990373f9d2cb125584333c69a3d41ae291845f05da221f", actual.to_string()); } #[test] fn will_be_256_hash() { let dest = sph_hamsi::hamsi256_init_load_close(""); let actual = utils::...
will_be_224_hash
identifier_name
sph_hamsi_test.rs
extern crate sphlib; extern crate libc; use sphlib::{sph_hamsi, utils}; #[test] fn will_be_224_hash() { let dest = sph_hamsi::hamsi224_init_load_close(""); let actual = utils::to_hex_hash(&dest); assert_eq!("b9f6eb1a9b990373f9d2cb125584333c69a3d41ae291845f05da221f", actual.to_string()); } #[test] fn wi...
} #[test] fn will_be_512_hash() { let dest = sph_hamsi::hamsi512_init_load_close(""); let actual = utils::to_hex_hash(&dest); assert_eq!("5cd7436a91e27fc809d7015c3407540633dab391127113ce6ba360f0c1e35f404510834a551610d6e871e75651ea381a8ba628af1dcf2b2be13af2eb6247290f", actual.to_string()); }
#[test] fn will_be_384_hash() { let dest = sph_hamsi::hamsi384_init_load_close(""); let actual = utils::to_hex_hash(&dest); assert_eq!("3943cd34e3b96b197a8bf4bac7aa982d18530dd12f41136b26d7e88759255f21153f4a4bd02e523612b8427f9dd96c8d", actual.to_string());
random_line_split
match.rs
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn | Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => { blah } Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn => meh, Patternnnnnnnnnnnnnnnnnnn | P...
} sfEvtKeyPressed => { let e = unsafe { event.key.as_ref() }; KeyPressed { code: unsafe { ::std::mem::transmute(e.code) }, alt: e.alt.to_bool(), ctrl: e.control.to_bool(), shift: e.shift.to_bool(), s...
{ Some(match type_ { sfEvtClosed => Closed, sfEvtResized => { let e = unsafe { *event.size.as_ref() }; Resized { width: e.width, height: e.height, } } sfEvtLostFocus => LostFocus, sfEvtGainedFocus => GainedF...
identifier_body
match.rs
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn | Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => { blah } Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn => meh, Patternnnnnnnnnnnnnnnnnnn | P...
() { foobar(f, "{}", match *self { TaskState::Started => "started", TaskState::Success => "success", TaskState::Failed => "failed", }); } // #1838, #1839 fn match_with_near_max_width() { let (this_line_uses_99_characters_and_is_formatted_properly, x012345) = match some_expression ...
issue525
identifier_name
match.rs
ternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn | Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => { blah } Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn | Patternnnnnnnnnnnnnnnnnnn => meh, Patternnnnnnnnnnnnnnnnnnn | ...
m => { } n => { } o => { } p => { // Don't collapse me } q => { } r => { } s => 0, // s comment // t comment t => 1, u => 2, v => { } /* funky block * comment */ // final comment } } ...
// } // l => { // // comment with ws below // // }
random_line_split
char_indexing.rs
use std::ops::Range; pub(crate) trait CharIndexable<'b> { fn char_index(&'b self, range: Range<usize>) -> &'b str; } pub struct CharIndexableStr<'a> { s: &'a str, indices: Vec<usize>, } impl CharIndexableStr<'_> { pub(crate) fn char_count(&self) -> usize { self.indices.len() } } impl<'a>...
(s: &'a str) -> Self { CharIndexableStr { indices: s.char_indices().map(|(i, _c)| i).collect(), s, } } } impl<'a, 'b: 'a> CharIndexable<'b> for CharIndexableStr<'a> { fn char_index(&'b self, range: Range<usize>) -> &'b str { if range.end >= self.indices.len() { ...
from
identifier_name
char_indexing.rs
use std::ops::Range; pub(crate) trait CharIndexable<'b> { fn char_index(&'b self, range: Range<usize>) -> &'b str; } pub struct CharIndexableStr<'a> { s: &'a str, indices: Vec<usize>, } impl CharIndexableStr<'_> { pub(crate) fn char_count(&self) -> usize { self.indices.len() } } impl<'a>...
} }
{ &self.s[self.indices[range.start]..self.indices[range.end]] }
conditional_block
char_indexing.rs
use std::ops::Range; pub(crate) trait CharIndexable<'b> { fn char_index(&'b self, range: Range<usize>) -> &'b str; } pub struct CharIndexableStr<'a> { s: &'a str, indices: Vec<usize>, } impl CharIndexableStr<'_> { pub(crate) fn char_count(&self) -> usize { self.indices.len() } } impl<'a>...
&self.s[self.indices[range.start]..self.indices[range.end]] } } }
&self.s[self.indices[range.start]..] } else {
random_line_split
estr-slice.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 ...
info!(a); assert!(a < b); assert!(a <= b); assert!(a!= b); assert!(b >= a); assert!(b > a); info!(b); assert!(a < c); assert!(a <= c); assert!(a!= c); assert!(c >= a); assert!(c > a); info!(c); assert!(c < cc); assert!(c <= cc); assert!(c!= cc); ...
{ let x = &"hello"; let v = &"hello"; let y : &str = &"there"; info!(x); info!(y); assert_eq!(x[0], 'h' as u8); assert_eq!(x[4], 'o' as u8); let z : &str = &"thing"; assert_eq!(v, x); assert!(x != z); let a = &"aaaa"; let b = &"bbbb"; let c = &"cccc"; let cc ...
identifier_body
estr-slice.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!(c > a); info!(c); assert!(c < cc); assert!(c <= cc); assert!(c!= cc); assert!(cc >= c); assert!(cc > c); info!(cc); }
assert!(a <= c); assert!(a != c); assert!(c >= a);
random_line_split
estr-slice.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 x = &"hello"; let v = &"hello"; let y : &str = &"there"; info!(x); info!(y); assert_eq!(x[0], 'h' as u8); assert_eq!(x[4], 'o' as u8); let z : &str = &"thing"; assert_eq!(v, x); assert!(x!= z); let a = &"aaaa"; let b = &"bbbb"; let c = &"cccc"; let c...
main
identifier_name
infer_regusage.rs
//! Infers how each function uses every register //! For every function, patch all of its call sites to ignore registers that the //! callee doesn't read and to preserve register values that the callee //! preserves. Then, record which registers it reads and which registers it //! preserves. //! //! After this, all fun...
( &self, call_node: <SSAStorage as SSA>::ValueRef, fn_addr: u64, fn_map: &mut BTreeMap<u64, RadecoFunction>, ) -> Option<()> { // bail on indirect or weird call let (call_tgt_addr, call_reg_map) = direct_call_info(fn_map[&fn_addr].ssa(), call_node)?; // remov...
patch_call_node
identifier_name
infer_regusage.rs
//! Infers how each function uses every register //! For every function, patch all of its call sites to ignore registers that the //! callee doesn't read and to preserve register values that the callee //! preserves. Then, record which registers it reads and which registers it //! preserves. //! //! After this, all fun...
} } None } } impl Inferer { pub fn new(reginfo: SubRegisterFile) -> Inferer { Inferer { reginfo: reginfo, analyzed: HashSet::new(), } } /// Using the callconv info we've gathered so far, patch-up call sites to /// to remove argu...
{ self.patch_fn(fn_addr, &mut rmod.functions); let rfn = &mut rmod.functions.get_mut(&fn_addr).unwrap(); let mut dce = DCE::new(); dce.analyze(rfn, Some(all)); let mut combiner = Combiner::new(); co...
conditional_block
infer_regusage.rs
//! Infers how each function uses every register //! For every function, patch all of its call sites to ignore registers that the //! callee doesn't read and to preserve register values that the callee //! preserves. Then, record which registers it reads and which registers it //! preserves. //! //! After this, all fun...
ret.set_all_ignored(); for regid in ssa.regfile.iter_register_ids() { // ignore registers not in entry regstate if let Some(&(reg_val_entry, _)) = entry_regstate.get(regid) { // bail if a register isn't present in exit regstate let &(reg_val_exit,...
let entry_regstate = utils::register_state_info(entry_regstate_node, ssa); let exit_regstate = utils::register_state_info(exit_regstate_node, ssa); let mut ret = reginfo.new_register_usage();
random_line_split
infer_regusage.rs
//! Infers how each function uses every register //! For every function, patch all of its call sites to ignore registers that the //! callee doesn't read and to preserve register values that the callee //! preserves. Then, record which registers it reads and which registers it //! preserves. //! //! After this, all fun...
fn patch_call_node( &self, call_node: <SSAStorage as SSA>::ValueRef, fn_addr: u64, fn_map: &mut BTreeMap<u64, RadecoFunction>, ) -> Option<()> { // bail on indirect or weird call let (call_tgt_addr, call_reg_map) = direct_call_info(fn_map[&fn_addr].ssa(), call_n...
{ radeco_trace!("patching calls in fn: {}", fn_map[&fn_addr].name); for node in fn_map[&fn_addr].ssa().inorder_walk() { if let Ok(NodeType::Op(ir::MOpcode::OpCall)) = fn_map[&fn_addr].ssa().node_data(node).map(|nd| nd.nt) { self.patch_call_node(nod...
identifier_body
main.rs
use std::thread; use std::thread::JoinHandle; mod factorial; use factorial::util::t_log; use factorial::find_factors; fn get_chunk(index: u64, chunk_size: u64, max: u64) -> Option<(u64, u64)> { let mut result = None; let low = chunk_size * (index - 1); let high = chunk_size * index; if high <= max {...
} t_log("waiting in main..."); for handle in handles.into_iter() { handle.join().unwrap(); } t_log("Ready."); } #[allow(unused_imports)] mod tests { use super::*; #[test] fn test_get_chunk_low_boundary() { let index: u64 = 1; let chunk: u64 = 10; let ...
{ done = true; }
conditional_block
main.rs
use std::thread; use std::thread::JoinHandle; mod factorial; use factorial::util::t_log; use factorial::find_factors; fn get_chunk(index: u64, chunk_size: u64, max: u64) -> Option<(u64, u64)> { let mut result = None; let low = chunk_size * (index - 1); let high = chunk_size * index; if high <= max {...
() { let index: u64 = 1; let chunk: u64 = 10; let max: u64 = 25; // test let (low, high) = get_chunk(index, chunk, max).unwrap(); assert_eq!(low, 0); assert_eq!(high, 10); } #[test] fn test_get_chunk_basic() { let index: u64 = 2; let...
test_get_chunk_low_boundary
identifier_name
main.rs
use std::thread; use std::thread::JoinHandle; mod factorial; use factorial::util::t_log; use factorial::find_factors; fn get_chunk(index: u64, chunk_size: u64, max: u64) -> Option<(u64, u64)> { let mut result = None; let low = chunk_size * (index - 1); let high = chunk_size * index; if high <= max { ...
assert_eq!(result.is_none(), true); } }
let result = get_chunk(index, chunk, max);
random_line_split
main.rs
use std::thread; use std::thread::JoinHandle; mod factorial; use factorial::util::t_log; use factorial::find_factors; fn get_chunk(index: u64, chunk_size: u64, max: u64) -> Option<(u64, u64)> { let mut result = None; let low = chunk_size * (index - 1); let high = chunk_size * index; if high <= max {...
}
{ let index: u64 = 4; let chunk: u64 = 10; let max: u64 = 25; // test let result = get_chunk(index, chunk, max); assert_eq!(result.is_none(), true); }
identifier_body
mod.rs
pub use self::os::{FNM_NOMATCH}; pub use self::os::{FNM_PATHNAME}; pub use self::os::{FNM_PERIOD}; pub use self::os::{FNM_NOESCAPE}; use {NTStr, int_t, char_t}; #[cfg(target_os = "linux")] #[path = "linux/mod.rs"] mod os; pub fn fnmatch<T: NTStr, U: NTStr>(pattern: &T, string: &U, flags: int_t) -> int_t { extern...
}
{ let pat = "abc*123".to_nt_str(); let stn = "abcTE/ST123".to_nt_str(); let pat2 = "*123".to_nt_str(); let stn2 = ".123".to_nt_str(); assert_eq!(super::fnmatch(&pat, &stn, 0), 0); assert_eq!(super::fnmatch(&pat, &stn, super::FNM_PATHNAME), super::FNM...
identifier_body
mod.rs
pub use self::os::{FNM_NOMATCH}; pub use self::os::{FNM_PATHNAME}; pub use self::os::{FNM_PERIOD}; pub use self::os::{FNM_NOESCAPE}; use {NTStr, int_t, char_t}; #[cfg(target_os = "linux")] #[path = "linux/mod.rs"] mod os; pub fn fnmatch<T: NTStr, U: NTStr>(pattern: &T, string: &U, flags: int_t) -> int_t { extern...
unsafe { fnmatch(pattern.as_ptr(), string.as_ptr(), flags) } } #[cfg(test)] mod tests { use {ToNTStr}; #[test] fn test() { let pat = "abc*123".to_nt_str(); let stn = "abcTE/ST123".to_nt_str(); let pat2 = "*123".to_nt_str(); let stn2 = ".123".to_nt_str(); assert_...
random_line_split
mod.rs
pub use self::os::{FNM_NOMATCH}; pub use self::os::{FNM_PATHNAME}; pub use self::os::{FNM_PERIOD}; pub use self::os::{FNM_NOESCAPE}; use {NTStr, int_t, char_t}; #[cfg(target_os = "linux")] #[path = "linux/mod.rs"] mod os; pub fn
<T: NTStr, U: NTStr>(pattern: &T, string: &U, flags: int_t) -> int_t { extern { fn fnmatch(pattern: *const char_t, name: *const char_t, flags: int_t) -> int_t; } unsafe { fnmatch(pattern.as_ptr(), string.as_ptr(), flags) } } #[cfg(test)] mod tests { use {ToNTStr}; #[test] fn test() { ...
fnmatch
identifier_name
calls.rs
use crate::types::{Error, Params, Value}; use crate::BoxFuture; use std::fmt; use std::future::Future; use std::sync::Arc; /// Metadata trait pub trait Metadata: Clone + Send +'static {} impl Metadata for () {} impl<T: Metadata> Metadata for Option<T> {} impl<T: Metadata> Metadata for Box<T> {} impl<T: Sync + Send +'s...
(self) -> BoxFuture<Result<T, E>> { self } } /// A synchronous or asynchronous method. pub trait RpcMethodSync: Send + Sync +'static { /// Call method fn call(&self, params: Params) -> BoxFuture<crate::Result<Value>>; } /// Asynchronous Method pub trait RpcMethodSimple: Send + Sync +'static { /// Output future ...
into_future
identifier_name
calls.rs
use crate::types::{Error, Params, Value}; use crate::BoxFuture; use std::fmt; use std::future::Future; use std::sync::Arc; /// Metadata trait pub trait Metadata: Clone + Send +'static {} impl Metadata for () {}
/// A future-conversion trait. pub trait WrapFuture<T, E> { /// Convert itself into a boxed future. fn into_future(self) -> BoxFuture<Result<T, E>>; } impl<T: Send +'static, E: Send +'static> WrapFuture<T, E> for Result<T, E> { fn into_future(self) -> BoxFuture<Result<T, E>> { Box::pin(async { self }) } } impl<...
impl<T: Metadata> Metadata for Option<T> {} impl<T: Metadata> Metadata for Box<T> {} impl<T: Sync + Send + 'static> Metadata for Arc<T> {}
random_line_split
calls.rs
use crate::types::{Error, Params, Value}; use crate::BoxFuture; use std::fmt; use std::future::Future; use std::sync::Arc; /// Metadata trait pub trait Metadata: Clone + Send +'static {} impl Metadata for () {} impl<T: Metadata> Metadata for Option<T> {} impl<T: Metadata> Metadata for Box<T> {} impl<T: Sync + Send +'s...
} impl<F: Send + Sync +'static, T> RpcNotification<T> for F where T: Metadata, F: Fn(Params, T), { fn execute(&self, params: Params, meta: T) { self(params, meta) } }
{ Box::pin(self(params, meta)) }
identifier_body
mutex.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 ...
} #[inline] #[cfg(target_os = "dragonfly")] pub unsafe fn destroy(&self) { use libc; let r = ffi::pthread_mutex_destroy(self.inner.get()); // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a // mutex that was just initialized with ffi::PTHREAD_MUTEX_INIT...
pub unsafe fn destroy(&self) { let r = ffi::pthread_mutex_destroy(self.inner.get()); debug_assert_eq!(r, 0);
random_line_split
mutex.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 ...
(&self) { } } #[cfg(not(feature = "thread"))] pub const MUTEX_INIT: Mutex = Mutex;
destroy
identifier_name
mod.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. mod engine; mod engine_factory; mod mvcc; mod storage; mod txn; use std::fmt;
use self::engine::bench_engine; use self::engine_factory::{BTreeEngineFactory, EngineFactory, RocksEngineFactory}; use self::mvcc::bench_mvcc; use self::storage::bench_storage; use self::txn::bench_txn; use criterion::Criterion; use tikv::storage::Engine; const DEFAULT_ITERATIONS: usize = 10; const DEFAULT_KEY_LENGTHS...
random_line_split
mod.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. mod engine; mod engine_factory; mod mvcc; mod storage; mod txn; use std::fmt; use self::engine::bench_engine; use self::engine_factory::{BTreeEngineFactory, EngineFactory, RocksEngineFactory}; use self::mvcc::bench_mvcc; use self::storage::bench_stor...
<F> { pub key_length: usize, pub value_length: usize, pub engine_factory: F, } impl<F: fmt::Debug> fmt::Debug for BenchConfig<F> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "{:?}_KL{:?}_VL{:?}", self.engine_factory, self.key_length...
BenchConfig
identifier_name
mod.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. mod engine; mod engine_factory; mod mvcc; mod storage; mod txn; use std::fmt; use self::engine::bench_engine; use self::engine_factory::{BTreeEngineFactory, EngineFactory, RocksEngineFactory}; use self::mvcc::bench_mvcc; use self::storage::bench_stor...
fn main() { let mut c = Criterion::default().configure_from_args(); let btree_engine_configs = load_configs(BTreeEngineFactory {}); let rocks_engine_configs = load_configs(RocksEngineFactory {}); bench_engine(&mut c, &btree_engine_configs); bench_engine(&mut c, &rocks_engine_configs); bench_...
{ let key_lengths = DEFAULT_KEY_LENGTHS; let value_lengths = DEFAULT_VALUE_LENGTHS; let mut configs = vec![]; for &kl in &key_lengths { for &vl in &value_lengths { configs.push(BenchConfig { key_length: kl, value_length: vl, engine_fac...
identifier_body
array.rs
//! Helper Module to treat Vec and fixed sized arrays as generic in some contexts use crate::linear_algebra::Vector; /// This trait is used to make up for the lack of generics over array lengths pub trait Array { /// Element type of the array type Element; /// Corresponding Vector type with same dimension...
} fn at_ref(&self, index: usize) -> &T { &self[index] } fn at_mut(&mut self, index: usize) -> &mut T { &mut self[index] } } }; } array_impl_for! { 1 } array_impl_for! { 2 } array_impl_for! { 3 } array_impl_for! { ...
fn length(&self) -> usize { $v
random_line_split
lib.rs
use wasm_bindgen::prelude::*; #[rustfmt::skip] #[wasm_bindgen] pub fn
( r: f64, g: f64, b: f64, a: f64, ref_x: f64, ref_y: f64, ref_z: f64, ) -> Vec<f64> { let mut r = r / 255.0; let mut g = g / 255.0; let mut b = b / 255.0; // Need lto = true in Cargo.toml to link pow r = if r > 0.04045 { ((r + 0.055) / 1.055).powf(2.4) } else { r / 12.92...
rgba2laba
identifier_name
lib.rs
use wasm_bindgen::prelude::*; #[rustfmt::skip] #[wasm_bindgen] pub fn rgba2laba( r: f64, g: f64, b: f64, a: f64, ref_x: f64, ref_y: f64, ref_z: f64, ) -> Vec<f64>
y /= ref_y; z /= ref_z; x = if x > 0.008856 { x.powf(1.0 / 3.0) } else { x * 7.787 + 16.0 / 116.0 }; y = if y > 0.008856 { y.powf(1.0 / 3.0) } else { y * 7.787 + 16.0 / 116.0 }; z = if z > 0.008856 { z.powf(1.0 / 3.0) } else { z * 7.787 + 16.0 / 116.0 }; let out_l = 116.0 * y - 16.0; let o...
{ let mut r = r / 255.0; let mut g = g / 255.0; let mut b = b / 255.0; // Need lto = true in Cargo.toml to link pow r = if r > 0.04045 { ((r + 0.055) / 1.055).powf(2.4) } else { r / 12.92 }; g = if g > 0.04045 { ((g + 0.055) / 1.055).powf(2.4) } else { g / 12.92 }; b = if b > 0.04045 { ((b ...
identifier_body
lib.rs
use wasm_bindgen::prelude::*; #[rustfmt::skip] #[wasm_bindgen] pub fn rgba2laba( r: f64, g: f64, b: f64, a: f64, ref_x: f64, ref_y: f64, ref_z: f64, ) -> Vec<f64> { let mut r = r / 255.0; let mut g = g / 255.0; let mut b = b / 255.0; // Need lto = true in Cargo.toml to link...
g2: f64, b2: f64, a2: f64, ref_x: f64, ref_y: f64, ref_z: f64, ) -> f64 { let left = rgba2laba(r1, g1, b1, a1, ref_x, ref_y, ref_z); let right = rgba2laba(r2, g2, b2, a2, ref_x, ref_y, ref_z); let dist = ((right[0] - left[0]).powf(2.0) + (right[1] - left[1]).powf(2.0) + (right[2] - l...
b1: f64, a1: f64, r2: f64,
random_line_split
lib.rs
use wasm_bindgen::prelude::*; #[rustfmt::skip] #[wasm_bindgen] pub fn rgba2laba( r: f64, g: f64, b: f64, a: f64, ref_x: f64, ref_y: f64, ref_z: f64, ) -> Vec<f64> { let mut r = r / 255.0; let mut g = g / 255.0; let mut b = b / 255.0; // Need lto = true in Cargo.toml to link...
; b = if b > 0.04045 { ((b + 0.055) / 1.055).powf(2.4) } else { b / 12.92 }; r *= 100.0; g *= 100.0; b *= 100.0; // Observer= 2° (Only use CIE 1931!) let mut x = r * 0.4124 + g * 0.3576 + b * 0.1805; let mut y = r * 0.2126 + g * 0.7152 + b * 0.0722; let mut z = r * 0.0193 + g * 0.1192 ...
{ g / 12.92 }
conditional_block
main.rs
extern crate clap; extern crate pwhash; extern crate termios; extern crate users; use clap::{App, Arg}; use std::error; use std::fmt; use std::fs::File; use std::io::{self, BufRead, BufReader, Write}; use std::path::Path; use termios::{tcsetattr, Termios}; #[derive(Debug)]
impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::Io(err) } } impl From<pwhash::error::Error> for Error { fn from(err: pwhash::error::Error) -> Error { Error::PwHash(err) } } impl From<String> for Error { fn from(err: String) -> Error { Error::Str(...
enum Error { Io(io::Error), PwHash(pwhash::error::Error), Str(String), }
random_line_split
main.rs
extern crate clap; extern crate pwhash; extern crate termios; extern crate users; use clap::{App, Arg}; use std::error; use std::fmt; use std::fs::File; use std::io::{self, BufRead, BufReader, Write}; use std::path::Path; use termios::{tcsetattr, Termios}; #[derive(Debug)] enum Error { Io(io::Error), PwHash(p...
(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::Io(ref err) => write!(f, "IO error: {}", err), Error::PwHash(ref err) => write!(f, "PwHash error: {}", err), Error::Str(ref err) => f.write_str(err), } } } impl error::Error for Error { fn ...
fmt
identifier_name
extrapolatable.rs
// // This file is part of zero_sum. // // zero_sum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // zero_sum is distributed in...
fn extrapolate(&self) -> Vec<P>; }
/// system does not assume that all plies returned are correct.
random_line_split
redis-to-sqs.rs
#[tokio::main] async fn
() -> Result<(), anyhow::Error> { use redis::Commands as _; use rusoto_sqs::Sqs as _; let config = encoder::load_config()?; let redis_client = redis::Client::open(config.redis.url)?; let mut conn = redis_client.get_connection()?; let sqs_client = rusoto_sqs::SqsClient::new(Default::default()); ...
main
identifier_name
redis-to-sqs.rs
#[tokio::main] async fn main() -> Result<(), anyhow::Error> { use redis::Commands as _; use rusoto_sqs::Sqs as _; let config = encoder::load_config()?; let redis_client = redis::Client::open(config.redis.url)?; let mut conn = redis_client.get_connection()?; let sqs_client = rusoto_sqs::SqsClien...
.send_message(rusoto_sqs::SendMessageRequest { queue_url: config.sqs.queue_url.clone(), message_body: fname, ..Default::default() }) .await?; } Ok(()) }
sqs_client
random_line_split
redis-to-sqs.rs
#[tokio::main] async fn main() -> Result<(), anyhow::Error>
message_body: fname, ..Default::default() }) .await?; } Ok(()) }
{ use redis::Commands as _; use rusoto_sqs::Sqs as _; let config = encoder::load_config()?; let redis_client = redis::Client::open(config.redis.url)?; let mut conn = redis_client.get_connection()?; let sqs_client = rusoto_sqs::SqsClient::new(Default::default()); loop { let job: Vec...
identifier_body
redis-to-sqs.rs
#[tokio::main] async fn main() -> Result<(), anyhow::Error> { use redis::Commands as _; use rusoto_sqs::Sqs as _; let config = encoder::load_config()?; let redis_client = redis::Client::open(config.redis.url)?; let mut conn = redis_client.get_connection()?; let sqs_client = rusoto_sqs::SqsClien...
let fname = job.into_iter().nth(1).unwrap(); println!("Enqueue {}", fname); sqs_client .send_message(rusoto_sqs::SendMessageRequest { queue_url: config.sqs.queue_url.clone(), message_body: fname, ..Default::default() }) ...
{ break; }
conditional_block
weight.rs
use super::Scorer; use crate::core::SegmentReader; use crate::query::Explanation; use crate::{DocId, Score, TERMINATED}; /// Iterates through all of the document matched by the DocSet /// `DocSet` and push the scored documents to the collector. pub(crate) fn for_each_scorer<TScorer: Scorer +?Sized>( scorer: &mut T...
} /// Iterates through all of the document matched by the DocSet /// `DocSet` and push the scored documents to the collector. fn for_each( &self, reader: &SegmentReader, callback: &mut dyn FnMut(DocId, Score), ) -> crate::Result<()> { let mut scorer = self.scorer(re...
{ Ok(scorer.count_including_deleted()) }
conditional_block
weight.rs
use super::Scorer; use crate::core::SegmentReader; use crate::query::Explanation; use crate::{DocId, Score, TERMINATED}; /// Iterates through all of the document matched by the DocSet /// `DocSet` and push the scored documents to the collector. pub(crate) fn for_each_scorer<TScorer: Scorer +?Sized>( scorer: &mut T...
/// Calls `callback` with all of the `(doc, score)` for which score /// is exceeding a given threshold. /// /// This method is useful for the TopDocs collector. /// For all docsets, the blanket implementation has the benefit /// of prefiltering (doc, score) pairs, avoiding the /// virtual dispatch cost. /// /// More ...
{ let mut doc = scorer.doc(); while doc != TERMINATED { callback(doc, scorer.score()); doc = scorer.advance(); } }
identifier_body
weight.rs
use super::Scorer; use crate::core::SegmentReader; use crate::query::Explanation; use crate::{DocId, Score, TERMINATED}; /// Iterates through all of the document matched by the DocSet /// `DocSet` and push the scored documents to the collector. pub(crate) fn for_each_scorer<TScorer: Scorer +?Sized>( scorer: &mut T...
( &self, reader: &SegmentReader, callback: &mut dyn FnMut(DocId, Score), ) -> crate::Result<()> { let mut scorer = self.scorer(reader, 1.0)?; for_each_scorer(scorer.as_mut(), callback); Ok(()) } /// Calls `callback` with all of the `(doc, score)` for which sc...
for_each
identifier_name
weight.rs
use super::Scorer; use crate::core::SegmentReader; use crate::query::Explanation; use crate::{DocId, Score, TERMINATED}; /// Iterates through all of the document matched by the DocSet /// `DocSet` and push the scored documents to the collector. pub(crate) fn for_each_scorer<TScorer: Scorer +?Sized>( scorer: &mut T...
/// important optimization (e.g. BlockWAND for union). fn for_each_pruning( &self, threshold: Score, reader: &SegmentReader, callback: &mut dyn FnMut(DocId, Score) -> Score, ) -> crate::Result<()> { let mut scorer = self.scorer(reader, 1.0)?; for_each_pruning_...
/// For all docsets, the blanket implementation has the benefit /// of prefiltering (doc, score) pairs, avoiding the /// virtual dispatch cost. /// /// More importantly, it makes it possible for scorers to implement
random_line_split
objects-owned-object-borrowed-method-headerless.rs
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test invoked ...
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
random_line_split
objects-owned-object-borrowed-method-headerless.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ x: uint } impl FooTrait for BarStruct { fn foo(&self) -> uint { self.x } } pub fn main() { let foos: Vec<Box<FooTrait>> = vec!( box BarStruct{ x: 0 } as Box<FooTrait>, box BarStruct{ x: 1 } as Box<FooTrait>, box BarStruct{ x: 2 } as Box<FooTrait> ); for i in...
BarStruct
identifier_name