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
MoTSA.rs
// pub fn find_median_sorted_arrays(nums1: Vec<i32>, nums2: Vec<i32>) -> f64 { // let (l1, l2) = (nums1.len() as f32, nums2.len() as f32); // let l = ((l1 + l2) / 2_f32).floor() as usize; // dbg!(l); // if l == 0 { // if l1 > l2 { // return nums1[0] as f64; // } else { // ...
() { assert_eq!(find_median_sorted_arrays(vec![1, 3], vec![2]), 2.0); assert_eq!(find_median_sorted_arrays(vec![1, 2], vec![3, 4]), 2.5); assert_eq!(find_median_sorted_arrays(vec![0, 0], vec![0, 0]), 0.0); assert_eq!(find_median_sorted_arrays(vec![], vec![1]), 1.0); assert_eq!(find_median_sorted_arr...
main
identifier_name
MoTSA.rs
// pub fn find_median_sorted_arrays(nums1: Vec<i32>, nums2: Vec<i32>) -> f64 { // let (l1, l2) = (nums1.len() as f32, nums2.len() as f32); // let l = ((l1 + l2) / 2_f32).floor() as usize; // dbg!(l);
// return nums1[0] as f64; // } else { // return nums2[0] as f64; // } // } // let (mut n1, mut n2) = (nums1.iter(), nums2.iter()); // let (mut a, mut b) = (n1.next(), n2.next()); // let mut i = 0; // while i < l - 1 { // match (a, b) { // ...
// if l == 0 { // if l1 > l2 {
random_line_split
read_manifest.rs
use docopt; use cargo::core::{MultiShell, Package, Source}; use cargo::util::{CliResult, CliError}; use cargo::sources::{PathSource}; docopt!(Options, " Usage: cargo clean [options] --manifest-path=PATH Options: -h, --help Print this message -v, --verbose Use verbose output ") pub...
{ let path = Path::new(options.flag_manifest_path.as_slice()); let mut source = try!(PathSource::for_path(&path).map_err(|e| { CliError::new(e.description(), 1) })); try!(source.update().map_err(|err| CliError::new(err.description(), 1))); source .get_root_package() .map(|p...
identifier_body
read_manifest.rs
use docopt; use cargo::core::{MultiShell, Package, Source}; use cargo::util::{CliResult, CliError}; use cargo::sources::{PathSource}; docopt!(Options, " Usage: cargo clean [options] --manifest-path=PATH Options: -h, --help Print this message -v, --verbose Use verbose output ") pub...
.get_root_package() .map(|pkg| Some(pkg)) .map_err(|err| CliError::from_boxed(err, 1)) }
random_line_split
read_manifest.rs
use docopt; use cargo::core::{MultiShell, Package, Source}; use cargo::util::{CliResult, CliError}; use cargo::sources::{PathSource}; docopt!(Options, " Usage: cargo clean [options] --manifest-path=PATH Options: -h, --help Print this message -v, --verbose Use verbose output ") pub...
(options: Options, _: &mut MultiShell) -> CliResult<Option<Package>> { let path = Path::new(options.flag_manifest_path.as_slice()); let mut source = try!(PathSource::for_path(&path).map_err(|e| { CliError::new(e.description(), 1) })); try!(source.update().map_err(|err| CliError::new(err.descrip...
execute
identifier_name
no-send-res-ports.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T>(Rc<T>); fn main() { #[derive(Show)] struct foo { _x: Port<()>, } #[unsafe_destructor] impl Drop for foo { fn drop(&mut self) {} } fn foo(x: Port<()>) -> foo { foo { _x: x } } let x = foo(Port(Rc::new(()))); Thread::spawn(move|| {...
Port
identifier_name
no-send-res-ports.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn foo(x: Port<()>) -> foo { foo { _x: x } } let x = foo(Port(Rc::new(()))); Thread::spawn(move|| { //~^ ERROR `core::marker::Send` is not implemented let y = x; println!("{:?}", y); }); }
{}
identifier_body
no-send-res-ports.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 ...
foo { _x: x } } let x = foo(Port(Rc::new(()))); Thread::spawn(move|| { //~^ ERROR `core::marker::Send` is not implemented let y = x; println!("{:?}", y); }); }
impl Drop for foo { fn drop(&mut self) {} } fn foo(x: Port<()>) -> foo {
random_line_split
oculus_stereo.rs
//! Post processing effect to support the Oculus Rift. use na::Vector2; use crate::context::Context; use crate::post_processing::post_processing_effect::PostProcessingEffect; use crate::resource::{ AllocationType, BufferType, Effect, GPUVec, RenderTarget, ShaderAttribute, ShaderUniform, }; #[path = "../error.rs"...
self.v_coord.disable(); } } static VERTEX_SHADER: &str = " #version 100 attribute vec2 v_coord; uniform sampler2D fbo_texture; varying vec2 f_texcoord; void main(void) { gl_Position = vec4(v_coord, 0.0, 1.0); f_texcoord = (v_coord + 1.0) / 2.0; } "; static FRAGMENT_SHADER: &str = " #version...
verify!(ctxt.draw_arrays(Context::TRIANGLE_STRIP, 0, 4));
random_line_split
oculus_stereo.rs
//! Post processing effect to support the Oculus Rift. use na::Vector2; use crate::context::Context; use crate::post_processing::post_processing_effect::PostProcessingEffect; use crate::resource::{ AllocationType, BufferType, Effect, GPUVec, RenderTarget, ShaderAttribute, ShaderUniform, }; #[path = "../error.rs"...
1.0f32 / aspect * scale_factor, )); /* * Finalize draw */ verify!(ctxt.clear_color(0.0, 0.0, 0.0, 1.0)); verify!(ctxt.clear(Context::COLOR_BUFFER_BIT | Context::DEPTH_BUFFER_BIT)); verify!(ctxt.bind_texture(Context::TEXTURE_2D, target.texture_id())...
{ let ctxt = Context::get(); let scale_factor = 0.9f32; // firebox: in Oculus SDK example it's "1.0f/Distortion.Scale" let aspect = (self.w / 2.0f32) / (self.h); // firebox: rift's "half screen aspect ratio" self.shader.use_program(); self.v_coord.enable(); /* ...
identifier_body
oculus_stereo.rs
//! Post processing effect to support the Oculus Rift. use na::Vector2; use crate::context::Context; use crate::post_processing::post_processing_effect::PostProcessingEffect; use crate::resource::{ AllocationType, BufferType, Effect, GPUVec, RenderTarget, ShaderAttribute, ShaderUniform, }; #[path = "../error.rs"...
{ shader: Effect, fbo_vertices: GPUVec<Vector2<f32>>, fbo_texture: ShaderUniform<i32>, v_coord: ShaderAttribute<Vector2<f32>>, kappa_0: ShaderUniform<f32>, kappa_1: ShaderUniform<f32>, kappa_2: ShaderUniform<f32>, kappa_3: ShaderUniform<f32>, scale: ShaderUniform<Vector2<f32>>, ...
OculusStereo
identifier_name
label.rs
/* Copyright 2016 Jordan Miner * * Licensed under the MIT license <LICENSE or * http://opensource.org/licenses/MIT>. This file may not be copied, * modified, or distributed except according to those terms. */ use super::control_prelude::*; #[derive(Clone)] pub struct Label(HandleRc); impl Label { // Creates...
() -> Self { unsafe { ::iup_open(); let ih = IupLabel(ptr::null_mut()); Label(HandleRc::new(ih)) } } /// Creates a label with text to be shown on it. pub fn with_title(title: &str) -> Self { unsafe { ::iup_open(); let mut b...
new
identifier_name
label.rs
/* Copyright 2016 Jordan Miner * * Licensed under the MIT license <LICENSE or * http://opensource.org/licenses/MIT>. This file may not be copied, * modified, or distributed except according to those terms. */ use super::control_prelude::*; #[derive(Clone)] pub struct Label(HandleRc); impl Label { // Creates...
impl TitleAttribute for Label {} impl VisibleAttribute for Label {} impl MenuCommonCallbacks for Label {} impl EnterLeaveWindowCallbacks for Label {}
impl MinMaxSizeAttribute for Label {} impl TipAttribute for Label {}
random_line_split
edition-deny-async-fns-2015.rs
// edition:2015 async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 fn baz() { async fn foo()
} //~ ERROR `async fn` is not permitted in Rust 2015 async fn async_baz() { //~ ERROR `async fn` is not permitted in Rust 2015 async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } struct Foo {} impl Foo { async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 } trait Bar { ...
{}
identifier_body
edition-deny-async-fns-2015.rs
// edition:2015 async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in Rust 2015 async fn async_baz() { //~ ERROR `async fn` is not permitted in Rust 2015 async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } ...
() { macro_rules! accept_item { ($x:item) => {} } accept_item! { async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 } accept_item! { impl Foo { async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } } let inside_closure = |...
main
identifier_name
edition-deny-async-fns-2015.rs
// edition:2015 async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in Rust 2015 async fn async_baz() { //~ ERROR `async fn` is not permitted in Rust 2015 async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } ...
fn main() { macro_rules! accept_item { ($x:item) => {} } accept_item! { async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 } accept_item! { impl Foo { async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } } let inside_clo...
random_line_split
area.rs
// Copyright (c) 2017-2019 Linaro LTD // Copyright (c) 2018-2019 JUUL Labs // Copyright (c) 2019 Arm Limited // // SPDX-License-Identifier: Apache-2.0 //! Describe flash areas. use simflash::{Flash, SimFlash, Sector}; use std::ptr; use std::collections::HashMap; /// Structure to build up the boot area table. #[deriv...
pub fn add_flash_sectors(&mut self, id: u8, flash: &SimFlash) { self.sectors.insert(id, flash.sector_iter().collect()); } /// Add a slot to the image. The slot must align with erasable units in the flash device. /// Panics if the description is not valid. There are also bootloader assumptio...
{ AreaDesc { areas: vec![], whole: vec![], sectors: HashMap::new(), } }
identifier_body
area.rs
// Copyright (c) 2017-2019 Linaro LTD // Copyright (c) 2018-2019 JUUL Labs // Copyright (c) 2019 Arm Limited // // SPDX-License-Identifier: Apache-2.0 //! Describe flash areas. use simflash::{Flash, SimFlash, Sector}; use std::ptr; use std::collections::HashMap; /// Structure to build up the boot area table. #[deriv...
/// The area descriptor, C format. #[repr(C)] #[derive(Debug, Default)] pub struct CAreaDesc { slots: [CArea; 16], num_slots: u32, } #[repr(C)] #[derive(Debug)] pub struct CArea { whole: FlashArea, areas: *const FlashArea, num_areas: u32, // FIXME: is this not already available on whole/areas?...
} }
random_line_split
area.rs
// Copyright (c) 2017-2019 Linaro LTD // Copyright (c) 2018-2019 JUUL Labs // Copyright (c) 2019 Arm Limited // // SPDX-License-Identifier: Apache-2.0 //! Describe flash areas. use simflash::{Flash, SimFlash, Sector}; use std::ptr; use std::collections::HashMap; /// Structure to build up the boot area table. #[deriv...
area.push(FlashArea { flash_id: id, device_id: dev_id, pad16: 0, off: sector.base as u32, size: sector.size as u32, }); base += sector.size; len -= sector.size; } if len!= ...
{ panic!("Image does not start on a sector boundary"); }
conditional_block
area.rs
// Copyright (c) 2017-2019 Linaro LTD // Copyright (c) 2018-2019 JUUL Labs // Copyright (c) 2019 Arm Limited // // SPDX-License-Identifier: Apache-2.0 //! Describe flash areas. use simflash::{Flash, SimFlash, Sector}; use std::ptr; use std::collections::HashMap; /// Structure to build up the boot area table. #[deriv...
(&self, id: FlashId) -> Option<(usize, usize, u8)> { for area in &self.whole { // FIXME: should we ensure id is not duplicated over multiple devices? if area.flash_id == id { return Some((area.off as usize, area.size as usize, area.device_id)); } } ...
find
identifier_name
client.rs
//! Main Playform client state code. use cgmath::Point3; use num; use rand; use rand::{Rng, SeedableRng}; use std::sync::Mutex; use common::id_allocator; use common::protocol; use common::surroundings_loader; use lod; use terrain; use view; // TODO: Remove this once our RAM usage doesn't skyrocket with load distanc...
polygon_budget -= polygons_in_layer; if polygon_budget < 0 { break; } width += 2; load_distance += 1; prev_square = square; } load_distance } #[allow(missing_docs)] pub fn new(client_id: protocol::ClientId, player_id: view::entity::id::Player, position: Point3<f32>) -> T { let mu...
random_line_split
client.rs
//! Main Playform client state code. use cgmath::Point3; use num; use rand; use rand::{Rng, SeedableRng}; use std::sync::Mutex; use common::id_allocator; use common::protocol; use common::surroundings_loader; use lod; use terrain; use view; // TODO: Remove this once our RAM usage doesn't skyrocket with load distanc...
(client_id: protocol::ClientId, player_id: view::entity::id::Player, position: Point3<f32>) -> T { let mut rng: rand::XorShiftRng = rand::SeedableRng::from_seed([1, 2, 3, 4]); let s1 = rng.next_u32(); let s2 = rng.next_u32(); let s3 = rng.next_u32(); let s4 = rng.next_u32(); rng.reseed([s1, s2, s3, s4]); ...
new
identifier_name
client.rs
//! Main Playform client state code. use cgmath::Point3; use num; use rand; use rand::{Rng, SeedableRng}; use std::sync::Mutex; use common::id_allocator; use common::protocol; use common::surroundings_loader; use lod; use terrain; use view; // TODO: Remove this once our RAM usage doesn't skyrocket with load distanc...
else { info!("load_distance {}", load_distance); } let surroundings_loader = { surroundings_loader::new( load_distance, lod::THRESHOLDS.iter().map(|&x| x as i32).collect(), ) }; T { id : client_id, player_id : player_id, player_position...
{ info!("load_distance {} capped at {}", load_distance, MAX_LOAD_DISTANCE); load_distance = MAX_LOAD_DISTANCE; }
conditional_block
htmlsourceelement.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::HTMLSourceElementBinding; use dom::bindings::codegen::InheritTypes::HTMLSour...
}
{ let element = HTMLSourceElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLSourceElementBinding::Wrap) }
identifier_body
htmlsourceelement.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::HTMLSourceElementBinding; use dom::bindings::codegen::InheritTypes::HTMLSour...
impl HTMLSourceElementDerived for EventTarget { fn is_htmlsourceelement(&self) -> bool { *self.type_id() == EventTargetTypeId::Node( NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSourceElement))) } } impl HTMLSourceElement { fn new_inherited(loca...
htmlelement: HTMLElement }
random_line_split
htmlsourceelement.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::HTMLSourceElementBinding; use dom::bindings::codegen::InheritTypes::HTMLSour...
(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> Root<HTMLSourceElement> { let element = HTMLSourceElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLSourceElementBinding::Wrap) } }
new
identifier_name
parsemode.rs
extern crate libc; use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; use uucore::mode; pub fn parse_mode(mode: Option<String>) -> Result<mode_t, String> { let fperm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; if let Some(mode) = mode
else { Ok(fperm) } } #[test] fn symbolic_modes() { assert_eq!(parse_mode(Some("u+x".to_owned())).unwrap(), 0o766); assert_eq!(parse_mode(Some("+x".to_owned())).unwrap(), 0o777); assert_eq!(parse_mode(Some("a-w".to_owned())).unwrap(), 0o444); assert_eq!(parse_mode(Some("g-r".to_owned())).un...
{ let arr: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; let result = if mode.contains(arr) { mode::parse_numeric(fperm as u32, mode.as_str()) } else { mode::parse_symbolic(fperm as u32, mode.as_str(), true) }; result.map(|mode| mode as mo...
conditional_block
parsemode.rs
extern crate libc; use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; use uucore::mode; pub fn parse_mode(mode: Option<String>) -> Result<mode_t, String> { let fperm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; if let Some(mode) = mode { let arr: &[char] = &['0',...
() { assert_eq!(parse_mode(Some("u+x".to_owned())).unwrap(), 0o766); assert_eq!(parse_mode(Some("+x".to_owned())).unwrap(), 0o777); assert_eq!(parse_mode(Some("a-w".to_owned())).unwrap(), 0o444); assert_eq!(parse_mode(Some("g-r".to_owned())).unwrap(), 0o626); } #[test] fn numeric_modes() { assert_e...
symbolic_modes
identifier_name
parsemode.rs
extern crate libc; use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; use uucore::mode; pub fn parse_mode(mode: Option<String>) -> Result<mode_t, String> { let fperm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; if let Some(mode) = mode { let arr: &[char] = &['0',...
#[test] fn numeric_modes() { assert_eq!(parse_mode(Some("644".to_owned())).unwrap(), 0o644); assert_eq!(parse_mode(Some("+100".to_owned())).unwrap(), 0o766); assert_eq!(parse_mode(Some("-4".to_owned())).unwrap(), 0o662); assert_eq!(parse_mode(None).unwrap(), 0o666); }
{ assert_eq!(parse_mode(Some("u+x".to_owned())).unwrap(), 0o766); assert_eq!(parse_mode(Some("+x".to_owned())).unwrap(), 0o777); assert_eq!(parse_mode(Some("a-w".to_owned())).unwrap(), 0o444); assert_eq!(parse_mode(Some("g-r".to_owned())).unwrap(), 0o626); }
identifier_body
parsemode.rs
extern crate libc; use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; use uucore::mode;
pub fn parse_mode(mode: Option<String>) -> Result<mode_t, String> { let fperm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; if let Some(mode) = mode { let arr: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; let result = if mode.contains(arr) { mode::pa...
random_line_split
main.rs
extern crate bodyparser; extern crate persistent; extern crate clap; extern crate params; extern crate dotenv; extern crate handlebars; extern crate handlebars_iron as hbs; extern crate hyper; extern crate iron; extern crate natord; #[cfg(test)] extern crate iron_test; extern crate mount; extern crate redis; extern cra...
fn run_http_listener(ip_port: &str) -> Listening { println!("Serving HTTP on: {}", ip_port); Iron::new(get_mount()) .http(ip_port) .expect("starting HTTP server FAILED") } fn setup_logger() -> slog::Logger { let decorator = slog_term::PlainSyncDecorator::new(std::io::stdout()); let drain...
mod websocket; use hyper::server::Listening; use routing::get_mount; use utils::{from_config, load_config}; use websocket::run_ws_listener;
random_line_split
main.rs
extern crate bodyparser; extern crate persistent; extern crate clap; extern crate params; extern crate dotenv; extern crate handlebars; extern crate handlebars_iron as hbs; extern crate hyper; extern crate iron; extern crate natord; #[cfg(test)] extern crate iron_test; extern crate mount; extern crate redis; extern cra...
() { let _guard = slog_scope::set_global_logger(setup_logger()); debug!("Logger registered.."); // cli args let matches = app_from_crate!() .arg( Arg::with_name("config-path") .help( "Path to.env file (see https://github.com/slapresta/rust-dotenv)",...
main
identifier_name
main.rs
extern crate bodyparser; extern crate persistent; extern crate clap; extern crate params; extern crate dotenv; extern crate handlebars; extern crate handlebars_iron as hbs; extern crate hyper; extern crate iron; extern crate natord; #[cfg(test)] extern crate iron_test; extern crate mount; extern crate redis; extern cra...
fn main() { let _guard = slog_scope::set_global_logger(setup_logger()); debug!("Logger registered.."); // cli args let matches = app_from_crate!() .arg( Arg::with_name("config-path") .help( "Path to.env file (see https://github.com/slapresta/rust-...
{ let decorator = slog_term::PlainSyncDecorator::new(std::io::stdout()); let drain = slog_term::FullFormat::new(decorator).build().fuse(); slog::Logger::root(drain, slog_o!()) }
identifier_body
nested-item-spans.rs
// Copyright 2018 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 ...
() { #[foo] fn bar() { let x: u32 = "x"; //~ ERROR: mismatched types } bar(); another(); }
main
identifier_name
nested-item-spans.rs
// Copyright 2018 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 ...
// aux-build:nested-item-spans.rs extern crate nested_item_spans; use nested_item_spans::foo; #[foo] fn another() { fn bar() { let x: u32 = "x"; //~ ERROR: mismatched types } bar(); } fn main() { #[foo] fn bar() { let x: u32 = "x"; //~ ERROR: mismatched types } bar(); ...
random_line_split
nested-item-spans.rs
// Copyright 2018 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 ...
bar(); another(); }
{ let x: u32 = "x"; //~ ERROR: mismatched types }
identifier_body
mod.rs
#![allow(non_camel_case_types, non_snake_case)] pub mod constants; use self::constants::*; use ncurses::{box_, getmouse, keyname, setlocale, LcCategory, COLORS, COLOR_PAIRS}; use ncurses::ll::{chtype, ungetch, wattroff, wattron, wattrset, MEVENT, NCURSES_ATTR_T, WINDOW}; use ncurses::ll::{resize_term, wgetch}; use li...
(code: i32) -> Option<String> { keyname(code) } pub fn _resize_term(nlines: i32, ncols: i32) -> i32 { unsafe { resize_term(nlines, ncols) } } pub fn _set_blink(_: bool) -> i32 { 0 // Not supported } pub fn _set_title(_: &str) { //Not supported } /// Converts an integer returned by getch() to a Input...
_keyname
identifier_name
mod.rs
#![allow(non_camel_case_types, non_snake_case)] pub mod constants; use self::constants::*; use ncurses::{box_, getmouse, keyname, setlocale, LcCategory, COLORS, COLOR_PAIRS}; use ncurses::ll::{chtype, ungetch, wattroff, wattron, wattrset, MEVENT, NCURSES_ATTR_T, WINDOW}; use ncurses::ll::{resize_term, wgetch}; use li...
} } pub fn _wgetch(w: WINDOW) -> Option<Input> { let i = unsafe { wgetch(w) }; if i < 0 { None } else { Some(to_special_keycode(i).unwrap_or_else(|| { // Assume that on Linux input is UTF-8 fn try_decode(mut v: Vec<u8>, w: WINDOW) -> Result<String, FromUtf8Error...
{ for (i, skc) in SPECIAL_KEY_CODES.iter().enumerate() { if *skc == specialKeyCode { let result = i as c_int + KEY_OFFSET; if result <= KEY_F15 { return unsafe { ungetch(result) }; } else { ...
conditional_block
mod.rs
#![allow(non_camel_case_types, non_snake_case)] pub mod constants; use self::constants::*; use ncurses::{box_, getmouse, keyname, setlocale, LcCategory, COLORS, COLOR_PAIRS}; use ncurses::ll::{chtype, ungetch, wattroff, wattron, wattrset, MEVENT, NCURSES_ATTR_T, WINDOW}; use ncurses::ll::{resize_term, wgetch}; use li...
pub fn _attron(w: WINDOW, attributes: chtype) -> i32 { unsafe { wattron(w, attributes as NCURSES_ATTR_T) } } pub fn _attroff(w: WINDOW, attributes: chtype) -> i32 { unsafe { wattroff(w, attributes as NCURSES_ATTR_T) } } pub fn _attrset(w: WINDOW, attributes: chtype) -> i32 { unsafe { wattrset(w, attribu...
{ setlocale(LcCategory::all, ""); }
identifier_body
mod.rs
#![allow(non_camel_case_types, non_snake_case)] pub mod constants; use self::constants::*; use ncurses::{box_, getmouse, keyname, setlocale, LcCategory, COLORS, COLOR_PAIRS}; use ncurses::ll::{chtype, ungetch, wattroff, wattron, wattrset, MEVENT, NCURSES_ATTR_T, WINDOW}; use ncurses::ll::{resize_term, wgetch}; use li...
let index = if i <= KEY_F15 { i - KEY_OFFSET } else { i - KEY_OFFSET - 48 }; if index < 0 || index as usize >= SPECIAL_KEY_CODES.len() { None } else { Some(SPECIAL_KEY_CODES[index as usize]) } } pub fn _ungetch(input: &Input) -> i32 { match *input { I...
/// Converts an integer returned by getch() to a Input value pub fn to_special_keycode(i: i32) -> Option<Input> {
random_line_split
store.rs
// Copyright 2021 The Grin Developers // // 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 agree...
(&self, p: Vec<PeerData>) -> Result<(), Error> { let batch = self.db.batch()?; for pd in p { debug!("save_peers: {:?} marked {:?}", pd.addr, pd.flags); batch.put_ser(&peer_key(pd.addr)[..], &pd)?; } batch.commit() } pub fn get_peer(&self, peer_addr: PeerAddr) -> Result<PeerData, Error> { option_to_no...
save_peers
identifier_name
store.rs
// Copyright 2021 The Grin Developers // // 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 agree...
} impl Readable for PeerData { fn read<R: Reader>(reader: &mut R) -> Result<PeerData, ser::Error> { let addr = PeerAddr::read(reader)?; let capab = reader.read_u32()?; let ua = reader.read_bytes_len_prefix()?; let (fl, lb, br) = ser_multiread!(reader, read_u8, read_i64, read_i32); let lc = reader.read_i64...
{ self.addr.write(writer)?; ser_multiwrite!( writer, [write_u32, self.capabilities.bits()], [write_bytes, &self.user_agent], [write_u8, self.flags as u8], [write_i64, self.last_banned], [write_i32, self.ban_reason as i32], [write_i64, self.last_connected] ); Ok(()) }
identifier_body
store.rs
// Copyright 2021 The Grin Developers // // 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 agree...
.peers_iter()? .filter(|p| p.flags == state && p.capabilities.contains(cap)) .choose_multiple(&mut thread_rng(), count); Ok(peers) } /// Iterator over all known peers. pub fn peers_iter(&self) -> Result<impl Iterator<Item = PeerData>, Error> { let key = to_key(PEER_PREFIX, ""); let protocol_version =...
) -> Result<Vec<PeerData>, Error> { let peers = self
random_line_split
core.rs
#![cfg(feature = "core")] use rusoto_core::request::{HttpClient, HttpResponse}; use rusoto_core::credential::{DefaultCredentialsProvider, ProvideAwsCredentials}; use rusoto_core::param::{Params, ServiceParams}; use rusoto_core::signature::SignedRequest; use rusoto_core::{Client, Region}; #[tokio::test] async fn
() { let provider = DefaultCredentialsProvider::new().unwrap(); let credentials = provider.credentials().await.unwrap(); let mut request = SignedRequest::new("GET", "sts", &Region::UsEast1, "/"); let mut params = Params::new(); params.put("Action", "GetCallerIdentity"); params.put("Version", "2...
get_caller_identity_presigned
identifier_name
core.rs
#![cfg(feature = "core")] use rusoto_core::request::{HttpClient, HttpResponse}; use rusoto_core::credential::{DefaultCredentialsProvider, ProvideAwsCredentials}; use rusoto_core::param::{Params, ServiceParams}; use rusoto_core::signature::SignedRequest; use rusoto_core::{Client, Region}; #[tokio::test] async fn get_c...
{ let client = Client::new_not_signing(HttpClient::new().expect("failed to create request dispatcher")); let mut request = SignedRequest::new("GET", "sts", &Region::UsEast1, "/"); let mut params = Params::new(); params.put("Action", "GetCallerIdentity"); params.put("Version", "2011-06-15"); ...
identifier_body
core.rs
#![cfg(feature = "core")] use rusoto_core::request::{HttpClient, HttpResponse}; use rusoto_core::credential::{DefaultCredentialsProvider, ProvideAwsCredentials}; use rusoto_core::param::{Params, ServiceParams}; use rusoto_core::signature::SignedRequest; use rusoto_core::{Client, Region}; #[tokio::test] async fn get_c...
params.put("Action", "GetCallerIdentity"); params.put("Version", "2011-06-15"); request.set_params(params); let response = client .sign_and_dispatch(request) .await; assert!(response.is_ok(), response.err()); let response: HttpResponse = response.unwrap(); assert!(response.stat...
Client::new_not_signing(HttpClient::new().expect("failed to create request dispatcher")); let mut request = SignedRequest::new("GET", "sts", &Region::UsEast1, "/"); let mut params = Params::new();
random_line_split
s3-object-lambda.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ // snippet-start:[s3.rust.s3-object-lambda-packages] use aws_endpoint::partition; use aws_endpoint::partition::endpoint; use aws_endpoint::{CredentialScope, Partition, PartitionResolver}; use aws_sdk_s3...
// snippet-start:[s3.rust.s3-object-lambda] // Create an endpoint resolver that creates S3 Object Lambda endpoints. let resolver = PartitionResolver::new( Partition::builder() .id("aws") // This regex captures the region prefix, such as the "us" in "us-east-1", /...
{ println!("S3 client version: {}", PKG_VERSION); println!("Account #: {}", &account); println!("Endpoint: {}", &endpoint); println!(); }
conditional_block
s3-object-lambda.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ // snippet-start:[s3.rust.s3-object-lambda-packages] use aws_endpoint::partition; use aws_endpoint::partition::endpoint; use aws_endpoint::{CredentialScope, Partition, PartitionResolver}; use aws_sdk_s3...
let mut uri = endpoint.to_string(); uri.push('-'); uri.push_str(account); uri.push_str(".s3-object-lambda.{region}.amazonaws.com"); Box::leak(uri.into_boxed_str()) } /// Lists your Amazon S3 buckets in the specified endpoint. /// # Arguments /// /// * `-a ACCOUNT` - Your AWS account number. /// * ...
random_line_split
s3-object-lambda.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ // snippet-start:[s3.rust.s3-object-lambda-packages] use aws_endpoint::partition; use aws_endpoint::partition::endpoint; use aws_endpoint::{CredentialScope, Partition, PartitionResolver}; use aws_sdk_s3...
(client: &Client) -> Result<(), Error> { let resp = client.list_buckets().send().await?; let buckets = resp.buckets().unwrap_or_default(); let num_buckets = buckets.len(); for bucket in buckets { println!("{}", bucket.name().as_deref().unwrap_or_default()); } println!(); println!("...
show_buckets
identifier_name
http_loader.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 net_traits::{ControlMsg, CookieSource, LoadData, Metadata, LoadConsumer}; use net_traits::ProgressMsg::{Payloa...
(cookies_chan: Sender<ControlMsg>, devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> Box<FnBox(LoadData, LoadConsumer, Arc<MIMEClassifier>) + Send> { box move |load_data, senders, classifier| { spawn_named("http_loader".to_owned(), move || load(load_data, senders, clas...
factory
identifier_name
http_loader.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 net_traits::{ControlMsg, CookieSource, LoadData, Metadata, LoadConsumer}; use net_traits::ProgressMsg::{Payloa...
fn send_error(url: Url, err: String, start_chan: LoadConsumer) { let mut metadata: Metadata = Metadata::default(url); metadata.status = None; match start_sending_opt(start_chan, metadata) { Ok(p) => p.send(Done(Err(err))).unwrap(), _ => {} }; } enum ReadResult { Payload(Vec<u8>),...
{ box move |load_data, senders, classifier| { spawn_named("http_loader".to_owned(), move || load(load_data, senders, classifier, cookies_chan, devtools_chan)) } }
identifier_body
http_loader.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 net_traits::{ControlMsg, CookieSource, LoadData, Metadata, LoadConsumer}; use net_traits::ProgressMsg::{Payloa...
if iters > max_redirects { send_error(url, "too many redirects".to_string(), start_chan); return; } match &*url.scheme { "http" | "https" => {} _ => { let s = format!("{} request, but we don't support that scheme", url.scheme); ...
// Loop to handle redirects. loop { iters = iters + 1;
random_line_split
issue-16596.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn next(&mut self) -> Option<()> { unimplemented!() } } fn main() {}
impl<'a> Iterator for Rows<&'a Mat> { type Item = ();
random_line_split
issue-16596.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) { }} struct Mat; impl<'a> MatrixRow for &'a Mat {} struct Rows<M: MatrixRow> { mat: M, } impl<'a> Iterator for Rows<&'a Mat> { type Item = (); fn next(&mut self) -> Option<()> { unimplemented!() } } fn main() {}
dummy
identifier_name
traversal.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/. */ //! Traversing the DOM tree; the bloom filter. use animation; use context::{SharedStyleContext, StyleContext}; us...
<'a, N, C>(context: &C, root: OpaqueNode, node: N) where N: TNode, C: StyleContext<'a> { let unsafe_layout_node = node.to_unsafe(); let (mut bf, old_node, old_generation) = STYLE_BLOOM.with(|style_bloom| { style_bloom.borrow_mut() .take() ...
remove_from_bloom_filter
identifier_name
traversal.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/. */ //! Traversing the DOM tree; the bloom filter. use animation; use context::{SharedStyleContext, StyleContext}; us...
/// rejected. /// /// When done styling a node, all selectors previously inserted into the filter /// are removed. /// /// Since a work-stealing queue is used for styling, sometimes, the bloom filter /// will no longer be the for the parent of the node we're currently on. When /// this happens, the thread local bloom f...
/// /// Before a `Descendant` selector match is tried, it's compared against the /// bloom filter. If the bloom filter can exclude it, the selector is quickly
random_line_split
traversal.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/. */ //! Traversing the DOM tree; the bloom filter. use animation; use context::{SharedStyleContext, StyleContext}; us...
/// Do an action over the child before pushing him to the work queue. /// /// By default, propagate the IS_DIRTY flag down the tree. #[allow(unsafe_code)] fn pre_process_child_hook(&self, parent: N, kid: N) { // NOTE: At this point is completely safe to modify either the parent or ...
{ node.is_dirty() || node.has_dirty_descendants() }
identifier_body
day4.rs
extern crate crypto; extern crate clap; use clap::App; use crypto::md5::Md5; use crypto::digest::Digest; fn main() { let matches = App::new("day4") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<KEY> 'Secret key for MD5 hash'") .get_matches(); le...
fn find_number_leading_zeroes(key : &str, num_zeroes : usize) -> u64 { let mut md5 = Md5::new(); let mut res = 0; let target_string : String = (vec!['0'; num_zeroes]).into_iter().collect(); for i in 0..std::u64::MAX { let mut tst = String::from(key); tst.push_str(&i.to_string()); md...
println!("For key {}, found {}", key, find_number_leading_zeroes(key, 6)); }
random_line_split
day4.rs
extern crate crypto; extern crate clap; use clap::App; use crypto::md5::Md5; use crypto::digest::Digest; fn main() { let matches = App::new("day4") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<KEY> 'Secret key for MD5 hash'") .get_matches(); le...
md5.reset(); } res } #[cfg(test)] mod tests { use find_number_leading_zeroes; #[test] fn number_check() { assert_eq!(609043, find_number_leading_zeroes("abcdef", 5)); assert_eq!(1048970, find_number_leading_zeroes("pqrstuv", 5)); } }
{ res = i; break; }
conditional_block
day4.rs
extern crate crypto; extern crate clap; use clap::App; use crypto::md5::Md5; use crypto::digest::Digest; fn main() { let matches = App::new("day4") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<KEY> 'Secret key for MD5 hash'") .get_matches(); le...
(key : &str, num_zeroes : usize) -> u64 { let mut md5 = Md5::new(); let mut res = 0; let target_string : String = (vec!['0'; num_zeroes]).into_iter().collect(); for i in 0..std::u64::MAX { let mut tst = String::from(key); tst.push_str(&i.to_string()); md5.input_str(&tst); if md...
find_number_leading_zeroes
identifier_name
day4.rs
extern crate crypto; extern crate clap; use clap::App; use crypto::md5::Md5; use crypto::digest::Digest; fn main() { let matches = App::new("day4") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<KEY> 'Secret key for MD5 hash'") .get_matches(); le...
}
{ assert_eq!(609043, find_number_leading_zeroes("abcdef", 5)); assert_eq!(1048970, find_number_leading_zeroes("pqrstuv", 5)); }
identifier_body
rule_hook.rs
/* Precached - A Linux process monitor and pre-caching daemon Copyright (C) 2017-2020 the precached developers This file is part of precached. Precached is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Softwar...
fn as_any(&self) -> &Any { self } fn as_any_mut(&mut self) -> &mut Any { self } }
{ match event.event_type { procmon::EventType::Fork => { // TODO: Implement this // // if (fork_bomb_detected) { // events::queue_internal_event(EventType::ForkBombDetected(*event), globals); // } } ...
identifier_body
rule_hook.rs
/* Precached - A Linux process monitor and pre-caching daemon Copyright (C) 2017-2020 the precached developers This file is part of precached. Precached is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Softwar...
use crate::events::EventType; use crate::globals::*; use crate::hooks::hook; use crate::manager::*; use crate::process::Process; use crate::procmon; static NAME: &str = "rule_hook"; static DESCRIPTION: &str = "Support rule actions for the rule matching engine"; /// Register this hook implementation with the system pu...
use std::any::Any; use std::collections::HashMap; use std::sync::mpsc::channel; use log::{trace, debug, info, warn, error, log, LevelFilter}; use crate::events;
random_line_split
rule_hook.rs
/* Precached - A Linux process monitor and pre-caching daemon Copyright (C) 2017-2020 the precached developers This file is part of precached. Precached is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Softwar...
(&mut self) -> &mut Any { self } }
as_any_mut
identifier_name
fetch.rs
// Copyright 2015, 2016 Ethcore (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 later version....
#[test] fn should_return_503_when_syncing_but_should_make_the_calls() { // given let (server, registrar) = serve_with_registrar_and_sync(); { let mut responses = registrar.responses.lock(); let res1 = responses.get(0).unwrap().clone(); let res2 = responses.get(1).unwrap().clone(); // Registrar will be call...
{ // given let (server, registrar) = serve_with_registrar(); // when let response = request(server, "\ GET / HTTP/1.1\r\n\ Host: 1472a9e190620cdf6b31f383373e45efcfe869a820c91f9ccd7eb9fb45e4985d.parity\r\n\ Connection: close\r\n\ \r\n\ " ); // then assert_eq!(response.status, "HTTP/1.1 404 Not F...
identifier_body
fetch.rs
// Copyright 2015, 2016 Ethcore (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 later version....
() { // given let (server, registrar) = serve_with_registrar_and_sync(); { let mut responses = registrar.responses.lock(); let res1 = responses.get(0).unwrap().clone(); let res2 = responses.get(1).unwrap().clone(); // Registrar will be called twice - fill up the responses. responses.push(res1); responses...
should_return_503_when_syncing_but_should_make_the_calls
identifier_name
fetch.rs
// Copyright 2015, 2016 Ethcore (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 later version....
}
random_line_split
data.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/. */ //! Per-node data used in style calculation. use context::{SharedStyleContext, StackLimitChecker}; use dom::TElem...
&mut processor, ); let result = invalidator.invalidate(); unsafe { element.set_handled_snapshot() } debug_assert!(element.handled_snapshot()); result } /// Returns true if this element has styles. #[inline] pub fn has_styles(&self) -> bool { ...
); let invalidator = TreeStyleInvalidator::new( element, stack_limit_checker,
random_line_split
data.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/. */ //! Per-node data used in style calculation. use context::{SharedStyleContext, StackLimitChecker}; use dom::TElem...
(&self, pseudo: &PseudoElement) -> Option<&Arc<ComputedValues>> { debug_assert!(pseudo.is_eager()); self.0.as_ref().and_then(|p| p[pseudo.eager_index()].as_ref()) } /// Sets the style for the eager pseudo. pub fn set(&mut self, pseudo: &PseudoElement, value: Arc<ComputedValues>) { i...
get
identifier_name
data.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/. */ //! Per-node data used in style calculation. use context::{SharedStyleContext, StackLimitChecker}; use dom::TElem...
if self.hint.match_self() { return RestyleKind::MatchAndCascade; } if self.hint.has_replacements() { debug_assert!(!self.hint.has_animation_hint(), "Animation only restyle hint should have already processed"); return RestyleKind::C...
{ return RestyleKind::MatchAndCascade; }
conditional_block
complex.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 ...
fn test_to_str() { fn test(c : Complex64, s: ~str) { assert_eq!(c.to_str(), s); } test(_0_0i, "0+0i".to_owned()); test(_1_0i, "1+0i".to_owned()); test(_0_1i, "0+1i".to_owned()); test(_1_1i, "1+1i".to_owned()); test(_neg1_1i, "-1+1i".to_owned()); ...
random_line_split
complex.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 ...
() { assert_eq!(_05_05i - _05_05i, _0_0i); assert_eq!(_0_1i - _1_0i, _neg1_1i); assert_eq!(_0_1i - _neg1_1i, _1_0i); for &c in all_consts.iter() { assert_eq!(c - _0_0i, c); assert_eq!(c - c, _0_0i); } } #[test]...
test_sub
identifier_name
complex.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 ...
} #[cfg(test)] mod test { #![allow(non_uppercase_statics)] use super::{Complex64, Cmplx}; use std::num::{Zero,One,Float}; pub static _0_0i : Complex64 = Cmplx { re: 0.0, im: 0.0 }; pub static _1_0i : Complex64 = Cmplx { re: 1.0, im: 0.0 }; pub static _1_1i : Complex64 = Cmplx { re: 1.0, im: ...
{ if self.im < Zero::zero() { format!("{}-{}i", self.re.to_str_radix(radix), (-self.im).to_str_radix(radix)) } else { format!("{}+{}i", self.re.to_str_radix(radix), self.im.to_str_radix(radix)) } }
identifier_body
complex.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 ...
} } impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> { fn to_str_radix(&self, radix: uint) -> ~str { if self.im < Zero::zero() { format!("{}-{}i", self.re.to_str_radix(radix), (-self.im).to_str_radix(radix)) } else { format!("{}+{}i", self.re.to_str_radix(radix),...
{ write!(f.buf, "{}+{}i", self.re, self.im) }
conditional_block
logging.rs
use jack_sys as j; use lazy_static::lazy_static; use std::ffi; use std::io::{stderr, Write}; use std::sync::{Mutex, Once}; lazy_static! { static ref INFO_FN: Mutex<Option<fn(&str)>> = Mutex::new(None); static ref ERROR_FN: Mutex<Option<fn(&str)>> = Mutex::new(None); } unsafe extern "C" fn error_wrapper(msg: *...
// set set_error_callback(null_log_fn); assert!(error_callback().is_some()); error_callback().unwrap()("Using error callback!."); // reset reset_error_callback(); assert!(error_callback().is_none()); } }
reset_error_callback(); assert!(error_callback().is_none());
random_line_split
logging.rs
use jack_sys as j; use lazy_static::lazy_static; use std::ffi; use std::io::{stderr, Write}; use std::sync::{Mutex, Once}; lazy_static! { static ref INFO_FN: Mutex<Option<fn(&str)>> = Mutex::new(None); static ref ERROR_FN: Mutex<Option<fn(&str)>> = Mutex::new(None); } unsafe extern "C" fn error_wrapper(msg: *...
() { // initial state reset_info_callback(); assert!(info_callback().is_none()); // set set_info_callback(null_log_fn); assert!(info_callback().is_some()); info_callback().unwrap()("Using info callback!."); // reset reset_info_callback(); ...
logging_can_set_info
identifier_name
logging.rs
use jack_sys as j; use lazy_static::lazy_static; use std::ffi; use std::io::{stderr, Write}; use std::sync::{Mutex, Once}; lazy_static! { static ref INFO_FN: Mutex<Option<fn(&str)>> = Mutex::new(None); static ref ERROR_FN: Mutex<Option<fn(&str)>> = Mutex::new(None); } unsafe extern "C" fn error_wrapper(msg: *...
#[cfg(test)] mod test { use super::*; fn null_log_fn(_: &str) {} #[test] fn logging_can_set_info() { // initial state reset_info_callback(); assert!(info_callback().is_none()); // set set_info_callback(null_log_fn); assert!(info_callback().is_some());...
{ *ERROR_FN.lock().unwrap() = None; }
identifier_body
remove_empty_func_test.rs
use super::*; use envmnt; #[test] #[should_panic] fn remove_empty_invoke_empty() { invoke(&vec![]); } #[test] #[should_panic] fn remove_empty_invoke_invalid_too_many_args() { invoke(&vec!["TEST".to_string(), "1".to_string()]); } #[test] fn
() { envmnt::set("TEST_REMOVE_EMPTY_VALID", "abc"); let output = invoke(&vec!["TEST_REMOVE_EMPTY_VALID".to_string()]); assert_eq!(output, vec!["abc"]); } #[test] fn remove_empty_invoke_exists_empty() { envmnt::set("TEST_REMOVE_EMPTY_EMPTY", ""); let output = invoke(&vec!["TEST_REMOVE_EMPTY_EMPTY...
remove_empty_invoke_exists_with_value
identifier_name
remove_empty_func_test.rs
use super::*; use envmnt; #[test] #[should_panic] fn remove_empty_invoke_empty() { invoke(&vec![]); } #[test] #[should_panic] fn remove_empty_invoke_invalid_too_many_args() { invoke(&vec!["TEST".to_string(), "1".to_string()]); } #[test] fn remove_empty_invoke_exists_with_value() { envmnt::set("TEST_REMO...
#[test] fn remove_empty_invoke_not_exists() { let output = invoke(&vec!["TEST_REMOVE_EMPTY_NOT_EXISTS".to_string()]); assert_eq!(output.len(), 0); }
random_line_split
remove_empty_func_test.rs
use super::*; use envmnt; #[test] #[should_panic] fn remove_empty_invoke_empty() { invoke(&vec![]); } #[test] #[should_panic] fn remove_empty_invoke_invalid_too_many_args() { invoke(&vec!["TEST".to_string(), "1".to_string()]); } #[test] fn remove_empty_invoke_exists_with_value() { envmnt::set("TEST_REMO...
#[test] fn remove_empty_invoke_not_exists() { let output = invoke(&vec!["TEST_REMOVE_EMPTY_NOT_EXISTS".to_string()]); assert_eq!(output.len(), 0); }
{ envmnt::set("TEST_REMOVE_EMPTY_EMPTY", ""); let output = invoke(&vec!["TEST_REMOVE_EMPTY_EMPTY".to_string()]); assert_eq!(output.len(), 0); }
identifier_body
sha1.rs
use byteorder::{ ReadBytesExt, WriteBytesExt, BigEndian }; use digest::Digest; use utils::buffer::{ FixedBuffer, FixedBuffer64, StandardPadding }; struct SHA1State { h0: u32, h1: u32, h2: u32, h3: u32, h4: u32 } impl SHA1State { fn new() -> Self { SHA1State { ...
self.h2 = self.h2.wrapping_add(c); self.h3 = self.h3.wrapping_add(d); self.h4 = self.h4.wrapping_add(e); } } pub struct SHA1 { state: SHA1State, buffer: FixedBuffer64, length: u64 } impl Default for SHA1 { fn default() -> Self { SHA1 { state: SHA1State::...
} self.h0 = self.h0.wrapping_add(a); self.h1 = self.h1.wrapping_add(b);
random_line_split
sha1.rs
use byteorder::{ ReadBytesExt, WriteBytesExt, BigEndian }; use digest::Digest; use utils::buffer::{ FixedBuffer, FixedBuffer64, StandardPadding }; struct
{ h0: u32, h1: u32, h2: u32, h3: u32, h4: u32 } impl SHA1State { fn new() -> Self { SHA1State { h0: 0x67452301, h1: 0xefcdab89, h2: 0x98badcfe, h3: 0x10325476, h4: 0xc3d2e1f0 } } fn process_block(&mut self, mu...
SHA1State
identifier_name
server.rs
#![feature(core)] extern crate eve; extern crate getopts; extern crate url; extern crate core; use std::thread; use std::env; use getopts::Options; use std::net::SocketAddr; use core::str::FromStr; use eve::server; use eve::login; #[allow(dead_code)] fn main() { // handle command line arguments let args: Vec<St...
let default_addr = SocketAddr::from_str("0.0.0.0:8080").unwrap(); let addr = match matches.opt_str("f") { Some(ip) => { match SocketAddr::from_str(&*ip) { Ok(addr) => addr, Err(_) => { println!("WARNING: Could not parse static file server address.\nDefaulting to {:?}",default_addr); defau...
random_line_split
server.rs
#![feature(core)] extern crate eve; extern crate getopts; extern crate url; extern crate core; use std::thread; use std::env; use getopts::Options; use std::net::SocketAddr; use core::str::FromStr; use eve::server; use eve::login; #[allow(dead_code)] fn
() { // handle command line arguments let args: Vec<String> = env::args().collect(); // define the command line arguments let mut opts = Options::new(); opts.optopt("f", "faddress", "specify a socket address for the static file server. Defaults to 0.0.0.0:8080","SOCKET ADDRESS"); opts.optopt("s", "saves",...
main
identifier_name
server.rs
#![feature(core)] extern crate eve; extern crate getopts; extern crate url; extern crate core; use std::thread; use std::env; use getopts::Options; use std::net::SocketAddr; use core::str::FromStr; use eve::server; use eve::login; #[allow(dead_code)] fn main()
return; } // parse static file server address let default_addr = SocketAddr::from_str("0.0.0.0:8080").unwrap(); let addr = match matches.opt_str("f") { Some(ip) => { match SocketAddr::from_str(&*ip) { Ok(addr) => addr, Err(_) => { println!("WARNING: Could not parse static file...
{ // handle command line arguments let args: Vec<String> = env::args().collect(); // define the command line arguments let mut opts = Options::new(); opts.optopt("f", "faddress", "specify a socket address for the static file server. Defaults to 0.0.0.0:8080","SOCKET ADDRESS"); opts.optopt("s", "saves", "s...
identifier_body
tests.rs
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::collections::HashMap; use Request; use http::hyper; macro_rules! assert_headers { ($($key:expr => [$($value:expr),+]),+) => ({ // Set up the parameters to the hyper request object. let h_method = hyper::Method::Get; let h_uri = hyper::...
#[test] fn test_multiple_headers_merge_into_one_from_hyp() { assert_headers!("friend" => ["alice"], "friend" => ["bob"]); assert_headers!("friend" => ["alice"], "friend" => ["bob"], "friend" => ["carol"]); assert_headers!("friend" => ["alice"], "friend" => ["bob"], "enemy" => ["carol"]); }
{ assert_headers!("friends" => ["alice"]); assert_headers!("friends" => ["alice", "bob"]); assert_headers!("friends" => ["alice", "bob, carol"]); assert_headers!("friends" => ["alice, david", "bob, carol", "eric, frank"]); assert_headers!("friends" => ["alice"], "enemies" => ["victor"]); assert_...
identifier_body
tests.rs
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::collections::HashMap; use Request; use http::hyper; macro_rules! assert_headers { ($($key:expr => [$($value:expr),+]),+) => ({ // Set up the parameters to the hyper request object. let h_method = hyper::Method::Get; let h_uri = hyper::...
() { assert_headers!("friends" => ["alice"]); assert_headers!("friends" => ["alice", "bob"]); assert_headers!("friends" => ["alice", "bob, carol"]); assert_headers!("friends" => ["alice, david", "bob, carol", "eric, frank"]); assert_headers!("friends" => ["alice"], "enemies" => ["victor"]); asse...
test_multiple_headers_from_hyp
identifier_name
tests.rs
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::collections::HashMap; use Request; use http::hyper; macro_rules! assert_headers { ($($key:expr => [$($value:expr),+]),+) => ({ // Set up the parameters to the hyper request object. let h_method = hyper::Method::Get; let h_uri = hyper::RequestUri::AbsolutePath("/test".to_string());...
random_line_split
unicast_block2.rs
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
(&mut self, context: Result<&IC, Error>) -> Result<ResponseStatus<R>, Error> { if let Some(context) = context.ok() { if context.is_dupe() { // Ignore dupes. return Ok(ResponseStatus::Continue); } let msg = context.message(); let blo...
handler
identifier_name
unicast_block2.rs
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
Ok(true) => return self.inner.handler(Ok(context)), Err(_) => { self.reconstructor = None; self.etag = None; return self.inner.handler(Err(Error::Reset)); } }; ...
{ return self .inner .handler(Ok(context)) .map(|_| ResponseStatus::SendNext) }
conditional_block
unicast_block2.rs
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
self.inner.handler(context) } } /// Unicast Block2 Collecting combinator, created by [`UnicastBlock2::emit_successful_collected_response`]. /// /// This `SendDesc` will collect all of the various pieces and emit a single allocated /// [`MessageRead`] instance that contains the entire payload. #[derive(Debu...
}
random_line_split
holisticword.rs
//! Holistic word use super::private::*; use super::*; use errors::*; use std::os::raw::c_char; use std::path::Path; use *; extern "C" { fn cv_holistic_new( archive_file: *const c_char, weights_file: *const c_char, words_file: *const c_char, result: *mut CResult<*mut COCR>, ); ...
(&mut self) { unsafe { cv_holistic_drop(self.value); } } } impl OcrImpl for OcrHolisticWord { fn get_value(&self) -> *mut COCR { self.value } } impl OcrImplInterface for OcrHolisticWord {}
drop
identifier_name
holisticword.rs
//! Holistic word use super::private::*; use super::*; use errors::*; use std::os::raw::c_char;
extern "C" { fn cv_holistic_new( archive_file: *const c_char, weights_file: *const c_char, words_file: *const c_char, result: *mut CResult<*mut COCR>, ); fn cv_holistic_drop(ocr: *mut COCR); } /// `OcrHolisticWord` class provides an interface with the tesseract-ocr API #[de...
use std::path::Path; use *;
random_line_split
holisticword.rs
//! Holistic word use super::private::*; use super::*; use errors::*; use std::os::raw::c_char; use std::path::Path; use *; extern "C" { fn cv_holistic_new( archive_file: *const c_char, weights_file: *const c_char, words_file: *const c_char, result: *mut CResult<*mut COCR>, ); ...
} impl OcrImplInterface for OcrHolisticWord {}
{ self.value }
identifier_body
cef_trace.rs
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of ...
}
{ if c_object.is_null() && c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefEndTracingCallback::from_c_object_addref(c_object)) } }
identifier_body
cef_trace.rs
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of ...
(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback { if!c_object.is_null() && c_object as usize!= mem::POST_DROP_USIZE { ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); } CefEndTracingCallback { c_object: c_object, } } pub fn c_object(&self) -> *mut...
from_c_object_addref
identifier_name
cef_trace.rs
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of ...
// // Called after all processes have sent their trace data. |tracing_file| is // the path at which tracing data was written. The client is responsible for // deleting |tracing_file|. // pub fn on_end_tracing_complete(&self, tracing_file: &[u16]) -> () { if self.c_object.is_null() || self.c_obje...
random_line_split
cef_trace.rs
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of ...
else { Some(CefEndTracingCallback::from_c_object_addref(c_object)) } } }
{ None }
conditional_block
version.rs
use crate::internal::consts; // ========================================================================= // /// The CFB format version to use. #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Version { /// Version 3, which uses 512-byte sectors. V3, /// Version 4, which uses 4...
} // ========================================================================= //
{ for &version in &[Version::V3, Version::V4] { assert_eq!(Version::from_number(version.number()), Some(version)); } }
identifier_body
version.rs
use crate::internal::consts; // ========================================================================= // /// The CFB format version to use. #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Version { /// Version 3, which uses 512-byte sectors. V3, /// Version 4, which uses 4...
} /// Returns the version number for this version. pub fn number(self) -> u16 { match self { Version::V3 => 3, Version::V4 => 4, } } /// Returns the sector shift used in this version. pub fn sector_shift(self) -> u16 { match self { Ve...
random_line_split