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
foreach-put-structured.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!(j, 45);
random_line_split
foreach-put-structured.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 mut i: int = 10; let mut j: int = 0; do pairs() |p| { let (_0, _1) = p; info!(_0); info!(_1); assert_eq!(_0 + 10, i); i += 1; j = _1; }; assert_eq!(j, 45); }
main
identifier_name
foreach-put-structured.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let mut i: int = 10; let mut j: int = 0; do pairs() |p| { let (_0, _1) = p; info!(_0); info!(_1); assert_eq!(_0 + 10, i); i += 1; j = _1; }; assert_eq!(j, 45); }
{ let mut i: int = 0; let mut j: int = 0; while i < 10 { it((i, j)); i += 1; j += i; } }
identifier_body
operator.rs
use super::graph::{Graph, IndexType}; use super::EdgeType; use crate::visit::IntoNodeReferences; /// \[Generic\] complement of the graph /// /// Computes the graph complement of the input Graphand stores it /// in the provided empty output Graph. /// /// The function does not create self-loops. /// /// Computes in **O...
} } }
{ output.add_edge(x, y, weight.clone()); }
conditional_block
operator.rs
use super::graph::{Graph, IndexType}; use super::EdgeType; use crate::visit::IntoNodeReferences; /// \[Generic\] complement of the graph /// /// Computes the graph complement of the input Graphand stores it /// in the provided empty output Graph. /// /// The function does not create self-loops. /// /// Computes in **O...
/// (a, c), /// (a, d), /// (b, a), /// (b, d), /// (c, a), /// (c, b), /// (d, a), /// (d, b), /// (d, c), /// ]); /// /// for x in graph.node_indices() { /// for y in graph.node_indices() { /// assert_eq!(output.contains_edge(x, y), expected_res.contains_edge(x, y)); //...
/// let c = expected_res.add_node(()); /// let d = expected_res.add_node(()); /// expected_res.extend_with_edges(&[
random_line_split
operator.rs
use super::graph::{Graph, IndexType}; use super::EdgeType; use crate::visit::IntoNodeReferences; /// \[Generic\] complement of the graph /// /// Computes the graph complement of the input Graphand stores it /// in the provided empty output Graph. /// /// The function does not create self-loops. /// /// Computes in **O...
<N, E, Ty, Ix>( input: &Graph<N, E, Ty, Ix>, output: &mut Graph<N, E, Ty, Ix>, weight: E, ) where Ty: EdgeType, Ix: IndexType, E: Clone, N: Clone, { for (_node, weight) in input.node_references() { output.add_node(weight.clone()); } for x in input.node_indices() { ...
complement
identifier_name
operator.rs
use super::graph::{Graph, IndexType}; use super::EdgeType; use crate::visit::IntoNodeReferences; /// \[Generic\] complement of the graph /// /// Computes the graph complement of the input Graphand stores it /// in the provided empty output Graph. /// /// The function does not create self-loops. /// /// Computes in **O...
{ for (_node, weight) in input.node_references() { output.add_node(weight.clone()); } for x in input.node_indices() { for y in input.node_indices() { if x != y && !input.contains_edge(x, y) { output.add_edge(x, y, weight.clone()); } } } }
identifier_body
htmlselectelement.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::attr::{Attr, AttrHelpers, AttrValue}; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; use...
Node::reflect_node(box element, document, HTMLSelectElementBinding::Wrap) } } impl<'a> HTMLSelectElementMethods for &'a HTMLSelectElement { // https://html.spec.whatwg.org/multipage/#dom-cva-validity fn Validity(self) -> Root<ValidityState> { let window = window_from_node(self); Val...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> Root<HTMLSelectElement> { let element = HTMLSelectElement::new_inherited(localName, prefix, document);
random_line_split
htmlselectelement.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::attr::{Attr, AttrHelpers, AttrValue}; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; use...
} static DEFAULT_SELECT_SIZE: u32 = 0; impl HTMLSelectElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLSelectElement { HTMLSelectElement { htmlelement: HTMLElement::new_inherited(H...
{ *self.type_id() == EventTargetTypeId::Node( NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement))) }
identifier_body
htmlselectelement.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::attr::{Attr, AttrHelpers, AttrValue}; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; use...
(&self, attr: &Attr) { if let Some(ref s) = self.super_type() { s.after_set_attr(attr); } match attr.local_name() { &atom!("disabled") => { let node = NodeCast::from_ref(*self); node.set_disabled_state(true); node.set_enabl...
after_set_attr
identifier_name
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
<F: Fetch = FetchClient, R: URLHint + Send + Sync +'static = URLHintContract> { dapps_path: PathBuf, resolver: R, cache: Arc<Mutex<ContentCache>>, sync: Arc<SyncStatus>, embeddable_on: Option<(String, u16)>, remote: Remote, fetch: F, } impl<R: URLHint + Send + Sync +'static, F: Fetch> Drop for ContentFetcher<F,...
ContentFetcher
identifier_name
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} fn to_async_handler(&self, path: EndpointPath, control: hyper::Control) -> Box<Handler> { let mut cache = self.cache.lock(); let content_id = path.app_id.clone(); let (new_status, handler) = { let status = cache.get(&content_id); match status { // Just serve the content Some(&mut ContentStatu...
{ false }
conditional_block
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} #[test] fn should_true_if_contains_the_app() { // given let path = env::temp_dir(); let fetcher = ContentFetcher::new(FakeResolver, Arc::new(|| false), None, Remote::new_sync(), Client::new().unwrap()); let handler = LocalPageEndpoint::new(path, EndpointInfo { name: "fake".into(), description: "".i...
{ None }
identifier_body
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
}, Some(URLHintResult::Dapp(dapp)) => { let handler = ContentFetcherHandler::new( dapp.url(), path, control, installers::Dapp::new( content_id.clone(), self.dapps_path.clone(), Box::new(on_done), self.embeddable_on.clone(), )...
(None, Self::still_syncing(self.embeddable_on.clone()))
random_line_split
media_rule.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/. */ //! An [`@media`][media] urle. //! //! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media use cs...
} impl ToCssWithGuard for MediaRule { // Serialization of MediaRule is not specced. // https://drafts.csswg.org/cssom/#serialize-a-css-rule CSSMediaRule fn to_css<W>(&self, guard: &SharedRwLockReadGuard, dest: &mut W) -> fmt::Result where W: fmt::Write { dest.write_str("@media ")?; sel...
{ // Measurement of other fields may be added later. self.rules.unconditional_shallow_size_of(ops) + self.rules.read_with(guard).size_of(guard, ops) }
identifier_body
media_rule.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/. */ //! An [`@media`][media] urle. //! //! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media use cs...
{ /// The list of media queries used by this media rule. pub media_queries: Arc<Locked<MediaList>>, /// The nested rules to this media rule. pub rules: Arc<Locked<CssRules>>, /// The source position where this media rule was found. pub source_location: SourceLocation, } impl MediaRule { //...
MediaRule
identifier_name
media_rule.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/. */ //! An [`@media`][media] urle. //! //! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media use cs...
/// [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media #[derive(Debug)] pub struct MediaRule { /// The list of media queries used by this media rule. pub media_queries: Arc<Locked<MediaList>>, /// The nested rules to this media rule. pub rules: Arc<Locked<CssRules>>, /// The source ...
/// An [`@media`][media] urle. ///
random_line_split
optimize.rs
// @lecorref - github.com/lecorref, @geam - github.com/geam, // @adjivas - github.com/adjivas. See the LICENSE // file at the top-level directory of this distribution and at // https://github.com/adjivas/krpsim // // This file may not be copied, modified, or distributed // except according to those terms. extern crate...
( stock: Vec<String>, time: bool, ) -> Self { Optimize { stock: stock, time: time, } } /// The `from_line` constructor function returns the optimization's item /// for a parsed line. pub fn from_line ( line: String, ) -> Self { let stock: Vec<String> = line.spl...
new
identifier_name
optimize.rs
// @lecorref - github.com/lecorref, @geam - github.com/geam, // @adjivas - github.com/adjivas. See the LICENSE // file at the top-level directory of this distribution and at // https://github.com/adjivas/krpsim // // This file may not be copied, modified, or distributed // except according to those terms. extern crate...
Optimize { stock: Vec::new(), time: false, } } } impl std::fmt::Display for Optimize { /// The `fmt` function prints the Optimization's items. fn fmt ( &self, f: &mut std::fmt::Formatter, ) -> Result<(), std::fmt::Error> { write!(f, "(optimize: {})", self.stock.iter().map(|a|...
/// The `default` constructor function returns a empty optimize. fn default() -> Self {
random_line_split
mod.rs
#![cfg(target_os = "android")] pub use api::android::*; use ContextError; pub struct HeadlessContext(i32); impl HeadlessContext { /// See the docs in the crate root file. pub fn new(_builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> { unimplemented!() } /// See the docs in ...
(&self, _addr: &str) -> *const () { unimplemented!() } pub fn get_api(&self) -> ::Api { ::Api::OpenGlEs } } unsafe impl Send for HeadlessContext {} unsafe impl Sync for HeadlessContext {}
get_proc_address
identifier_name
mod.rs
#![cfg(target_os = "android")] pub use api::android::*; use ContextError; pub struct HeadlessContext(i32); impl HeadlessContext { /// See the docs in the crate root file. pub fn new(_builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> { unimplemented!() } /// See the docs in ...
/// See the docs in the crate root file. pub fn is_current(&self) -> bool { unimplemented!() } /// See the docs in the crate root file. pub fn get_proc_address(&self, _addr: &str) -> *const () { unimplemented!() } pub fn get_api(&self) -> ::Api { ::Api::OpenGlEs ...
{ unimplemented!() }
identifier_body
mod.rs
#![cfg(target_os = "android")]
pub struct HeadlessContext(i32); impl HeadlessContext { /// See the docs in the crate root file. pub fn new(_builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> { unimplemented!() } /// See the docs in the crate root file. pub unsafe fn make_current(&self) -> Result<(), Con...
pub use api::android::*; use ContextError;
random_line_split
main.rs
use instr::Instr; use cpu::Cpu; use cpu::CpuInterrupt; use time::precise_time_ns; use std::fs::File; use std::cmp::Ordering; use std::collections::BinaryHeap; use std::thread; use std::sync::mpsc; use std::sync::mpsc::TryRecvError; use glium::DisplayBuild; use glium::Surface; use glium::SwapBuffersError; use glium::gl...
} // Initialize virtual LCD let mut lcd = render::GbDisplay::new(&display); let mut viewport = { let window = display.get_window(); let (width, height) = window.unwrap().get_inner_size_pixels().unwrap(); render::calculate_viewport(width, height) }; let (io_tx, sim_rx)...
{ println!("Error loading rom data: {}", e); return; }
conditional_block
main.rs
use instr::Instr; use cpu::Cpu; use cpu::CpuInterrupt; use time::precise_time_ns; use std::fs::File; use std::cmp::Ordering; use std::collections::BinaryHeap; use std::thread; use std::sync::mpsc; use std::sync::mpsc::TryRecvError; use glium::DisplayBuild; use glium::Surface; use glium::SwapBuffersError; use glium::gl...
match self.int_target.partial_cmp(&other.int_target) { Some(Ordering::Less) => Some(Ordering::Greater), Some(Ordering::Greater) => Some(Ordering::Less), ord => ord, } } } impl Ord for ClockInt { #[inline] fn cmp(&self, other: &Self) -> Ordering { ...
impl Eq for ClockInt {} impl PartialOrd for ClockInt { #[inline] fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
random_line_split
main.rs
use instr::Instr; use cpu::Cpu; use cpu::CpuInterrupt; use time::precise_time_ns; use std::fs::File; use std::cmp::Ordering; use std::collections::BinaryHeap; use std::thread; use std::sync::mpsc; use std::sync::mpsc::TryRecvError; use glium::DisplayBuild; use glium::Surface; use glium::SwapBuffersError; use glium::gl...
} const NS_PER_S: u64 = 1_000_000_000; const NS_PER_MS: u64 = 1_000_000; // 10ms const BUSY_WAIT_THRESHOLD: u64 = 10_000_000; pub struct Clock { freq: u32, period: u64, int_heap: BinaryHeap<ClockInt>, } impl Clock { pub fn new(freq: u32) -> Clock { Clock { freq: fre...
{ match self.int_target.cmp(&other.int_target) { Ordering::Less => Ordering::Greater, Ordering::Greater => Ordering::Less, ord => ord, } }
identifier_body
main.rs
use instr::Instr; use cpu::Cpu; use cpu::CpuInterrupt; use time::precise_time_ns; use std::fs::File; use std::cmp::Ordering; use std::collections::BinaryHeap; use std::thread; use std::sync::mpsc; use std::sync::mpsc::TryRecvError; use glium::DisplayBuild; use glium::Surface; use glium::SwapBuffersError; use glium::gl...
() { // Gather command line args let args: Vec<String> = std::env::args().collect(); let mut opts = getopts::Options::new(); let matches = match opts.parse(&args[1..]) { Ok(m) => { m }, Err(e) => panic!("Error: {}", e), }; let input = if!matches.free.is_empty() { matches...
main
identifier_name
mod.rs
//! Entry point for the CSS filters infrastructure. use cssparser::{BasicParseError, Parser}; use markup5ever::{expanded_name, local_name, namespace_url, ns}; use std::rc::Rc; use std::time::Instant; use crate::bbox::BoundingBox; use crate::document::AcquiredNodes; use crate::drawing_ctx::DrawingCtx; use crate::eleme...
{ Blend(blend::Blend), ColorMatrix(color_matrix::ColorMatrix), ComponentTransfer(component_transfer::ComponentTransfer), Composite(composite::Composite), ConvolveMatrix(convolve_matrix::ConvolveMatrix), DiffuseLighting(lighting::DiffuseLighting), DisplacementMap(displacement_map::Displaceme...
PrimitiveParams
identifier_name
mod.rs
//! Entry point for the CSS filters infrastructure. use cssparser::{BasicParseError, Parser}; use markup5ever::{expanded_name, local_name, namespace_url, ns}; use std::rc::Rc; use std::time::Instant; use crate::bbox::BoundingBox; use crate::document::AcquiredNodes; use crate::drawing_ctx::DrawingCtx; use crate::eleme...
DiffuseLighting(lighting::DiffuseLighting), DisplacementMap(displacement_map::DisplacementMap), Flood(flood::Flood), GaussianBlur(gaussian_blur::GaussianBlur), Image(image::Image), Merge(merge::Merge), Morphology(morphology::Morphology), Offset(offset::Offset), SpecularLighting(light...
ComponentTransfer(component_transfer::ComponentTransfer), Composite(composite::Composite), ConvolveMatrix(convolve_matrix::ConvolveMatrix),
random_line_split
parsed_jvm_command_lines.rs
use itertools::Itertools; use std::slice::Iter; /// Represents the result of parsing the args of a nailgunnable Process /// TODO(#8481) We may want to split the classpath by the ":", and store it as a Vec<String> /// to allow for deep fingerprinting. #[derive(PartialEq, Eq, Debug)] pub struct ParsedJVMCommandL...
else { Ok(elem) } })? .clone(); Ok((classpath_flag, classpath_value)) } fn parse_jvm_args(args_to_consume: &mut Iter<String>) -> Result<Vec<String>, String> { Ok( args_to_consume .take_while_ref(|elem| ParsedJVMCommandLines::is_flag(elem)) .cloned() ...
{ Err(format!( "Classpath value has incorrect formatting {}.", elem )) }
conditional_block
parsed_jvm_command_lines.rs
use itertools::Itertools; use std::slice::Iter; /// Represents the result of parsing the args of a nailgunnable Process /// TODO(#8481) We may want to split the classpath by the ":", and store it as a Vec<String> /// to allow for deep fingerprinting. #[derive(PartialEq, Eq, Debug)] pub struct ParsedJVMCommandL...
fn is_flag(arg: &str) -> bool { arg.starts_with('-') || arg.starts_with('@') } fn is_classpath_flag(arg: &str) -> bool { arg == "-cp" || arg == "-classpath" } }
{ Ok(args_to_consume.cloned().collect()) }
identifier_body
parsed_jvm_command_lines.rs
use itertools::Itertools; use std::slice::Iter; /// Represents the result of parsing the args of a nailgunnable Process /// TODO(#8481) We may want to split the classpath by the ":", and store it as a Vec<String> /// to allow for deep fingerprinting. #[derive(PartialEq, Eq, Debug)] pub struct ParsedJVMCommandL...
(arg: &str) -> bool { arg.starts_with('-') || arg.starts_with('@') } fn is_classpath_flag(arg: &str) -> bool { arg == "-cp" || arg == "-classpath" } }
is_flag
identifier_name
parsed_jvm_command_lines.rs
use itertools::Itertools; use std::slice::Iter; /// Represents the result of parsing the args of a nailgunnable Process /// TODO(#8481) We may want to split the classpath by the ":", and store it as a Vec<String> /// to allow for deep fingerprinting. #[derive(PartialEq, Eq, Debug)] pub struct ParsedJVMCommandL...
nailgun_args.push(classpath_value); nailgun_args.extend(nailgun_args_after_classpath); Ok(ParsedJVMCommandLines { nailgun_args, client_args, client_main_class: main_class, }) } fn parse_to_classpath(args_to_consume: &mut Iter<String>) -> Result<Vec<String>, String> { Ok( ...
let mut nailgun_args = nailgun_args_before_classpath; nailgun_args.push(classpath_flag);
random_line_split
loads.rs
use bus::Bus; use super::super::{AddressingMode, Cpu}; // LD #[inline(always)] pub fn ld<T>(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingMode<T>, src: &dyn AddressingMode<T>) { let val = src.read(cpu, bus); dest.write(cpu, bus, val); } // LDHL SP, r8 // Affects flags: Z, N, H, C #[inline(always)] pub fn...
cpu.regs.set_carry(((sp & 0xFF) + (unsigned & 0xFF)) & 0x100 == 0x100); cpu.regs.set_halfcarry(((sp & 0xF) + (unsigned & 0xF)) & 0x10 == 0x10); cpu.regs.set_subtract(false); cpu.regs.set_zero(false); } // LDD #[inline(always)] pub fn ldd(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingMode<u8>, sr...
{ cpu.regs.set_hl(sp.wrapping_add(signed.abs() as u16)); }
conditional_block
loads.rs
use bus::Bus; use super::super::{AddressingMode, Cpu}; // LD #[inline(always)] pub fn ld<T>(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingMode<T>, src: &dyn AddressingMode<T>) { let val = src.read(cpu, bus); dest.write(cpu, bus, val); } // LDHL SP, r8 // Affects flags: Z, N, H, C #[inline(always)] pub fn...
(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingMode<u8>, src: &dyn AddressingMode<u8>) { let val = src.read(cpu, bus); let hl = cpu.regs.hl(); dest.write(cpu, bus, val); cpu.regs.set_hl(hl.wrapping_sub(1)); } // LDI #[inline(always)] pub fn ldi(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingM...
ldd
identifier_name
loads.rs
use bus::Bus; use super::super::{AddressingMode, Cpu}; // LD #[inline(always)] pub fn ld<T>(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingMode<T>, src: &dyn AddressingMode<T>) { let val = src.read(cpu, bus); dest.write(cpu, bus, val); } // LDHL SP, r8 // Affects flags: Z, N, H, C #[inline(always)] pub fn...
{ let val = cpu.pop_stack(bus); dest.write(cpu, bus, val); }
identifier_body
loads.rs
use bus::Bus; use super::super::{AddressingMode, Cpu}; // LD #[inline(always)] pub fn ld<T>(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingMode<T>, src: &dyn AddressingMode<T>) { let val = src.read(cpu, bus); dest.write(cpu, bus, val); } // LDHL SP, r8 // Affects flags: Z, N, H, C #[inline(always)] pub fn...
// LDI #[inline(always)] pub fn ldi(cpu: &mut Cpu, bus: &mut Bus, dest: &dyn AddressingMode<u8>, src: &dyn AddressingMode<u8>) { let val = src.read(cpu, bus); let hl = cpu.regs.hl(); dest.write(cpu, bus, val); cpu.regs.set_hl(hl.wrapping_add(1)); } // PUSH #[inline(always)] pub fn push(cpu: &mut Cpu,...
dest.write(cpu, bus, val); cpu.regs.set_hl(hl.wrapping_sub(1)); }
random_line_split
lib.rs
// You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // Se...
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.
random_line_split
lib.rs
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors // // 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 // // Unl...
(&self) -> &mut zmq::Context { unsafe { &mut *self.0.get() } } } unsafe impl Send for ServerContext {} unsafe impl Sync for ServerContext {}
as_mut
identifier_name
lib.rs
pub struct WordProblem { cmd: String, } #[derive(PartialEq, Debug)] enum Token { CmdWhat, CmdIs, Number, Operator, OperatorBy, } enum Operator { Plus, Minus, Multiply, Divide, } impl WordProblem { pub fn new(command: &str) -> WordProblem { WordProblem { ...
match lastop { Operator::Plus => result += value, Operator::Minus => result -= value, Operator::Multiply => result *= value, Operator::Divide => result /= value, } ...
{ return Err("Invalid number".to_string()); }
conditional_block
lib.rs
pub struct WordProblem { cmd: String, }
CmdIs, Number, Operator, OperatorBy, } enum Operator { Plus, Minus, Multiply, Divide, } impl WordProblem { pub fn new(command: &str) -> WordProblem { WordProblem { cmd: command.to_string(), } } pub fn answer(&self) -> Result<i32, String> { ...
#[derive(PartialEq, Debug)] enum Token { CmdWhat,
random_line_split
lib.rs
pub struct WordProblem { cmd: String, } #[derive(PartialEq, Debug)] enum Token { CmdWhat, CmdIs, Number, Operator, OperatorBy, } enum Operator { Plus, Minus, Multiply, Divide, } impl WordProblem { pub fn new(command: &str) -> WordProblem { WordProblem { ...
status = Token::Number } "multiplied" if status == Token::Operator => { lastop = Operator::Multiply; status = Token::OperatorBy } "divided" if status == Token::Operator => { la...
{ let command = self.cmd .split(|x| x == '?' || char::is_whitespace(x)) .filter(|w| !w.is_empty()) .collect::<Vec<_>>(); let mut result: i32 = 0; let mut lastop = Operator::Plus; let mut status = Token::CmdWhat; for word in command { ...
identifier_body
lib.rs
pub struct WordProblem { cmd: String, } #[derive(PartialEq, Debug)] enum Token { CmdWhat, CmdIs, Number, Operator, OperatorBy, } enum Operator { Plus, Minus, Multiply, Divide, } impl WordProblem { pub fn
(command: &str) -> WordProblem { WordProblem { cmd: command.to_string(), } } pub fn answer(&self) -> Result<i32, String> { let command = self.cmd .split(|x| x == '?' || char::is_whitespace(x)) .filter(|w|!w.is_empty()) .collect::<Vec<_>>(); ...
new
identifier_name
typetest.rs
// This file is part of Grust, GObject introspection bindings for Rust // // Copyright (C) 2015 Mikhail Zabaluev <mikhail.zabaluev@gmail.com> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Fo...
#[test] fn value_flags() { let mut value = Value::new(flags::type_of::<FileAttributeInfoFlags>()); let flags = value.get_flags::<FileAttributeInfoFlags>().unwrap(); assert_eq!(flags, FileAttributeInfoFlags::empty()); value.set_flags(COPY_WITH_FILE | COPY_WHEN_MOVED); let value = value.clone(); ...
{ let a = COPY_WITH_FILE.bits() | 0b10000; let _ = flags::from_uint::<FileAttributeInfoFlags>(a).unwrap(); }
identifier_body
typetest.rs
// This file is part of Grust, GObject introspection bindings for Rust // // Copyright (C) 2015 Mikhail Zabaluev <mikhail.zabaluev@gmail.com> // // This library is free software; you can redistribute it and/or
// This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Pub...
// modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. //
random_line_split
typetest.rs
// This file is part of Grust, GObject introspection bindings for Rust // // Copyright (C) 2015 Mikhail Zabaluev <mikhail.zabaluev@gmail.com> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Fo...
() { assert_eq!(NONE, FileAttributeInfoFlags::empty()); let flags: FileAttributeInfoFlags = flags::from_uint(COPY_WITH_FILE.bits() | COPY_WHEN_MOVED.bits()) .unwrap(); assert_eq!(flags, COPY_WITH_FILE | COPY_WHEN_MOVED); } #[test] fn unknown_flags() { let a = COPY_WITH_FILE.bits() | ...
flags
identifier_name
compiletest.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 ...
optopt("", "save-metrics", "file to save metrics to", "FILE"), optopt("", "ratchet-metrics", "file to ratchet metrics against", "FILE"), optopt("", "ratchet-noise-percent", "percent change in metrics to consider noise", "N"), optflag("", "jit", "run tests under t...
{ let groups : ~[getopts::groups::OptGroup] = ~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"), reqopt("", "run-lib-path", "path to target shared libraries", "PATH"), reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"), optopt("", "c...
identifier_body
compiletest.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
else { false }, test_shard: test::opt_shard(matches.opt_str("test-shard")), verbose: matches.opt_present("verbose") } } pub fn log_config(config: &config) { let c = config; logv(c, format!("configuration:")); logv(c, format!("compile_lib_path: {}", config.compile_lib_path)); logv(c...
{ if (opt_str2(matches.opt_str("adb-test-dir")) != ~"(none)" && opt_str2(matches.opt_str("adb-test-dir")) != ~"") { true } else { false } }
conditional_block
compiletest.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 config = (*config).clone(); // FIXME (#9639): This needs to handle non-utf8 paths let testfile = testfile.as_str().unwrap().to_owned(); test::DynMetricFn(proc(mm) { runtest::run_metrics(config, testfile, mm) }) }
test::DynTestFn(proc() { runtest::run(config, testfile) }) } pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
random_line_split
compiletest.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 ...
(config: &config) { let c = config; logv(c, format!("configuration:")); logv(c, format!("compile_lib_path: {}", config.compile_lib_path)); logv(c, format!("run_lib_path: {}", config.run_lib_path)); logv(c, format!("rustc_path: {}", config.rustc_path.display())); logv(c, format!("src_base: {}", c...
log_config
identifier_name
uploader.rs
// External Dependencies ------------------------------------------------------ use diesel; use diesel::prelude::*; // Internal Dependencies ------------------------------------------------------ use super::super::Server; use ::db::models::User; use ::db::schema::users::dsl::{server_id, nickname as user_nickname, is_...
} }
{ false }
conditional_block
uploader.rs
// External Dependencies ------------------------------------------------------ use diesel; use diesel::prelude::*; // Internal Dependencies ------------------------------------------------------ use super::super::Server; use ::db::models::User; use ::db::schema::users::dsl::{server_id, nickname as user_nickname, is_...
.load::<User>(&self.config.connection) .unwrap_or_else(|_| vec![]) } pub fn add_uploader(&mut self, nickname: &str) -> bool { ::db::create_user_if_not_exists(&self.config, nickname).ok(); self.update_upload_user(nickname, true) } pub fn remove_uploader(&mut self, nickna...
).filter(is_uploader.eq(true)) .order(user_nickname)
random_line_split
uploader.rs
// External Dependencies ------------------------------------------------------ use diesel; use diesel::prelude::*; // Internal Dependencies ------------------------------------------------------ use super::super::Server; use ::db::models::User; use ::db::schema::users::dsl::{server_id, nickname as user_nickname, is_...
}
{ if ::db::user_exists(&self.config, nickname) { diesel::update( userTable.filter( server_id.eq(&self.config.table_id) ).filter( user_nickname.eq(nickname) ) ).set(is_uploader.eq(set_uploader)).execu...
identifier_body
uploader.rs
// External Dependencies ------------------------------------------------------ use diesel; use diesel::prelude::*; // Internal Dependencies ------------------------------------------------------ use super::super::Server; use ::db::models::User; use ::db::schema::users::dsl::{server_id, nickname as user_nickname, is_...
(&mut self, nickname: &str) -> bool { ::db::create_user_if_not_exists(&self.config, nickname).ok(); self.update_upload_user(nickname, true) } pub fn remove_uploader(&mut self, nickname: &str) -> bool { self.update_upload_user(nickname, false) } fn update_upload_user(&self, nick...
add_uploader
identifier_name
parallel.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/. */ //! Implements parallel traversal over the DOM tree. //! //! This traversal is based on Rayon, and therefore its s...
} /// A callback to create our thread local context. This needs to be /// out of line so we don't allocate stack space for the entire struct /// in the caller. #[inline(never)] fn create_thread_local_context<'scope, E, D>( traversal: &'scope D, slot: &mut Option<ThreadLocalStyleContext<E>>) where E: TEle...
{ let slots = unsafe { tls.unsafe_get() }; let mut aggregate = slots.iter().fold(TraversalStatistics::default(), |acc, t| { match *t.borrow() { None => acc, Some(ref cx) => &cx.borrow().statistics + &acc, } }); aggregate.finish(trav...
conditional_block
parallel.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/. */ //! Implements parallel traversal over the DOM tree. //! //! This traversal is based on Rayon, and therefore its s...
/// out of line so we don't allocate stack space for the entire struct /// in the caller. #[inline(never)] fn create_thread_local_context<'scope, E, D>( traversal: &'scope D, slot: &mut Option<ThreadLocalStyleContext<E>>) where E: TElement +'scope, D: DomTraversal<E> { *slot = Some(ThreadLocal...
} } /// A callback to create our thread local context. This needs to be
random_line_split
parallel.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/. */ //! Implements parallel traversal over the DOM tree. //! //! This traversal is based on Rayon, and therefore its s...
{ TailCall, NotTailCall, } impl DispatchMode { fn is_tail_call(&self) -> bool { matches!(*self, DispatchMode::TailCall) } } // On x86_64-linux, a recursive cycle requires 3472 bytes of stack. Limiting // the depth to 150 therefore should keep the stack use by the recursion to // 520800 bytes, which woul...
DispatchMode
identifier_name
parallel.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/. */ //! Implements parallel traversal over the DOM tree. //! //! This traversal is based on Rayon, and therefore its s...
// into a work item. We do this at the beginning of the loop (rather // than at the end) so that we can traverse the children of the last // sibling directly on this thread without a spawn call. // // This has the important effect of removing the allocation an...
{ debug_assert!(nodes.len() <= WORK_UNIT_MAX); // Collect all the children of the elements in our work unit. This will // contain the combined children of up to WORK_UNIT_MAX nodes, which may // be numerous. As such, we store it in a large SmallVec to minimize heap- // spilling, and never move it. ...
identifier_body
window.rs
extern crate ncurses; use self::ncurses::*; // Window are actually implemented has ncurcesw subwin // of the stdscr pub struct Window { start_y: i32, start_x: i32, size_y: i32,
size_x: i32, handle: WINDOW, // ncurses subwin handle } impl Window { pub fn new(start_y: i32, start_x: i32, size_y: i32, size_x: i32) -> Window { unsafe { Window { start_y: start_y, start_x: start_x, size_y: size_y, size_...
random_line_split
window.rs
extern crate ncurses; use self::ncurses::*; // Window are actually implemented has ncurcesw subwin // of the stdscr pub struct
{ start_y: i32, start_x: i32, size_y: i32, size_x: i32, handle: WINDOW, // ncurses subwin handle } impl Window { pub fn new(start_y: i32, start_x: i32, size_y: i32, size_x: i32) -> Window { unsafe { Window { start_y: start_y, start_x: start...
Window
identifier_name
window.rs
extern crate ncurses; use self::ncurses::*; // Window are actually implemented has ncurcesw subwin // of the stdscr pub struct Window { start_y: i32, start_x: i32, size_y: i32, size_x: i32, handle: WINDOW, // ncurses subwin handle } impl Window { pub fn new(start_y: i32, start_x: i32, size_...
pub fn write(&self, text: String) { ncurses::waddstr(self.handle, text.as_ref()); } pub fn mvaddch(&self, y: i32, x: i32, ch: u64) { ncurses::mvwaddch(self.handle, y, x, ch); } pub fn refresh(&self) { ncurses::wrefresh(self.handle); } pub fn delwin(&self) { ...
{ unsafe { self.handle = ncurses::subwin(stdscr, self.size_y, self.size_x, self.start_y, self.start_x); } ncurses::box_(self.handle, 0, 0); }
identifier_body
cell.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/. */ //! A shareable mutable container for the DOM. use dom::bindings::trace::JSTraceable; use js::jsapi::{JSTracer}; ...
(&self, trc: *mut JSTracer) { unsafe { (*self).borrow_for_gc_trace().trace(trc) } } } // Functionality duplicated with `core::cell::RefCell` // =================================================== impl<T> DOMRefCell<T> { /// Create a new `DOMRefCell` containing `value`. pub fn ne...
trace
identifier_name
cell.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/. */ //! A shareable mutable container for the DOM. use dom::bindings::trace::JSTraceable; use js::jsapi::{JSTracer}; ...
_ => Some(self.value.borrow()), } } /// Mutably borrows the wrapped value. /// /// The borrow lasts until the returned `RefMut` exits scope. The value /// cannot be borrowed while this borrow is active. /// /// Returns `None` if the value is currently borrowed. /// ...
BorrowState::Writing => None,
random_line_split
cell.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/. */ //! A shareable mutable container for the DOM. use dom::bindings::trace::JSTraceable; use js::jsapi::{JSTracer}; ...
}
{ self.try_borrow_mut().expect("DOMRefCell<T> already borrowed") }
identifier_body
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(register: |Name, SyntaxExtension|) { register(token::intern("make_a_1"), NormalTT(~BasicMacroExpander { expander: expand_make_a_1, span: None, }, None)); register(token::intern("into_foo"), ItemModifier(expand_into_foo)); } fn expand_make_a_1(cx: &mut ExtCtxt, s...
macro_registrar
identifier_name
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
MacExpr::new(quote_expr!(cx, 1i)) } fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: @MetaItem, it: @Item) -> @Item { @Item { attrs: it.attrs.clone(), ..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone() } } pub fn foo() {}
{ cx.span_fatal(sp, "make_a_1 takes no arguments"); }
conditional_block
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
use syntax::parse::token; #[macro_export] macro_rules! exported_macro (() => (2)) macro_rules! unexported_macro (() => (3)) #[macro_registrar] pub fn macro_registrar(register: |Name, SyntaxExtension|) { register(token::intern("make_a_1"), NormalTT(~BasicMacroExpander { expander: expand_make_a...
use syntax::ast::{Name, TokenTree, Item, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::*;
random_line_split
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{}
identifier_body
ui.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
//! Computed values for UI properties use crate::values::computed::color::Color; use crate::values::computed::url::ComputedImageUrl; use crate::values::computed::Number; use crate::values::generics::ui as generics; pub use crate::values::specified::ui::CursorKind; pub use crate::values::specified::ui::{MozForceBroken...
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
random_line_split
display.rs
use sdl2::video::Window; use sdl2::render::Renderer; use sdl2::pixels::Color::RGB; use sdl2::rect::{Point, Rect}; use sdl2::sdl::Sdl; use gpu::Color; pub struct Display { renderer: Renderer<'static>, /// Upscaling factor, log2. upscale: u8, } impl Display { pub fn new(sdl2: &Sdl, upscale: u8) -> Dis...
(&mut self, x: u32, y: u32, color: Color) { let color = match color { Color::Black => RGB(0x00, 0x00, 0x00), Color::DarkGrey => RGB(0x55, 0x55, 0x55), Color::LightGrey => RGB(0xab, 0xab, 0xab), Color::White => RGB(0xff, 0xff, 0xff), }; le...
set_pixel
identifier_name
display.rs
use sdl2::video::Window; use sdl2::render::Renderer; use sdl2::pixels::Color::RGB; use sdl2::rect::{Point, Rect}; use sdl2::sdl::Sdl; use gpu::Color; pub struct Display { renderer: Renderer<'static>, /// Upscaling factor, log2. upscale: u8, } impl Display { pub fn new(sdl2: &Sdl, upscale: u8) -> Dis...
}; Display { renderer: renderer, upscale: upscale } } } impl ::ui::Display for Display { fn clear(&mut self) { let mut drawer = self.renderer.drawer(); let _ = drawer.set_draw_color(RGB(0xff, 0x00, 0x00)); let _ = drawer.clear(); } fn set_pixel(&mut self, x: ...
{ let up = 1 << (upscale as usize); let xres = 160 * up; let yres = 144 * up; let window = match Window::new(sdl2, "gb-rs", ::sdl2::video::WindowPos::PosCentered, ::sdl2::video::WindowPos::PosCentered, ...
identifier_body
display.rs
use sdl2::video::Window; use sdl2::render::Renderer; use sdl2::pixels::Color::RGB; use sdl2::rect::{Point, Rect}; use sdl2::sdl::Sdl; use gpu::Color; pub struct Display { renderer: Renderer<'static>, /// Upscaling factor, log2. upscale: u8, } impl Display { pub fn new(sdl2: &Sdl, upscale: u8) -> Dis...
Display { renderer: renderer, upscale: upscale } } } impl ::ui::Display for Display { fn clear(&mut self) { let mut drawer = self.renderer.drawer(); let _ = drawer.set_draw_color(RGB(0xff, 0x00, 0x00)); let _ = drawer.clear(); } fn set_pixel(&mut self, x: u32, y: u32, ...
};
random_line_split
query.rs
use async_trait::async_trait; use super::ElasticsearchStorage; use crate::domain::ports::secondary::get::{Error as GetError, Get, Parameters as GetParameters}; use crate::domain::ports::secondary::search::{ Error as SearchError, Parameters as SearchParameters, Search, }; #[async_trait] impl Search for Elasticsear...
( &self, parameters: SearchParameters, ) -> Result<Vec<Self::Doc>, SearchError> { self.search_documents( parameters.es_indices_to_search_in, parameters.query, parameters.result_limit, parameters.timeout, ) .await .map_err(...
search_documents
identifier_name
query.rs
use async_trait::async_trait; use super::ElasticsearchStorage; use crate::domain::ports::secondary::get::{Error as GetError, Get, Parameters as GetParameters}; use crate::domain::ports::secondary::search::{ Error as SearchError, Parameters as SearchParameters, Search, }; #[async_trait] impl Search for Elasticsear...
} #[async_trait] impl Get for ElasticsearchStorage { type Doc = serde_json::Value; async fn get_documents_by_id( &self, parameters: GetParameters, ) -> Result<Vec<Self::Doc>, GetError> { self.get_documents_by_id(parameters.query, parameters.timeout) .await .m...
{ self.search_documents( parameters.es_indices_to_search_in, parameters.query, parameters.result_limit, parameters.timeout, ) .await .map_err(|err| SearchError::DocumentRetrievalError { source: err.into() }) }
identifier_body
query.rs
use async_trait::async_trait; use super::ElasticsearchStorage; use crate::domain::ports::secondary::get::{Error as GetError, Get, Parameters as GetParameters}; use crate::domain::ports::secondary::search::{ Error as SearchError, Parameters as SearchParameters, Search, };
type Doc = serde_json::Value; async fn search_documents( &self, parameters: SearchParameters, ) -> Result<Vec<Self::Doc>, SearchError> { self.search_documents( parameters.es_indices_to_search_in, parameters.query, parameters.result_limit, ...
#[async_trait] impl Search for ElasticsearchStorage {
random_line_split
main.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
} Ok(()) } } impl Service for MarkerService {} // Several helpers for testkit. /// Time oracle instance ID. const TIME_SERVICE_ID: InstanceId = 112; /// Time oracle instance name. const TIME_SERVICE_NAME: &str = "time-oracle"; /// Marker service ID. const SERVICE_ID: InstanceId = 128; /// Marker...
{}
conditional_block
main.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
runtime::{ExecutionContext, ExecutionError, InstanceId, SnapshotExt}, }; use exonum_derive::{ exonum_interface, BinaryValue, FromAccess, ObjectHash, RequireArtifact, ServiceDispatcher, ServiceFactory, }; use exonum_rust_runtime::Service; use exonum_testkit::{Spec, TestKitBuilder}; use serde_derive::{Deseria...
access::{Access, FromAccess}, ProofMapIndex, },
random_line_split
main.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
<T: Access> { pub marks: ProofMapIndex<T::Base, PublicKey, i32>, } impl<T: Access> MarkerSchema<T> { fn new(access: T) -> Self { Self::from_root(access).unwrap() } } impl MarkerTransactions<ExecutionContext<'_>> for MarkerService { type Output = Result<(), ExecutionError>; fn mark(&self, ...
MarkerSchema
identifier_name
version.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 chrono::{DateTime, Utc}; use exempi::Xmp; use std::path::Path; use crate::audit::{ audit_get_array_value, au...
{ uuid: Option<String>, model_id: Option<i64>, /// The associated `Master`. master_uuid: Option<String>, /// uuid of the `Folder` project this reside in. pub project_uuid: Option<String>, /// uuid of the raw `Master`. pub raw_master_uuid: Option<String>, /// uuid of the non raw `Ma...
Version
identifier_name
version.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 chrono::{DateTime, Utc}; use exempi::Xmp; use std::path::Path; use crate::audit::{ audit_get_array_value, au...
auditor.skip("thumbnailGroup", SkipReason::Ignore); auditor.skip("faceDetectionIsFromPreview", SkipReason::Ignore); auditor.skip("processedHeight", SkipReason::Ignore); auditor.skip("processedWidth", SkipReason::Ignore); ...
auditor.skip("statistics", SkipReason::Ignore);
random_line_split
version.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 chrono::{DateTime, Utc}; use exempi::Xmp; use std::path::Path; use crate::audit::{ audit_get_array_value, au...
} result } _ => None, } } } impl AplibObject for Version { fn obj_type(&self) -> AplibType { AplibType::Version } fn uuid(&self) -> &Option<String> { &self.uuid } fn parent(&self) -> &Option<String> { &self...
{ auditor.skip("statistics", SkipReason::Ignore); auditor.skip("thumbnailGroup", SkipReason::Ignore); auditor.skip("faceDetectionIsFromPreview", SkipReason::Ignore); auditor.skip("processedHeight", SkipReason::Ignore); a...
conditional_block
version.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 chrono::{DateTime, Utc}; use exempi::Xmp; use std::path::Path; use crate::audit::{ audit_get_array_value, au...
} impl ToXmp for Version { fn to_xmp(&self, xmp: &mut Xmp) -> bool { // Here we make sure the Exif data are // processed before Iptc. if let Some(ref exif) = self.exif { exif.to_xmp(xmp); } if let Some(ref iptc) = self.iptc { iptc.to_xmp(xmp); ...
{ store::Wrapper::Version(Box::new(obj)) }
identifier_body
readme_example.rs
// This file is released into Public Domain. use crate::common::*; use gnuplot::*; mod common; fn example(c: Common) { let mut fg = Figure::new(); fg.axes2d() .set_title("A plot", &[]) .set_legend(Graph(0.5), Graph(0.9), &[], &[]) .set_x_label("x", &[]) .set_y_label("y^2", &[]) .lines( &[-3., -2., -1...
} fn main() { Common::new().map(|c| example(c)); }
{ fg.set_terminal("pngcairo", "readme_example.png"); fg.show().unwrap(); }
conditional_block
readme_example.rs
// This file is released into Public Domain. use crate::common::*; use gnuplot::*; mod common; fn example(c: Common) { let mut fg = Figure::new(); fg.axes2d() .set_title("A plot", &[]) .set_legend(Graph(0.5), Graph(0.9), &[], &[]) .set_x_label("x", &[]) .set_y_label("y^2", &[]) .lines( &[-3., -2., -1...
() { Common::new().map(|c| example(c)); }
main
identifier_name
readme_example.rs
// This file is released into Public Domain. use crate::common::*; use gnuplot::*; mod common; fn example(c: Common) { let mut fg = Figure::new(); fg.axes2d() .set_title("A plot", &[]) .set_legend(Graph(0.5), Graph(0.9), &[], &[]) .set_x_label("x", &[]) .set_y_label("y^2", &[]) .lines( &[-3., -2., -1...
{ Common::new().map(|c| example(c)); }
identifier_body
readme_example.rs
// This file is released into Public Domain. use crate::common::*; use gnuplot::*; mod common; fn example(c: Common) { let mut fg = Figure::new(); fg.axes2d() .set_title("A plot", &[]) .set_legend(Graph(0.5), Graph(0.9), &[], &[]) .set_x_label("x", &[]) .set_y_label("y^2", &[]) .lines( &[-3., -2., -1...
}
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 https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] #![crate_name = "servo_url"] #![crate_type = "rlib"] #[macro_use] extern crate malloc_size...
// Step 6 } else { self.scheme() == "file" } } } impl fmt::Display for ServoUrl { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(formatter) } } impl fmt::Debug for ServoUrl { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::R...
{ host == "localhost" || host.ends_with(".localhost") }
conditional_block
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 https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] #![crate_name = "servo_url"] #![crate_type = "rlib"] #[macro_use] extern crate malloc_size...
return false; } // Step 3 if self.scheme() == "https" || self.scheme() == "wss" { true // Steps 4-5 } else if self.host().is_some() { let host = self.host_str().unwrap(); // Step 4 if let Ok(ip_addr) = host.parse::<IpAd...
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 https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] #![crate_name = "servo_url"] #![crate_type = "rlib"] #[macro_use] extern crate malloc_size...
pub fn username(&self) -> &str { self.0.username() } pub fn password(&self) -> Option<&str> { self.0.password() } pub fn to_file_path(&self) -> Result<::std::path::PathBuf, ()> { self.0.to_file_path() } pub fn host(&self) -> Option<url::Host<&str>> { self...
{ self.as_mut_url().set_fragment(fragment) }
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 https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] #![crate_name = "servo_url"] #![crate_type = "rlib"] #[macro_use] extern crate malloc_size...
(&mut self) -> &mut Url { Arc::make_mut(&mut self.0) } pub fn set_username(&mut self, user: &str) -> Result<(), ()> { self.as_mut_url().set_username(user) } pub fn set_ip_host(&mut self, addr: IpAddr) -> Result<(), ()> { self.as_mut_url().set_ip_host(addr) } pub fn set...
as_mut_url
identifier_name
last_modified.rs
use header::HttpDate; header! { #[doc="`Last-Modified` header, defined in [RFC7232](http://tools.ietf.org/html/rfc7232#section-2.2)"] #[doc=""] #[doc="The `Last-Modified` header field in a response provides a timestamp"] #[doc="indicating the date and time at which the origin server believes the"] ...
bench_header!(imf_fixdate, LastModified, { vec![b"Sun, 07 Nov 1994 08:48:37 GMT".to_vec()] }); bench_header!(rfc_850, LastModified, { vec![b"Sunday, 06-Nov-94 08:49:37 GMT".to_vec()] }); bench_header!(asctime, LastModified, { vec![b"Sun Nov 6 08:49:37 1994".to_vec()] });
#[doc="```"] (LastModified, "Last-Modified") => [HttpDate] }
random_line_split
wordlist.rs
extern crate regex; extern crate rustc_serialize; extern crate strsim; use std::collections::HashMap; use std::io::{self, Read, Write}; use dopt::Docopt; use parse::{Atom, Parser}; // cheat until we get syntax extensions back :-( macro_rules! regex( ($s:expr) => (::regex::Regex::new($s).unwrap()); ); macro_rule...
given usage (provided on stdin). Example use: your-command --help | docopt-wordlist This command also supports completing positional arguments when given a list of choices. The choices are included in the word list if and only if the argument name appears in the usage string. For example: your-command --help | ...
const USAGE: &'static str = " Usage: docopt-wordlist [(<name> <possibles>)] ... docopt-wordlist prints a list of available flags and commands arguments for the
random_line_split
wordlist.rs
extern crate regex; extern crate rustc_serialize; extern crate strsim; use std::collections::HashMap; use std::io::{self, Read, Write}; use dopt::Docopt; use parse::{Atom, Parser}; // cheat until we get syntax extensions back :-( macro_rules! regex( ($s:expr) => (::regex::Regex::new($s).unwrap()); ); macro_rule...
fn run(args: Args) -> Result<(), String> { let mut usage = String::new(); try!(io::stdin().read_to_string(&mut usage).map_err(|e| e.to_string())); let parsed = try!(Parser::new(&usage).map_err(|e| e.to_string())); let arg_possibles: HashMap<String, Vec<String>> = args.arg_name.iter() ...
{ let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(args) { Ok(_) => {}, Err(err) => { write!(&mut io::stderr(), "{}", err).unwrap(); ::std::process::exit(1) ...
identifier_body
wordlist.rs
extern crate regex; extern crate rustc_serialize; extern crate strsim; use std::collections::HashMap; use std::io::{self, Read, Write}; use dopt::Docopt; use parse::{Atom, Parser}; // cheat until we get syntax extensions back :-( macro_rules! regex( ($s:expr) => (::regex::Regex::new($s).unwrap()); ); macro_rule...
} } fn run(args: Args) -> Result<(), String> { let mut usage = String::new(); try!(io::stdin().read_to_string(&mut usage).map_err(|e| e.to_string())); let parsed = try!(Parser::new(&usage).map_err(|e| e.to_string())); let arg_possibles: HashMap<String, Vec<String>> = args.arg_name.iter() ...
{ write!(&mut io::stderr(), "{}", err).unwrap(); ::std::process::exit(1) }
conditional_block
wordlist.rs
extern crate regex; extern crate rustc_serialize; extern crate strsim; use std::collections::HashMap; use std::io::{self, Read, Write}; use dopt::Docopt; use parse::{Atom, Parser}; // cheat until we get syntax extensions back :-( macro_rules! regex( ($s:expr) => (::regex::Regex::new($s).unwrap()); ); macro_rule...
{ arg_name: Vec<String>, arg_possibles: Vec<String>, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(args) { Ok(_) => {}, Err(err) => { write!(&mut io:...
Args
identifier_name
cuda_af_app.rs
use arrayfire::{af_print, dim4, info, set_device, Array}; use rustacuda::prelude::*; fn main()
}; let mut in_x = DeviceBuffer::from_slice(&[1.0f32; 10]).unwrap(); let mut in_y = DeviceBuffer::from_slice(&[2.0f32; 10]).unwrap(); // wait for any prior kernels to finish before passing // the device pointers to ArrayFire match stream.synchronize() { Ok(()) => {} Err(e) => pa...
{ // MAKE SURE to do all rustacuda initilization before arrayfire API's // first call. It seems like some CUDA context state is getting messed up // if we mix CUDA context init(device, context, module, stream) with ArrayFire API match rustacuda::init(CudaFlags::empty()) { Ok(()) => {} Er...
identifier_body
cuda_af_app.rs
use arrayfire::{af_print, dim4, info, set_device, Array}; use rustacuda::prelude::*; fn
() { // MAKE SURE to do all rustacuda initilization before arrayfire API's // first call. It seems like some CUDA context state is getting messed up // if we mix CUDA context init(device, context, module, stream) with ArrayFire API match rustacuda::init(CudaFlags::empty()) { Ok(()) => {} ...
main
identifier_name
cuda_af_app.rs
use arrayfire::{af_print, dim4, info, set_device, Array}; use rustacuda::prelude::*; fn main() { // MAKE SURE to do all rustacuda initilization before arrayfire API's // first call. It seems like some CUDA context state is getting messed up // if we mix CUDA context init(device, context, module, stream) wi...
x.lock(); y.lock(); af_print!("x", x); af_print!("y", y); let o = x + y; af_print!("out", o); let _o_dptr = unsafe { o.device_ptr() }; // Calls an implicit lock // User has to call unlock if they want to relenquish control to ArrayFire // Once the non-arrayfire operations are do...
// Lock so that ArrayFire doesn't free pointers from RustaCUDA // But we have to make sure these pointers stay in valid scope // as long as the associated ArrayFire Array objects are valid
random_line_split
derive_form.rs
#![feature(plugin, custom_derive)] #![plugin(rocket_codegen)] extern crate rocket; use rocket::request::{FromForm, FromFormValue, FormItems}; use rocket::http::RawStr; #[derive(Debug, PartialEq, FromForm)] struct TodoTask { description: String, completed: bool } // TODO: Make deriving `FromForm` for this en...
() { // Same number of arguments: simple case. let task: Option<TodoTask> = strict("description=Hello&completed=on"); assert_eq!(task, Some(TodoTask { description: "Hello".to_string(), completed: true })); // Argument in string but not in form. let task: Option<TodoTask> = stric...
main
identifier_name
derive_form.rs
#![feature(plugin, custom_derive)] #![plugin(rocket_codegen)] extern crate rocket; use rocket::request::{FromForm, FromFormValue, FormItems}; use rocket::http::RawStr; #[derive(Debug, PartialEq, FromForm)] struct TodoTask { description: String, completed: bool } // TODO: Make deriving `FromForm` for this en...
} #[derive(Debug, PartialEq, FromForm)] struct UnpresentCheckbox { checkbox: bool } #[derive(Debug, PartialEq, FromForm)] struct UnpresentCheckboxTwo<'r> { checkbox: bool, something: &'r RawStr } #[derive(Debug, PartialEq, FromForm)] struct FieldNamedV<'r> { v: &'r RawStr, } fn parse<'f, T: FromForm...
#[derive(Debug, PartialEq, FromForm)] struct ManualMethod<'r> { _method: Option<&'r RawStr>, done: bool
random_line_split
to_twos_complement_limbs.rs
use malachite_base::num::arithmetic::traits::WrappingNegAssign; use malachite_nz::natural::arithmetic::sub::limbs_sub_limb_in_place; use malachite_nz::natural::logic::not::limbs_not_in_place; use malachite_nz::platform::Limb; pub fn limbs_twos_complement_in_place_alt_1(limbs: &mut [Limb]) -> bool { let i = limbs.i...
limbs[i].wrapping_neg_assign(); let j = i + 1; if j!= len { limbs_not_in_place(&mut limbs[j..]); } false } pub fn limbs_twos_complement_in_place_alt_2(limbs: &mut [Limb]) -> bool { let carry = limbs_sub_limb_in_place(limbs, 1); limbs_not_in_place(limbs); carry }
{ return true; }
conditional_block