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
pattern-tyvar-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(t: bar) -> isize { match t { bar::t1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } //~^ ERROR binary operation `*` cannot be applied to fn main() { }
foo
identifier_name
pattern-tyvar-2.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 ...
{ }
identifier_body
pattern-tyvar-2.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
// option. This file may not be copied, modified, or distributed // except according to those terms. enum bar { t1((), Option<Vec<isize>>), t2, } // n.b. my change changes this error message, but I think it's right -- tjc fn foo(t: bar) -> isize { match t { bar::t1(_, Some(x)) => { return x * 3; } _ => { panic!(); } ...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
pattern-tyvar-2.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 ...
} } //~^ ERROR binary operation `*` cannot be applied to fn main() { }
{ panic!(); }
conditional_block
dbvt_broad_phase2d.rs
extern crate nalgebra as na; extern crate ncollide; use na::{Vec2, Iso2}; use ncollide::shape::Ball; use ncollide::bounding_volume; use ncollide::broad_phase::{DBVTBroadPhase, BroadPhase}; fn
() { /* * Create the objects. */ let poss = [ Iso2::new(Vec2::new(0.0, 0.0), na::zero()), Iso2::new(Vec2::new(0.0, 0.5), na::zero()), Iso2::new(Vec2::new(0.5, 0.0), na::zero()), Iso2::new(Vec2::new(0.5, 0.5), na::zero()) ]; // We will use the sam...
main
identifier_name
dbvt_broad_phase2d.rs
extern crate nalgebra as na; extern crate ncollide; use na::{Vec2, Iso2}; use ncollide::shape::Ball; use ncollide::bounding_volume; use ncollide::broad_phase::{DBVTBroadPhase, BroadPhase}; fn main() { /* * Create the objects. */ let poss = [ Iso2::new(Vec2::new(0.0, 0.0), na::zero()), ...
// First parameter: a unique id for each object. // Second parameter: the object bounding box. // Third parameter: some data (here, the id that identify each object). bf.deferred_add(0, bounding_volume::aabb(&ball, &poss[0]), 0); bf.deferred_add(1, bounding_volume::aabb(&ball, &poss[1]), 1); ...
* Create the broad phase. * We know we will use small uids (from 0 to 3)so we can pass `true` as the second argument. */ let mut bf = DBVTBroadPhase::new(0.2, true);
random_line_split
dbvt_broad_phase2d.rs
extern crate nalgebra as na; extern crate ncollide; use na::{Vec2, Iso2}; use ncollide::shape::Ball; use ncollide::bounding_volume; use ncollide::broad_phase::{DBVTBroadPhase, BroadPhase}; fn main()
// Third parameter: some data (here, the id that identify each object). bf.deferred_add(0, bounding_volume::aabb(&ball, &poss[0]), 0); bf.deferred_add(1, bounding_volume::aabb(&ball, &poss[1]), 1); bf.deferred_add(2, bounding_volume::aabb(&ball, &poss[2]), 2); bf.deferred_add(3, bounding_volume::aa...
{ /* * Create the objects. */ let poss = [ Iso2::new(Vec2::new(0.0, 0.0), na::zero()), Iso2::new(Vec2::new(0.0, 0.5), na::zero()), Iso2::new(Vec2::new(0.5, 0.0), na::zero()), Iso2::new(Vec2::new(0.5, 0.5), na::zero()) ]; // We will use the same g...
identifier_body
test.rs
// a test file that imports the library extern mod re; use std::{libc, io, run, os, path, uint}; use re::UncompiledRegexp; fn
() { println("--Case 0--"); let mut re = UncompiledRegexp::new("[a-z]d|abc"); re.run("abc"); println("--Case 1--"); let mut re = UncompiledRegexp::new("(?:http(s)?://)?(www.)?([a-zA-Z0-9_.]+).(com|org|net|edu)/?"); re.run("http://ferristseng.comuASDAFASFASBVZKXJVBKZXBVKJZBXVKBZXV"); re.run("http://reddit...
main
identifier_name
test.rs
// a test file that imports the library extern mod re; use std::{libc, io, run, os, path, uint}; use re::UncompiledRegexp; fn main() { println("--Case 0--"); let mut re = UncompiledRegexp::new("[a-z]d|abc"); re.run("abc"); println("--Case 1--"); let mut re = UncompiledRegexp::new("(?:http(s)?://)?(www.)?(...
rror reading file: %?", read_result.unwrap_err())); return ~[]; }
ead_result.unwrap(); return file.read_lines(); } println(fmt!("E
conditional_block
test.rs
// a test file that imports the library extern mod re; use std::{libc, io, run, os, path, uint}; use re::UncompiledRegexp; fn main() { println("--Case 0--"); let mut re = UncompiledRegexp::new("[a-z]d|abc"); re.run("abc"); println("--Case 1--"); let mut re = UncompiledRegexp::new("(?:http(s)?://)?(www.)?(...
Result<@Reader, ~str>; read_result = io::file_reader(~path::Path(filename)); if read_result.is_ok() { let file = read_result.unwrap(); return file.read_lines(); } println(fmt!("Error reading file: %?", read_result.unwrap_err())); return ~[]; }
identifier_body
test.rs
// a test file that imports the library extern mod re; use std::{libc, io, run, os, path, uint}; use re::UncompiledRegexp; fn main() { println("--Case 0--"); let mut re = UncompiledRegexp::new("[a-z]d|abc"); re.run("abc"); println("--Case 1--"); let mut re = UncompiledRegexp::new("(?:http(s)?://)?(www.)?(...
/* println("--Case 7--"); //Regexp::new("[[A-Z]0-9(fgh)]]]|[abc]").parse(); Regexp::new("1\\d2").parse(); println("--Case 8--"); UncompiledRegexp::new("(abc){1,}").parse(); println("--Case 9--"); UncompiledRegexp::new("abc{3,4}?").parse(); println("--Case 10--"); UncompiledRegexp::new("a|b{3}"...
random_line_split
str.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 ...
tle lämb\n"; let mut split: Vec<&str> = data.split('\n').rev().collect(); split.reverse(); assert_eq!(split, vec!["", "Märy häd ä little lämb", "Little lämb", ""]); let mut split: Vec<&str> = data.split_terminator('\n').rev().collect(); split.reverse(); assert_eq!(split, vec!["", "Märy häd ä l...
et data = "\nMäry häd ä little lämb\nLit
identifier_name
str.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 ...
#[test] fn test_rsplitn_char_iterator() { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let mut split: Vec<&str> = data.rsplitn(3,'').collect(); split.reverse(); assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); let mut split: Vec<&str> = data.rsplitn(3, |c: ch...
{ let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'"; check_contains_all_substrings(x); }
identifier_body
str.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'"; check_contains_all_substrings(x); } #[test] fn test_rsplitn_char_iterator() { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let mut split: Vec<&str> = data.rsplitn(3,'').collect(); split.reverse(); asser...
#[test] fn test_strslice_contains() {
random_line_split
from_str_radix_10.rs
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{def, Expr, ExprKind, PrimTy, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use...
(&mut self, cx: &LateContext<'tcx>, exp: &Expr<'tcx>) { if_chain! { if let ExprKind::Call(maybe_path, arguments) = &exp.kind; if let ExprKind::Path(QPath::TypeRelative(ty, pathseg)) = &maybe_path.kind; // check if the first part of the path is some integer primitive ...
check_expr
identifier_name
from_str_radix_10.rs
use clippy_utils::diagnostics::span_lint_and_sugg;
use rustc_errors::Applicability; use rustc_hir::{def, Expr, ExprKind, PrimTy, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; declare_clippy_lint! { /// ### What it does /// /// Ch...
use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain;
random_line_split
from_str_radix_10.rs
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{def, Expr, ExprKind, PrimTy, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use...
{ is_type_diagnostic_item(cx, ty, sym::String) || is_type_diagnostic_item(cx, ty, sym::str) }
identifier_body
chunk.rs
use super::{Separator}; pub struct Chunk { pub index: u64, pub size: u64, pub separator_hash: u64, } pub struct ChunkIter<Iter> { separators: Iter, stream_length: u64, last_separator_index: u64, } impl<Iter: Iterator<Item=Separator>> ChunkIter<Iter> { pub fn new(iter: Iter, stream_length:...
, None => { let chunk_size = self.stream_length - self.last_separator_index; self.last_separator_index = self.stream_length; if chunk_size > 0 { return Some(Chunk { index: self.last_separator_index, ...
{ let chunk_size = separator.index - self.last_separator_index; self.last_separator_index = separator.index; return Some(Chunk { index: self.last_separator_index, size: chunk_size, separator_hash: separator.hash,...
conditional_block
chunk.rs
use super::{Separator}; pub struct Chunk { pub index: u64, pub size: u64, pub separator_hash: u64, } pub struct ChunkIter<Iter> { separators: Iter, stream_length: u64, last_separator_index: u64, } impl<Iter: Iterator<Item=Separator>> ChunkIter<Iter> { pub fn new(iter: Iter, stream_length:...
} else { return None; } } } } }
{ match self.separators.next() { Some(separator) => { let chunk_size = separator.index - self.last_separator_index; self.last_separator_index = separator.index; return Some(Chunk { index: self.last_separator_index, ...
identifier_body
chunk.rs
use super::{Separator}; pub struct Chunk { pub index: u64, pub size: u64, pub separator_hash: u64, } pub struct
<Iter> { separators: Iter, stream_length: u64, last_separator_index: u64, } impl<Iter: Iterator<Item=Separator>> ChunkIter<Iter> { pub fn new(iter: Iter, stream_length: u64) -> ChunkIter<Iter> { ChunkIter { separators: iter, stream_length: stream_length, last...
ChunkIter
identifier_name
chunk.rs
use super::{Separator}; pub struct Chunk { pub index: u64, pub size: u64, pub separator_hash: u64, } pub struct ChunkIter<Iter> { separators: Iter, stream_length: u64, last_separator_index: u64, } impl<Iter: Iterator<Item=Separator>> ChunkIter<Iter> { pub fn new(iter: Iter, stream_length:...
size: chunk_size, separator_hash: separator.hash, }); }, None => { let chunk_size = self.stream_length - self.last_separator_index; self.last_separator_index = self.stream_length; if chunk_siz...
Some(separator) => { let chunk_size = separator.index - self.last_separator_index; self.last_separator_index = separator.index; return Some(Chunk { index: self.last_separator_index,
random_line_split
LA.rs
fn
(input: &str) -> bool { let mut input = input .chars() .filter(|&x| x!='') .map(|x| x.to_digit(10)) .collect::<Vec<_>>(); if input.len() <= 1 { return false; } if!input.iter().all(|x| x.is_some()) { return false; } input.reverse(); // let m...
luhn_is_valid
identifier_name
LA.rs
fn luhn_is_valid(input: &str) -> bool { let mut input = input .chars() .filter(|&x| x!='') .map(|x| x.to_digit(10)) .collect::<Vec<_>>(); if input.len() <= 1 { return false; } if!input.iter().all(|x| x.is_some()) { return false; } input.reverse(); ...
fn main() { assert!(!luhn_is_valid("1")); assert!(!luhn_is_valid("0")); assert!(luhn_is_valid("059")); assert!(luhn_is_valid("59")); assert!(luhn_is_valid("055 444 285")); assert!(!luhn_is_valid("055 444 286")); assert!(!luhn_is_valid("0")); assert!(luhn_is_valid("0000 0")); }
{ if *i > 9 { i - 9 } else { *i } }
identifier_body
LA.rs
fn luhn_is_valid(input: &str) -> bool { let mut input = input .chars() .filter(|&x| x!='') .map(|x| x.to_digit(10)) .collect::<Vec<_>>(); if input.len() <= 1 { return false; } if!input.iter().all(|x| x.is_some()) { return false; } input.reverse(); ...
fn check_nine(i: &u32) -> u32 { if *i > 9 { i - 9 } else { *i } } fn main() { assert!(!luhn_is_valid("1")); assert!(!luhn_is_valid("0")); assert!(luhn_is_valid("059")); assert!(luhn_is_valid("59")); assert!(luhn_is_valid("055 444 285")); assert!(!luhn_is_valid("055 ...
result % 10 == 0 }
random_line_split
LA.rs
fn luhn_is_valid(input: &str) -> bool { let mut input = input .chars() .filter(|&x| x!='') .map(|x| x.to_digit(10)) .collect::<Vec<_>>(); if input.len() <= 1
if!input.iter().all(|x| x.is_some()) { return false; } input.reverse(); // let mut flag = true; let mut result = 0; for i in input { if flag { result += i.as_ref().unwrap(); } else { result += check_nine(&(*i.as_ref().unwrap() * 2)); ...
{ return false; }
conditional_block
mod.rs
//! The persistent storage of Raft state. //!
mod mem; use std::error; use std::fmt::Debug; use std::result; pub use persistent_log::mem::{MemLog, Error}; use LogIndex; use Term; use ServerId; /// A store of persistent Raft state. pub trait Log: Clone + Debug + Send +'static { type Error: error::Error + Debug + Sized +'static; /// Returns the latest ...
//! In your consuming application you will want to implement this trait on one of your structures. //! This could adapt to a database, a file, or even just POD. //! //! *Note:* Your consuming application should not necessarily interface with this data. It is meant //! for internal use by the library, we simply chose no...
random_line_split
lib.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 ...
<T: One>() -> T { One::one() } /// Computes the absolute value. /// /// For `f32` and `f64`, `NaN` will be returned if the number is `NaN` /// /// For signed integers, `::MIN` will be returned if the number is `::MIN`. #[inline(always)] pub fn abs<T: Signed>(value: T) -> T { value.abs() } /// The positive differe...
one
identifier_name
lib.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 ...
{ if exp == 1 { base } else { let mut acc = one::<T>(); while exp > 0 { if (exp & 1) == 1 { acc = acc * base.clone(); } base = base.clone() * base; exp = exp >> 1; } acc } }
identifier_body
lib.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 ...
/// Raises a value to the power of exp, using exponentiation by squaring. /// /// # Example /// /// ```rust /// use num; /// /// assert_eq!(num::pow(2i, 4), 16); /// ``` #[inline] pub fn pow<T: Clone + One + Mul<T, T>>(mut base: T, mut exp: uint) -> T { if exp == 1 { base } else { let mut acc = one::<T>...
/// * `1` if the number is positive /// * `-1` if the number is negative #[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }
random_line_split
lib.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 mut acc = one::<T>(); while exp > 0 { if (exp & 1) == 1 { acc = acc * base.clone(); } base = base.clone() * base; exp = exp >> 1; } acc }
conditional_block
main.rs
/* Aurélien DESBRIÈRES aurelien(at)hackers(dot)camp License GNU GPL latest */ // Rust experimentations // The Problem in Rust struct Container(i32, i32); // A trait which checks if 2 items are stored inside of container. // Also retrieves first or last value. trait Contains<A, B> { fn contains(&self, &A, &B) -> ...
self, number_1: &i32, number_2: &i32) -> bool { (&self.0 == number_1) && (&self.1 == number_2) } // Grab the first number. fn first(&self) -> i32 { self.0 } // Grab the last number. fn last(&self) -> i32 { self.1 } } // `C` contains `A` and `B`. In light of that, having to express `A` and...
ntains(&
identifier_name
main.rs
/* Aurélien DESBRIÈRES aurelien(at)hackers(dot)camp License GNU GPL latest */ // Rust experimentations // The Problem in Rust struct Container(i32, i32); // A trait which checks if 2 items are stored inside of container. // Also retrieves first or last value. trait Contains<A, B> { fn contains(&self, &A, &B) -> ...
println!("Does container contain {} and {}: {}", &number_1, &number_2, container.contains(&number_1, &number_2)); println!("First number: {}", container.first()); println!("Last number: {}", container.last()); println!("the difference is: {}", difference(&container)); }
let container = Container(number_1, number_2);
random_line_split
ast.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
{ pub print_attr: PrintAttribute } impl GrammarAttributes { pub fn new(print_attr: PrintAttribute) -> GrammarAttributes { GrammarAttributes { print_attr: print_attr } } } #[derive(Clone, Copy, PartialEq, Eq)] pub enum PrintAttribute { DebugApi, ShowApi, Nothing } impl PrintAttribute { pu...
GrammarAttributes
identifier_name
ast.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
pub fn debug_api(self) -> bool { self == PrintAttribute::DebugApi } pub fn show_api(self) -> bool { self == PrintAttribute::ShowApi } } impl Default for PrintAttribute { fn default() -> PrintAttribute { PrintAttribute::Nothing } } pub struct Rule { pub name: SpannedIdent, pub def: Box<E...
{ use self::PrintAttribute::*; match (self, other) { (Nothing, DebugApi) | (ShowApi, DebugApi) => DebugApi, (Nothing, ShowApi) => ShowApi, _ => Nothing } }
identifier_body
ast.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
pub use ast::*; pub use front::ast::Expression; pub use rust::{ExtCtxt,Attribute,SpannedIdent}; pub use monad::partial::Partial; use front::ast::Grammar as FGrammar; use std::collections::HashMap; use std::default::Default; pub struct Grammar { pub name: Ident, pub rules: HashMap<Ident, Rule>, pub rust_function...
// limitations under the License.
random_line_split
strings.rs
fn takes_slice(slice: &str) { println!("got {}", slice); } fn main() { // two types of string // &str and String // &str is string slices // has fixed size and cannot be mutated // reference to the sequence of UTF8 bytes let greeting = "Hello there."; // greeting: &'static str ...
println!("{}", multi); let multi2 = "this is too\ weird syntax without newline and spaces"; println!("{}", multi2); // String is heap allocated and growable let mut hello = "hello".to_string(); hello.push_str(" world!"); println!("{}", hello); takes_slice(&hello);...
let multi = "this is weird syntax with newline and spaces";
random_line_split
strings.rs
fn
(slice: &str) { println!("got {}", slice); } fn main() { // two types of string // &str and String // &str is string slices // has fixed size and cannot be mutated // reference to the sequence of UTF8 bytes let greeting = "Hello there."; // greeting: &'static str println!("{}"...
takes_slice
identifier_name
strings.rs
fn takes_slice(slice: &str)
fn main() { // two types of string // &str and String // &str is string slices // has fixed size and cannot be mutated // reference to the sequence of UTF8 bytes let greeting = "Hello there."; // greeting: &'static str println!("{}", greeting); let multi = "this is w...
{ println!("got {}", slice); }
identifier_body
lut.rs
use crate::asset::AssetLoadContext; use anyhow::Error; use rayon::prelude::*; use serde::{Deserialize, Serialize}; pub(crate) trait LookupTableDefinition: Sync { fn name(&self) -> String; fn size(&self) -> [u16; 3]; fn compute(&self, _: [u16; 3]) -> [f32; 4]; fn inv_size(&self) -> [f64; 3] { l...
{ pub size: [u16; 3], pub data: Vec<[f32; 4]>, } impl LookupTable { pub fn get2(&self, x: f64, y: f64) -> [f32; 4] { assert_eq!(self.size[2], 1); assert!(x >= 0.0); assert!(y >= 0.0); assert!(x <= 1.0); assert!(y <= 1.0); let x = (x * (self.size[0] - 1) as f...
LookupTable
identifier_name
lut.rs
use crate::asset::AssetLoadContext; use anyhow::Error; use rayon::prelude::*; use serde::{Deserialize, Serialize}; pub(crate) trait LookupTableDefinition: Sync { fn name(&self) -> String; fn size(&self) -> [u16; 3]; fn compute(&self, _: [u16; 3]) -> [f32; 4]; fn inv_size(&self) -> [f64; 3] { l...
// } // }
random_line_split
resource-cycle.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 ...
{ v: *int, } impl Drop for r { fn finalize(&self) { unsafe { debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x", cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(self)), cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(&(self.v))), cas...
r
identifier_name
resource-cycle.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { unsafe { let i1 = ~0; let i1p = cast::reinterpret_cast(&i1); cast::forget(i1); let i2 = ~0; let i2p = cast::reinterpret_cast(&i2); cast::forget(i2); let mut x1 = @mut t(Node{ next: None, r: { let rs = r...
r: r }
random_line_split
outlives.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 ...
// reasonable code like this: // // ``` // fn foo<'a>(p: &Data<'a>) { // bar(|q: &mut Parser| q.read_addr()) // } // fn bar(p: Box<FnMut(&mut Parser)+'static>) { // } // ``` // // Note ...
{ // Descend through the types, looking for the various "base" // components and collecting them into `out`. This is not written // with `collect()` because of the need to sometimes skip subtrees // in the `subtys` iterator (e.g., when encountering a // projection). match ty.sty { ty::Ty...
identifier_body
outlives.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 ...
// For projections, we prefer to generate an obligation like // `<P0 as Trait<P1...Pn>>::Foo: 'a`, because this gives the // regionck more ways to prove that it holds. However, // regionck is not (at least currently) prepared to deal with // higher-ranked regions that may appea...
{ out.push(Component::Param(p)); }
conditional_block
outlives.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 ...
// from RFC1214.) ty::TyBool(..) | // OutlivesScalar ty::TyChar(..) | // OutlivesScalar ty::TyInt(..) | // OutlivesScalar ty::TyUint(..) | // OutlivesScalar ty::TyFloat(..) | // OutlivesScalar ty::TyEnum(..) | // OutlivesN...
// involve any other subtle cases, and so the WF relation // simply constraints any regions referenced directly by // the type and then visits the types that are lexically // contained within. (The comments refer to relevant rules
random_line_split
outlives.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 ...
<'tcx> { Region(ty::Region), Param(ty::ParamTy), UnresolvedInferenceVariable(ty::InferTy), // Projections like `T::Foo` are tricky because a constraint like // `T::Foo: 'a` can be satisfied in so many ways. There may be a // where-clause that says `T::Foo: 'a`, or the defining trait may // ...
Component
identifier_name
to_ordered_representation.rs
use malachite_base::num::basic::floats::PrimitiveFloat; use malachite_base::num::float::NiceFloat; use malachite_base_test_util::bench::bucketers::primitive_float_bucketer; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use ma...
register_primitive_float_demos!(runner, demo_to_ordered_representation); register_primitive_float_benches!(runner, benchmark_to_ordered_representation); } fn demo_to_ordered_representation<T: PrimitiveFloat>(gm: GenMode, config: GenConfig, limit: usize) { for x in primitive_float_gen_var_11::<T>() ....
pub(crate) fn register(runner: &mut Runner) {
random_line_split
to_ordered_representation.rs
use malachite_base::num::basic::floats::PrimitiveFloat; use malachite_base::num::float::NiceFloat; use malachite_base_test_util::bench::bucketers::primitive_float_bucketer; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use ma...
fn demo_to_ordered_representation<T: PrimitiveFloat>(gm: GenMode, config: GenConfig, limit: usize) { for x in primitive_float_gen_var_11::<T>() .get(gm, &config) .take(limit) { println!( "to_ordered_representation({}) = {}", NiceFloat(x), x.to_ordered_...
{ register_primitive_float_demos!(runner, demo_to_ordered_representation); register_primitive_float_benches!(runner, benchmark_to_ordered_representation); }
identifier_body
to_ordered_representation.rs
use malachite_base::num::basic::floats::PrimitiveFloat; use malachite_base::num::float::NiceFloat; use malachite_base_test_util::bench::bucketers::primitive_float_bucketer; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use ma...
(runner: &mut Runner) { register_primitive_float_demos!(runner, demo_to_ordered_representation); register_primitive_float_benches!(runner, benchmark_to_ordered_representation); } fn demo_to_ordered_representation<T: PrimitiveFloat>(gm: GenMode, config: GenConfig, limit: usize) { for x in primitive_float_ge...
register
identifier_name
decoder_test_case.rs
// SPDX-License-Identifier: MIT // Copyright wtfsckgh@gmail.com // Copyright iced contributors use super::super::super::iced_constants::IcedConstants; use super::super::super::*; use alloc::string::String; #[derive(Default)] pub(crate) struct DecoderTestCase { pub(crate) line_number: u32, pub(crate) test_options: u...
pub(crate) segment_prefix: Register, pub(crate) memory_segment: Register, pub(crate) memory_base: Register, pub(crate) memory_index: Register, pub(crate) memory_displ_size: u32, pub(crate) memory_size: MemorySize, pub(crate) memory_index_scale: u32, pub(crate) memory_displacement: u64, pub(crate) immediate: u6...
pub(crate) has_lock_prefix: bool, pub(crate) vsib_bitness: u32, pub(crate) op_mask: Register, pub(crate) rounding_control: RoundingControl, pub(crate) op_kinds: [OpKind; IcedConstants::MAX_OP_COUNT],
random_line_split
decoder_test_case.rs
// SPDX-License-Identifier: MIT // Copyright wtfsckgh@gmail.com // Copyright iced contributors use super::super::super::iced_constants::IcedConstants; use super::super::super::*; use alloc::string::String; #[derive(Default)] pub(crate) struct
{ pub(crate) line_number: u32, pub(crate) test_options: u32, pub(crate) decoder_error: DecoderError, pub(crate) decoder_options: u32, pub(crate) bitness: u32, pub(crate) hex_bytes: String, pub(crate) encoded_hex_bytes: String, pub(crate) code: Code, pub(crate) mnemonic: Mnemonic, pub(crate) op_count: u32, p...
DecoderTestCase
identifier_name
echo.rs
extern crate getopts; use std::os; use std::old_io::{print, println}; use std::old_io::stdio; static VERSION: &'static str = "1.0.0"; fn main()
return; // The exit code is 0 (success) by default. // Any exit code other than 0 indicates failure. } }; if matches.opt_present("help") { //^ We could as well have used the short name: "h" println!("echo {} - display a line of text", VERSION); ...
{ let args = os::args(); let ref program = args[0]; // Set possible flags. // The first argument to `optflag` is the short flag name. // The second argument is the long flag name. // The third argument is the help text. let opts = [ getopts::optflag("n", "", "do not output the trail...
identifier_body
echo.rs
extern crate getopts; use std::os; use std::old_io::{print, println}; use std::old_io::stdio; static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); let ref program = args[0]; // Set possible flags. // The first argument to `optflag` is the short flag name. // The second argu...
} else { stdio::flush(); } }
random_line_split
echo.rs
extern crate getopts; use std::os; use std::old_io::{print, println}; use std::old_io::stdio; static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); let ref program = args[0]; // Set possible flags. // The first argument to `optflag` is the short flag name. // The second argu...
else { stdio::flush(); } }
{ println!("") }
conditional_block
echo.rs
extern crate getopts; use std::os; use std::old_io::{print, println}; use std::old_io::stdio; static VERSION: &'static str = "1.0.0"; fn
() { let args = os::args(); let ref program = args[0]; // Set possible flags. // The first argument to `optflag` is the short flag name. // The second argument is the long flag name. // The third argument is the help text. let opts = [ getopts::optflag("n", "", "do not output the tr...
main
identifier_name
font_template.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::Read; use string_cache::Atom; use webrender_traits::NativeFontHandle; /// Platfor...
/// Returns the native font that underlies this font template, if applicable. pub fn native_font(&self) -> Option<NativeFontHandle> { None } }
pub fn bytes_if_in_memory(&self) -> Option<Vec<u8>> { Some(self.bytes()) }
random_line_split
font_template.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::Read; use string_cache::Atom; use webrender_traits::NativeFontHandle; /// Platfor...
/// Returns a clone of the bytes in this font if they are in memory. This function never /// performs disk I/O. pub fn bytes_if_in_memory(&self) -> Option<Vec<u8>> { Some(self.bytes()) } /// Returns the native font that underlies this font template, if applicable. pub fn native_font(&...
{ self.bytes.clone() }
identifier_body
font_template.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::Read; use string_cache::Atom; use webrender_traits::NativeFontHandle; /// Platfor...
(&self) -> Option<NativeFontHandle> { None } }
native_font
identifier_name
impl-disambiguation.rs
#![crate_name = "foo"] pub trait Foo {} pub struct Bar<T> { field: T } // @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ // "impl Foo for Bar<u8>" impl Foo for Bar<u8> {} // @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ // "impl F...
// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ // "impl Foo for foo::mod1::Baz" impl Foo for mod1::Baz {} // @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ // "impl<'a> Foo for &'a foo::mod2::Baz" impl<'a> Foo for &'a mod2::Baz {}
pub mod mod2 { pub enum Baz {} }
random_line_split
impl-disambiguation.rs
#![crate_name = "foo"] pub trait Foo {} pub struct
<T> { field: T } // @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ // "impl Foo for Bar<u8>" impl Foo for Bar<u8> {} // @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header in-band"]' \ // "impl Foo for Bar<u16>" impl Foo for Bar<u16> {} // @has foo/tr...
Bar
identifier_name
initialization.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 in ...
() -> lsp_types::ServerCapabilities { let options = lsp_types::TextDocumentSyncOptions { open_close: Some(true), change: Some(lsp_types::TextDocumentSyncKind::FULL), will_save: None, will_save_wait_until: None, save: None, }; let text_document_sync = lsp_types::TextD...
create_server_capabilities
identifier_name
initialization.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 in ...
let capabilities = create_server_capabilities(); let res = lsp_types::InitializeResult { capabilities: capabilities, server_info: Some(lsp_types::ServerInfo { name: "mojom-lsp".to_string(), version: Some("0.1.0".to_string()), }), }; write_success_result(wr...
{ use lsp_types::notification::Notification; use lsp_types::request::Request; let message = read_message(reader)?; let (id, params) = match message { Message::Request(req) => { if req.method != lsp_types::request::Initialize::METHOD { let error_message = anyhow!("Exp...
identifier_body
initialization.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 in ...
// limitations under the License. use std::io::{BufRead, Write}; use anyhow::anyhow; use super::protocol::{read_message, write_success_result, Message}; fn create_server_capabilities() -> lsp_types::ServerCapabilities { let options = lsp_types::TextDocumentSyncOptions { open_close: Some(true), c...
random_line_split
initialization.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 in ...
_ => { let error_message = anyhow!("Expected initialized message but got {:?}", message); return Err(error_message); } }; Ok(params) }
{ if notif.method != lsp_types::notification::Initialized::METHOD { let error_message = anyhow!("Expected initialized message but got {:?}", notif.method); return Err(error_message); } }
conditional_block
lineformat.rs
// _ _ // | |_| |__ ___ ___ __ _ // | __| '_ \ / _ \/ __/ _` | // | |_| | | | __/ (_| (_| | // \__|_| |_|\___|\___\__,_| // // licensed under the MIT license <http://opensource.org/licenses/MIT> // // lineformat.rs // definition of LineFormat, it looks at all the notes provided and // t...
.max_by(|n| n.id.to_string().len()) { Some(w) => w.id.to_string().len(), None => 0 }; // if longest id is 1 char and we are using extended printing // then set id_width to 2 so "id" isn't truncated if line_format.id_width <...
{ // get termsize :> let console_width = termsize(); // set colsep let colsep = match condensed { true => 1, false => 2 }; let mut line_format = LineFormat { colsep: colsep, id_width:0, title_width:0, ...
identifier_body
lineformat.rs
// _ _ // | |_| |__ ___ ___ __ _ // | __| '_ \ / _ \/ __/ _` | // | |_| | | | __/ (_| (_| | // \__|_| |_|\___|\___\__,_| // // licensed under the MIT license <http://opensource.org/licenses/MIT> // // lineformat.rs // definition of LineFormat, it looks at all the notes provided and // t...
Some(n) => match n.body.is_empty() || search { true => n.title.len(), false => n.title.len()+4 }, None => 0 }; // if using extended and longest title is less than 5 chars // set title_width to 5 so "title" won't be truncated ...
.max_by(|n| match n.body.len() > 0 { true => n.title.len()+4, false => n.title.len() }) {
random_line_split
lineformat.rs
// _ _ // | |_| |__ ___ ___ __ _ // | __| '_ \ / _ \/ __/ _` | // | |_| | | | __/ (_| (_| | // \__|_| |_|\___|\___\__,_| // // licensed under the MIT license <http://opensource.org/licenses/MIT> // // lineformat.rs // definition of LineFormat, it looks at all the notes provided and // t...
(&self) -> usize { let columns = match self.status_width == 0 { true => 2*self.colsep, false => 3*self.colsep }; self.id_width+self.title_width+self.status_width+self.touched_width+columns } }
line_width
identifier_name
js.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::utils::{Reflector, Reflectable}; use dom::window::Window; use js::jsapi::JSContext; use layout_...
} impl<T: Reflectable> Reflectable for JS<T> { fn reflector<'a>(&'a self) -> &'a Reflector { self.get().reflector() } fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector { self.get_mut().mut_reflector() } } impl<T> JS<T> { pub fn get<'a>(&'a self) -> &'a T { let borro...
{ let TrustedNodeAddress(addr) = inner; JS { ptr: RefCell::new(addr as *mut T) } }
identifier_body
js.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::utils::{Reflector, Reflectable}; use dom::window::Window; use js::jsapi::JSContext; use layout_...
(inner: TrustedNodeAddress) -> JS<T> { let TrustedNodeAddress(addr) = inner; JS { ptr: RefCell::new(addr as *mut T) } } } impl<T: Reflectable> Reflectable for JS<T> { fn reflector<'a>(&'a self) -> &'a Reflector { self.get().reflector() } fn mut_reflector<'a>...
from_trusted_node_address
identifier_name
js.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::utils::{Reflector, Reflectable}; use dom::window::Window; use js::jsapi::JSContext; use layout_...
cast::transmute_copy(self) } }
random_line_split
interface.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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>,...
} #[derive(PartialEq, Eq, Show)] pub enum Token { DoctypeToken(Doctype), TagToken(Tag), CommentToken(String), CharacterTokens(String), NullCharacterToken, EOFToken, ParseError(CowString<'static>), } /// Types which can receive tokens from the tokenizer. pub trait TokenSink { /// Proce...
{ if (self.kind != other.kind) || (self.name != other.name) { return false; } let mut self_attrs = self.attrs.clone(); let mut other_attrs = other.attrs.clone(); self_attrs.as_mut_slice().sort(); other_attrs.as_mut_slice().sort(); self_attrs == other...
identifier_body
interface.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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>,...
pub self_closing: bool, pub attrs: Vec<Attribute>, } impl Tag { /// Are the tags equivalent when we don't care about attribute order? /// Also ignores the self-closing flag. pub fn equiv_modulo_attr_order(&self, other: &Tag) -> bool { if (self.kind!= other.kind) || (self.name!= other.name) ...
random_line_split
interface.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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>,...
(&mut self) -> Option<states::State> { None } }
query_state_change
identifier_name
interface.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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>,...
let mut self_attrs = self.attrs.clone(); let mut other_attrs = other.attrs.clone(); self_attrs.as_mut_slice().sort(); other_attrs.as_mut_slice().sort(); self_attrs == other_attrs } } #[derive(PartialEq, Eq, Show)] pub enum Token { DoctypeToken(Doctype), TagToken(T...
{ return false; }
conditional_block
lib.rs
en(); let cap_names = self.vec_expr(self.names.as_slice().iter(), |cx, name| match *name { Some(ref name) => { let name = name.as_slice(); quote_expr!(cx, Some($name)) } None => cx.expr_none(self.sp), ...
} } } self.sparse[pc] = self.size; self.size += 1; } #[inline] fn add_empty(&mut self, pc: uint) { self.queue[self.size].pc = pc; self.sparse[pc] = self.size; self.size += 1; } ...
t.groups[1] = groups[1]; } Submatches => { for (slot, val) in t.groups.iter_mut().zip(groups.iter()) { *slot = *val;
random_line_split
lib.rs
add(&self, nlist: &mut Threads, pc: uint, groups: &mut Captures) { if nlist.contains(pc) { return } $add_insts } } struct Thread { pc: uint, groups: Captures, } struct Threads { which: MatchKind, ...
wild_arm_expr
identifier_name
lib.rs
sparse: [uint,..$num_insts], size: uint, } impl Threads { fn new(which: MatchKind) -> Threads { Threads { which: which, // These unsafe blocks are used for performance reasons, as it // gives us a zero-cost initialization of a spar...
{ ast::Arm { attrs: vec!(), pats: vec!(P(ast::Pat{ id: ast::DUMMY_NODE_ID, span: self.sp, node: ast::PatWild(ast::PatWildSingle), })), guard: None, body: body, } }
identifier_body
list-log-streams.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatchlogs::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS R...
let shared_config = aws_config::from_env().region(region_provider).load().await; let client = Client::new(&shared_config); show_log_streams(&client, &name).await }
{ println!(); println!("CloudWatchLogs client version: {}", PKG_VERSION); println!( "Region: {}", region_provider.region().await.unwrap().as_ref() ); println!("Log group name: {}", &name); println!(); }
conditional_block
list-log-streams.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatchlogs::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS R...
name.push_str(&group); if verbose { println!(); println!("CloudWatchLogs client version: {}", PKG_VERSION); println!( "Region: {}", region_provider.region().await.unwrap().as_ref() ); println!("Log group name: ...
{ let Opt { region, group, prefix, verbose, } = Opt::from_args(); if verbose { tracing_subscriber::fmt::init(); } let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() .or_else(Region::new("us-we...
identifier_body
list-log-streams.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatchlogs::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS R...
.log_group_name(name) .send() .await?; let streams = resp.log_streams().unwrap_or_default(); println!("Found {} streams:", streams.len()); for stream in streams { println!(" {}", stream.log_stream_name().unwrap_or_default()); } Ok(()) } // snippet-end:[cloudwatchlogs.r...
random_line_split
list-log-streams.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatchlogs::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS R...
() -> Result<(), Error> { let Opt { region, group, prefix, verbose, } = Opt::from_args(); if verbose { tracing_subscriber::fmt::init(); } let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() .or_e...
main
identifier_name
device.rs
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // // Portions Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. use std::result; /// ...
.unwrap_or_else(|e| { error!("Failed to add available descriptor {}: {}", head.index, e) }); } have_used } /// Walk the driver-provided TX queue buffers, package them up as vsock packets, and send them /// to the backend for processing. Re...
have_used = true; self.queues[RXQ_INDEX] .add_used(mem, head.index, used_len)
random_line_split
device.rs
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // // Portions Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. use std::result; /// ...
pub fn backend(&self) -> &B { &self.backend } /// Signal the guest driver that we've used some virtio buffers that it had previously made /// available. pub fn signal_used_queue(&self) -> result::Result<(), DeviceError> { debug!("vsock: raising IRQ"); self.irq_trigger ...
{ self.cid }
identifier_body
device.rs
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // // Portions Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. use std::result; /// ...
}; if self.backend.send_pkt(&pkt, mem).is_err() { self.queues[TXQ_INDEX].undo_pop(); break; } have_used = true; self.queues[TXQ_INDEX] .add_used(mem, head.index, 0) .unwrap_or_else(|e| { ...
{ error!("vsock: error reading TX packet: {:?}", e); have_used = true; self.queues[TXQ_INDEX] .add_used(mem, head.index, 0) .unwrap_or_else(|e| { error!("Failed to add available descri...
conditional_block
device.rs
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // // Portions Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. use std::result; /// ...
(cid: u64, backend: B) -> super::Result<Vsock<B>> { let queues: Vec<VirtQueue> = defs::QUEUE_SIZES .iter() .map(|&max_size| VirtQueue::new(max_size)) .collect(); Self::with_queues(cid, backend, queues) } pub fn id(&self) -> &str { defs::VSOCK_DEV_ID ...
new
identifier_name
pool.rs
use memory::bucket::Bucket; use memory::bucket::BUCKET_PAGES; use memory::heap::Heap; use memory::heapbucket::HeapBucket; use memory::page::Page; use memory::page::PAGE_SIZE; use std::alloc::alloc; use std::alloc::dealloc; use std::alloc::Layout; use std::mem::size_of; use std::ptr::null_mut; use std::usize::MAX; pub ...
(&mut self) { if self.map!= MAX { panic!("Pool is not empty!") } unsafe { // println!( // "Pool: dealloc {:X}", // Page::get(self as *const Pool as usize) as usize // ); dealloc( Page::get(self as *co...
deallocate
identifier_name
pool.rs
use memory::bucket::Bucket; use memory::bucket::BUCKET_PAGES; use memory::heap::Heap; use memory::heapbucket::HeapBucket; use memory::page::Page; use memory::page::PAGE_SIZE; use std::alloc::alloc; use std::alloc::dealloc; use std::alloc::Layout; use std::mem::size_of; use std::ptr::null_mut; use std::usize::MAX; pub ...
let position = Bucket::find_least_position(self.map); // println!("Pool least position: {}.", position); pool_page_address + PAGE_SIZE * BUCKET_PAGES * (position - 1) }; // println!("Bucket page address: {:X}.", bucket_page_address); let bucket = (bucket_page_...
} let pool_page_address = Page::get(self as *const Pool as usize) as usize; // println!("Pool page address: {:X}.", pool_page_address); let bucket_page_address = {
random_line_split
pool.rs
use memory::bucket::Bucket; use memory::bucket::BUCKET_PAGES; use memory::heap::Heap; use memory::heapbucket::HeapBucket; use memory::page::Page; use memory::page::PAGE_SIZE; use std::alloc::alloc; use std::alloc::dealloc; use std::alloc::Layout; use std::mem::size_of; use std::ptr::null_mut; use std::usize::MAX; pub ...
pub fn mark_as_free(&mut self, page: usize) { let bit = self.get_allocation_bit(page); // println!("Pool bit to be marked as free: {:X}", bit); let old_map = self.map; self.map = self.map | bit; if old_map == 0 { unsafe { (*self.heap).mark_as_fre...
{ let bit = self.get_allocation_bit(page); // println!("Pool bit to be marked as full: {:X}", bit); self.map = self.map & !bit; }
identifier_body
pool.rs
use memory::bucket::Bucket; use memory::bucket::BUCKET_PAGES; use memory::heap::Heap; use memory::heapbucket::HeapBucket; use memory::page::Page; use memory::page::PAGE_SIZE; use std::alloc::alloc; use std::alloc::dealloc; use std::alloc::Layout; use std::mem::size_of; use std::ptr::null_mut; use std::usize::MAX; pub ...
} pub fn deallocate(&mut self) { if self.map!= MAX { panic!("Pool is not empty!") } unsafe { // println!( // "Pool: dealloc {:X}", // Page::get(self as *const Pool as usize) as usize // ); dealloc( ...
{ unsafe { (*self.heap).mark_as_free(self); } }
conditional_block
test.rs
// Copyright 2014 Tyler Neely // // 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 in writ...
let writeopts = rocksdb_writeoptions_create(); assert!(!writeopts.is_null()); let key = b"name\x00"; let val = b"spacejam\x00"; rocksdb_put(db, writeopts.clone(), key.as_ptr() as *const c_char, 4, va...
{ unsafe { let opts = rocksdb_options_create(); assert!(!opts.is_null()); rocksdb_options_increase_parallelism(opts, 0); rocksdb_options_optimize_level_style_compaction(opts, 0); rocksdb_options_set_create_if_missing(opts, true as c_uchar); let rustpath = "_rust_roc...
identifier_body
test.rs
// Copyright 2014 Tyler Neely // // 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 in writ...
rocksdb_destroy_db(opts, cpath.as_ptr() as *const _, err_ptr); assert!(err.is_null()); } }
rocksdb_close(db);
random_line_split
test.rs
// Copyright 2014 Tyler Neely // // 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 in writ...
assert!(err.is_null()); let writeopts = rocksdb_writeoptions_create(); assert!(!writeopts.is_null()); let key = b"name\x00"; let val = b"spacejam\x00"; rocksdb_put(db, writeopts.clone(), key.as_ptr() as *const c_char, ...
{ println!("failed to open rocksdb: {}", error_message(err)); }
conditional_block
test.rs
// Copyright 2014 Tyler Neely // // 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 in writ...
() { unsafe { let opts = rocksdb_options_create(); assert!(!opts.is_null()); rocksdb_options_increase_parallelism(opts, 0); rocksdb_options_optimize_level_style_compaction(opts, 0); rocksdb_options_set_create_if_missing(opts, true as c_uchar); let rustpath = "_rust_...
internal
identifier_name
regions-copy-closure.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> { cl: Box<FnMut() + 'a>, } fn box_it<'a>(x: Box<FnMut() + 'a>) -> closure_box<'a> { closure_box {cl: x} } pub fn main() { let mut i = 3; assert_eq!(i, 3); { let cl = || i += 1; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let mut cl_box = box...
closure_box
identifier_name
regions-copy-closure.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let mut i = 3; assert_eq!(i, 3); { let cl = || i += 1; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let mut cl_box = box_it(Box::new(cl)); cl_box.cl.call_mut(()); } assert_eq!(i, 4); }
{ closure_box {cl: x} }
identifier_body
regions-copy-closure.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 ...
}
random_line_split
setext_header.rs
use regex::Regex; use parser::Block; use parser::Block::Header; use parser::span::parse_spans; pub fn parse_setext_header(lines: &[&str]) -> Option<(Block, usize)> { let HORIZONTAL_RULE_1 = Regex::new(r"^===+$").unwrap(); let HORIZONTAL_RULE_2 = Regex::new(r"^---+$").unwrap(); if lines.len() > 1 { ...
() { assert_eq!( parse_setext_header(&vec!["Test", "=========="]).unwrap(), (Header(vec![Text("Test".to_string())], 1), 2) ); assert_eq!( parse_setext_header(&vec!["Test", "----------"]).unwrap(), (Header(vec![Text("Test".to_string())], 2), 2) ...
finds_atx_header
identifier_name
setext_header.rs
use regex::Regex; use parser::Block; use parser::Block::Header; use parser::span::parse_spans; pub fn parse_setext_header(lines: &[&str]) -> Option<(Block, usize)> { let HORIZONTAL_RULE_1 = Regex::new(r"^===+$").unwrap(); let HORIZONTAL_RULE_2 = Regex::new(r"^---+$").unwrap(); if lines.len() > 1 { ...
(Header(vec![Text("Test".to_string())], 2), 2) ); assert_eq!( parse_setext_header(&vec!["This is a test", "==="]).unwrap(), (Header(vec![Text("This is a test".to_string())], 1), 2) ); assert_eq!( parse_setext_header(&vec!["This is a test"...
assert_eq!( parse_setext_header(&vec!["Test", "----------"]).unwrap(),
random_line_split
setext_header.rs
use regex::Regex; use parser::Block; use parser::Block::Header; use parser::span::parse_spans; pub fn parse_setext_header(lines: &[&str]) -> Option<(Block, usize)> { let HORIZONTAL_RULE_1 = Regex::new(r"^===+$").unwrap(); let HORIZONTAL_RULE_2 = Regex::new(r"^---+$").unwrap(); if lines.len() > 1 { ...
} }
{ assert_eq!( parse_setext_header(&vec!["Test", "=========="]).unwrap(), (Header(vec![Text("Test".to_string())], 1), 2) ); assert_eq!( parse_setext_header(&vec!["Test", "----------"]).unwrap(), (Header(vec![Text("Test".to_string())], 2), 2) ...
identifier_body
timer.rs
use crate::sys; use libc::c_void; use std::marker::PhantomData; use std::mem; use crate::TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer is dropped ...
_marker: PhantomData<&'b ()>, } impl<'b, 'a> Timer<'b, 'a> { /// Returns the closure as a trait-object and cancels the timer /// by consuming it... pub fn into_inner(mut self) -> TimerCallback<'a> { *self.callback.take().unwrap() } } impl<'b, 'a> Drop for Timer<'b, 'a> { #[inline] ...
pub struct Timer<'b, 'a> { callback: Option<Box<TimerCallback<'a>>>, raw: sys::SDL_TimerID,
random_line_split