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
testoak.rs
// Copyright 2014 Pierre Talbot (IRCAM) // 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...
} struct TestDisplay { terminal: Box<Terminal<WriterWrapper>+'static>, num_success: u32, num_failure: u32, num_system_failure: u32 } impl TestDisplay { pub fn new() -> TestDisplay { TestDisplay{ terminal: term::stdout().unwrap(), num_success: 0, num_failure: 0, num_system_fail...
{ let state = (self.info.recognizer)(input); let result = state.into_result(); match (expectation.clone(), result) { (Match, Ok((ref state, _))) if state.full_read() => self.display.success(test_path), (Error, Ok((ref state, _))) if state.partial_read() => self.display.success(test_path), ...
identifier_body
testoak.rs
// Copyright 2014 Pierre Talbot (IRCAM) // 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...
(&mut self, msg: &str) { (write!(self.terminal, "{}", msg)).unwrap(); } }
write_msg
identifier_name
testoak.rs
// Copyright 2014 Pierre Talbot (IRCAM) // 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...
terminal: term::stdout().unwrap(), num_success: 0, num_failure: 0, num_system_failure: 0 } } pub fn title(&mut self, msg: &str) { self.write_header(term::color::CYAN, msg); self.write_msg("\n\n"); } pub fn info(&mut self, msg: &String) { self.write_line(term::color:...
random_line_split
mod.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
() { arch::serial::init(); log::init(); } /// Reinitializes the I/O module (for VPE::run) pub fn reinit() { log::reinit(); }
init
identifier_name
mod.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
/// Reinitializes the I/O module (for VPE::run) pub fn reinit() { log::reinit(); }
{ arch::serial::init(); log::init(); }
identifier_body
mod.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
}
random_line_split
incremental.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 flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED}; use std::fmt; ...
(old: Option<&Arc<ServoComputedValues>>, new: &ServoComputedValues) -> RestyleDamage { let old: &ServoComputedValues = match old { None => return RestyleDamage::rebuild_and_reflow(), Some(cv) => &**cv, }; let mut damage = RestyleDamage::empty(); // This should check every CSS property,...
compute_damage
identifier_name
incremental.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 flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED}; use std::fmt; ...
} } } impl fmt::Display for RestyleDamage { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { let mut first_elem = true; let to_iter = [ (REPAINT, "Repaint") , (STORE_OVERFLOW, "StoreOverflow") , (BUBBLE_ISIZES, "BubbleISizes") ...
{ // TODO(pcwalton): Take floatedness into account. self & (REPAINT | REFLOW) }
conditional_block
incremental.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 flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED}; use std::fmt; ...
pub fn damage_for_child(self, parent_is_absolutely_positioned: bool, child_is_absolutely_positioned: bool) -> RestyleDamage { match (parent_is_absolutely_positioned, child_is_absolutely_positioned) { (false, true...
} } /// Supposing the *parent* of a flow with the given `position` property has this damage, /// returns the damage that we should add to this flow.
random_line_split
incremental.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 flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED}; use std::fmt; ...
} impl RestyleDamage { /// Supposing a flow has the given `position` property and this damage, returns the damage that /// we should add to the *parent* of this flow. pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> RestyleDamage { if child_is_absolutely_positioned { ...
{ REPAINT | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW | RECONSTRUCT_FLOW }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![cfg(test)] #![feature(core_intrinsics)] #![feature(plugin)] extern crate app_units; extern crate cssparser; ex...
mod attr; mod cache; mod logical_geometry; mod media_queries; mod owning_handle; mod parsing; mod properties; mod selector_matching; mod str; mod stylesheets; mod value; mod viewport; mod writing_modes { use style::logical_geometry::WritingMode; use style::properties::{INITIAL_SERVO_VALUES, get_writing_mode}; ...
extern crate url; extern crate util; mod atomic_refcell;
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![cfg(test)] #![feature(core_intrinsics)] #![feature(plugin)] extern crate app_units; extern crate cssparser; ex...
}
{ assert_eq!(get_writing_mode(INITIAL_SERVO_VALUES.get_inheritedbox()), WritingMode::empty()) }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![cfg(test)] #![feature(core_intrinsics)] #![feature(plugin)] extern crate app_units; extern crate cssparser; ex...
() { assert_eq!(get_writing_mode(INITIAL_SERVO_VALUES.get_inheritedbox()), WritingMode::empty()) } }
initial_writing_mode_is_empty
identifier_name
mod.rs
pub const C_IRUSR: ::int_t = 0o000400;
pub const C_IWUSR: ::int_t = 0o000200; pub const C_IXUSR: ::int_t = 0o000100; pub const C_IRGRP: ::int_t = 0o000040; pub const C_IWGRP: ::int_t = 0o000020; pub const C_IXGRP: ::int_t = 0o000010; pub const C_IROTH: ::int_t = 0o000004; pub const C_IWOTH: ::int_t = 0o000002; pub const C_IXOTH: ::int_t = 0o000001; ...
random_line_split
truncate.rs
// * This file is part of the uutils coreutils package. // * // * (c) Alex Lyon <arcterus@mail.com> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize use clap::...
(args: impl uucore::Args) -> UResult<()> { let long_usage = get_long_usage(); let matches = uu_app() .after_help(&long_usage[..]) .try_get_matches_from(args) .map_err(|e| { e.print().expect("Error writing clap::Error"); match e.kind { clap::ErrorKind...
uumain
identifier_name
truncate.rs
// * This file is part of the uutils coreutils package. // * // * (c) Alex Lyon <arcterus@mail.com> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize use clap::...
} } Ok(()) } fn truncate( no_create: bool, _: bool, reference: Option<String>, size: Option<String>, filenames: &[String], ) -> UResult<()> { let create =!no_create; // There are four possibilities // - reference file given and size given, // - reference file given ...
{ return Err( e.map_err_context(|| format!("cannot open {} for writing", filename.quote())) ) }
conditional_block
truncate.rs
// * This file is part of the uutils coreutils package. // * // * (c) Alex Lyon <arcterus@mail.com> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize use clap::...
.long(options::REFERENCE) .required_unless_present(options::SIZE) .help("base the size of each file on the size of RFILE") .value_name("RFILE") ) .arg( Arg::new(options::SIZE) .short('s') .long(options::SIZE) .requir...
Arg::new(options::REFERENCE) .short('r')
random_line_split
truncate.rs
// * This file is part of the uutils coreutils package. // * // * (c) Alex Lyon <arcterus@mail.com> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize use clap::...
return Err(UUsageError::new(1, "missing file operand")); } else { let io_blocks = matches.is_present(options::IO_BLOCKS); let no_create = matches.is_present(options::NO_CREATE); let reference = matches.value_of(options::REFERENCE).map(String::from); let size = matches.value_o...
{ let long_usage = get_long_usage(); let matches = uu_app() .after_help(&long_usage[..]) .try_get_matches_from(args) .map_err(|e| { e.print().expect("Error writing clap::Error"); match e.kind { clap::ErrorKind::DisplayHelp | clap::ErrorKind::Displ...
identifier_body
main.rs
#![allow(unused_variables)] fn if_expression() { // `if` expressions (NOT statements!) let number = 3; if number < 5 { println!("condition was true"); } else { println!("condition was false"); } // Since `if`s are expressions, we can do things like this: let z = if number ...
() { if_expression(); loops(); }
main
identifier_name
main.rs
#![allow(unused_variables)] fn if_expression() { // `if` expressions (NOT statements!) let number = 3; if number < 5 { println!("condition was true"); } else { println!("condition was false"); } // Since `if`s are expressions, we can do things like this: let z = if number ...
// *** For loop println!("*** for ***"); for element in [10, 20, 30].iter() { println!("{}!", element); } // Also sweet: for element in (1..4).rev() { println!("{}!", element); } } fn main() { if_expression(); loops(); }
println!("LIFTOFF!!!");
random_line_split
main.rs
#![allow(unused_variables)] fn if_expression() { // `if` expressions (NOT statements!) let number = 3; if number < 5 { println!("condition was true"); } else
// Since `if`s are expressions, we can do things like this: let z = if number > 5 { true } else { false }; // As you can guess, each arm of the whole if expression // must return values of the same type println!("Z: {}", z); } fn loops() { // *** Forever: loop println!("*** loop ***"); ...
{ println!("condition was false"); }
conditional_block
main.rs
#![allow(unused_variables)] fn if_expression()
fn loops() { // *** Forever: loop println!("*** loop ***"); let mut number = 3; let z = loop { println!("again"); number -= 1; if number == 0 { break; } }; // *** While loop println!("*** while ***"); let mut number = 3; while number!= 0...
{ // `if` expressions (NOT statements!) let number = 3; if number < 5 { println!("condition was true"); } else { println!("condition was false"); } // Since `if`s are expressions, we can do things like this: let z = if number > 5 { true } else { false }; // As you can ...
identifier_body
load.rs
use tcod::colors::Color; // use std::collections::BTreeMap; use rustc_serialize::json::{self, Json}; use std::fs::File; use std::error::Error; use std::io::Read; use std::collections::HashMap; use rand; use rand::distributions::{Weighted, IndependentSample}; use ai; use object; use object::item; use object::actor; use...
item: class.clone()}); } let mut rng = rand::thread_rng(); ObjectRandomizer{ weighted_choice: OwnedWeightedChoice::new(weighted), rng: rng, } } pub fn get_class(&mut self) -> object::ObjectClass { self.weighted_ch...
let mut weighted = vec![]; for class in classes { weighted.push(Weighted{weight: class.chance,
random_line_split
load.rs
use tcod::colors::Color; // use std::collections::BTreeMap; use rustc_serialize::json::{self, Json}; use std::fs::File; use std::error::Error; use std::io::Read; use std::collections::HashMap; use rand; use rand::distributions::{Weighted, IndependentSample}; use ai; use object; use object::item; use object::actor; use...
None } } pub struct ObjectRandomizer { weighted_choice: OwnedWeightedChoice<object::ObjectClass>, rng: rand::ThreadRng } impl ObjectRandomizer { fn new(classes: &Vec<object::ObjectClass>) -> Self { let mut weighted = vec![]; for class in classes { weighted.push(Wei...
{ return Some(ObjectRandomizer::new(classes)); }
conditional_block
load.rs
use tcod::colors::Color; // use std::collections::BTreeMap; use rustc_serialize::json::{self, Json}; use std::fs::File; use std::error::Error; use std::io::Read; use std::collections::HashMap; use rand; use rand::distributions::{Weighted, IndependentSample}; use ai; use object; use object::item; use object::actor; use...
{ object_types: Vec<String>, by_type: HashMap<String, Vec<object::ObjectClass>>, by_name: HashMap<String, object::ObjectClass>, } impl ObjectTypes { pub fn new(object_types: Vec<String>) -> Self { let mut by_name = HashMap::new(); let mut by_type = HashMap::new(); let mut types...
ObjectTypes
identifier_name
template.rs
use ::flota::config; use ::distro; use ::exec::session::*; use ::exec::session::ssh::SessSeedSsh; use ::util::errors::*; use ::virt::*; use ::virt::domain::snapshot::*; #[derive(Clone, Debug)] pub struct Template<'a> { pub name: String, pub path_disk: String, pub resources: &'a ResourceBlend<'a>, pub s...
(resources: &'a ResourceBlend, template: &config::template::Template, distro: Box<distro::Distro>) -> Result<Self> { let (dom, volume) = distro.build_image(None, resources.conn(), resources.pool().as_ref().unwrap(), ...
new
identifier_name
template.rs
use ::flota::config; use ::distro; use ::exec::session::*; use ::exec::session::ssh::SessSeedSsh; use ::util::errors::*; use ::virt::*; use ::virt::domain::snapshot::*; #[derive(Clone, Debug)] pub struct Template<'a> { pub name: String, pub path_disk: String, pub resources: &'a ResourceBlend<'a>, pub s...
try!(dom.destroy()); // XXX: now its okay to have only one choice, maybe not? let session_seeds = vec![ SessSeedSsh::new( &template.mgmt_user, None, 22, template.mgmt_user_ssh_private_key.as_path() ) ]; Ok...
let snapshot_name = format!("{}.001", dom.name()); let snapshot = DomainSnapshot::ensure(&dom, &pool_root, Some(&snapshot_name));
random_line_split
import-glob-0.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { println!("f3"); } pub fn f4() { println!("f4"); } } fn main() { f1(); f2(); f999(); // 'export' currently doesn't work? f4(); }
f3
identifier_name
import-glob-0.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} fn main() { f1(); f2(); f999(); // 'export' currently doesn't work? f4(); }
{ println!("f4"); }
identifier_body
import-glob-0.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// error-pattern: unresolved name use module_of_many_things::*; mod module_of_many_things { pub fn f1() { println!("f1"); } pub fn f2() { println!("f2"); } fn f3() { println!("f3"); } pub fn f4() { println!("f4"); } } fn main() { f1(); f2(); f999(); // 'export' currently doesn't work? ...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
llrepr.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 ...
(&self, ccx: &CrateContext) -> String { ccx.tn().type_to_string(*self) } } impl LlvmRepr for ValueRef { fn llrepr(&self, ccx: &CrateContext) -> String { ccx.tn().val_to_string(*self) } }
llrepr
identifier_name
llrepr.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 ...
} impl LlvmRepr for ValueRef { fn llrepr(&self, ccx: &CrateContext) -> String { ccx.tn().val_to_string(*self) } }
{ ccx.tn().type_to_string(*self) }
identifier_body
llrepr.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 llrepr(&self, ccx: &CrateContext) -> String; } impl<T:LlvmRepr> LlvmRepr for [T] { fn llrepr(&self, ccx: &CrateContext) -> String { let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect(); format!("[{}]", reprs.join(",")) } } impl LlvmRepr for Type { fn llrepr(&self, c...
use trans::context::CrateContext; use trans::type_::Type; use llvm::ValueRef; pub trait LlvmRepr {
random_line_split
to_animated_zero.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 animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use cg; use quote; use syn; use sy...
let (mapped, mapped_bindings) = cg::value(variant, "mapped"); let bindings_pairs = variant.bindings().into_iter().zip(mapped_bindings); let mut computations = quote!(); computations.append_all(bindings_pairs.map(|(binding, mapped_binding)| { let field_attrs = cg::parse_field...
{ return Some(quote! { Err(()) }); }
conditional_block
to_animated_zero.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 animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use cg; use quote; use syn; use sy...
(mut input: syn::DeriveInput) -> quote::Tokens { let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input); let no_bound = animation_input_attrs.no_bound.unwrap_or_default(); let mut where_clause = input.generics.where_clause.take(); for param in input.generics.type_params() { ...
derive
identifier_name
to_animated_zero.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 animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use cg; use quote; use syn; use sy...
let mut computations = quote!(); computations.append_all(bindings_pairs.map(|(binding, mapped_binding)| { let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&binding.ast()); if field_attrs.constant { quote! { let #mapped_binding = :...
{ let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input); let no_bound = animation_input_attrs.no_bound.unwrap_or_default(); let mut where_clause = input.generics.where_clause.take(); for param in input.generics.type_params() { if !no_bound.contains(&param.ident) { ...
identifier_body
to_animated_zero.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 animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use cg; use quote; use syn; use sy...
let attrs = cg::parse_variant_attrs_from_ast::<AnimationVariantAttrs>(&variant.ast()); if attrs.error { return Some(quote! { Err(()) }); } let (mapped, mapped_bindings) = cg::value(variant, "mapped"); let bindings_pairs = variant.bindings().into_iter().zip(mapped_bind...
} let to_body = synstructure::Structure::new(&input).each_variant(|variant| {
random_line_split
shell.rs
use std::path::PathBuf; use std::rc::Rc; use config::Config; pub struct Shell<T: Config> { pub name: String, pub config: Rc<T>, } impl<T: Config> Shell<T> { pub fn new<S>(name: S, config: Rc<T>) -> Shell<T> where S: Into<String> { Shell { name: name.into(), con...
(path_str: &str) -> PathBuf { PathBuf::from(path_str) } fn std_mock_config() -> Rc<MockConfig> { let root_path = PathBuf::from("/"); mock_config(root_path) } fn mock_config(root_path: PathBuf) -> Rc<MockConfig> { Rc::new(MockConfig { root_path: root_path, ...
root_path
identifier_name
shell.rs
use std::path::PathBuf; use std::rc::Rc; use config::Config; pub struct Shell<T: Config> { pub name: String, pub config: Rc<T>, } impl<T: Config> Shell<T> { pub fn new<S>(name: S, config: Rc<T>) -> Shell<T> where S: Into<String> { Shell { name: name.into(), con...
} #[test] fn can_resolve_its_path() { let root_path = root_path("/Users/geoff/.config/hermit"); let config = mock_config(root_path.clone()); let s = Shell::new("default", config); let expected_path = root_path.join("shells") .join("default"); assert_eq!(s...
let config = std_mock_config(); let s = Shell::new(String::from("my_shell"), config); assert_eq!(s.name, "my_shell");
random_line_split
adaptors_no_collect.rs
use itertools::Itertools; struct PanickingCounter { curr: usize, max: usize, } impl Iterator for PanickingCounter { type Item = (); fn next(&mut self) -> Option<Self::Item> { self.curr += 1; if self.curr == self.max
Some(()) } } fn no_collect_test<A, T>(to_adaptor: T) where A: Iterator, T: Fn(PanickingCounter) -> A { let counter = PanickingCounter { curr: 0, max: 10_000 }; let adaptor = to_adaptor(counter); for _ in adaptor.take(5) {} } #[test] fn permutations_no_collect() { no_collect_test(|it...
{ panic!( "Input iterator reached maximum of {} suggesting collection by adaptor", self.max ); }
conditional_block
adaptors_no_collect.rs
use itertools::Itertools;
impl Iterator for PanickingCounter { type Item = (); fn next(&mut self) -> Option<Self::Item> { self.curr += 1; if self.curr == self.max { panic!( "Input iterator reached maximum of {} suggesting collection by adaptor", self.max ); ...
struct PanickingCounter { curr: usize, max: usize, }
random_line_split
adaptors_no_collect.rs
use itertools::Itertools; struct PanickingCounter { curr: usize, max: usize, } impl Iterator for PanickingCounter { type Item = (); fn next(&mut self) -> Option<Self::Item> { self.curr += 1; if self.curr == self.max { panic!( "Input iterator reached maximu...
#[test] fn combinations_with_replacement_no_collect() { no_collect_test(|iter| iter.combinations_with_replacement(5)) }
{ no_collect_test(|iter| iter.combinations(5)) }
identifier_body
adaptors_no_collect.rs
use itertools::Itertools; struct PanickingCounter { curr: usize, max: usize, } impl Iterator for PanickingCounter { type Item = (); fn next(&mut self) -> Option<Self::Item> { self.curr += 1; if self.curr == self.max { panic!( "Input iterator reached maximu...
() { no_collect_test(|iter| iter.combinations_with_replacement(5)) }
combinations_with_replacement_no_collect
identifier_name
atomics.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 uint_and() { let x = AtomicUint::new(0xf731); assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731); assert_eq!(x.load(SeqCst), 0xf731 & 0x137f); } #[test] fn uint_or() { let x = AtomicUint::new(0xf731); assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731); assert_eq!(x.load(SeqCst), 0xf731 | 0x137f); }...
#[test]
random_line_split
atomics.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 ...
{ unsafe { assert!(!S_BOOL.load(SeqCst)); assert!(S_INT.load(SeqCst) == 0); assert!(S_UINT.load(SeqCst) == 0); } }
identifier_body
atomics.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x = AtomicInt::new(0xf731); assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731); assert_eq!(x.load(SeqCst), 0xf731 & 0x137f); } #[test] fn int_or() { let x = AtomicInt::new(0xf731); assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731); assert_eq!(x.load(SeqCst), 0xf731 | 0x137f); } #[test] fn i...
int_and
identifier_name
main.rs
fn main() { for x in 1..10 { println!("{}", x); } // An iterator is something that we can call the.next() method on repeatedly, // and it gives us a sequence of things. let mut num_range = 0..5; loop { match num_range.next() { Some(x) => { println!("{}", x); }, Node => ...
// and the result is the value of the accumulator on the next iteration. } fn iterators() { // (1..).step_by(5); // This iterator counts up from one, adding five each time. // It will give you a new integer every time, forever // (well, technically, until it reaches the maximum number representable by an i3...
{ // - .collect() let one_to_one_hundred = (1..101).collect::<Vec<i32>>(); // partial hint let one_to_one_hundred2 = (1..101).collect::<Vec<_>>(); // - .find() // takes a closure and works on a reference to each element of an iterator let greater_than_forty_two = (0..100).find(|x| *x > 42); match gr...
identifier_body
main.rs
fn main() { for x in 1..10 {
let mut num_range = 0..5; loop { match num_range.next() { Some(x) => { println!("{}", x); }, Node => { break } } } // we make mutable binding to the num_range, which is iterator // then loop with inner match // match is result of num_range.next() which gives reference to ...
println!("{}", x); } // An iterator is something that we can call the .next() method on repeatedly, // and it gives us a sequence of things.
random_line_split
main.rs
fn main() { for x in 1..10 { println!("{}", x); } // An iterator is something that we can call the.next() method on repeatedly, // and it gives us a sequence of things. let mut num_range = 0..5; loop { match num_range.next() { Some(x) =>
, Node => { break } } } // we make mutable binding to the num_range, which is iterator // then loop with inner match // match is result of num_range.next() which gives reference to the next // value of the iterator next() returns an Option<i32> which will become // Some(i32) when we have a value a...
{ println!("{}", x); }
conditional_block
main.rs
fn main() { for x in 1..10 { println!("{}", x); } // An iterator is something that we can call the.next() method on repeatedly, // and it gives us a sequence of things. let mut num_range = 0..5; loop { match num_range.next() { Some(x) => { println!("{}", x); }, Node => ...
() { let nums = (1..1000) .filter(|&x| x % 2 == 0) .filter(|&x| x % 3 == 0) .take(5) .collect::<Vec<i32>>(); for num in &nums { println!("num {}", num); } }
combo
identifier_name
root.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/. */ /// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d...
#[deriving(Encodable)] struct ListTabsReply { from: String, selected: uint, tabs: Vec<TabActorMsg>, } #[deriving(Encodable)] struct RootActorMsg { from: String, applicationType: String, traits: ActorTraits, } pub struct RootActor { pub tabs: Vec<String>, } impl Actor for RootActor { f...
random_line_split
root.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/. */ /// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d...
fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, _msg: &json::JsonObject, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "listAddons" => { ...
{ "root".to_string() }
identifier_body
root.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/. */ /// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d...
_ => false }) } } impl RootActor { pub fn encodable(&self) -> RootActorMsg { RootActorMsg { from: "root".to_string(), applicationType: "browser".to_string(), traits: ActorTraits { sources: true, highlightable: tru...
{ let actor = ListTabsReply { from: "root".to_string(), selected: 0, tabs: self.tabs.iter().map(|tab| { registry.find::<TabActor>(tab.as_slice()).encodable() }).collect() }; ...
conditional_block
root.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/. */ /// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d...
{ from: String, selected: uint, tabs: Vec<TabActorMsg>, } #[deriving(Encodable)] struct RootActorMsg { from: String, applicationType: String, traits: ActorTraits, } pub struct RootActor { pub tabs: Vec<String>, } impl Actor for RootActor { fn name(&self) -> String { "root".to...
ListTabsReply
identifier_name
lifetime_start_end.rs
// compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 #![crate_type = "lib"] // CHECK-LABEL: @test #[no_mangle] pub fn test()
// CHECK: [[E_b:%[0-9]+]] = bitcast { i32, i32 }** %b to i8* // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E_b]]) } let c = 1; &c; // keep variable in an alloca // CHECK: [[S_c:%[0-9]+]] = bitcast i32* %c to i8* // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_c]]) ...
{ let a = 0; &a; // keep variable in an alloca // CHECK: [[S_a:%[0-9]+]] = bitcast i32* %a to i8* // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_a]]) { let b = &Some(a); &b; // keep variable in an alloca // CHECK: [[S_b:%[0-9]+]] = bitcast { i32, i32 }** %b to i8* //...
identifier_body
lifetime_start_end.rs
// compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 #![crate_type = "lib"] // CHECK-LABEL: @test #[no_mangle] pub fn
() { let a = 0; &a; // keep variable in an alloca // CHECK: [[S_a:%[0-9]+]] = bitcast i32* %a to i8* // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_a]]) { let b = &Some(a); &b; // keep variable in an alloca // CHECK: [[S_b:%[0-9]+]] = bitcast { i32, i32 }** %b to i8*...
test
identifier_name
lifetime_start_end.rs
// compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 #![crate_type = "lib"] // CHECK-LABEL: @test #[no_mangle] pub fn test() { let a = 0; &a; // keep variable in an alloca // CHECK: [[S_a:%[0-9]+]] = bitcast i32* %a to i8* // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_a]]) ...
// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E_c]]) // CHECK: [[E_a:%[0-9]+]] = bitcast i32* %a to i8* // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E_a]]) }
// CHECK: [[S_c:%[0-9]+]] = bitcast i32* %c to i8* // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_c]]) // CHECK: [[E_c:%[0-9]+]] = bitcast i32* %c to i8*
random_line_split
start.rs
use std::io::{Read, BufReader, Write}; use std::thread; use std::sync::mpsc::sync_channel; use types::{Cmd, Response}; use process::process; use state::State; use input::parse_input; use output::format_output; pub fn start<R, W>(input: R, output: W) where R: Read + Send +'static, W: Write + Send +'static
{ let mut state = State::new(); let (cmd_tx, cmd_rx) = sync_channel::<Cmd>(0); let temp = cmd_tx.clone(); let _input_guard = thread::spawn(move || parse_input(BufReader::new(input), temp)); let (resp_tx, resp_rx) = sync_channel::<Response>(0); let _output_guard = thread::spawn(move || format_out...
identifier_body
start.rs
use std::io::{Read, BufReader, Write}; use std::thread; use std::sync::mpsc::sync_channel; use types::{Cmd, Response}; use process::process; use state::State; use input::parse_input; use output::format_output; pub fn start<R, W>(input: R, output: W) where R: Read + Send +'static, W: Write + Send +'static { let mu...
if cmd == Cmd::Quit { return; } else { process(&mut state, cmd, &resp_tx, &cmd_tx); } debug!("state.mode = {:?}", state.mode); } }
random_line_split
start.rs
use std::io::{Read, BufReader, Write}; use std::thread; use std::sync::mpsc::sync_channel; use types::{Cmd, Response}; use process::process; use state::State; use input::parse_input; use output::format_output; pub fn
<R, W>(input: R, output: W) where R: Read + Send +'static, W: Write + Send +'static { let mut state = State::new(); let (cmd_tx, cmd_rx) = sync_channel::<Cmd>(0); let temp = cmd_tx.clone(); let _input_guard = thread::spawn(move || parse_input(BufReader::new(input), temp)); let (resp_tx, resp_rx) = s...
start
identifier_name
start.rs
use std::io::{Read, BufReader, Write}; use std::thread; use std::sync::mpsc::sync_channel; use types::{Cmd, Response}; use process::process; use state::State; use input::parse_input; use output::format_output; pub fn start<R, W>(input: R, output: W) where R: Read + Send +'static, W: Write + Send +'static { let mu...
debug!("state.mode = {:?}", state.mode); } }
{ process(&mut state, cmd, &resp_tx, &cmd_tx); }
conditional_block
function_section.rs
/* Copyright 2018 Mozilla Foundation * * 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...
pub fn get_count(&self) -> u32 { self.count } /// Reads function type index from the function section. /// /// # Examples /// ``` /// # let data: &[u8] = &[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, /// # 0x01, 0x4, 0x01, 0x60, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, ...
{ self.reader.original_position() }
identifier_body
function_section.rs
/* Copyright 2018 Mozilla Foundation * * 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...
/// # let data: &[u8] = &[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, /// # 0x01, 0x4, 0x01, 0x60, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, /// # 0x0a, 0x05, 0x01, 0x03, 0x00, 0x01, 0x0b]; /// use wasmparser::ModuleReader; /// let mut reader = ModuleReader::new(data).expect("module reader"); ...
/// Reads function type index from the function section. /// /// # Examples /// ```
random_line_split
function_section.rs
/* Copyright 2018 Mozilla Foundation * * 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...
<'a> { reader: BinaryReader<'a>, count: u32, } impl<'a> FunctionSectionReader<'a> { pub fn new(data: &'a [u8], offset: usize) -> Result<FunctionSectionReader<'a>> { let mut reader = BinaryReader::new_with_offset(data, offset); let count = reader.read_var_u32()?; Ok(FunctionSectionRe...
FunctionSectionReader
identifier_name
main.rs
extern crate clap; extern crate lib; use clap::{Arg, App}; use std::fs::File; use std::io::Seek; use std::io::SeekFrom; use std::io::Read; use std::str::FromStr; fn main() { let matches = App::new("wbmeta") .version(lib::VERSION) .author(lib::AUTHOR) .about("Dump a segment header") .ar...
.arg(Arg::with_name("SEGID") .help("Segment id") .required(true) .index(2)) .get_matches(); let devname: String = matches.value_of("CACHEDEV").unwrap().to_string(); let id: i32 = i32::from_str(matches.value_of("SEGID").unwrap()).expect("Segment id should be int...
.required(true) .index(1))
random_line_split
main.rs
extern crate clap; extern crate lib; use clap::{Arg, App}; use std::fs::File; use std::io::Seek; use std::io::SeekFrom; use std::io::Read; use std::str::FromStr; fn
() { let matches = App::new("wbmeta") .version(lib::VERSION) .author(lib::AUTHOR) .about("Dump a segment header") .arg(Arg::with_name("CACHEDEV") .help("Path to the cache device") .required(true) .index(1)) .arg(Arg::with_name("SEGID") ...
main
identifier_name
main.rs
extern crate clap; extern crate lib; use clap::{Arg, App}; use std::fs::File; use std::io::Seek; use std::io::SeekFrom; use std::io::Read; use std::str::FromStr; fn main()
if id == 0 { // superblock let mut buf = [0;512]; let mut f = File::open(&devname).unwrap(); f.read(&mut buf).unwrap(); let sup_header = lib::SuperBlockHeader::from_buf(&buf); let s = if sup_header.magic == 0x57427374 { "formatted" } else { "u...
{ let matches = App::new("wbmeta") .version(lib::VERSION) .author(lib::AUTHOR) .about("Dump a segment header") .arg(Arg::with_name("CACHEDEV") .help("Path to the cache device") .required(true) .index(1)) .arg(Arg::with_name("SEGID") ...
identifier_body
main.rs
extern crate clap; extern crate lib; use clap::{Arg, App}; use std::fs::File; use std::io::Seek; use std::io::SeekFrom; use std::io::Read; use std::str::FromStr; fn main() { let matches = App::new("wbmeta") .version(lib::VERSION) .author(lib::AUTHOR) .about("Dump a segment header") .ar...
println!("last writeback id = {}", sup_record.last_writeback_segment_id); } else { // header let mut buf = [0;4096]; let mut f = File::open(&devname).unwrap(); let start_byte: u64 = (cache_dev.calc_segment_start(id) as u64) << 9; f.seek(SeekFrom::Start(start_byte)).unwrap();...
{ // superblock let mut buf = [0;512]; let mut f = File::open(&devname).unwrap(); f.read(&mut buf).unwrap(); let sup_header = lib::SuperBlockHeader::from_buf(&buf); let s = if sup_header.magic == 0x57427374 { "formatted" } else { "unformatted" ...
conditional_block
task.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...
(*me).awoken = false; match f(task) { Ok(()) => { while!(*me).awoken { (*me).lock.wait(); } } Err(task) => { cast::forget(task.wake()); } ...
let cur_task_dupe = *cast::transmute::<&~Task, &uint>(&cur_task); let task = BlockedTask::block(cur_task); if times == 1 { (*me).lock.lock();
random_line_split
task.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...
} impl Drop for Ops { fn drop(&mut self) { unsafe { self.lock.destroy() } } } #[cfg(test)] mod tests { use std::rt::Runtime; use std::rt::local::Local; use std::rt::task::Task; use std::task; use std::task::TaskOpts; use super::{spawn, spawn_opts, Ops}; #[test] fn smo...
{ Some(rtio::LocalIo::new(&mut self.io as &mut rtio::IoFactory)) }
identifier_body
task.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(~self, mut cur_task: ~Task, opts: TaskOpts, f: proc()) { cur_task.put_runtime(self as ~rt::Runtime); Local::put(cur_task); task::spawn_opts(opts, f); } fn local_io<'a>(&'a mut self) -> Option<rtio::LocalIo<'a>> { Some(rtio::LocalIo::new(&mut self.io as &mut rtio::IoFactory)) ...
spawn_sibling
identifier_name
inline_fragments.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::no_inline::NO_INLINE_DIRECTIVE_NAME; use crate::node_identifier::{LocationAgnosticHash, LocationAgnosticPartialEq}; use ...
#[derive(Eq, Clone, Debug)] struct FragmentSpreadKey(Arc<FragmentSpread>); type Seen = FnvHashMap<FragmentSpreadKey, Arc<InlineFragment>>; impl PartialEq for FragmentSpreadKey { fn eq(&self, other: &Self) -> bool { self.0.fragment.item == other.0.fragment.item && self.0.directives.location_ag...
{ let mut transform = InlineFragmentsTransform::new(program); transform .transform_program(program) .replace_or_else(|| program.clone()) }
identifier_body
inline_fragments.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::no_inline::NO_INLINE_DIRECTIVE_NAME; use crate::node_identifier::{LocationAgnosticHash, LocationAgnosticPartialEq}; use ...
(&self, other: &Self) -> bool { self.0.fragment.item == other.0.fragment.item && self.0.directives.location_agnostic_eq(&other.0.directives) } } impl Hash for FragmentSpreadKey { fn hash<H: std::hash::Hasher>(&self, state: &mut H) { self.0.fragment.item.hash(state); self.0.d...
eq
identifier_name
inline_fragments.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::no_inline::NO_INLINE_DIRECTIVE_NAME; use crate::node_identifier::{LocationAgnosticHash, LocationAgnosticPartialEq}; use ...
} } _ => self.default_transform_selection(selection), } } fn transform_scalar_field(&mut self, _field: &ScalarField) -> Transformed<Selection> { Transformed::Keep } }
} else { Transformed::Replace(Selection::InlineFragment( self.transform_fragment_spread(selection), ))
random_line_split
xchacha20poly1305_key_manager.rs
// Copyright 2020 The Tink-Rust Authors // // 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 ag...
Ok(()) }
}
random_line_split
xchacha20poly1305_key_manager.rs
// Copyright 2020 The Tink-Rust Authors // // 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 ag...
{ tink_core::keyset::validate_key_version(key.version, X_CHA_CHA20_POLY1305_KEY_VERSION) .map_err(|e| wrap_err("XChaCha20Poly1305KeyManager", e))?; let key_size = key.key_value.len(); if key_size != subtle::X_CHA_CHA20_KEY_SIZE { return Err(format!( "XChaCha20Poly1305KeyManager: ...
identifier_body
xchacha20poly1305_key_manager.rs
// Copyright 2020 The Tink-Rust Authors // // 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 ag...
(&self) -> &'static str { X_CHA_CHA20_POLY1305_TYPE_URL } fn key_material_type(&self) -> tink_proto::key_data::KeyMaterialType { tink_proto::key_data::KeyMaterialType::Symmetric } } fn new_x_cha_cha20_poly1305_key() -> tink_proto::XChaCha20Poly1305Key { let key_value = tink_core::subtl...
type_url
identifier_name
lib.rs
use std::collections::HashMap; pub struct SourcePrimes { primes: Vec<u64>, until: u64 } pub struct Factors { primes: Vec<u64>, counts: Vec<u64> } impl Factors { pub fn new(factor_map: &HashMap<u64, u64>) -> Factors { let (primes, counts) = factor_map.iter().unzip(); Factors { prim...
Factors::new(&factors_map) } }
{ *factors_map.entry(remaining).or_insert(0u64) += 1; }
conditional_block
lib.rs
use std::collections::HashMap; pub struct SourcePrimes { primes: Vec<u64>, until: u64 } pub struct Factors { primes: Vec<u64>, counts: Vec<u64> } impl Factors { pub fn new(factor_map: &HashMap<u64, u64>) -> Factors { let (primes, counts) = factor_map.iter().unzip(); Factors { prim...
} } } if remaining > 1 { *factors_map.entry(remaining).or_insert(0u64) += 1; } Factors::new(&factors_map) } }
let prime = *prime_ref; if remaining % prime == 0 { *factors_map.entry(prime).or_insert(0u64) += 1; remaining = remaining / prime; break;
random_line_split
lib.rs
use std::collections::HashMap; pub struct SourcePrimes { primes: Vec<u64>, until: u64 } pub struct Factors { primes: Vec<u64>, counts: Vec<u64> } impl Factors { pub fn new(factor_map: &HashMap<u64, u64>) -> Factors { let (primes, counts) = factor_map.iter().unzip(); Factors { prim...
(&self) -> u64 { let mut product = 1u64; for (prime, count) in self.primes.iter().zip(self.counts.iter()) { for _ in 0..*count { product = product * prime; } } product } pub fn proper_factors(&self) -> Vec<u64> { let mut factors:Ve...
product
identifier_name
rtio.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 ...
() -> LocalIo { use rt::sched::Scheduler; use rt::local::Local; unsafe { // First, attempt to use the local scheduler's I/O services let sched: Option<*mut Scheduler> = Local::try_unsafe_borrow(); match sched { Some(sched) => { ...
borrow
identifier_name
rtio.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 ...
} /// Data needed to make a successful open(2) call /// Using unix flag conventions for now, which happens to also be what's supported /// libuv (it does translation to windows under the hood). pub struct FileOpenConfig { /// Path to file to be opened path: Path, /// Flags for file access mode (as per open...
fn fire(&mut self);
random_line_split
x86.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 ...
(target_triple: String, target_os: abi::Os) -> target_strs::t { return target_strs::t { module_asm: "".to_string(), data_layout: match target_os { abi::OsMacos => { "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\ -i32:32:32-i64:32:64\ ...
get_target_strs
identifier_name
x86.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 ...
abi::OsFreebsd => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string() } }, target_triple: target_triple, cc_args: vec!("-m32".to_string()), }; }
{ "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string() }
conditional_block
x86.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 ...
abi::OsWin32 => { "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string() } abi::OsLinux => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string() } abi::OsAndroid => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16...
{ return target_strs::t { module_asm: "".to_string(), data_layout: match target_os { abi::OsMacos => { "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\ -i32:32:32-i64:32:64\ -f32:32:32-f64:32:64-v64:64:64\ -v128:128:128-a0:0:64-f80:128:128...
identifier_body
x86.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 ...
}; }
cc_args: vec!("-m32".to_string()),
random_line_split
d2d1effects_1.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
D2D1_YCBCR_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff, }}
D2D1_YCBCR_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC = 5,
random_line_split
simplepattern_test.rs
use simplepattern::SimplePattern; #[test] fn root_url_matches_only_root() { let p=SimplePattern::new("/"); assert!(p.matches("/").is_match); assert!(!p.matches("/foo").is_match); assert!(!p.matches("/foo/bar").is_match); }
let p=SimplePattern::new("/foo/bar"); assert!(p.matches("/foo/bar").is_match); assert!(p.matches("/foo/bar/").is_match); assert!(!p.matches("/biz/bar").is_match); assert!(!p.matches("/foo/bar/baz").is_match); assert!(!p.matches("/").is_match); } #[test] fn named_route_params_match_anything() { ...
#[test] fn raw_routes_match_urls() {
random_line_split
simplepattern_test.rs
use simplepattern::SimplePattern; #[test] fn
() { let p=SimplePattern::new("/"); assert!(p.matches("/").is_match); assert!(!p.matches("/foo").is_match); assert!(!p.matches("/foo/bar").is_match); } #[test] fn raw_routes_match_urls() { let p=SimplePattern::new("/foo/bar"); assert!(p.matches("/foo/bar").is_match); assert!(p.matches("/foo...
root_url_matches_only_root
identifier_name
simplepattern_test.rs
use simplepattern::SimplePattern; #[test] fn root_url_matches_only_root()
#[test] fn raw_routes_match_urls() { let p=SimplePattern::new("/foo/bar"); assert!(p.matches("/foo/bar").is_match); assert!(p.matches("/foo/bar/").is_match); assert!(!p.matches("/biz/bar").is_match); assert!(!p.matches("/foo/bar/baz").is_match); assert!(!p.matches("/").is_match); } #[test] fn...
{ let p=SimplePattern::new("/"); assert!(p.matches("/").is_match); assert!(!p.matches("/foo").is_match); assert!(!p.matches("/foo/bar").is_match); }
identifier_body
error.rs
use std::error::Error as StdError; use std::fmt; use std::io::Error as IoError; use std::num::ParseIntError; use std::result::Result as StdResult; use std::str::Utf8Error; /// A specialized Result type for metadata operations. pub type Result<T> = StdResult<T, Error>; /// Describes all errors that may occur. pub enum...
/// Not allowed are the following keys: ID3, TAG, OggS and MP+. ItemKeyDenied, /// There is no APE tag in a file. TagNotFound, } impl StdError for Error { fn description(&self) -> &str { match *self { Error::Io(ref err) => err.description(), Error::ParseInt(ref err) ...
InvalidApeVersion, /// Item keys can have a length of 2 (including) up to 255 (including) characters. InvalidItemKeyLen, /// Item key contains non-ascii characters. InvalidItemKeyValue,
random_line_split
error.rs
use std::error::Error as StdError; use std::fmt; use std::io::Error as IoError; use std::num::ParseIntError; use std::result::Result as StdResult; use std::str::Utf8Error; /// A specialized Result type for metadata operations. pub type Result<T> = StdResult<T, Error>; /// Describes all errors that may occur. pub enum...
} impl From<IoError> for Error { fn from(error: IoError) -> Error { Error::Io(error) } } impl From<ParseIntError> for Error { fn from(error: ParseIntError) -> Error { Error::ParseInt(error) } } impl From<Utf8Error> for Error { fn from(error: Utf8Error) -> Error { Error::F...
{ write!(out, "{}", self.description()) }
identifier_body
error.rs
use std::error::Error as StdError; use std::fmt; use std::io::Error as IoError; use std::num::ParseIntError; use std::result::Result as StdResult; use std::str::Utf8Error; /// A specialized Result type for metadata operations. pub type Result<T> = StdResult<T, Error>; /// Describes all errors that may occur. pub enum...
(error: Utf8Error) -> Error { Error::FromUtf8(error) } }
from
identifier_name
memory_arena.rs
//! 32-bits Memory arena for types implementing `Copy`. //! This Memory arena has been implemented to fit the use of tantivy's indexer //! and has *twisted specifications*. //! //! - It works on stable rust. //! - One can get an accurate figure of the memory usage of the arena. //! - Allocation are very cheap. //! - Al...
pub fn allocate_space(&mut self, len: usize) -> Addr { let page_id = self.pages.len() - 1; if let Some(addr) = self.pages[page_id].allocate_space(len) { return addr; } self.add_page().allocate_space(len).unwrap() } } struct Page { page_id: usize, len: usize, ...
random_line_split
memory_arena.rs
//! 32-bits Memory arena for types implementing `Copy`. //! This Memory arena has been implemented to fit the use of tantivy's indexer //! and has *twisted specifications*. //! //! - It works on stable rust. //! - One can get an accurate figure of the memory usage of the arena. //! - Allocation are very cheap. //! - Al...
fn allocate_space(&mut self, len: usize) -> Option<Addr> { if self.is_available(len) { let addr = Addr::new(self.page_id, self.len); self.len += len; Some(addr) } else { None } } } #[cfg(test)] mod tests { use super::MemoryArena; ...
{ &mut self.data[local_addr..][..len] }
identifier_body
memory_arena.rs
//! 32-bits Memory arena for types implementing `Copy`. //! This Memory arena has been implemented to fit the use of tantivy's indexer //! and has *twisted specifications*. //! //! - It works on stable rust. //! - One can get an accurate figure of the memory usage of the arena. //! - Allocation are very cheap. //! - Al...
} } #[cfg(test)] mod tests { use super::MemoryArena; #[test] fn test_arena_allocate_slice() { let mut arena = MemoryArena::new(); let a = b"hello"; let b = b"happy tax payer"; let addr_a = arena.allocate_space(a.len()); arena.slice_mut(addr_a, a.len()).copy_f...
{ None }
conditional_block
memory_arena.rs
//! 32-bits Memory arena for types implementing `Copy`. //! This Memory arena has been implemented to fit the use of tantivy's indexer //! and has *twisted specifications*. //! //! - It works on stable rust. //! - One can get an accurate figure of the memory usage of the arena. //! - Allocation are very cheap. //! - Al...
(self, offset: u32) -> Addr { Addr(self.0.wrapping_add(offset)) } fn new(page_id: usize, local_addr: usize) -> Addr { Addr((page_id << NUM_BITS_PAGE_ADDR | local_addr) as u32) } fn page_id(self) -> usize { (self.0 as usize) >> NUM_BITS_PAGE_ADDR } fn page_local_addr(se...
offset
identifier_name
solutions.rs
use num::integer; use num::Integer; use rayon::prelude::*; use std; pub fn largest_product_in_a_series(x: usize, digits: &Vec<u64>) -> Option<u64> { (0..digits.len() - x) .into_par_iter() .map(|i| (&digits[i..i + x]).iter().product()) .max() } pub fn special_pythagorean_triplet(sum: u32) -> O...
if c + 3 < grid[0].len() && r + 3 < grid.len() { result = result.max(Some( grid[r][c] * grid[r + 1][c + 1] * grid[r + 2][c + 2] * grid[r + 3][c + 3], ...
{ result = result.max(Some( grid[r][c] * grid[r + 1][c] * grid[r + 2][c] * grid[r + 3][c], )); }
conditional_block
solutions.rs
use num::integer; use num::Integer; use rayon::prelude::*; use std; pub fn largest_product_in_a_series(x: usize, digits: &Vec<u64>) -> Option<u64> { (0..digits.len() - x) .into_par_iter() .map(|i| (&digits[i..i + x]).iter().product()) .max() } pub fn special_pythagorean_triplet(sum: u32) -> O...
grid[r][c] * grid[r + 1][c + 1] * grid[r + 2][c + 2] * grid[r + 3][c + 3], )); } if 2 < c && r + 3 < grid.len() { ...
{ (0..grid.len()) .into_par_iter() .filter_map(|r| { (0..grid[0].len()) .into_par_iter() .filter_map(|c| { let mut result: Option<u32> = None; if c + 3 < grid[0].len() { result = result.max(So...
identifier_body
solutions.rs
use num::integer; use num::Integer; use rayon::prelude::*; use std; pub fn largest_product_in_a_series(x: usize, digits: &Vec<u64>) -> Option<u64> { (0..digits.len() - x) .into_par_iter() .map(|i| (&digits[i..i + x]).iter().product()) .max() } pub fn special_pythagorean_triplet(sum: u32) -> O...
#[test] fn test_special_pythagorean_triplet() { assert_eq!(special_pythagorean_triplet(3 + 4 + 5), Some(3 * 4 * 5)); } #[test] fn test_largest_product_in_a_grid() { let input = Vec::new(); assert_eq!(largest_product_in_a_grid(&input), None); let input = vec![Vec::ne...
); }
random_line_split