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
unsized7.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 ...
{ }
identifier_body
clause.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 ver...
} write!(formatter, " }}") } }
{ try!(write!(formatter, ", ")); }
conditional_block
clause.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 ver...
} /// Set the ID of the clause. /// The IDs should be unique so care must be taken. pub fn set_id(&mut self, new_id: u64) { self.id = Some(new_id); } /// Get the ID of the clause. pub fn get_id(&self) -> u64 { self.id.expect("ID should always exist") } } impl In...
/// Calculates the symbol count with given weights to function and variable symbols. pub fn symbol_count(&self, f_value: u64, v_value: u64) -> u64 { self.iter().fold(0, |acc, l| acc + l.symbol_count(f_value, v_value))
random_line_split
clause.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 ver...
(&mut self, index: usize) -> Literal { self.literals.swap_remove(index) } /// Add the literal to the clause (without checking for duplicates). pub fn add_literal(&mut self, l: Literal) { self.literals.push(l); } /// Add the literals in a given clause to this clause (without checkin...
swap_remove
identifier_name
clause.rs
// Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos. // // Serkr 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 ver...
} impl Index<usize> for Clause { type Output = Literal; fn index(&self, index: usize) -> &Literal { &self.literals[index] } } impl Debug for Clause { fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { try!(write!(formatter, "{{ ")); for (i, l) in self.iter().enum...
{ self.id.expect("ID should always exist") }
identifier_body
lru.rs
use std::time::*; use std::hash::Hash; use lru_cache::LruCache; // A cache that allows for per-value timeout invalidation pub enum LRUEntry<T> { Present(T), Expired, Vacant, } pub struct LRU<'a, K: 'a + Hash + Eq, T> { cache: LruCache<&'a K, (T, Instant, Duration)>, hits: u128, misses: u128, ...
fn is_timed_out(then: Instant, dur: Duration) -> bool { let age = then.elapsed(); if age >= dur { false } else { true } } }
{ let (val, then, lifespan) = match self.cache.get_mut(key) { Some(&mut (ref val, then, lifespan)) => (val as *const T, then, lifespan), None => { self.misses += 1; return LRUEntry::Vacant; } }; if Self::is_timed_out(then, life...
identifier_body
lru.rs
use std::time::*; use std::hash::Hash; use lru_cache::LruCache; // A cache that allows for per-value timeout invalidation pub enum LRUEntry<T> { Present(T), Expired, Vacant, } pub struct
<'a, K: 'a + Hash + Eq, T> { cache: LruCache<&'a K, (T, Instant, Duration)>, hits: u128, misses: u128, exp_misses: u128, } impl<'a, K, T> LRU<'a, K, T> where K: Hash + Eq { pub fn new(limit: usize) -> LRU<'a, K, T> { LRU { cache: LruCache::new(limit), hits: 1, ...
LRU
identifier_name
lru.rs
use std::time::*; use std::hash::Hash; use lru_cache::LruCache; // A cache that allows for per-value timeout invalidation pub enum LRUEntry<T> { Present(T), Expired, Vacant, } pub struct LRU<'a, K: 'a + Hash + Eq, T> { cache: LruCache<&'a K, (T, Instant, Duration)>, hits: u128, misses: u128, ...
} fn is_timed_out(then: Instant, dur: Duration) -> bool { let age = then.elapsed(); if age >= dur { false } else { true } } }
{ self.hits += 1; LRUEntry::Present(unsafe { &*val }) }
conditional_block
lru.rs
use std::time::*; use std::hash::Hash; use lru_cache::LruCache; // A cache that allows for per-value timeout invalidation pub enum LRUEntry<T> { Present(T), Expired, Vacant, } pub struct LRU<'a, K: 'a + Hash + Eq, T> { cache: LruCache<&'a K, (T, Instant, Duration)>, hits: u128, misses: u128, ...
if Self::is_timed_out(then, lifespan) { self.cache.remove(key); self.exp_misses += 1; LRUEntry::Expired } else { self.hits += 1; LRUEntry::Present(unsafe { &*val }) } } fn is_timed_out(then: Instant, dur: Duration) -> bool { ...
random_line_split
queued.rs
// Copyright (c) 2013-2016 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
0 } fn get_resolved(&self) -> Option<Box<ClientHook>> { match self.inner.borrow().redirect { Some(ref inner) => { Some(inner.clone()) } None => { None } } } fn when_more_resolved(&self) -> Option<Pr...
fn get_brand(&self) -> usize {
random_line_split
queued.rs
// Copyright (c) 2013-2016 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
let _ = waiter.send(()); } this.borrow_mut().promise_to_drive = ForkedPromise::new(Promise::ok(())); } } pub struct PipelineInnerSender { inner: Option<Weak<RefCell<PipelineInner>>>, } impl Drop for PipelineInnerSender { fn drop(&mut self) { if let Some(weak_queued) =...
{ let clienthook = pipeline.get_pipelined_cap_move(ops); ClientInner::resolve(&client, Ok(clienthook)); }
conditional_block
queued.rs
// Copyright (c) 2013-2016 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
(&self) -> usize { 0 } fn get_resolved(&self) -> Option<Box<ClientHook>> { match self.inner.borrow().redirect { Some(ref inner) => { Some(inner.clone()) } None => { None } } } fn when_more_resolved(...
get_brand
identifier_name
queued.rs
// Copyright (c) 2013-2016 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
fn call(&self, interface_id: u64, method_id: u16, params: Box<ParamsHook>, results: Box<ResultsHook>) -> Promise<(), Error> { if let Some(ref client) = self.inner.borrow().redirect { return client.call(interface_id, method_id, params, results) } let inner_clone = se...
{ ::capnp::capability::Request::new( Box::new(local::Request::new(interface_id, method_id, size_hint, self.add_ref()))) }
identifier_body
sub.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 ...
_ => { super_tys(self, a, b) } } } fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>> where T : Combineable<'tcx> { self.higher_ranked_sub(a, b) } }
{ Ok(self.tcx().types.err) }
conditional_block
sub.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 ...
<'a>(&'a self) -> Sub<'a, 'tcx> { Sub(self.fields.clone()) } fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields.clone()) } fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields.clone()) } fn contratys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> { Sub(self.fields.switch_expected(...
sub
identifier_name
sub.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 mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> { debug!("mts({} <: {})", a.repr(self.tcx()), b.repr(self.tcx())); if a.mutbl!= b.mutbl { return Err(ty::terr_mutability); } match b.mutbl { MutMuta...
{ debug!("{}.regions({}, {})", self.tag(), a.repr(self.tcx()), b.repr(self.tcx())); self.infcx().region_vars.make_subregion(Subtype(self.trace()), a, b); Ok(a) }
identifier_body
sub.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 mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> { debug!("mts({} <: {})", a.repr(self.tcx()), b.repr(self.tcx())); if a.mutbl!= b.mutbl { return Err(ty::terr_mutability); } match b.mutbl { MutMutabl...
b.repr(self.tcx())); self.infcx().region_vars.make_subregion(Subtype(self.trace()), a, b); Ok(a) }
random_line_split
attributes.rs
use std::collections::HashMap; use std::collections::hash_map::Iter; use super::attribute::Attribute; static dataPrefix: &'static str = "data-"; pub struct Attributes { attributes: HashMap<String, Attribute>, } impl Attributes { pub fn new() -> Attributes { Attributes { attributes: HashMap::<String, Attribute>:...
pub fn has_key(&self, key: &str) -> bool { self.attributes.contains_key(key) } pub fn size(&self) -> usize { self.attributes.len() } pub fn iter(&self) -> Iter<String, Attribute> { self.attributes.iter() } pub fn add_all(&mut self, attributes: &Attributes) { if attributes.size() > 0 { for (key, v...
{ self.attributes.remove(key); }
identifier_body
attributes.rs
use std::collections::HashMap; use std::collections::hash_map::Iter; use super::attribute::Attribute; static dataPrefix: &'static str = "data-"; pub struct Attributes { attributes: HashMap<String, Attribute>, } impl Attributes { pub fn new() -> Attributes { Attributes { attributes: HashMap::<String, Attribute>:...
} } impl Clone for Attributes { fn clone(&self) -> Attributes { Attributes { attributes: self.attributes.clone() } } }
{ for (key, value) in attributes.iter() { self.attributes.insert(key.to_string(), value.clone()); } }
conditional_block
attributes.rs
use std::collections::HashMap; use std::collections::hash_map::Iter; use super::attribute::Attribute; static dataPrefix: &'static str = "data-"; pub struct Attributes { attributes: HashMap<String, Attribute>, } impl Attributes { pub fn new() -> Attributes { Attributes { attributes: HashMap::<String, Attribute>:...
(&mut self, attribute: Attribute) { self.attributes.insert(attribute.get_value(), attribute.clone()); } pub fn remove(&mut self, key: &str) { self.attributes.remove(key); } pub fn has_key(&self, key: &str) -> bool { self.attributes.contains_key(key) } pub fn size(&self) -> usize { self.attributes.len()...
put_attribute
identifier_name
attributes.rs
use std::collections::HashMap; use std::collections::hash_map::Iter; use super::attribute::Attribute; static dataPrefix: &'static str = "data-"; pub struct Attributes { attributes: HashMap<String, Attribute>, } impl Attributes { pub fn new() -> Attributes { Attributes { attributes: HashMap::<String, Attribute>:...
self.attributes.get(key).unwrap().get_value() } pub fn put(&mut self, key: &str, value: &str) { self.attributes.insert(key.to_string(), Attribute::new(key, value)); } pub fn put_attribute(&mut self, attribute: Attribute) { self.attributes.insert(attribute.get_value(), attribute.clone()); } pub fn remove...
pub fn get(&self, key: &str) -> String { // TODO: validate key // validate.not_empty(key);
random_line_split
discrim-overflow-2.rs
// Copyright 2015 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 ...
enum A { Ok = u32::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] } } fn f_i64() { #[repr(i64)] enum A { Ok = i64::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] } } fn f_u64() { #[repr(u64)] enum A { ...
} fn f_u32() { #[repr(u32)]
random_line_split
discrim-overflow-2.rs
// Copyright 2015 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 ...
{ }
identifier_body
discrim-overflow-2.rs
// Copyright 2015 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 ...
{ Ok = i16::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] } } fn f_u16() { #[repr(u16)] enum A { Ok = u16::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] } } fn f_i32() { #[repr(i32)] enum A { Ok ...
A
identifier_name
template-param-usage-9.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct DoesNotUse { pub _address: u8, } pub type DoesNotUse_Aliased<T> = T; pub type DoesNotUse_Typedefed<U> = U; #[repr(C)] #[derive(Debug, Copy, Clone)] pub s...
let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); unsafe { ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } }
fn default() -> Self {
random_line_split
template-param-usage-9.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct DoesNotUse { pub _address: u8, } pub type DoesNotUse_Aliased<T> = T; pub type DoesNotUse_Typedefed<U> = U; #[repr(C)] #[derive(Debug, Copy, Clone)] pub s...
<T, U> { pub member: DoesNotUse_Aliased<T>, pub another: DoesNotUse_Typedefed<U>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } impl<T, U> Default for DoesNotUse_IndirectUsage<T, U> { fn default() -> ...
DoesNotUse_IndirectUsage
identifier_name
custom.rs
//! Custom RLE compressed recording format //! //! This works by pushing all bits read by the CPU onto bit vectors, and comparing the data read in //! each frame with the data from the last frame. //! //! Each entry we write to the recording is prefixed by the number of frames after the previous //! entry the new entry...
(reader: Box<BufRead>, _snes: &Snes) -> io::Result<Self> { Ok(Replayer { reader: reader, }) } fn replay_frame(&mut self, ports: &mut Ports) -> io::Result<()> { unimplemented!() } }
new
identifier_name
custom.rs
//! Custom RLE compressed recording format //! //! This works by pushing all bits read by the CPU onto bit vectors, and comparing the data read in //! each frame with the data from the last frame. //! //! Each entry we write to the recording is prefixed by the number of frames after the previous //! entry the new entry...
reader: reader, }) } fn replay_frame(&mut self, ports: &mut Ports) -> io::Result<()> { unimplemented!() } }
impl super::Replayer for Replayer { fn new(reader: Box<BufRead>, _snes: &Snes) -> io::Result<Self> { Ok(Replayer {
random_line_split
unilateral.rs
use crate::{ algo::TarjanScc, core::{ property::{ proxy_remove_edge_where_weight, proxy_remove_vertex, HasVertexGraph, RemoveEdge, RemoveVertex, Subgraph, Weak, }, Directed, Ensure, Graph, GraphDerefMut, }, }; use std::borrow::Borrow; /// A marker trait for graphs that are unilaterally connected. /// //...
(c: Self::Ensured, _: ()) -> Self { Self(c) } fn validate(c: &Self::Ensured, _: &()) -> bool { if let Ok(graph) = HasVertexGraph::ensure(c.graph(), ()) { // Algorithm: First use Tarjan's Strongly Connected Component (SCC) algorithm to // find SCCs and then check whether every component has an edge to t...
ensure_unvalidated
identifier_name
unilateral.rs
use crate::{ algo::TarjanScc, core::{ property::{ proxy_remove_edge_where_weight, proxy_remove_vertex, HasVertexGraph, RemoveEdge, RemoveVertex, Subgraph, Weak, }, Directed, Ensure, Graph, GraphDerefMut, }, }; use std::borrow::Borrow; /// A marker trait for graphs that are unilaterally connected. /// //...
where C::Graph: Graph<Directedness = Directed>; impl<C: Ensure> Ensure for UnilateralGraph<C> where C::Graph: Graph<Directedness = Directed>, { fn ensure_unvalidated(c: Self::Ensured, _: ()) -> Self { Self(c) } fn validate(c: &Self::Ensured, _: &()) -> bool { if let Ok(graph) = HasVertexGraph::ensure(c.gra...
pub struct UnilateralGraph<C: Ensure>(C)
random_line_split
unilateral.rs
use crate::{ algo::TarjanScc, core::{ property::{ proxy_remove_edge_where_weight, proxy_remove_vertex, HasVertexGraph, RemoveEdge, RemoveVertex, Subgraph, Weak, }, Directed, Ensure, Graph, GraphDerefMut, }, }; use std::borrow::Borrow; /// A marker trait for graphs that are unilaterally connected. /// //...
} scc_current = scc_next; } } true } } impl<C: Ensure + GraphDerefMut> RemoveVertex for UnilateralGraph<C> where C::Graph: RemoveVertex<Directedness = Directed>, { fn remove_vertex(&mut self, v: impl Borrow<Self::Vertex>) -> Result<Self::VertexWeight, ()> { proxy_remove_vertex::<UnilateralGraph<_...
{ // Algorithm: First use Tarjan's Strongly Connected Component (SCC) algorithm to // find SCCs and then check whether every component has an edge to the next one // in the list. Note: Tarjan's algorithm produces SCCs in reverse topological // order, so we don't need to sort, just check the first has an ed...
conditional_block
unilateral.rs
use crate::{ algo::TarjanScc, core::{ property::{ proxy_remove_edge_where_weight, proxy_remove_vertex, HasVertexGraph, RemoveEdge, RemoveVertex, Subgraph, Weak, }, Directed, Ensure, Graph, GraphDerefMut, }, }; use std::borrow::Borrow; /// A marker trait for graphs that are unilaterally connected. /// //...
fn validate(c: &Self::Ensured, _: &()) -> bool { if let Ok(graph) = HasVertexGraph::ensure(c.graph(), ()) { // Algorithm: First use Tarjan's Strongly Connected Component (SCC) algorithm to // find SCCs and then check whether every component has an edge to the next one // in the list. Note: Tarjan's al...
{ Self(c) }
identifier_body
inline.rs
match cx.tcx_opt() { Some(tcx) => tcx, None => return None, }; let def = match tcx.def_map.borrow().get(&id) { Some(d) => d.full_def(), None => return None, }; let did = def.def_id(); if ast_util::is_local(did) { return None } try_inline_def(cx, tcx, def).map(|ve...
(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum { let t = tcx.lookup_item_type(did); let predicates = tcx.lookup_predicates(did); match t.ty.sty { ty::TyEnum(edef, _) if!csearch::is_typedef(&tcx.sess.cstore, did) => { return clean::EnumItem(clean::Enum { ...
build_type
identifier_name
inline.rs
item }).collect() }) } fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt, def: def::Def) -> Option<Vec<clean::Item>> { let mut ret = Vec::new(); let did = def.def_id(); let inner = match def { def::DefTrait(did) => { record_extern_fqn(cx, did, clean::T...
{clean::Immutable}
conditional_block
inline.rs
x = match cx.tcx_opt() { Some(tcx) => tcx, None => return None, }; let def = match tcx.def_map.borrow().get(&id) { Some(d) => d.full_def(), None => return None, }; let did = def.def_id(); if ast_util::is_local(did) { return None } try_inline_def(cx, tcx, def).map(...
let did = def.def_id(); let inner = match def { def::DefTrait(did) => { record_extern_fqn(cx, did, clean::TypeTrait); clean::TraitItem(build_external_trait(cx, tcx, did)) } def::DefFn(did, false) => { // If this function is a tuple struct constructor, ...
let mut ret = Vec::new();
random_line_split
inline.rs
, did)) } def::DefStatic(did, mtbl) => { record_extern_fqn(cx, did, clean::TypeStatic); clean::StaticItem(build_static(cx, tcx, did, mtbl)) } def::DefConst(did) | def::DefAssociatedConst(did) => { record_extern_fqn(cx, did, clean::TypeConst); ...
{ let mut ty_bounds = Vec::new(); g.where_predicates.retain(|pred| { match *pred { clean::WherePredicate::BoundPredicate { ty: clean::Generic(ref s), ref bounds } if *s == "Self" => { ty_bounds.extend(bounds.iter().cloned()); ...
identifier_body
ga.rs
extern crate rand; extern crate evo; extern crate petgraph; extern crate graph_annealing; use rand::{Rng, SeedableRng}; use rand::isaac::Isaac64Rng; use evo::{Evaluator, Individual, MinFitness, OpCrossover1, OpMutate, OpSelect, OpSelectRandomIndividual, OpVariation, Probability, ProbabilityValue, RatedPopul...
VariationMethod::Reproduction } } } // XXX: No need for Fitness impl<I: Individual, F: PartialOrd> OpSelectRandomIndividual<I, F> for Toolbox { fn select_random_individual(&mut self, population: &RatedPopulation<I, F>) -> usize { // let (idx, _) = tournament_selection(&mut self.rng,...
random_line_split
ga.rs
extern crate rand; extern crate evo; extern crate petgraph; extern crate graph_annealing; use rand::{Rng, SeedableRng}; use rand::isaac::Isaac64Rng; use evo::{Evaluator, Individual, MinFitness, OpCrossover1, OpMutate, OpSelect, OpSelectRandomIndividual, OpVariation, Probability, ProbabilityValue, RatedPopul...
let filename = format!("line_{:04}.svg", gen); let ind = pop.get_individual(pop.fittest()); draw_graph(&ind.to_graph(), &filename); } let _optimum = evo::ea_mu_plus_lambda(&mut toolbox, &evaluator, rat...
{ return; }
conditional_block
ga.rs
extern crate rand; extern crate evo; extern crate petgraph; extern crate graph_annealing; use rand::{Rng, SeedableRng}; use rand::isaac::Isaac64Rng; use evo::{Evaluator, Individual, MinFitness, OpCrossover1, OpMutate, OpSelect, OpSelectRandomIndividual, OpVariation, Probability, ProbabilityValue, RatedPopul...
(&mut self, population: &RatedPopulation<I, F>, mu: usize) -> RatedPopulation<I, F> { let mut pop: RatedPopulation<I, F> = RatedPopulation::with_capacity(mu); for _ in 0..mu { let choice = tournament_selection_fast(&mut self.rng, |i1, i2| po...
select
identifier_name
ga.rs
extern crate rand; extern crate evo; extern crate petgraph; extern crate graph_annealing; use rand::{Rng, SeedableRng}; use rand::isaac::Isaac64Rng; use evo::{Evaluator, Individual, MinFitness, OpCrossover1, OpMutate, OpSelect, OpSelectRandomIndividual, OpVariation, Probability, ProbabilityValue, RatedPopul...
rng: Box::new(rng), prob_crossover: Probability::new(0.3), // 0.7, 0.3 -> 20. prob_mutation: Probability::new(0.5), prob_bitflip: Probability::new(2.0 / BITS as f32), tournament_size: 3, }; fn stat(gen: usize, nevals: usize, pop: &RatedPopulation<AdjGenome, MinFitness<f6...
{ const MATRIX_N: usize = 40; const BITS: usize = MATRIX_N * MATRIX_N; const MU: usize = 6000; const LAMBDA: usize = 60 * MATRIX_N; const NGEN: usize = 2000; let evaluator = MyEval { goal: Goal::new(line_graph(MATRIX_N as u32)) }; let seed: &[_] = &[45234341, 12343423, 123239]; let mut...
identifier_body
poll.rs
the [`register`] function. When `Poll` returns a readiness /// event, it will include this token. This associates the event with the /// `Evented` handle that generated the event. /// /// [`read`]: tcp/struct.TcpStream.html#method.read /// [`write`]: tcp/struct.TcpStream.html#method.write /// [`register`]: #method.re...
/// A basic example -- establishing a `TcpStream` connection. /// /// ``` /// # use std::error::Error; /// # fn try_main() -> Result<(), Box<dyn Error>> { /// use mio::{Events, Poll, Interests, Token}; /// use mio::net::TcpStream; /// /// use std::net::{TcpListener, SocketAddr}; ...
///
random_line_split
poll.rs
register`] function. When `Poll` returns a readiness /// event, it will include this token. This associates the event with the /// `Evented` handle that generated the event. /// /// [`read`]: tcp/struct.TcpStream.html#method.read /// [`write`]: tcp/struct.TcpStream.html#method.write /// [`register`]: #method.register ...
<E:?Sized>( &self, handle: &E, token: Token, interests: Interests, ) -> io::Result<()> where E: Evented, { validate_args(token)?; trace!("registering with poller"); // Register interests for this socket handle.reregister(self, token, ...
reregister
identifier_name
poll.rs
[`register`] function. When `Poll` returns a readiness /// event, it will include this token. This associates the event with the /// `Evented` handle that generated the event. /// /// [`read`]: tcp/struct.TcpStream.html#method.read /// [`write`]: tcp/struct.TcpStream.html#method.write /// [`register`]: #method.regist...
} } Err(e) => return Err(e), } } // Return number of polled events Ok(events.sys().len()) } } fn validate_args(token: Token) -> io::Result<()> { if token == WAKE { return Err(io::Error::new(io::ErrorKind::Other, "...
{ timeout = Some(to - elapsed); }
conditional_block
poll.rs
[`register`] function. When `Poll` returns a readiness /// event, it will include this token. This associates the event with the /// `Evented` handle that generated the event. /// /// [`read`]: tcp/struct.TcpStream.html#method.read /// [`write`]: tcp/struct.TcpStream.html#method.write /// [`register`]: #method.regist...
} impl fmt::Debug for Registry { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Registry").finish() } } #[cfg(unix)] impl AsRawFd for Poll { fn as_raw_fd(&self) -> RawFd { self.registry.selector.as_raw_fd() } } impl Registry { /// Register an `Even...
{ fmt.debug_struct("Poll").finish() }
identifier_body
entry_with_else.rs
// run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; macro_rules! m { ($e:expr) => {{ $e }}; } fn foo() {} fn insert_if_absent0<K: Eq + Hash + Copy, V: Copy>(m: &mut HashMap<K, V>, k:...
foo(); } else { m.insert(k, v); } if!m.contains_key(&k) { m.insert(k, v); } else { m.insert(k, v2); } if m.contains_key(&k) { if true { m.insert(k, v) } else { m.insert(k, v2) } } else { m.insert(k, v) }; if m.contains_key(&k) { ...
{ if !m.contains_key(&k) { m.insert(k, v); } else { m.insert(k, v2); } if m.contains_key(&k) { m.insert(k, v); } else { m.insert(k, v2); } if !m.contains_key(&k) { m.insert(k, v); } else { foo(); } if !m.contains_key(&k) {
identifier_body
entry_with_else.rs
// run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; macro_rules! m { ($e:expr) => {{ $e }}; } fn foo() {} fn insert_if_absent0<K: Eq + Hash + Copy, V: Copy>(m: &mut HashMap<K, V>, k:...
() {}
main
identifier_name
entry_with_else.rs
// run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; macro_rules! m { ($e:expr) => {{ $e }}; } fn foo() {} fn insert_if_absent0<K: Eq + Hash + Copy, V: Copy>(m: &mut HashMap<K, V>, k:...
fn main() {}
None }; }
random_line_split
entry_with_else.rs
// run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; macro_rules! m { ($e:expr) => {{ $e }}; } fn foo() {} fn insert_if_absent0<K: Eq + Hash + Copy, V: Copy>(m: &mut HashMap<K, V>, k:...
else { m.insert(k, v2) } } else { m.insert(k, v) }; if m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; } fn main() {}
{ m.insert(k, v) }
conditional_block
regions-bound-missing-bound-in-impl.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 ...
() { }
main
identifier_name
regions-bound-missing-bound-in-impl.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Check that expli...
random_line_split
regions-bound-missing-bound-in-impl.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 wrong_bound2<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { //~^ ERROR distinct set of bounds from its counterpart } } fn main() { }
{ //~^ ERROR method `wrong_bound1` has an incompatible type for trait // // Note: This is a terrible error message. It is caused // because, in the trait, 'b is early bound, and in the impl, // 'c is early bound, so -- after substitution -- the // lifetimes themselves loo...
identifier_body
future_ext.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use crate::ResourceMeteringTag; use std::pin::Pin; use std::task::{Context, Poll}; #[pin_project::pin_project] pub struct InTags<T> { #[pin] inner: T, tag: ResourceMeteringTag, } impl<T: std::future::Future> FutureExt for T {} pub trait...
} impl<T: std::future::Future> std::future::Future for InTags<T> { type Output = T::Output; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let this = self.project(); let _guard = this.tag.attach(); this.inner.poll(cx) } } impl<T: futures::Stream> Stre...
{ InTags { inner: self, tag } }
identifier_body
future_ext.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use crate::ResourceMeteringTag; use std::pin::Pin; use std::task::{Context, Poll}; #[pin_project::pin_project] pub struct InTags<T> { #[pin] inner: T, tag: ResourceMeteringTag, } impl<T: std::future::Future> FutureExt for T {} pub trait...
} }
let this = self.project(); let _guard = this.tag.attach(); this.inner.poll_next(cx)
random_line_split
future_ext.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use crate::ResourceMeteringTag; use std::pin::Pin; use std::task::{Context, Poll}; #[pin_project::pin_project] pub struct InTags<T> { #[pin] inner: T, tag: ResourceMeteringTag, } impl<T: std::future::Future> FutureExt for T {} pub trait...
(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { let this = self.project(); let _guard = this.tag.attach(); this.inner.poll_next(cx) } }
poll_next
identifier_name
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
pub use self::transaction::Transaction; pub use self::txtest::TransactionTest; pub use self::test::Test;
mod transaction; mod txtest; mod test;
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/. //! This module is the main module for the Ligature-SQLite project. //! It implements the traits supplied by Ligature...
fn new_memory_store() -> LigatureSQLite { todo!() } } impl Ligature for LigatureSQLite { fn all_datasets(&self) -> Box<dyn Iterator<Item=Result<Dataset, LigatureError>>> { todo!() } fn dataset_exists(&self, dataset: &Dataset) -> Result<bool, LigatureError> { todo!() }...
{ todo!() }
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/. //! This module is the main module for the Ligature-SQLite project. //! It implements the traits supplied by Ligature...
(&self, dataset: &Dataset) -> Result<(), LigatureError> { todo!() } fn delete_dataset(&self, dataset: &Dataset) -> Result<(), LigatureError> { todo!() } fn query<T>(&self, dataset: &Dataset, f: QueryFn<T>) -> Result<T, LigatureError> { todo!() } fn write<T>(&self, data...
create_dataset
identifier_name
lib.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. //! This module is the main module for the Ligature-SQLite project. //! It implements the traits supplied by Ligature...
} fn dataset_exists(&self, dataset: &Dataset) -> Result<bool, LigatureError> { todo!() } fn match_datasets_prefix(&self, prefix: &str) -> Box<dyn Iterator<Item=Result<Dataset, LigatureError>>> { todo!() } fn match_datasets_range(&self, start: &str, end: &str) -> Box<dyn Iterat...
impl Ligature for LigatureSQLite { fn all_datasets(&self) -> Box<dyn Iterator<Item=Result<Dataset, LigatureError>>> { todo!()
random_line_split
main.rs
#[macro_use] extern crate clap; extern crate rouille; extern crate filetime; extern crate time; use std::path::Path; use clap::{App, Arg, AppSettings}; use rouille::*; fn
() { let m = App::new("servent") .author(crate_authors!()) .version(crate_version!()) .about(env!("CARGO_PKG_DESCRIPTION")) .setting(AppSettings::ColoredHelp) .arg( Arg::with_name("addr") .help("Address the server will bind to (e.g. 127.0.0.1:3000)") ...
main
identifier_name
main.rs
#[macro_use] extern crate clap; extern crate rouille; extern crate filetime; extern crate time; use std::path::Path; use clap::{App, Arg, AppSettings}; use rouille::*; fn main() { let m = App::new("servent") .author(crate_authors!()) .version(crate_version!()) .about(env!("CARGO_PKG_DESCRIPTI...
if!potential_file.starts_with(path) { return Response::empty_404(); } match fs::metadata(&potential_file) { Ok(ref m) if m.is_file() => (), Ok(ref m) if m.is_dir() => potential_file = potential_file.join("index.html"), _ => return Response::empty_404(), }; let exten...
{ let path = path.as_ref(); let path = match path.canonicalize() { Ok(p) => p, Err(_) => return Response::empty_404(), }; let potential_file = { let mut path = path.to_path_buf(); for component in req.url().split('/') { path.push(component); } ...
identifier_body
main.rs
#[macro_use] extern crate clap; extern crate rouille; extern crate filetime; extern crate time; use std::path::Path; use clap::{App, Arg, AppSettings}; use rouille::*; fn main() { let m = App::new("servent") .author(crate_authors!()) .version(crate_version!()) .about(env!("CARGO_PKG_DESCRIPTI...
// Code below is a modified version of `rouille::match_assets` fn handle<P: AsRef<Path>>(req: &Request, path: &P) -> Response{ let path = path.as_ref(); let path = match path.canonicalize() { Ok(p) => p, Err(_) => return Response::empty_404(), }; let potential_file = { let mut p...
use std::fs;
random_line_split
mod.rs
//! Parser guides //! //! A parser uses a guide to decide which transition to us given a particular //! parser state. This module defines traits for parser guides, `Guide` and //! `BatchGuide`, and provides an implementation using Tensorflow in the
//! `Tensorflow` submodule. use crate::system::{ParserState, Transition}; /// Guide for parsers without batch processing pub trait Guide { type Transition: Transition; /// Returns the best (permissible) transition given the current parser /// state. fn best_transition(&mut self, state: &ParserState<'...
random_line_split
ignore.rs
use crate::{api_client::Client, common::ui::{Status, UIWriter, UI}, error::{Error, Result}, PRODUCT, VERSION}; pub async fn start(ui: &mut UI, bldr_url: &str, orig...
{ let api_client = Client::new(bldr_url, PRODUCT, VERSION, None).map_err(Error::APIClient)?; ui.status(Status::Ignoring, format!("invitation id {} in origin {}", invitation_id, origin))?; match api_client.ignore_origin_invitation(origin, token, invitation_id) .await {...
identifier_body
ignore.rs
use crate::{api_client::Client, common::ui::{Status, UIWriter, UI}, error::{Error, Result}, PRODUCT, VERSION}; pub async fn
(ui: &mut UI, bldr_url: &str, origin: &str, token: &str, invitation_id: u64) -> Result<()> { let api_client = Client::new(bldr_url, PRODUCT, VERSION, None).map_err(Error::APIClient)?; ui.status(Status::Ignoring, ...
start
identifier_name
ignore.rs
use crate::{api_client::Client, common::ui::{Status, UIWriter, UI}, error::{Error, Result}, PRODUCT, VERSION}; pub async fn start(ui: &mut UI, bldr_url: &str, orig...
} }
{ ui.fatal(format!("Failed to ignore invitation {} in origin {}, {:?}", invitation_id, origin, e))?; Err(Error::from(e)) }
conditional_block
ignore.rs
use crate::{api_client::Client, common::ui::{Status, UIWriter, UI}, error::{Error, Result}, PRODUCT, VERSION}; pub async fn start(ui: &mut UI, bldr_url: &str, orig...
ui.status(Status::Ignored, "the invitation successfully!".to_string()) .or(Ok(())) } Err(e) => { ui.fatal(format!("Failed to ignore invitation {} in origin {}, {:?}", invitation_id, origin, e))?; Err(Error::from(e)) } ...
random_line_split
ct_result.rs
use std::io::Error as IoError; use std::fmt::Display; use serde_json::Error as SerdeError; use clap::Error as ClapError; use tempfile; use atomicwrites; /// the result type used for the whole application pub type CtResult<T> = Result<T, CtError>; // the error type used for the whole application error_type! { #[de...
(err: atomicwrites::Error<E>) -> CtError { CtError::Msg(format!("{}", err)) } } pub trait OkOr { type R; fn ok_or<E>(self, err: E) -> Result<Self::R, E>; } impl OkOr for bool { type R = (); fn ok_or<E>(self, err: E) -> Result<Self::R, E> { if self { Ok(()) } e...
from
identifier_name
ct_result.rs
use std::io::Error as IoError; use std::fmt::Display; use serde_json::Error as SerdeError; use clap::Error as ClapError; use tempfile; use atomicwrites; /// the result type used for the whole application pub type CtResult<T> = Result<T, CtError>; // the error type used for the whole application error_type! { #[de...
else { Err(err) } } }
{ Ok(()) }
conditional_block
ct_result.rs
use std::io::Error as IoError; use std::fmt::Display; use serde_json::Error as SerdeError; use clap::Error as ClapError; use tempfile; use atomicwrites; /// the result type used for the whole application pub type CtResult<T> = Result<T, CtError>; // the error type used for the whole application error_type! { #[de...
}
{ if self { Ok(()) } else { Err(err) } }
identifier_body
ct_result.rs
use std::io::Error as IoError; use std::fmt::Display; use serde_json::Error as SerdeError; use clap::Error as ClapError; use tempfile; use atomicwrites; /// the result type used for the whole application pub type CtResult<T> = Result<T, CtError>; // the error type used for the whole application error_type! { #[de...
} else { Err(err) } } }
random_line_split
mod.rs
// Copyright 2015 The Athena 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 ag...
fn raise_event( &mut self, event: &Event, prev_area: &render::RenderArea, offset: &mut render::RenderOffset); /// Writes rendering data for this widget to `data`. fn render( &self, renderer: &mut render::Renderer<R>, prev_area: &render::RenderArea, offset: &mut render::Rende...
pub use widget::text::*; /// An interface for referencing to any kind of widget. pub trait Widget<R: gfx::Resources> { /// Handles an event that may or may not apply to this widget.
random_line_split
lib.rs
// Copyright 2016 LambdaStack All rights reserved. // // 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...
// NOTE: This attribute only needs to be set once. #![doc(html_logo_url = "https://lambdastackio.github.io/static/images/lambdastack-200x200.png", html_favicon_url = "https://lambdastackio.github.io/static/images/favicon.ico", html_root_url = "https://lambdastackio.github.io/aws-sdk-rust/ceph-rust/ceph_r...
// distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
random_line_split
metrics.rs
/* * Copyright 2020 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
<T: Collector + Sized +'static>( registry: &Registry, collector: T, ) -> Result<()> { registry.register(Box::new(collector)) } pub trait CollectorExt: Collector + Clone + Sized +'static { /// Registers the current metric collector with the provided registry /// if not already registered. fn reg...
register_metric
identifier_name
metrics.rs
/* * Copyright 2020 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
impl<C: Collector + Clone +'static> CollectorExt for C {}
}
random_line_split
metrics.rs
/* * Copyright 2020 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
} impl<C: Collector + Clone +'static> CollectorExt for C {}
{ match register_metric(crate::metrics::registry(), self.clone()) { Ok(_) | Err(prometheus::Error::AlreadyReg) => Ok(self), Err(err) => Err(err), } }
identifier_body
heartbeats.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use self::synchronized_heartbeat::{heartbeat_window_callback, lock_and_work}; use heartbeats_simple::HeartbeatPow...
} } }
{ for (_, v) in (*hbs_ptr).iter_mut() { if &v.hb as *const HeartbeatContext == hb { log_heartbeat_records(v); } } }
conditional_block
heartbeats.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use self::synchronized_heartbeat::{heartbeat_window_callback, lock_and_work}; use heartbeats_simple::HeartbeatPow...
#[cfg(not(target_os = "android"))] fn get_heartbeat_log(category: &ProfilerCategory) -> Option<File> { var_os(format!("SERVO_HEARTBEAT_LOG_{:?}", category)).and_then(|name| open_heartbeat_log(&name)) } fn get_heartbeat_window_size(category: &ProfilerCategory) -> usize { const WINDOW_SIZE_DEFAULT: usize = 1; ...
{ open_heartbeat_log(format!("/sdcard/servo/heartbeat-{:?}.log", category)) }
identifier_body
heartbeats.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use self::synchronized_heartbeat::{heartbeat_window_callback, lock_and_work}; use heartbeats_simple::HeartbeatPow...
(category: &ProfilerCategory) -> bool { opts::get().profile_heartbeats || var_os(format!("SERVO_HEARTBEAT_ENABLE_{:?}", category)).is_some() } fn open_heartbeat_log<P: AsRef<Path>>(name: P) -> Option<File> { match File::create(name) { Ok(f) => Some(f), Err(e) => { warn!("Fai...
is_create_heartbeat
identifier_name
heartbeats.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use self::synchronized_heartbeat::{heartbeat_window_callback, lock_and_work}; use heartbeats_simple::HeartbeatPow...
let logfile: Option<File> = get_heartbeat_log(&category); // window size let window_size: usize = get_heartbeat_window_size(&category); // create the heartbeat match Heartbeat::new(window_size, Some(heartbeat_window_callback), logfile) { Ok(hb) => { de...
category: ProfilerCategory, ) { if is_create_heartbeat(&category) { // get optional log file
random_line_split
union-transmute.rs
// Copyright 2016 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 { let mut u = U { a: (1, 1) }; assert_eq!(u.b, (1 << 8) + 1); u.b = (2 << 8) + 2; assert_eq!(u.a, (2, 2)); let mut w = W { a: 0b0_11111111_00000000000000000000000 }; assert_eq!(w.b, f32::INFINITY); w.b = f32::NEG_INFINITY; assert_eq!(w.a, ...
main
identifier_name
union-transmute.rs
// Copyright 2016 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 { let mut u = U { a: (1, 1) }; assert_eq!(u.b, (1 << 8) + 1); u.b = (2 << 8) + 2; assert_eq!(u.a, (2, 2)); let mut w = W { a: 0b0_11111111_00000000000000000000000 }; assert_eq!(w.b, f32::INFINITY); w.b = f32::NEG_INFINITY; assert_eq!(w.a, 0b1...
identifier_body
union-transmute.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // run-pass ext...
// http://rust-lang.org/COPYRIGHT.
random_line_split
bounding_volume.rs
use crate::math::{Isometry, Point}; use na::RealField; /// Traits of objects having a bounding volume. pub trait HasBoundingVolume<N: RealField, BV> { /// The bounding volume of `self` transformed by `m`. fn bounding_volume(&self, m: &Isometry<N>) -> BV; /// The bounding volume of `self`. fn local_boun...
} /// Trait of bounding volumes. /// /// Bounding volumes are coarse approximations of shapes. It usually have constant time /// intersection, inclusion test. Two bounding volume must also be mergeable into a bigger bounding /// volume. pub trait BoundingVolume<N: RealField>: std::fmt::Debug { // FIXME: keep that...
{ self.bounding_volume(&Isometry::identity()) }
identifier_body
bounding_volume.rs
use crate::math::{Isometry, Point}; use na::RealField; /// Traits of objects having a bounding volume. pub trait HasBoundingVolume<N: RealField, BV> { /// The bounding volume of `self` transformed by `m`. fn bounding_volume(&self, m: &Isometry<N>) -> BV; /// The bounding volume of `self`. fn
(&self) -> BV { self.bounding_volume(&Isometry::identity()) } } /// Trait of bounding volumes. /// /// Bounding volumes are coarse approximations of shapes. It usually have constant time /// intersection, inclusion test. Two bounding volume must also be mergeable into a bigger bounding /// volume. pub trai...
local_bounding_volume
identifier_name
bounding_volume.rs
use crate::math::{Isometry, Point}; use na::RealField; /// Traits of objects having a bounding volume. pub trait HasBoundingVolume<N: RealField, BV> { /// The bounding volume of `self` transformed by `m`. fn bounding_volume(&self, m: &Isometry<N>) -> BV; /// The bounding volume of `self`. fn local_boun...
/// Merges this bounding volume with another one. The merge is done in-place. fn merge(&mut self, _: &Self); /// Merges this bounding volume with another one. fn merged(&self, _: &Self) -> Self; /// Enlarges this bounding volume. fn loosen(&mut self, _: N); /// Creates a new, enlarged ver...
random_line_split
font_face.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/. */ //! The [`@font-face`][ff] at-rule. //! //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule #![deny(m...
(&self) -> EffectiveSources { EffectiveSources(self.sources().iter().rev().filter(|source| { if let Source::Url(ref url_source) = **source { let hints = &url_source.format_hints; // We support only opentype fonts and truetype is an alias for // that fo...
effective_sources
identifier_name
font_face.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/. */ //! The [`@font-face`][ff] at-rule. //! //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule #![deny(m...
fn next(&mut self) -> Option<Source> { self.0.pop() } fn size_hint(&self) -> (usize, Option<usize>) { (self.0.len(), Some(self.0.len())) } } struct FontFaceRuleParser<'a, 'b: 'a> { context: &'a ParserContext<'b>, rule: &'a mut FontFaceRuleData, } /// Default methods reject all...
type Item = Source;
random_line_split
font_face.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/. */ //! The [`@font-face`][ff] at-rule. //! //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule #![deny(m...
; Ok(Source::Url(UrlSource { url: url, format_hints: format_hints, })) } } macro_rules! is_descriptor_enabled { ("font-display") => { unsafe { use gecko_bindings::structs::mozilla; mozilla::StylePrefs_sFontDisplayEnabled } }; ...
{ vec![] }
conditional_block
font_face.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/. */ //! The [`@font-face`][ff] at-rule. //! //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule #![deny(m...
/// A @font-face rule that is known to have font-family and src declarations. #[cfg(feature = "servo")] pub struct FontFace<'a>(&'a FontFaceRuleData); /// A list of effective sources that we send over through IPC to the font cache. #[cfg(feature = "servo")] #[derive(Clone, Debug)] #[cfg_attr(feature = "servo", deriv...
{ let mut rule = FontFaceRuleData::empty(location); { let parser = FontFaceRuleParser { context: context, rule: &mut rule, }; let mut iter = DeclarationListParser::new(input, parser); while let Some(declaration) = iter.next() { if let Err((erro...
identifier_body
day8.rs
use std::io::prelude::*; use std::fs::File; const MAX_X: usize = 50; const MAX_Y: usize = 6; fn print_board(board: &Vec<Vec<bool>>) { let mut count = 0; for i in 0..MAX_Y { let mut line = String::new();; for j in 0..MAX_X { if board[i][j] { line += "#"; count += 1; } else { ...
() { let mut f = File::open("day8.txt").unwrap(); let mut f_s = String::new(); f.read_to_string(&mut f_s).unwrap(); let mut board = vec![vec![false; 50]; 6]; for l in f_s.lines() { let line = l.to_string(); if line.contains("rect") { let (_, last) = l.split_at(5); let mut last_str = last...
main
identifier_name
day8.rs
use std::io::prelude::*; use std::fs::File; const MAX_X: usize = 50; const MAX_Y: usize = 6; fn print_board(board: &Vec<Vec<bool>>) { let mut count = 0; for i in 0..MAX_Y { let mut line = String::new();; for j in 0..MAX_X { if board[i][j] { line += "#"; count += 1; } else { ...
else if line.contains("column") { let (_, last) = l.split_at(16); let mut last_str = last.to_string(); let by_pos = last_str.find(" by").unwrap(); for _ in 0..4{ last_str.remove(by_pos); } let (x, times) = last_str.split_at(by_pos); for _ in 0..times.parse().unwrap()...
{ let (_, last) = l.split_at(5); let mut last_str = last.to_string(); let cross_pos = last_str.find("x").unwrap(); last_str.remove(cross_pos); let (x, y) = last_str.split_at(cross_pos); add_rect(&mut board, x.parse().unwrap(), y.parse().unwrap()) }
conditional_block
day8.rs
use std::io::prelude::*; use std::fs::File; const MAX_X: usize = 50; const MAX_Y: usize = 6; fn print_board(board: &Vec<Vec<bool>>) { let mut count = 0; for i in 0..MAX_Y { let mut line = String::new();; for j in 0..MAX_X { if board[i][j] { line += "#"; count += 1; } else { ...
rotate_column(&mut board, x.parse().unwrap()) } } else if line.contains("row") { let (_, last) = l.split_at(13); let mut last_str = last.to_string(); let by_pos = last_str.find(" by").unwrap(); for _ in 0..4{ last_str.remove(by_pos); } let (y, times) = las...
last_str.remove(by_pos); } let (x, times) = last_str.split_at(by_pos); for _ in 0..times.parse().unwrap() {
random_line_split
day8.rs
use std::io::prelude::*; use std::fs::File; const MAX_X: usize = 50; const MAX_Y: usize = 6; fn print_board(board: &Vec<Vec<bool>>) { let mut count = 0; for i in 0..MAX_Y { let mut line = String::new();; for j in 0..MAX_X { if board[i][j] { line += "#"; count += 1; } else { ...
fn rotate_column(board: &mut Vec<Vec<bool>>, x: usize) { let mut val = board[0][x]; for y in 1..MAX_Y { let temp = board[y][x]; board[y][x] = val; val = temp; } board[0][x] = val; } fn main() { let mut f = File::open("day8.txt").unwrap(); let mut f_s = String::new(); f.read_to_string(&mut ...
{ let mut val = board[y][0]; for x in 1..MAX_X { let temp = board[y][x]; board[y][x] = val; val = temp; } board[y][0] = val; }
identifier_body
day_5.rs
pub use tdd_kata::string_calc_kata::iter_2::day_5::Calculator; pub use expectest::prelude::be_ok; describe! string_calculator { before_each {
} it "should evaluate number" { expect!(calc.evaluate("4350.264")).to(be_ok().value(4350.264)); } it "should evaluate add operation" { expect!(calc.evaluate("34543.767+324.654")).to(be_ok().value(34868.421)); } it "should evaluate sub operation" { expect!(calc.evaluate...
let calc = Calculator::new();
random_line_split
rsqrt.rs
#![feature(cfg_target_feature, link_llvm_intrinsics, platform_intrinsics, simd_ffi, test)] extern crate hagane_simd; extern crate test; use hagane_simd::*; use test::*; #[cfg(target_feature = "sse")] extern "platform-intrinsic" { fn x86_mm_sqrt_ps(x: float4) -> float4; fn x86_mm_rsqrt_ps(x: float4) -> float4; } ...
(b: &mut Bencher) { let n = black_box(float4(1.0, 3.0, 5.0, 7.0)); b.iter(|| { let mut sum = n; for _ in 0.. 10000 { let sqrt = unsafe { x86_mm_sqrt_ps(sum) }; sum = sum + 1.0 / sqrt; } sum }); } #[cfg(target_feature = "sse")] #[bench] fn bench_intel_rsqrt(b: &mut Bencher) { let...
bench_sqrt_plus_div
identifier_name
rsqrt.rs
#![feature(cfg_target_feature, link_llvm_intrinsics, platform_intrinsics, simd_ffi, test)] extern crate hagane_simd; extern crate test; use hagane_simd::*; use test::*; #[cfg(target_feature = "sse")] extern "platform-intrinsic" { fn x86_mm_sqrt_ps(x: float4) -> float4; fn x86_mm_rsqrt_ps(x: float4) -> float4; } ...
fn bench_apple_rsqrt(b: &mut Bencher) { let n = black_box(float4(1.0, 3.0, 5.0, 7.0)); b.iter(|| { let mut sum = n; for _ in 0.. 10000 { let r = unsafe { x86_mm_rsqrt_ps(sum) }; let r = r * (1.5 - 0.5 * sum.eq(float4::broadcast(0.0)).bitselect(sum, float4::broadcast(-std::f32::INFINITY)) * r *...
#[bench]
random_line_split
rsqrt.rs
#![feature(cfg_target_feature, link_llvm_intrinsics, platform_intrinsics, simd_ffi, test)] extern crate hagane_simd; extern crate test; use hagane_simd::*; use test::*; #[cfg(target_feature = "sse")] extern "platform-intrinsic" { fn x86_mm_sqrt_ps(x: float4) -> float4; fn x86_mm_rsqrt_ps(x: float4) -> float4; } ...
#[cfg(target_feature = "sse")] #[bench] fn bench_apple_rsqrt(b: &mut Bencher) { let n = black_box(float4(1.0, 3.0, 5.0, 7.0)); b.iter(|| { let mut sum = n; for _ in 0.. 10000 { let r = unsafe { x86_mm_rsqrt_ps(sum) }; let r = r * (1.5 - 0.5 * sum.eq(float4::broadcast(0.0)).bitselect(sum, flo...
{ let n = black_box(float4(1.0, 3.0, 5.0, 7.0)); b.iter(|| { let mut sum = n; for _ in 0 .. 10000 { let r = unsafe { x86_mm_rsqrt_ps(sum) }; sum = sum - 0.5 * (r * (3.0 - r * r * sum)); } sum }); }
identifier_body
flat.rs
// 書き換えたがLexerと同様の構造にするのが難しそうだったので一旦保留 /* #[derive(Eq, PartialEq, Clone, Debug)] enum State { Aexp, WaitOtag, Error(String),
/* fn parse_flat() { loop { let s = self.state.clone(); let t = self.current_token.borrow().clone(); println!("parser state: {:?} token: {:?}", s, t); match s { State::Aexp => { match t { CurrentToken::SOT => { ...
} */
random_line_split
hidecm.rs
extern crate usbg; use std::path::PathBuf; use std::fs; use usbg::UsbGadget; use usbg::UsbGadgetState; use usbg::UsbGadgetFunction; use usbg::UsbGadgetConfig; use usbg::hid; use usbg::ecm; fn
() { // general setup let mut g1 = UsbGadget::new("g1", 0x1d6b, // Linux Foundation 0x0104, // Multifunction Composite Gadget usbg::LANGID_EN_US, // LANGID English "USB Armory", ...
main
identifier_name
hidecm.rs
extern crate usbg; use std::path::PathBuf; use std::fs; use usbg::UsbGadget; use usbg::UsbGadgetState; use usbg::UsbGadgetFunction; use usbg::UsbGadgetConfig; use usbg::hid; use usbg::ecm; fn main()
// add HID keyboard let hid_function = Box::new(hid::HIDFunction { instance_name: "usb0", protocol: hid::HID_PROTOCOL_KEYBOARD, subclass: hid::HID_SUBCLASS_BOOT, report...
{ // general setup let mut g1 = UsbGadget::new("g1", 0x1d6b, // Linux Foundation 0x0104, // Multifunction Composite Gadget usbg::LANGID_EN_US, // LANGID English "USB Armory", ...
identifier_body