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
svh.rs
// 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. //! Calculation and management of a Strict Version Hash for crates //! //! # Today's AB...
(&mut self, i: &ViewItem) { // Two kinds of view items can affect the ABI for a crate: // exported `pub use` view items (since that may expose // items that downstream crates can call), and `use // foo::Trait`, since changing that may affect method // resoluti...
visit_view_item
identifier_name
svh.rs
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. //! Calculation and management of a Strict Version Hash for crates //! //! # Today's...
impl InternKey for Name { fn get_content(self) -> token::InternedString { token::get_name(self) } } fn content<K:InternKey>(k: K) -> token::InternedString { k.get_content() } impl<'a, 'v> Visitor<'v> for StrictVersionHashVisitor<'a> { fn visit_mac(&mut self, macro: &Mac) { ...
impl InternKey for Ident { fn get_content(self) -> token::InternedString { token::get_ident(self) } }
random_line_split
svh.rs
// 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. //! Calculation and management of a Strict Version Hash for crates //! //! # Today's AB...
impl<'a, 'v> Visitor<'v> for StrictVersionHashVisitor<'a> { fn visit_mac(&mut self, macro: &Mac) { // macro invocations, namely macro_rules definitions, // *can* appear as items, even in the expanded crate AST. if macro_name(macro).get() == "macro_rules" { ...
{ k.get_content() }
identifier_body
generation_size.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::HashMap; use crate::utils; use crate::MononokeSQLBlobGCArgs; use anyhow::Result; use bytesize::ByteSize; use clap::P...
(sizes: &HashMap<Option<u64>, u64>) { let generations = { let mut keys: Vec<_> = sizes.keys().collect(); keys.sort_unstable(); keys }; println!("Generation | Size"); println!("-----------------"); for generation in generations { let size = ByteSize::b(sizes[generati...
print_sizes
identifier_name
generation_size.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::HashMap; use crate::utils; use crate::MononokeSQLBlobGCArgs; use anyhow::Result; use bytesize::ByteSize; use clap::P...
for (shard, sizes) in shard_sizes { for (generation, (size, chunk_id_count)) in sizes.into_iter() { let mut sample = scuba_sample_builder.clone(); sample.add("shard", shard); sample.add_opt("generation", generation); sample.add("size", size); sampl...
{ let common_args: MononokeSQLBlobGCArgs = app.args()?; let max_parallelism: usize = common_args.scheduled_max; let (sqlblob, shard_range) = utils::get_sqlblob_and_shard_range(&app).await?; let scuba_sample_builder = app.environment().scuba_sample_builder.clone(); let shard_sizes: Vec<(usize, Ha...
identifier_body
generation_size.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::HashMap; use crate::utils; use crate::MononokeSQLBlobGCArgs; use anyhow::Result; use bytesize::ByteSize; use clap::P...
}; println!("{:>10} | {}", generation, size.to_string_as(true)); } } pub async fn run(app: MononokeApp, _args: CommandArgs) -> Result<()> { let common_args: MononokeSQLBlobGCArgs = app.args()?; let max_parallelism: usize = common_args.scheduled_max; let (sqlblob, shard_range) = utils:...
Some(g) => g.to_string(),
random_line_split
ast_util.rs
BiLe => "<=", BiNe => "!=", BiGe => ">=", BiGt => ">" } } pub fn lazy_binop(b: BinOp) -> bool { match b { BiAnd => true, BiOr => true, _ => false } } pub fn is_shift_binop(b: BinOp) -> bool { match b { BiShl => true, BiShr => true, _ => fal...
/// Generate a "pretty" name for an `impl` from its type and trait. /// This is designed so that symbols of `impl`'d methods give some /// hint of where they came from, (previously they would all just be /// listed as `__extensions__::method_name::hash`, with no indication /// of the type). pub fn impl_pretty_name(tr...
{ if is_unguarded(a) { Some(/* FIXME (#2543) */ a.pats.clone()) } else { None } }
identifier_body
ast_util.rs
BiLe => "<=", BiNe => "!=", BiGe => ">=", BiGt => ">" } } pub fn lazy_binop(b: BinOp) -> bool { match b { BiAnd => true, BiOr => true, _ => false } } pub fn is_shift_binop(b: BinOp) -> bool { match b { BiShl => true, BiShr => true, _ => fa...
} impl IdVisitingOperation for IdRangeComputingVisitor { fn visit_id(&self, id: NodeId) { let mut id_range = self.result.get(); id_range.add(id); self.result.set(id_range) } } pub fn compute_id_range_for_inlined_item(item: &InlinedItem) -> IdRange { let visitor = IdRangeComputingVi...
result: Cell<IdRange>,
random_line_split
ast_util.rs
BiLe => "<=", BiNe => "!=", BiGe => ">=", BiGt => ">" } } pub fn lazy_binop(b: BinOp) -> bool { match b { BiAnd => true, BiOr => true, _ => false } } pub fn is_shift_binop(b: BinOp) -> bool { match b { BiShl => true, BiShr => true, _ => fal...
(trait_ref: &Option<TraitRef>, ty: &Ty) -> Ident { let mut pretty = pprust::ty_to_str(ty); match *trait_ref { Some(ref trait_ref) => { pretty.push_char('.'); pretty.push_str(pprust::path_to_str(&trait_ref.path).as_slice()); } None => {} } token::gensym_ide...
impl_pretty_name
identifier_name
float.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...
for j in range(i as uint + 1, end).rev() { buf[j + 1] = buf[j]; } buf[(i + 1) as uint] = value2ascii(1); end += 1; break; } // Skip...
|| buf[i as uint] == b'-' || buf[i as uint] == b'+' {
random_line_split
float.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...
(&mut self, bytes: &[u8]) -> fmt::Result { slice::bytes::copy_memory(self.buf.slice_from_mut(*self.end), bytes); *self.end += bytes.len(); Ok(()) } } let mut filler = Filler...
write
identifier_name
dst-coerce-rc.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 ...
(&self) -> i32 { *self } } fn main() { let a: Rc<[i32; 3]> = Rc::new([1, 2, 3]); let b: Rc<[i32]> = a; assert_eq!(b[0], 1); assert_eq!(b[1], 2); assert_eq!(b[2], 3); let a: Rc<i32> = Rc::new(42); let b: Rc<Baz> = a.clone(); assert_eq!(b.get(), 42); let _c = b.clone(); ...
get
identifier_name
dst-coerce-rc.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test a very simple custom DST coercion. #![feature(core)] use std::rc::Rc; trait B...
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
dst-coerce-rc.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 ...
} fn main() { let a: Rc<[i32; 3]> = Rc::new([1, 2, 3]); let b: Rc<[i32]> = a; assert_eq!(b[0], 1); assert_eq!(b[1], 2); assert_eq!(b[2], 3); let a: Rc<i32> = Rc::new(42); let b: Rc<Baz> = a.clone(); assert_eq!(b.get(), 42); let _c = b.clone(); }
{ *self }
identifier_body
appthread.rs
//! Types for the mutator to use to build data structures use std::cell::Cell; use std::mem::transmute; use std::ops::{Deref, DerefMut}; use std::ptr::{null, null_mut}; use std::raw::TraitObject; use std::sync::atomic::{AtomicPtr, Ordering}; use std::thread; use constants::{INC_BIT, JOURNAL_BUFFER_SIZE, NEW_BIT, TRA...
<T: Trace>(object: &T) -> TraitObject { let trace: &Trace = object; unsafe { transmute(trace) } } /// Write a reference count increment to the journal for a newly allocated object #[inline] fn write<T: Trace>(object: &T, is_new: bool, flags: usize) { GC_JOURNAL.with(|j| { let tx = unsafe { &*j.get...
as_traitobject
identifier_name
appthread.rs
//! Types for the mutator to use to build data structures use std::cell::Cell; use std::mem::transmute; use std::ops::{Deref, DerefMut}; use std::ptr::{null, null_mut}; use std::raw::TraitObject; use std::sync::atomic::{AtomicPtr, Ordering}; use std::thread; use constants::{INC_BIT, JOURNAL_BUFFER_SIZE, NEW_BIT, TRA...
} // GcBox implementation impl<T: Trace> GcBox<T> { fn new(value: T) -> GcBox<T> { GcBox { value: value, } } } unsafe impl<T: Trace> Trace for GcBox<T> { #[inline] fn traversible(&self) -> bool { self.value.traversible() } #[inline] unsafe fn trace(&...
{ GC_JOURNAL.with(|j| { let tx = unsafe { &*j.get() }; let tobj = as_traitobject(object); // set the refcount-increment bit let ptr = (tobj.data as usize) | flags; // set the traversible bit let mut vtable = tobj.vtable as usize; if is_new && object.travers...
identifier_body
appthread.rs
//! Types for the mutator to use to build data structures use std::cell::Cell; use std::mem::transmute; use std::ops::{Deref, DerefMut}; use std::ptr::{null, null_mut}; use std::raw::TraitObject; use std::sync::atomic::{AtomicPtr, Ordering}; use std::thread; use constants::{INC_BIT, JOURNAL_BUFFER_SIZE, NEW_BIT, TRA...
} } fn ptr(&self) -> *mut GcBox<T> { self.ptr } fn value(&self) -> &T { unsafe { &(*self.ptr).value } } fn value_mut(&mut self) -> &mut T { unsafe { &mut (*self.ptr).value } } } impl<T: Trace> Deref for Gc<T> { type Target = T; fn deref(&self) ->...
ptr: ptr,
random_line_split
appthread.rs
//! Types for the mutator to use to build data structures use std::cell::Cell; use std::mem::transmute; use std::ops::{Deref, DerefMut}; use std::ptr::{null, null_mut}; use std::raw::TraitObject; use std::sync::atomic::{AtomicPtr, Ordering}; use std::thread; use constants::{INC_BIT, JOURNAL_BUFFER_SIZE, NEW_BIT, TRA...
} /// Pointer equality comparison. pub fn is(&self, other: Gc<T>) -> bool { self.ptr == other.ptr } fn from_raw(ptr: *mut GcBox<T>) -> Gc<T> { Gc { ptr: ptr, } } fn ptr(&self) -> *mut GcBox<T> { self.ptr } fn value(&self) -> &T { ...
{ Some(self.ptr) }
conditional_block
self-impl-2.rs
// run-pass #![allow(dead_code)] #![allow(unused_variables)] // Test that we can use `Self` types in impls in the expected way. // pretty-expanded FIXME #23616 struct Foo; // Test uses on inherent impl. impl Foo { fn
(_x: Self, _y: &Self, _z: Box<Self>) -> Self { Foo } fn baz() { // Test that Self cannot be shadowed. type Foo = i32; // There is no empty method on i32. Self::empty(); let _: Self = Foo; } fn empty() {} } // Test uses when implementing a trait and wit...
foo
identifier_name
self-impl-2.rs
// run-pass #![allow(dead_code)] #![allow(unused_variables)] // Test that we can use `Self` types in impls in the expected way. // pretty-expanded FIXME #23616 struct Foo; // Test uses on inherent impl. impl Foo { fn foo(_x: Self, _y: &Self, _z: Box<Self>) -> Self { Foo } fn baz() { // T...
impl SuperBar for Box<Baz<isize>> { type SuperQux = bool; } impl Bar<isize> for Box<Baz<isize>> { type Qux = i32; fn bar(_x: Self, _y: &Self, _z: Box<Self>, _: Self::SuperQux) -> Self { let _: Self::Qux = 42; let _: <Self as Bar<isize>>::Qux = 42; let _: Self::SuperQux = true; ...
fn bar(x: Self, y: &Self, z: Box<Self>, _: Self::SuperQux) -> Self; fn dummy(&self, x: X) { } }
random_line_split
self-impl-2.rs
// run-pass #![allow(dead_code)] #![allow(unused_variables)] // Test that we can use `Self` types in impls in the expected way. // pretty-expanded FIXME #23616 struct Foo; // Test uses on inherent impl. impl Foo { fn foo(_x: Self, _y: &Self, _z: Box<Self>) -> Self { Foo } fn baz()
fn empty() {} } // Test uses when implementing a trait and with a type parameter. pub struct Baz<X> { pub f: X, } trait SuperBar { type SuperQux; } trait Bar<X>: SuperBar { type Qux; fn bar(x: Self, y: &Self, z: Box<Self>, _: Self::SuperQux) -> Self; fn dummy(&self, x: X) { } } impl Super...
{ // Test that Self cannot be shadowed. type Foo = i32; // There is no empty method on i32. Self::empty(); let _: Self = Foo; }
identifier_body
areas.rs
use spin::Once; static AREAS: Once<Areas> = Once::new(); #[derive(Debug)] struct Areas { areas: [Area; 16], count: usize, } //TODO Do we align the base and length here, // provide methods for it, // or leave it up to the user #[derive(Copy, Clone, Debug)] pub struct Area { pub base: u64, pub...
fn add_area(&mut self, base: u64, length: u64) { self.areas[self.count] = Area{base:base, length: length}; self.count += 1; } fn iter(&'static self) -> AreaIter { AreaIter {i: 0, areas: self} } } impl Iterator for AreaIter { type Item = &'static Area; fn next(&mut self)...
}
random_line_split
areas.rs
use spin::Once; static AREAS: Once<Areas> = Once::new(); #[derive(Debug)] struct Areas { areas: [Area; 16], count: usize, } //TODO Do we align the base and length here, // provide methods for it, // or leave it up to the user #[derive(Copy, Clone, Debug)] pub struct Area { pub base: u64, pub...
} areas }); //TODO I'm not sure if I want this here // We should probably move this to a print function, or something. println!("Areas"); for area in memory_areas() { println!(" start: 0x{:x}, length: 0x{:x}", area.base, area.length); } }
{ areas.add_area(area.start, area.length); }
conditional_block
areas.rs
use spin::Once; static AREAS: Once<Areas> = Once::new(); #[derive(Debug)] struct Areas { areas: [Area; 16], count: usize, } //TODO Do we align the base and length here, // provide methods for it, // or leave it up to the user #[derive(Copy, Clone, Debug)] pub struct Area { pub base: u64, pub...
} impl Iterator for AreaIter { type Item = &'static Area; fn next(&mut self) -> Option<Self::Item> { if self.i < self.areas.count { let item = &self.areas.areas[self.i]; self.i += 1; Some(item) } else { None } } } fn areas() -> &'sta...
{ AreaIter {i: 0, areas: self} }
identifier_body
areas.rs
use spin::Once; static AREAS: Once<Areas> = Once::new(); #[derive(Debug)] struct Areas { areas: [Area; 16], count: usize, } //TODO Do we align the base and length here, // provide methods for it, // or leave it up to the user #[derive(Copy, Clone, Debug)] pub struct Area { pub base: u64, pub...
() -> Areas { Areas { areas: [Area{base:0, length: 0};16], count: 0, } } fn add_area(&mut self, base: u64, length: u64) { self.areas[self.count] = Area{base:base, length: length}; self.count += 1; } fn iter(&'static self) -> AreaIter { Ar...
new
identifier_name
dominators.rs
//! Compute dominators of a control-flow graph. //! //! # The Dominance Relation //! //! In a directed graph with a root node **R**, a node **A** is said to *dominate* a //! node **B** iff every path from **R** to **B** contains **A**. //! //! The node **A** is said to *strictly dominate* the node **B** iff **A** domin...
/// Iterate over the given node's strict dominators. /// /// If the given node is not reachable from the root, then `None` is /// returned. pub fn strict_dominators(&self, node: N) -> Option<DominatorsIter<N>> { if self.dominators.contains_key(&node) { Some(DominatorsIter { ...
if node == self.root { None } else { self.dominators.get(&node).cloned() } }
identifier_body
dominators.rs
//! Compute dominators of a control-flow graph. //! //! # The Dominance Relation //! //! In a directed graph with a root node **R**, a node **A** is said to *dominate* a //! node **B** iff every path from **R** to **B** contains **A**. //! //! The node **A** is said to *strictly dominate* the node **B** iff **A** domin...
}; let all_doms: Vec<_> = doms.dominators(2).unwrap().collect(); assert_eq!(vec![2, 1, 0], all_doms); assert_eq!(None::<()>, doms.dominators(99).map(|_| unreachable!())); let strict_doms: Vec<_> = doms.strict_dominators(2).unwrap().collect(); assert_eq!(vec![1, 0], str...
fn test_iter_dominators() { let doms: Dominators<u32> = Dominators { root: 0, dominators: [(2, 1), (1, 0), (0, 0)].iter().cloned().collect(),
random_line_split
dominators.rs
//! Compute dominators of a control-flow graph. //! //! # The Dominance Relation //! //! In a directed graph with a root node **R**, a node **A** is said to *dominate* a //! node **B** iff every path from **R** to **B** contains **A**. //! //! The node **A** is said to *strictly dominate* the node **B** iff **A** domin...
} /// Iterate over all of the given node's dominators (including the given /// node itself). /// /// If the given node is not reachable from the root, then `None` is /// returned. pub fn dominators(&self, node: N) -> Option<DominatorsIter<N>> { if self.dominators.contains_key(&node) ...
None }
conditional_block
dominators.rs
//! Compute dominators of a control-flow graph. //! //! # The Dominance Relation //! //! In a directed graph with a root node **R**, a node **A** is said to *dominate* a //! node **B** iff every path from **R** to **B** contains **A**. //! //! The node **A** is said to *strictly dominate* the node **B** iff **A** domin...
( post_order: &[N], node_to_post_order_idx: &HashMap<N, usize>, mut predecessor_sets: HashMap<N, HashSet<N>>, ) -> Vec<Vec<usize>> where N: Copy + Eq + Hash, { post_order .iter() .map(|node| { predecessor_sets .remove(node) .map(|predecessors| ...
decessor_sets_to_idx_vecs<N>
identifier_name
boolean.rs
// Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation // Copyright (C) 2020 Stacks Open Internet Foundation // // This program 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...
Ok(Value::Bool(false)) } pub fn special_and( args: &[SymbolicExpression], env: &mut Environment, context: &LocalContext, ) -> Result<Value> { check_arguments_at_least(1, args)?; runtime_cost(ClarityCostFunction::And, env, args.len())?; for arg in args.iter() { let evaluated = eval...
if result { return Ok(Value::Bool(true)); } }
random_line_split
boolean.rs
// Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation // Copyright (C) 2020 Stacks Open Internet Foundation // // This program 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...
( args: &[SymbolicExpression], env: &mut Environment, context: &LocalContext, ) -> Result<Value> { check_arguments_at_least(1, args)?; runtime_cost(ClarityCostFunction::Or, env, args.len())?; for arg in args.iter() { let evaluated = eval(&arg, env, context)?; let result = type_...
special_or
identifier_name
boolean.rs
// Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation // Copyright (C) 2020 Stacks Open Internet Foundation // // This program 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...
{ let value = type_force_bool(&input)?; Ok(Value::Bool(!value)) }
identifier_body
touch.rs
use crate::sys; pub type Finger = sys::SDL_Finger; pub type TouchDevice = sys::SDL_TouchID; #[doc(alias = "SDL_GetNumTouchDevices")] pub fn num_touch_devices() -> i32 { unsafe { sys::SDL_GetNumTouchDevices() } } #[doc(alias = "SDL_GetTouchDevice")] pub fn touch_device(index: i32) -> TouchDevice { unsafe { sy...
pub fn touch_finger(touch: TouchDevice, index: i32) -> Option<Finger> { let raw = unsafe { sys::SDL_GetTouchFinger(touch, index) }; if raw.is_null() { None } else { unsafe { Some(*raw) } } }
#[doc(alias = "SDL_GetTouchFinger")]
random_line_split
touch.rs
use crate::sys; pub type Finger = sys::SDL_Finger; pub type TouchDevice = sys::SDL_TouchID; #[doc(alias = "SDL_GetNumTouchDevices")] pub fn num_touch_devices() -> i32 { unsafe { sys::SDL_GetNumTouchDevices() } } #[doc(alias = "SDL_GetTouchDevice")] pub fn touch_device(index: i32) -> TouchDevice { unsafe { sy...
}
{ unsafe { Some(*raw) } }
conditional_block
touch.rs
use crate::sys; pub type Finger = sys::SDL_Finger; pub type TouchDevice = sys::SDL_TouchID; #[doc(alias = "SDL_GetNumTouchDevices")] pub fn num_touch_devices() -> i32 { unsafe { sys::SDL_GetNumTouchDevices() } } #[doc(alias = "SDL_GetTouchDevice")] pub fn touch_device(index: i32) -> TouchDevice { unsafe { sy...
(touch: TouchDevice, index: i32) -> Option<Finger> { let raw = unsafe { sys::SDL_GetTouchFinger(touch, index) }; if raw.is_null() { None } else { unsafe { Some(*raw) } } }
touch_finger
identifier_name
touch.rs
use crate::sys; pub type Finger = sys::SDL_Finger; pub type TouchDevice = sys::SDL_TouchID; #[doc(alias = "SDL_GetNumTouchDevices")] pub fn num_touch_devices() -> i32
#[doc(alias = "SDL_GetTouchDevice")] pub fn touch_device(index: i32) -> TouchDevice { unsafe { sys::SDL_GetTouchDevice(index) } } #[doc(alias = "SDL_GetNumTouchFingers")] pub fn num_touch_fingers(touch: TouchDevice) -> i32 { unsafe { sys::SDL_GetNumTouchFingers(touch) } } #[doc(alias = "SDL_GetTouchFinger")...
{ unsafe { sys::SDL_GetNumTouchDevices() } }
identifier_body
mod.rs
af_get_features_score(out: *mut af_array, feat: af_features) -> c_int; fn af_get_features_orientation(out: *mut af_array, feat: af_features) -> c_int; fn af_get_features_size(out: *mut af_array, feat: af_features) -> c_int;
thr: c_float, arc_len: c_uint, non_max: bool, feature_ratio: c_float, edge: c_uint, ) -> c_int; fn af_harris( out: *mut af_features, input: af_array, m: c_uint, r: c_float, s: c_float, bs: c_uint, k: c_float, ) ...
fn af_release_features(feat: af_features) -> c_int; fn af_fast( out: *mut af_features, input: af_array,
random_line_split
mod.rs
_get_features_score(out: *mut af_array, feat: af_features) -> c_int; fn af_get_features_orientation(out: *mut af_array, feat: af_features) -> c_int; fn af_get_features_size(out: *mut af_array, feat: af_features) -> c_int; fn af_release_features(feat: af_features) -> c_int; fn af_fast( out: *mut...
/// SUSAN corner detector. /// /// SUSAN is an acronym standing for Smallest Univalue Segment Assimilating Nucleus. This method /// places a circular disc over the pixel to be tested (a.k.a nucleus) to compute the corner /// measure of that corresponding pixel. The region covered by the circular disc is M, and a pixe...
{ unsafe { let mut temp: af_array = std::ptr::null_mut(); let err_val = af_match_template( &mut temp as *mut af_array, search_img.get(), template_img.get(), mtype as c_uint, ); HANDLE_ERROR(AfError::from(err_val)); temp.into() ...
identifier_body
mod.rs
get_features_score(out: *mut af_array, feat: af_features) -> c_int; fn af_get_features_orientation(out: *mut af_array, feat: af_features) -> c_int; fn af_get_features_size(out: *mut af_array, feat: af_features) -> c_int; fn af_release_features(feat: af_features) -> c_int; fn af_fast( out: *mut ...
<T>( input: &Array<T>, thr: f32, arc_len: u32, non_max: bool, feat_ratio: f32, edge: u32, ) -> Features where T: HasAfEnum + ImageFilterType, { unsafe { let mut temp: af_features = std::ptr::null_mut(); let err_val = af_fast( &mut temp as *mut af_features, ...
fast
identifier_name
decode_properties.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. //! Base types used by various rocks properties decoders use std::collections::BTreeMap; use std::io::Read; use std::ops::{Deref, DerefMut}; use tikv_util::codec::number::{self, NumberEncoder}; use tikv_util::codec::Result; #[derive(Clone, Debug, Def...
fn decode_handles(&self, k: &str) -> Result<IndexHandles> { let buf = self.decode(k)?; IndexHandles::decode(buf) } } impl DecodeProperties for rocksdb::UserCollectedProperties { fn decode(&self, k: &str) -> tikv_util::codec::Result<&[u8]> { self.get(k.as_bytes()) .ok_or(t...
random_line_split
decode_properties.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. //! Base types used by various rocks properties decoders use std::collections::BTreeMap; use std::io::Read; use std::ops::{Deref, DerefMut}; use tikv_util::codec::number::{self, NumberEncoder}; use tikv_util::codec::Result; #[derive(Clone, Debug, Def...
(&mut self) -> &mut BTreeMap<Vec<u8>, IndexHandle> { &mut self.0 } } impl IndexHandles { pub fn new() -> IndexHandles { IndexHandles(BTreeMap::new()) } pub fn into_map(self) -> BTreeMap<Vec<u8>, IndexHandle> { self.0 } pub fn add(&mut self, key: Vec<u8>, index_handle: ...
deref_mut
identifier_name
knowledge.rs
use std::collections::BTreeMap; use game::*; use spatial_hash::*; use coord::Coord; use util::TwoDimensionalCons; /// Trait implemented by representations of knowledge about a level pub trait LevelKnowledge { /// Updates a cell of the knowledge representation, returnig true iff the /// knowledge of the cell c...
(&mut self, level_id: LevelId, width: usize, height: usize) -> &mut K { self.levels.entry(level_id).or_insert_with(|| K::new(width, height)) } }
level_mut_or_insert_size
identifier_name
knowledge.rs
use std::collections::BTreeMap; use game::*; use spatial_hash::*; use coord::Coord; use util::TwoDimensionalCons; /// Trait implemented by representations of knowledge about a level pub trait LevelKnowledge { /// Updates a cell of the knowledge representation, returnig true iff the /// knowledge of the cell c...
self.levels.entry(level_id).or_insert_with(|| K::new(width, height)) } }
impl<K: LevelKnowledge + TwoDimensionalCons> GameKnowledge<K> { pub fn level_mut_or_insert_size(&mut self, level_id: LevelId, width: usize, height: usize) -> &mut K {
random_line_split
knowledge.rs
use std::collections::BTreeMap; use game::*; use spatial_hash::*; use coord::Coord; use util::TwoDimensionalCons; /// Trait implemented by representations of knowledge about a level pub trait LevelKnowledge { /// Updates a cell of the knowledge representation, returnig true iff the /// knowledge of the cell c...
} impl<K: LevelKnowledge + Default> Default for GameKnowledge<K> { fn default() -> Self { Self::new() } } impl<K: LevelKnowledge + TwoDimensionalCons> GameKnowledge<K> { pub fn level_mut_or_insert_size(&mut self, level_id: LevelId, width: usize, height: usize) ...
{ self.levels.get_mut(&level_id).expect("No such level") }
identifier_body
no_1109_corporate_flight_bookings.rs
pub fn corp_flight_bookings(bookings: Vec<Vec<i32>>, n: i32) -> Vec<i32> { let mut answer = vec![0; n as usize]; for booking in bookings { answer[booking[0] as usize - 1] += booking[2]; if booking[1] < n { answer[booking[1] as usize] -= booking[2]; } } let mut sum =...
answer } #[cfg(test)] mod test { use super::*; #[test] fn test_corp_flight_bookings() { let answer = corp_flight_bookings(vec![vec![1, 2, 10], vec![2, 3, 20], vec![2, 5, 25]], 5); assert_eq!(answer, vec![10, 55, 45, 25, 25]); } }
random_line_split
no_1109_corporate_flight_bookings.rs
pub fn corp_flight_bookings(bookings: Vec<Vec<i32>>, n: i32) -> Vec<i32> { let mut answer = vec![0; n as usize]; for booking in bookings { answer[booking[0] as usize - 1] += booking[2]; if booking[1] < n { answer[booking[1] as usize] -= booking[2]; } } let mut sum =...
() { let answer = corp_flight_bookings(vec![vec![1, 2, 10], vec![2, 3, 20], vec![2, 5, 25]], 5); assert_eq!(answer, vec![10, 55, 45, 25, 25]); } }
test_corp_flight_bookings
identifier_name
no_1109_corporate_flight_bookings.rs
pub fn corp_flight_bookings(bookings: Vec<Vec<i32>>, n: i32) -> Vec<i32> { let mut answer = vec![0; n as usize]; for booking in bookings { answer[booking[0] as usize - 1] += booking[2]; if booking[1] < n
} let mut sum = 0; for a in answer.iter_mut() { sum += *a; *a = sum; } answer } #[cfg(test)] mod test { use super::*; #[test] fn test_corp_flight_bookings() { let answer = corp_flight_bookings(vec![vec![1, 2, 10], vec![2, 3, 20], vec![2, 5, 25]], 5); ...
{ answer[booking[1] as usize] -= booking[2]; }
conditional_block
no_1109_corporate_flight_bookings.rs
pub fn corp_flight_bookings(bookings: Vec<Vec<i32>>, n: i32) -> Vec<i32>
#[cfg(test)] mod test { use super::*; #[test] fn test_corp_flight_bookings() { let answer = corp_flight_bookings(vec![vec![1, 2, 10], vec![2, 3, 20], vec![2, 5, 25]], 5); assert_eq!(answer, vec![10, 55, 45, 25, 25]); } }
{ let mut answer = vec![0; n as usize]; for booking in bookings { answer[booking[0] as usize - 1] += booking[2]; if booking[1] < n { answer[booking[1] as usize] -= booking[2]; } } let mut sum = 0; for a in answer.iter_mut() { sum += *a; *a = sum;...
identifier_body
client_json.rs
#![deny(warnings)] extern crate hyper; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; use hyper::Client; use hyper::rt::{self, Future, Stream}; fn main() { let url = "http://jsonplaceholder.typicode.com/users".parse().unwrap(); let fut = fetch_json(url) // use th...
Json(serde_json::Error), } impl From<hyper::Error> for FetchError { fn from(err: hyper::Error) -> FetchError { FetchError::Http(err) } } impl From<serde_json::Error> for FetchError { fn from(err: serde_json::Error) -> FetchError { FetchError::Json(err) } }
enum FetchError { Http(hyper::Error),
random_line_split
client_json.rs
#![deny(warnings)] extern crate hyper; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; use hyper::Client; use hyper::rt::{self, Future, Stream}; fn
() { let url = "http://jsonplaceholder.typicode.com/users".parse().unwrap(); let fut = fetch_json(url) // use the parsed vector .map(|users| { // print users println!("users: {:#?}", users); // print the sum of ids let sum = users.iter().fold(0, |...
main
identifier_name
client_json.rs
#![deny(warnings)] extern crate hyper; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; use hyper::Client; use hyper::rt::{self, Future, Stream}; fn main() { let url = "http://jsonplaceholder.typicode.com/users".parse().unwrap(); let fut = fetch_json(url) // use th...
} #[derive(Deserialize, Debug)] struct User { id: i32, name: String, } // Define a type so we can return multiple types of errors enum FetchError { Http(hyper::Error), Json(serde_json::Error), } impl From<hyper::Error> for FetchError { fn from(err: hyper::Error) -> FetchError { FetchErro...
{ let client = Client::new(); client // Fetch the url... .get(url) // And then, if we get a response back... .and_then(|res| { // asynchronously concatenate chunks of the body res.into_body().concat2() }) .from_err::<FetchError>() ...
identifier_body
TestNativeExp2.rs
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License");
* http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language gover...
* you may not use this file except in compliance with the License. * You may obtain a copy of the License at *
random_line_split
lib.rs
//! A wrapper around the uchardet library. Detects character encodings. //! //! Note that the underlying implemention is written in C and C++, and I'm //! not aware of any security audits which have been performed against it. //! //! ``` //! use uchardet::detect_encoding_name; //! //! assert_eq!("WINDOWS-1252", //! ...
/// We declare our `error_chain!` in a private submodule so that we can /// `allow(missing_docs)`. #[allow(missing_docs)] mod errors { error_chain! { errors { UnrecognizableCharset { description("unrecognizable charset") display("uchardet was unable to recognize ...
random_line_split
lib.rs
//! A wrapper around the uchardet library. Detects character encodings. //! //! Note that the underlying implemention is written in C and C++, and I'm //! not aware of any security audits which have been performed against it. //! //! ``` //! use uchardet::detect_encoding_name; //! //! assert_eq!("WINDOWS-1252", //! ...
unsafe { ffi::uchardet_delete(self.ptr) }; } }
identifier_body
lib.rs
//! A wrapper around the uchardet library. Detects character encodings. //! //! Note that the underlying implemention is written in C and C++, and I'm //! not aware of any security audits which have been performed against it. //! //! ``` //! use uchardet::detect_encoding_name; //! //! assert_eq!("WINDOWS-1252", //! ...
mut self) { unsafe { ffi::uchardet_data_end(self.ptr); } } /// Get the decoder's current best guess as to the encoding. May return /// an error if uchardet was unable to detect an encoding. fn charset(&self) -> Result<String> { unsafe { let internal_str = ffi::uchardet_get_c...
ta_end(&
identifier_name
synonym.rs
use std::collections::HashMap; use std::collections::hash_map::{Iter, Keys}; use std::fmt::Debug; use std::hash::Hash; use std::iter::{FromIterator, IntoIterator}; use std::mem; #[derive(Clone)] pub struct SynonymMap<K, V> { vals: HashMap<K, V>, syns: HashMap<K, K>, } impl<K: Eq + Hash, V> SynonymMap<K, V> { ...
} } impl<K: Eq + Hash + Clone, V> SynonymMap<K, V> { pub fn resolve(&self, k: &K) -> K { self.with_key(k, |k| k.clone()) } pub fn get<'a>(&'a self, k: &K) -> &'a V { self.find(k).unwrap() } pub fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> { if self.syns.c...
{ with(k) }
conditional_block
synonym.rs
use std::collections::HashMap; use std::collections::hash_map::{Iter, Keys}; use std::fmt::Debug; use std::hash::Hash; use std::iter::{FromIterator, IntoIterator}; use std::mem; #[derive(Clone)] pub struct SynonymMap<K, V> { vals: HashMap<K, V>, syns: HashMap<K, K>, } impl<K: Eq + Hash, V> SynonymMap<K, V> { ...
write!(f, " (synomyns: {:?})", self.syns) } }
} impl<K: Eq + Hash + Debug, V: Debug> Debug for SynonymMap<K, V> { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { try!(self.vals.fmt(f));
random_line_split
synonym.rs
use std::collections::HashMap; use std::collections::hash_map::{Iter, Keys}; use std::fmt::Debug; use std::hash::Hash; use std::iter::{FromIterator, IntoIterator}; use std::mem; #[derive(Clone)] pub struct SynonymMap<K, V> { vals: HashMap<K, V>, syns: HashMap<K, K>, } impl<K: Eq + Hash, V> SynonymMap<K, V> { ...
() -> SynonymMap<K, V> { SynonymMap { vals: HashMap::new(), syns: HashMap::new(), } } pub fn insert_synonym(&mut self, from: K, to: K) -> bool { assert!(self.vals.contains_key(&to)); self.syns.insert(from, to).is_none() } pub fn keys<'a>(&'a self...
new
identifier_name
synonym.rs
use std::collections::HashMap; use std::collections::hash_map::{Iter, Keys}; use std::fmt::Debug; use std::hash::Hash; use std::iter::{FromIterator, IntoIterator}; use std::mem; #[derive(Clone)] pub struct SynonymMap<K, V> { vals: HashMap<K, V>, syns: HashMap<K, K>, } impl<K: Eq + Hash, V> SynonymMap<K, V> { ...
pub fn contains_key(&self, k: &K) -> bool { self.with_key(k, |k| self.vals.contains_key(k)) } pub fn len(&self) -> usize { self.vals.len() } fn with_key<T, F>(&self, k: &K, with: F) -> T where F: FnOnce(&K) -> T { if self.syns.contains_key(k) { with(&self.syns...
{ self.with_key(k, |k| self.vals.get(k)) }
identifier_body
base.rs
use std::io::Write; pub enum Color { Reset, Black, White, Grey, } // Shamelessly stolen from termios // which doesn't compile on Win32 // which is why I'm doing all this nonsense in the first place pub enum Event { Key(Key), Mouse(MouseEvent), Unsupported(Vec<u32>), } // Derived from term...
F(u8), Char(char), Shift(Box<Key>), Alt(Box<Key>), Ctrl(Box<Key>), Null, Esc, } impl Key { pub fn is_char(&self) -> bool { match self { &Key::Char(_) => true, _ => false } } pub fn is_navigation(&self) -> bool { match self { ...
random_line_split
base.rs
use std::io::Write; pub enum Color { Reset, Black, White, Grey, } // Shamelessly stolen from termios // which doesn't compile on Win32 // which is why I'm doing all this nonsense in the first place pub enum Event { Key(Key), Mouse(MouseEvent), Unsupported(Vec<u32>), } // Derived from term...
(&self) -> bool { match self { &Key::Char(_) => true, _ => false } } pub fn is_navigation(&self) -> bool { match self { &Key::Left | &Key::Right | &Key::Up | &Key::Down | &Key::Home | &Key::End | &Key::PageUp | &Key::PageDown => tr...
is_char
identifier_name
status.rs
// Copyright (C) 2016 Stefan Luecke // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ...
impl StatusHandler { pub fn new() -> StatusHandler { StatusHandler {} } } impl Handler for StatusHandler { fn msg_type() -> telegram_bot::MessageType { telegram_bot::MessageType::Text("".to_string()) } fn command() -> Vec<String> { vec![String::from_str("/status").unwrap()...
random_line_split
status.rs
// Copyright (C) 2016 Stefan Luecke // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ...
} impl Handler for StatusHandler { fn msg_type() -> telegram_bot::MessageType { telegram_bot::MessageType::Text("".to_string()) } fn command() -> Vec<String> { vec![String::from_str("/status").unwrap()] } fn process(&self, m: telegram_bot::Message, ...
{ StatusHandler {} }
identifier_body
status.rs
// Copyright (C) 2016 Stefan Luecke // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ...
() -> StatusHandler { StatusHandler {} } } impl Handler for StatusHandler { fn msg_type() -> telegram_bot::MessageType { telegram_bot::MessageType::Text("".to_string()) } fn command() -> Vec<String> { vec![String::from_str("/status").unwrap()] } fn process(&self, ...
new
identifier_name
render.rs
use smithay::{ backend::renderer::{Frame, ImportAll, Renderer}, desktop::{ draw_window, space::{DynamicRenderElements, RenderError, Space}, }, utils::{Logical, Rectangle}, wayland::output::Output, }; use crate::{drawing::*, shell::FullscreenSurface}; pub fn render_output<R>( ou...
}
{ space.render_output(&mut *renderer, output, age as usize, CLEAR_COLOR, &*elements) }
conditional_block
render.rs
use smithay::{ backend::renderer::{Frame, ImportAll, Renderer}, desktop::{ draw_window, space::{DynamicRenderElements, RenderError, Space}, }, utils::{Logical, Rectangle}, wayland::output::Output, }; use crate::{drawing::*, shell::FullscreenSurface}; pub fn render_output<R>( ou...
scale, (0, 0), &[Rectangle::from_loc_and_size( (0, 0), mode.size.to_f64().to_logical(scale).to_i32_round(), )], log, )?; for elem in element...
{ if let Some(window) = output .user_data() .get::<FullscreenSurface>() .and_then(|f| f.get()) { let transform = output.current_transform().into(); let mode = output.current_mode().unwrap(); let scale = space.output_scale(output).unwrap(); let output_geo =...
identifier_body
render.rs
use smithay::{ backend::renderer::{Frame, ImportAll, Renderer}, desktop::{ draw_window, space::{DynamicRenderElements, RenderError, Space}, }, utils::{Logical, Rectangle}, wayland::output::Output, }; use crate::{drawing::*, shell::FullscreenSurface}; pub fn
<R>( output: &Output, space: &mut Space, renderer: &mut R, age: usize, elements: &[DynamicRenderElements<R>], log: &slog::Logger, ) -> Result<Option<Vec<Rectangle<i32, Logical>>>, RenderError<R>> where R: Renderer + ImportAll +'static, R::Frame:'static, R::TextureId:'static, R::E...
render_output
identifier_name
render.rs
use smithay::{ backend::renderer::{Frame, ImportAll, Renderer}, desktop::{ draw_window, space::{DynamicRenderElements, RenderError, Space}, }, utils::{Logical, Rectangle}, wayland::output::Output, }; use crate::{drawing::*, shell::FullscreenSurface}; pub fn render_output<R>( ou...
{ if let Some(window) = output .user_data() .get::<FullscreenSurface>() .and_then(|f| f.get()) { let transform = output.current_transform().into(); let mode = output.current_mode().unwrap(); let scale = space.output_scale(output).unwrap(); let output_geo = sp...
R::TextureId: 'static, R::Error: 'static,
random_line_split
advent20.rs
// advent20.rs // factorizing // Used the first crate I found that did what I needed; turned out to be quite slow, oh well extern crate tcorp_math_mods; use std::io; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input) .ok() .expect("Failed to read line"); let pres...
() { assert_eq!(10, count_presents(1)); assert_eq!(30, count_presents(2)); assert_eq!(40, count_presents(3)); assert_eq!(70, count_presents(4)); assert_eq!(60, count_presents(5)); assert_eq!(120, count_presents(6)); assert_eq!(80, count_presents(7)); assert_eq!(150, count_presents(8)); ...
test_count_presents
identifier_name
advent20.rs
// advent20.rs // factorizing // Used the first crate I found that did what I needed; turned out to be quite slow, oh well extern crate tcorp_math_mods; use std::io; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input) .ok() .expect("Failed to read line"); let pres...
fn count_presents2(house: u32) -> u32 { assert!(house > 0); let v = tcorp_math_mods::factors::factors_for(house); // skip the factors that are less than house/50 let mut split_idx = 0; for x in v.iter() { if *x * 50 >= house { break; } split_idx += 1; } ...
{ (1u32..).find(|x| count_presents2(*x) >= min_presents).unwrap() }
identifier_body
advent20.rs
// advent20.rs // factorizing // Used the first crate I found that did what I needed; turned out to be quite slow, oh well extern crate tcorp_math_mods; use std::io; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input) .ok() .expect("Failed to read line"); let pres...
split_idx += 1; } let (_, factors) = v.split_at(split_idx); 11 * factors.iter().fold(0, |acc, x| acc + x) } #[test] fn test_count_presents2() { assert_eq!(11, count_presents2(1)); assert_eq!(33, count_presents2(2)); assert_eq!(44, count_presents2(3)); assert_eq!(77, count_presents...
{ break; }
conditional_block
advent20.rs
// advent20.rs // factorizing // Used the first crate I found that did what I needed; turned out to be quite slow, oh well extern crate tcorp_math_mods; use std::io; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input) .ok() .expect("Failed to read line"); let pres...
fn find_lowest_house2(min_presents: u32) -> u32 { (1u32..).find(|x| count_presents2(*x) >= min_presents).unwrap() } fn count_presents2(house: u32) -> u32 { assert!(house > 0); let v = tcorp_math_mods::factors::factors_for(house); // skip the factors that are less than house/50 let mut split_idx =...
assert_eq!(8, find_lowest_house(121)); } // part 2
random_line_split
transform.rs
// Copyright (C) 2011 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applic...
if (rsIsObject(data->children)) { rs_allocation nullAlloc; rsForEach(gTransformScript, data->children, nullAlloc, &toChild, sizeof(toChild)); } data->isDirty = 0; }
{ toChild.changed = 1; data->timestamp ++; }
conditional_block
transform.rs
// Copyright (C) 2011 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applic...
rsMatrixLoadRotate(&temp, data.w, data.x, data.y, data.z); break; case TRANSFORM_SCALE: rsMatrixLoadScale(&temp, data.x, data.y, data.z); break; } rsMatrixMultiply(mat, &temp); } void root(const rs_allocation *v_in, rs_allocation *v_out, const void *usrData) { SgTransfo...
case TRANSFORM_TRANSLATE: rsMatrixLoadTranslate(&temp, data.x, data.y, data.z); break; case TRANSFORM_ROTATE:
random_line_split
regions-infer-invariance-due-to-mutability-4.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 main() { }
random_line_split
regions-infer-invariance-due-to-mutability-4.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 main() { }
{ bi //~ ERROR mismatched types }
identifier_body
regions-infer-invariance-due-to-mutability-4.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 ...
<'r>(bi: Invariant<'r>) -> Invariant<'static> { bi //~ ERROR mismatched types } fn main() { }
to_longer_lifetime
identifier_name
lint.rs
use conf; use itertools::Itertools; use lisp::LispExpr; use lisp; use rusqlite as sql; use rustc::hir::*; use rustc::hir::map::Node; use rustc::lint::{LateContext, LintArray, LintContext, LintPass, LateLintPass}; use rustc::ty::TypeVariants; use std::borrow::Cow; use std::io::{Read, Write}; use std::process::{Command, ...
ttr: &Attribute) -> bool { if let MetaItemKind::Word(ref word) = attr.node.value.node { word == &"herbie_ignore" } else { false } } let attrs = match cx.tcx.map.find(cx.tcx.map.get_parent(expr.id)) { Some(Node::...
_herbie_ignore(a
identifier_name
lint.rs
use conf; use itertools::Itertools; use lisp::LispExpr; use lisp; use rusqlite as sql; use rustc::hir::*; use rustc::hir::map::Node; use rustc::lint::{LateContext, LintArray, LintContext, LintPass, LateLintPass}; use rustc::ty::TypeVariants; use std::borrow::Cow; use std::io::{Read, Write}; use std::process::{Command, ...
} let mut output = output.lines(); let parse_error = |s: Option<&str>| -> Option<f64> { match s { Some(s) => { match s.split(' ').last().map(str::parse::<f64>) { Some(Ok(f)) => Some(f), _ => None, } } ...
if let Err(err) = stdout.read_to_string(&mut output) { return Err(format!("cannot read output: {}", err).into());
random_line_split
lint.rs
use conf; use itertools::Itertools; use lisp::LispExpr; use lisp; use rusqlite as sql; use rustc::hir::*; use rustc::hir::map::Node; use rustc::lint::{LateContext, LintArray, LintContext, LintPass, LateLintPass}; use rustc::ty::TypeVariants; use std::borrow::Cow; use std::io::{Read, Write}; use std::process::{Command, ...
} impl Herbie { pub fn new() -> Herbie { Herbie::default() } pub fn init(&mut self) -> Result<(), InitError> { if self.initialized { return Ok(()) } self.initialized = true; let conf = try!(conf::read_conf()); let connection = try!(sql::Connec...
{ match *self { InitError::Conf { ref error } => write!(f, "Configuration error: {}", error), InitError::SQL { ref error } => write!(f, "Got SQL error: {}", error), } }
identifier_body
coerce-bare-fn-to-closure-and-proc.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 f = foo; let f_closure: || = f; //~^ ERROR: cannot coerce non-statically resolved bare fn to closure //~^^ HELP: consider embedding the function in a closure let f_proc: proc() = f; //~^ ERROR: cannot coerce non-statically resolved bare fn to closure //~^^ HELP: consider embedding the ...
identifier_body
coerce-bare-fn-to-closure-and-proc.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 ...
//~^ ERROR: cannot coerce non-statically resolved bare fn to closure //~^^ HELP: consider embedding the function in a closure let f_proc: proc() = f; //~^ ERROR: cannot coerce non-statically resolved bare fn to closure //~^^ HELP: consider embedding the function in a closure }
fn main() { let f = foo; let f_closure: || = f;
random_line_split
coerce-bare-fn-to-closure-and-proc.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 main() { let f = foo; let f_closure: || = f; //~^ ERROR: cannot coerce non-statically resolved bare fn to closure //~^^ HELP: consider embedding the function in a closure let f_proc: proc() = f; //~^ ERROR: cannot coerce non-statically resolved bare fn to closure //~^^ HELP: consid...
foo
identifier_name
file.rs
use std::io::{Read, Write}; use std::io::BufReader; use std::io::BufRead; use std::path::{PathBuf, Path}; use std::fs::{File, DirBuilder, OpenOptions}; pub fn read_file<P: AsRef<Path>>(file: P) -> Result<String, String> { let mut file = File::open(file) .map_err(error_err!()) .map_err(|_| "Can't read...
let mut file = OpenOptions::new() .write(true) .create(true) .open(path) .map_err(error_err!()) .map_err(|err| format!("Can't open the file: {}", err))?; file .write_all(content.as_bytes()) .map_err(error_err!()) .map_err(|err| format!("Can't write cont...
{ DirBuilder::new() .recursive(true) .create(parent_path) .map_err(error_err!()) .map_err(|err| format!("Can't create the file: {}", err))?; }
conditional_block
file.rs
use std::io::{Read, Write}; use std::io::BufReader; use std::io::BufRead; use std::path::{PathBuf, Path}; use std::fs::{File, DirBuilder, OpenOptions}; pub fn read_file<P: AsRef<Path>>(file: P) -> Result<String, String> { let mut file = File::open(file) .map_err(error_err!()) .map_err(|_| "Can't read...
.map_err(|err| format!("Can't read the file: {}", err))?; s }; Ok(content) } pub fn read_lines_from_file<P: AsRef<Path>>(file: P) -> Result<impl Iterator<Item=Result<String, ::std::io::Error>>, String> { let file = File::open(file) .map_err(error_err!()) .map_err(|_| "Can'...
let mut s = String::new(); file.read_to_string(&mut s) .map_err(error_err!())
random_line_split
file.rs
use std::io::{Read, Write}; use std::io::BufReader; use std::io::BufRead; use std::path::{PathBuf, Path}; use std::fs::{File, DirBuilder, OpenOptions}; pub fn read_file<P: AsRef<Path>>(file: P) -> Result<String, String> { let mut file = File::open(file) .map_err(error_err!()) .map_err(|_| "Can't read...
<P: AsRef<Path>>(file: P, content: &str) -> Result<(), String> where P: std::convert::AsRef<std::ffi::OsStr> { let path = PathBuf::from(&file); if let Some(parent_path) = path.parent() { DirBuilder::new() .recursive(true) .create(parent_path) .map_err(error_err!()) ...
write_file
identifier_name
file.rs
use std::io::{Read, Write}; use std::io::BufReader; use std::io::BufRead; use std::path::{PathBuf, Path}; use std::fs::{File, DirBuilder, OpenOptions}; pub fn read_file<P: AsRef<Path>>(file: P) -> Result<String, String>
pub fn read_lines_from_file<P: AsRef<Path>>(file: P) -> Result<impl Iterator<Item=Result<String, ::std::io::Error>>, String> { let file = File::open(file) .map_err(error_err!()) .map_err(|_| "Can't read the file".to_string())?; let lines = BufReader::new(file).lines(); Ok(lines) } pub fn w...
{ let mut file = File::open(file) .map_err(error_err!()) .map_err(|_| "Can't read the file".to_string())?; let content = { let mut s = String::new(); file.read_to_string(&mut s) .map_err(error_err!()) .map_err(|err| format!("Can't read the file: {}", err)...
identifier_body
iostat.rs
use alloc::string::String; use alloc::vec::Vec; use core::fmt::Write; use core::str; use crate::context; use crate::scheme; use crate::syscall::error::Result; pub fn
() -> Result<Vec<u8>> { let mut string = String::new(); { let mut rows = Vec::new(); { let contexts = context::contexts(); for (id, context_lock) in contexts.iter() { let context = context_lock.read(); rows.push((*id, context.name.read().c...
resource
identifier_name
iostat.rs
use alloc::string::String; use alloc::vec::Vec; use core::fmt::Write; use core::str; use crate::context;
let mut string = String::new(); { let mut rows = Vec::new(); { let contexts = context::contexts(); for (id, context_lock) in contexts.iter() { let context = context_lock.read(); rows.push((*id, context.name.read().clone(), context.files.re...
use crate::scheme; use crate::syscall::error::Result; pub fn resource() -> Result<Vec<u8>> {
random_line_split
iostat.rs
use alloc::string::String; use alloc::vec::Vec; use core::fmt::Write; use core::str; use crate::context; use crate::scheme; use crate::syscall::error::Result; pub fn resource() -> Result<Vec<u8>>
None => continue, Some(ref file) => file.clone() }; let description = file.description.read(); let scheme = { let schemes = scheme::schemes(); match schemes.get(description.scheme) { ...
{ let mut string = String::new(); { let mut rows = Vec::new(); { let contexts = context::contexts(); for (id, context_lock) in contexts.iter() { let context = context_lock.read(); rows.push((*id, context.name.read().clone(), context.files....
identifier_body
resource_files.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 std::fs::File; use std::io::{self, Read}; use std::path::PathBuf; use std::sync::{Arc, Mutex}; lazy_static! {...
path } } } pub fn read_resource_file(relative_path_components: &[&str]) -> io::Result<Vec<u8>> { let mut path = resources_dir_path(); for component in relative_path_components { path.push(component); } let mut file = try!(File::open(&path)); let mut data = Vec::new(...
{ // resources dir not in same dir as exe? // exe is probably in target/{debug,release} so we need to go back to topdir path.pop(); path.pop(); path.pop(); path.push("resources"); if !path.is_dir() { //...
conditional_block
resource_files.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 std::fs::File; use std::io::{self, Read}; use std::path::PathBuf; use std::sync::{Arc, Mutex}; lazy_static! {...
} #[cfg(target_os = "android")] pub fn resources_dir_path() -> PathBuf { PathBuf::from("/sdcard/servo/") } #[cfg(not(target_os = "android"))] pub fn resources_dir_path() -> PathBuf { use std::env; match *CMD_RESOURCE_DIR.lock().unwrap() { Some(ref path) => PathBuf::from(path), None => { ...
random_line_split
resource_files.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 std::fs::File; use std::io::{self, Read}; use std::path::PathBuf; use std::sync::{Arc, Mutex}; lazy_static! {...
() -> PathBuf { use std::env; match *CMD_RESOURCE_DIR.lock().unwrap() { Some(ref path) => PathBuf::from(path), None => { // FIXME: Find a way to not rely on the executable being // under `<servo source>[/$target_triple]/target/debug` // or `<servo source>[/$t...
resources_dir_path
identifier_name
resource_files.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 std::fs::File; use std::io::{self, Read}; use std::path::PathBuf; use std::sync::{Arc, Mutex}; lazy_static! {...
{ let mut path = resources_dir_path(); for component in relative_path_components { path.push(component); } let mut file = try!(File::open(&path)); let mut data = Vec::new(); try!(file.read_to_end(&mut data)); Ok(data) }
identifier_body
where.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub struct Echo<E>(E); // @has foo/struct.Echo.html '//*[@class="impl"]//code' \ // "impl<E> MyTrait for Echo<E> where E: MyTrait" // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \ // "impl<E> MyTrait for Echo<E> where E: MyTrait" impl<E> MyTrait for Echo<E> where E: MyTrait {...
{}
identifier_body
where.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub struct Alpha<A>(A) where A: MyTrait; // @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B> where B: MyTrait" pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); } // @has foo/fn.charlie.html '//pre' "pub fn charlie<C>() where C: MyTrait" pub fn charlie<C>() where C: MyTrait {} pub struct Delta<D>(D); //...
#![crate_name = "foo"] pub trait MyTrait { fn dummy(&self) { } } // @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A> where A: MyTrait"
random_line_split
where.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 ...
<A>(A) where A: MyTrait; // @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B> where B: MyTrait" pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); } // @has foo/fn.charlie.html '//pre' "pub fn charlie<C>() where C: MyTrait" pub fn charlie<C>() where C: MyTrait {} pub struct Delta<D>(D); // @has foo/struct...
Alpha
identifier_name
authorized.rs
use session::game::{Session, GameState}; use session::game::chunk::{self, Ref}; use protocol::messages::authorized::*; use std::io::Result; use server::SERVER; #[register_handlers] impl Session { pub fn handle_admin_quiet_command_message<'a>(&mut self, chunk: Ref<'a>, ...
chunk::teleport(chunk, ch, map_id, cell_id); } Ok(()) } }
{ let ch = match self.state { GameState::InContext(ref mut ch) => ch, _ => return Ok(()), }; if ch.movements.is_some() { return Ok(()); } let map_id: i32 = match msg.base.content.split(" ").last().map(|id| id.parse()) { Some(Ok(ma...
identifier_body
authorized.rs
use session::game::{Session, GameState}; use session::game::chunk::{self, Ref}; use protocol::messages::authorized::*; use std::io::Result; use server::SERVER; #[register_handlers] impl Session { pub fn
<'a>(&mut self, chunk: Ref<'a>, msg: AdminQuietCommandMessage) -> Result<()> { let ch = match self.state { GameState::InContext(ref mut ch) => ch, _ => return Ok(()), }; if ch.movements.is_some() { return Ok((...
handle_admin_quiet_command_message
identifier_name
authorized.rs
use session::game::{Session, GameState}; use session::game::chunk::{self, Ref}; use protocol::messages::authorized::*; use std::io::Result; use server::SERVER; #[register_handlers] impl Session { pub fn handle_admin_quiet_command_message<'a>(&mut self, chunk: Ref<'a>, ...
Ok(()) } }
{ chunk::teleport(chunk, ch, map_id, cell_id); }
conditional_block