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
job.rs
use std::collections::HashSet; use std::net::SocketAddr; use std::time; use crate::control::cio; use crate::torrent::Torrent; use crate::util::UHashMap; pub trait Job<T: cio::CIO> { fn update(&mut self, torrents: &mut UHashMap<Torrent<T>>); } pub struct TrackerUpdate; impl<T: cio::CIO> Job<T> for TrackerUpdate ...
impl<T: cio::CIO> Job<T> for SessionUpdate { fn update(&mut self, torrents: &mut UHashMap<Torrent<T>>) { for (_, torrent) in torrents.iter_mut() { if torrent.dirty() { torrent.serialize(); } } } } pub struct TorrentTxUpdate { piece_update: time::Inst...
random_line_split
job.rs
use std::collections::HashSet; use std::net::SocketAddr; use std::time; use crate::control::cio; use crate::torrent::Torrent; use crate::util::UHashMap; pub trait Job<T: cio::CIO> { fn update(&mut self, torrents: &mut UHashMap<Torrent<T>>); } pub struct TrackerUpdate; impl<T: cio::CIO> Job<T> for TrackerUpdate ...
{ piece_update: time::Instant, active: UHashMap<bool>, } impl TorrentTxUpdate { pub fn new() -> TorrentTxUpdate { TorrentTxUpdate { piece_update: time::Instant::now(), active: UHashMap::default(), } } } impl<T: cio::CIO> Job<T> for TorrentTxUpdate { fn upda...
TorrentTxUpdate
identifier_name
2_4_1_a.rs
/* 2.4.6: a) S -> + S S | - S S | a $> rustc -o parser 2_4_1_a.rs $>./parser */ static CODE: &'static str = "-+aa-aa"; pub fn sa(mut head: i32) -> i32
fn main() { let head = sa(0); if head as usize!= CODE.len() { panic!("parsed {} chars, but totally {} chars", head, CODE.len()); } }
{ match CODE.chars().nth(head as usize){ None => { panic!("missing required element!"); }, Some('a') => { head += 1; }, Some('+') | Some('-') => { head += 1; head = sa(head); head = sa(head); }, _ => ...
identifier_body
2_4_1_a.rs
/* 2.4.6: a) S -> + S S | - S S | a $> rustc -o parser 2_4_1_a.rs $>./parser */ static CODE: &'static str = "-+aa-aa"; pub fn sa(mut head: i32) -> i32 { match CODE.chars().nth(head as usize){ None => { panic!("missing required element!"); }, Some('a') => { ...
}
{ panic!("parsed {} chars, but totally {} chars", head, CODE.len()); }
conditional_block
2_4_1_a.rs
/* 2.4.6: a) S -> + S S | - S S | a $> rustc -o parser 2_4_1_a.rs $>./parser */ static CODE: &'static str = "-+aa-aa"; pub fn sa(mut head: i32) -> i32 { match CODE.chars().nth(head as usize){ None => { panic!("missing required element!"); }, Some('a') => { ...
() { let head = sa(0); if head as usize!= CODE.len() { panic!("parsed {} chars, but totally {} chars", head, CODE.len()); } }
main
identifier_name
2_4_1_a.rs
/* 2.4.6: a) S -> + S S | - S S | a $> rustc -o parser 2_4_1_a.rs $>./parser */ static CODE: &'static str = "-+aa-aa"; pub fn sa(mut head: i32) -> i32 { match CODE.chars().nth(head as usize){ None => { panic!("missing required element!"); }, Some('a') => { ...
}, _ => { panic!("undefind element!"); } } head } fn main() { let head = sa(0); if head as usize!= CODE.len() { panic!("parsed {} chars, but totally {} chars", head, CODE.len()); } }
random_line_split
error.rs
use std::{error, fmt, str}; use string::SafeString;
pub struct Error { desc: SafeString, } impl Error { /// Creates a new Error. pub fn new(desc: &str) -> Error { Self { desc: SafeString::from(desc), } } } impl fmt::Debug for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Error: {}", er...
/// An error object. #[repr(C)] #[derive(Clone, PartialEq)]
random_line_split
error.rs
use std::{error, fmt, str}; use string::SafeString; /// An error object. #[repr(C)] #[derive(Clone, PartialEq)] pub struct Error { desc: SafeString, } impl Error { /// Creates a new Error. pub fn new(desc: &str) -> Error { Self { desc: SafeString::from(desc), } } } impl fm...
() { let msg = "out of bounds"; let err = Error::new(msg); assert_eq!(error::Error::description(&err), msg); } }
description
identifier_name
task.rs
use std::collections::HashMap; use std::str::FromStr; use author::Author; #[derive(Debug)] pub struct Task { pub task_type: String, pub id: u32, pub title: String, description: Option<String>, assignees: Vec<Author>, properties: HashMap<String, String>, } impl Task { pub fn new(lines: &Ve...
else { let index = subject.find(id_str).unwrap(); subject[index + id_str.len() + 1..].trim().to_string() }; Task { id: id, title: title, task_type: task_type, description: None, assignees: Vec::new(), ...
{ let index = subject.find('-').unwrap(); subject[index + 1..].trim().to_string() }
conditional_block
task.rs
use std::collections::HashMap; use std::str::FromStr; use author::Author; #[derive(Debug)] pub struct Task { pub task_type: String, pub id: u32, pub title: String, description: Option<String>, assignees: Vec<Author>, properties: HashMap<String, String>, } impl Task { pub fn new(lines: &Ve...
title: title, task_type: task_type, description: None, assignees: Vec::new(), properties: HashMap::new(), } } }
{ let subject = lines[0][4..].to_string(); let words: Vec<&str> = lines[0][4..].split_whitespace().collect(); let task_type = words[0].to_string(); let id_str = words[1]; let id: u32 = FromStr::from_str(id_str).unwrap(); let title = if words[2] == "-" { ...
identifier_body
task.rs
use std::collections::HashMap; use std::str::FromStr; use author::Author; #[derive(Debug)] pub struct Task { pub task_type: String, pub id: u32, pub title: String, description: Option<String>, assignees: Vec<Author>, properties: HashMap<String, String>, } impl Task { pub fn
(lines: &Vec<&str>) -> Task { let subject = lines[0][4..].to_string(); let words: Vec<&str> = lines[0][4..].split_whitespace().collect(); let task_type = words[0].to_string(); let id_str = words[1]; let id: u32 = FromStr::from_str(id_str).unwrap(); let title = ...
new
identifier_name
task.rs
use std::collections::HashMap; use std::str::FromStr; use author::Author; #[derive(Debug)] pub struct Task { pub task_type: String, pub id: u32, pub title: String, description: Option<String>, assignees: Vec<Author>, properties: HashMap<String, String>, } impl Task { pub fn new(lines: &Ve...
Task { id: id, title: title, task_type: task_type, description: None, assignees: Vec::new(), properties: HashMap::new(), } } }
subject[index + 1..].trim().to_string() } else { let index = subject.find(id_str).unwrap(); subject[index + id_str.len() + 1..].trim().to_string() };
random_line_split
struct-return.rs
// Copyright 2012-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-MI...
() { unsafe { let f = Floats { a: 1.234567890e-15_f64, b: 0b_1010_1010_u8, c: 1.0987654321e-15_f64 }; let ff = rustrt::rust_dbg_abi_2(f); println!("a: {}", ff.a as f64); println!("b: {}", ff.b as uint); println!("c: {}", ff.c as f64); ...
test2
identifier_name
struct-return.rs
// Copyright 2012-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-MI...
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] fn test2() { unsafe { let f = Floats { a: 1.234567890e-15_f64, b: 0b_1010_1010_u8, c: 1.0987654321e-15_f64 }; let ff = rustrt::rust_dbg_abi_2(f); println!("a: {}", ff.a as f64); println!(...
{ unsafe { let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa_u64, b: 0xbbbb_bbbb_bbbb_bbbb_u64, c: 0xcccc_cccc_cccc_cccc_u64, d: 0xdddd_dddd_dddd_dddd_u64 }; let qq = rustrt::rust_dbg_abi_1(q); println!("a: {:x}", qq.a as uint); println!("b: {...
identifier_body
struct-return.rs
// Copyright 2012-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-MI...
b: 0b_1010_1010_u8, c: 1.0987654321e-15_f64 }; let ff = rustrt::rust_dbg_abi_2(f); println!("a: {}", ff.a as f64); println!("b: {}", ff.b as uint); println!("c: {}", ff.c as f64); assert_eq!(ff.a, f.c + 1.0f64); assert_eq!(ff.b, 0xff_u8);...
random_line_split
ray.rs
use std::f32; use linalg::{Point, Vector}; /// Ray is a standard 3D ray, starting at origin `o` and heading in direction `d` /// The min and max points along the ray can be specified with `min_t` and `max_t` /// `depth` is the recursion depth of the ray #[derive(Debug, Copy, Clone, PartialEq)] pub struct Ray { //...
/// Create a child ray from the parent starting at `o` and heading in `d` pub fn child(&self, o: &Point, d: &Vector) -> Ray { Ray { o: *o, d: *d, min_t: 0f32, max_t: f32::INFINITY, depth: self.depth + 1 } } /// Create a child ray segment from `o + min_t * d` to `o + max_t * d` pub fn child_...
{ Ray { o: *o, d: *d, min_t: min_t, max_t: max_t, depth: 0} }
identifier_body
ray.rs
use std::f32; use linalg::{Point, Vector}; /// Ray is a standard 3D ray, starting at origin `o` and heading in direction `d` /// The min and max points along the ray can be specified with `min_t` and `max_t` /// `depth` is the recursion depth of the ray #[derive(Debug, Copy, Clone, PartialEq)] pub struct
{ /// Origin of the ray pub o: Point, /// Direction the ray is heading pub d: Vector, /// Point along the ray that the actual ray starts at, `p = o + min_t * d` pub min_t: f32, /// Point along the ray at which it stops, will be inf if the ray is infinite pub max_t: f32, /// Recursio...
Ray
identifier_name
ray.rs
use std::f32; use linalg::{Point, Vector};
/// Ray is a standard 3D ray, starting at origin `o` and heading in direction `d` /// The min and max points along the ray can be specified with `min_t` and `max_t` /// `depth` is the recursion depth of the ray #[derive(Debug, Copy, Clone, PartialEq)] pub struct Ray { /// Origin of the ray pub o: Point, //...
random_line_split
lint-shorthand-field.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 Foo { x: x, //~ ERROR the `x:` in this pattern is redundant y: ref y, //~ ERROR the `y:` in this pattern is redundant } = Foo { x: 0, y: 0 }; let Foo { x, ref y, } = Foo { x: 0, y: 0 }; } { const x: i...
x: isize, y: isize, }
random_line_split
lint-shorthand-field.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 ...
{ x: Foo, } enum Foo { x } match (Bar { x: Foo::x }) { Bar { x: Foo::x } => {}, } } }
Bar
identifier_name
testcaselinkedlistsource0.rs
use List::*; enum List { // Cons: Un tuple contenant un élément(i.e. u32) et un pointeur vers le noeud suivant (i.e. Box<List>). Cons(u32, Box<List>), // Nil: Un noeud témoignant de la fin de la liste. Nil, } // Il est possible de lier, d'implémenter des méthodes // pour une énumération. impl List { ...
32) -> List { // `Cons` est également une variante de `List`. Cons(elem, Box::new(self)) } // Renvoie la longueur de la liste. fn len(&self) -> u32 { // `self` doit être analysé car le comportement de cette méthode // dépend du type de variante auquel appartient `self`. ...
elem: u
identifier_name
testcaselinkedlistsource0.rs
use List::*; enum List { // Cons: Un tuple contenant un élément(i.e. u32) et un pointeur vers le noeud suivant (i.e. Box<List>). Cons(u32, Box<List>), // Nil: Un noeud témoignant de la fin de la liste. Nil, } // Il est possible de lier, d'implémenter des méthodes // pour une énumération. impl List { ...
Consomme, s'approprie la liste et renvoie une copie de cette même liste // avec un nouvel élément ajouté à la suite. fn prepend(self, elem: u32) -> List { // `Cons` est également une variante de `List`. Cons(elem, Box::new(self)) } // Renvoie la longueur de la liste. fn len(&self) ...
// `Nil` est une variante de `List`. Nil } //
identifier_body
testcaselinkedlistsource0.rs
use List::*; enum List { // Cons: Un tuple contenant un élément(i.e. u32) et un pointeur vers le noeud suivant (i.e. Box<List>). Cons(u32, Box<List>), // Nil: Un noeud témoignant de la fin de la liste. Nil, } // Il est possible de lier, d'implémenter des méthodes // pour une énumération. impl List { ...
fn stringify(&self) -> String { match *self { Cons(head, ref tail) => { // `format!` est équivalente à `println!` mais elle renvoie // une chaîne de caractères allouée dans le tas (wrapper) // plutôt que de l'afficher dans la console. ...
// (wrapper)
random_line_split
testcaselinkedlistsource0.rs
use List::*; enum List { // Cons: Un tuple contenant un élément(i.e. u32) et un pointeur vers le noeud suivant (i.e. Box<List>). Cons(u32, Box<List>), // Nil: Un noeud témoignant de la fin de la liste. Nil, } // Il est possible de lier, d'implémenter des méthodes // pour une énumération. impl List { ...
Nil") }, } } } fn main() { // Créé une liste vide. let mut list = List::new(); // On ajoute quelques éléments. list = list.prepend(1); list = list.prepend(2); list = list.prepend(3); // Affiche l'état définitif de la liste. println!("La linked list possède une ...
ente à `println!` mais elle renvoie // une chaîne de caractères allouée dans le tas (wrapper) // plutôt que de l'afficher dans la console. format!("{}, {}", head, tail.stringify()) }, Nil => { format!("
conditional_block
execute_brainfuck.rs
// http://rosettacode.org/wiki/Execute_Brain**** use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::stdin; use std::num::Wrapping; fn main() { let args: Vec<_> = env::args().collect(); if args.len() < 2 { println!("Usage: {} [path] (--debug)", args[0]...
else { print!("{}", val as char); } } ',' => { mem[ptr] = Wrapping(reader.next().unwrap().unwrap()); } _ => { /* ignore */ } } pc += 1; } }
{ println!("(BFDB) STDOUT: '{}'", val as char); // Intercept output }
conditional_block
execute_brainfuck.rs
// http://rosettacode.org/wiki/Execute_Brain**** use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::stdin; use std::num::Wrapping; fn main() { let args: Vec<_> = env::args().collect(); if args.len() < 2 { println!("Usage: {} [path] (--debug)", args[0]...
',' => { mem[ptr] = Wrapping(reader.next().unwrap().unwrap()); } _ => { /* ignore */ } } pc += 1; } }
} else { print!("{}", val as char); } }
random_line_split
execute_brainfuck.rs
// http://rosettacode.org/wiki/Execute_Brain**** use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::stdin; use std::num::Wrapping; fn
() { let args: Vec<_> = env::args().collect(); if args.len() < 2 { println!("Usage: {} [path] (--debug)", args[0]); return; } let src: Vec<char> = { let mut buf = String::new(); match File::open(&args[1]) { Ok(mut f) => { f.read_to_string(&mut buf).un...
main
identifier_name
execute_brainfuck.rs
// http://rosettacode.org/wiki/Execute_Brain**** use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::stdin; use std::num::Wrapping; fn main()
// Launch options let debug = args.contains(&"--debug".to_owned()); // One pass to find bracket pairs. let brackets: HashMap<usize, usize> = { let mut m = HashMap::new(); let mut scope_stack = Vec::new(); for (idx, ch) in src.iter().enumerate() { match ch { ...
{ let args: Vec<_> = env::args().collect(); if args.len() < 2 { println!("Usage: {} [path] (--debug)", args[0]); return; } let src: Vec<char> = { let mut buf = String::new(); match File::open(&args[1]) { Ok(mut f) => { f.read_to_string(&mut buf).unwra...
identifier_body
strict_and_lenient_forms.rs
#![feature(plugin, custom_derive)] #![plugin(rocket_codegen)] extern crate rocket; use rocket::request::{Form, LenientForm}; use rocket::http::RawStr; #[derive(FromForm)] struct
<'r> { field: &'r RawStr, } #[post("/strict", data = "<form>")] fn strict<'r>(form: Form<'r, MyForm<'r>>) -> String { form.get().field.as_str().into() } #[post("/lenient", data = "<form>")] fn lenient<'r>(form: LenientForm<'r, MyForm<'r>>) -> String { form.get().field.as_str().into() } mod strict_and_len...
MyForm
identifier_name
strict_and_lenient_forms.rs
#![feature(plugin, custom_derive)] #![plugin(rocket_codegen)] extern crate rocket; use rocket::request::{Form, LenientForm}; use rocket::http::RawStr; #[derive(FromForm)] struct MyForm<'r> { field: &'r RawStr, } #[post("/strict", data = "<form>")] fn strict<'r>(form: Form<'r, MyForm<'r>>) -> String { form.g...
let mut response = client.post("/lenient") .header(ContentType::Form) .body(format!("field={}&extra=whoops", FIELD_VALUE)) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.body_string(), Some(FIELD_VALUE.into())); } }
assert_eq!(response.status(), Status::Ok); assert_eq!(response.body_string(), Some(FIELD_VALUE.into()));
random_line_split
strict_and_lenient_forms.rs
#![feature(plugin, custom_derive)] #![plugin(rocket_codegen)] extern crate rocket; use rocket::request::{Form, LenientForm}; use rocket::http::RawStr; #[derive(FromForm)] struct MyForm<'r> { field: &'r RawStr, } #[post("/strict", data = "<form>")] fn strict<'r>(form: Form<'r, MyForm<'r>>) -> String
#[post("/lenient", data = "<form>")] fn lenient<'r>(form: LenientForm<'r, MyForm<'r>>) -> String { form.get().field.as_str().into() } mod strict_and_lenient_forms_tests { use super::*; use rocket::local::Client; use rocket::http::{Status, ContentType}; const FIELD_VALUE: &str = "just_some_value"...
{ form.get().field.as_str().into() }
identifier_body
main.rs
fn main() { // demonstrate the Option<T> and Some let five = Some(5); let six = plus_one(five); let none = plus_one(None); println!("Five: {:?}", five); println!("Six: {:?}", six); println!("None: {:?}", none); // simpler syntax if you want to do something with // only one value (o...
else { println!("Found something different"); } } fn plus_one(x: Option<i32>) -> Option<i32> { // if no value, return none, otherwise return // the addition of the value plus one match x { None => None, Some(i) => Some(i + 1), } }
{ println!("Found 2"); }
conditional_block
main.rs
fn main() { // demonstrate the Option<T> and Some let five = Some(5); let six = plus_one(five); let none = plus_one(None); println!("Five: {:?}", five); println!("Six: {:?}", six); println!("None: {:?}", none); // simpler syntax if you want to do something with // only one value (o...
(x: Option<i32>) -> Option<i32> { // if no value, return none, otherwise return // the addition of the value plus one match x { None => None, Some(i) => Some(i + 1), } }
plus_one
identifier_name
main.rs
fn main()
} else { println!("Found something different"); } } fn plus_one(x: Option<i32>) -> Option<i32> { // if no value, return none, otherwise return // the addition of the value plus one match x { None => None, Some(i) => Some(i + 1), } }
{ // demonstrate the Option<T> and Some let five = Some(5); let six = plus_one(five); let none = plus_one(None); println!("Five: {:?}", five); println!("Six: {:?}", six); println!("None: {:?}", none); // simpler syntax if you want to do something with // only one value (one pattern...
identifier_body
type_resolver.rs
use std::iter; use crate::model; use crate::model::WithLoc; use crate::protobuf_path::ProtobufPath; use crate::pure::convert::WithFullName; use crate::FileDescriptorPair; use crate::ProtobufAbsPath; use crate::ProtobufAbsPathRef; use crate::ProtobufIdent; use crate::ProtobufIdentRef; use crate::ProtobufRelPath; use cr...
(&self) -> &'a [model::WithLoc<model::Message>] { match self { &LookupScope::File(file) => &file.messages, &LookupScope::Message(messasge, _) => &messasge.messages, } } fn find_message(&self, simple_name: &ProtobufIdentRef) -> Option<&'a model::Message> { self.me...
messages
identifier_name
type_resolver.rs
use std::iter; use crate::model; use crate::model::WithLoc; use crate::protobuf_path::ProtobufPath; use crate::pure::convert::WithFullName; use crate::FileDescriptorPair; use crate::ProtobufAbsPath; use crate::ProtobufAbsPathRef; use crate::ProtobufIdent; use crate::ProtobufIdentRef; use crate::ProtobufRelPath; use cr...
}
{ match name { ProtobufPath::Abs(name) => Ok(self.find_message_or_enum_by_abs_name(&name)?), ProtobufPath::Rel(name) => { // find message or enum in current package for p in scope.self_and_parents() { let mut fq = p.to_owned(); ...
identifier_body
type_resolver.rs
use std::iter; use crate::model; use crate::model::WithLoc; use crate::protobuf_path::ProtobufPath; use crate::pure::convert::WithFullName; use crate::FileDescriptorPair; use crate::ProtobufAbsPath; use crate::ProtobufAbsPathRef; use crate::ProtobufIdent; use crate::ProtobufIdentRef; use crate::ProtobufRelPath; use cr...
name: &ProtobufPath, ) -> anyhow::Result<WithFullName<MessageOrEnum>> { match name { ProtobufPath::Abs(name) => Ok(self.find_message_or_enum_by_abs_name(&name)?), ProtobufPath::Rel(name) => { // find message or enum in current package for p in ...
pub(crate) fn resolve_message_or_enum( &self, scope: &ProtobufAbsPathRef,
random_line_split
issue-888-enum-var-decl-jump.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] use self::super::root; pub mod Halide { #[allow(unused_imports)] use self::supe...
} #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum a { __bindgen_cannot_repr_c_on_empty_enum = 0, } }
{ assert_eq!( ::std::mem::size_of::<Type>(), 1usize, concat!("Size of: ", stringify!(Type)) ); assert_eq!( ::std::mem::align_of::<Type>(), 1usize, concat!("Alignment of ", stringify!(Type)...
identifier_body
issue-888-enum-var-decl-jump.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] use self::super::root; pub mod Halide { #[allow(unused_imports)] use self::supe...
() { assert_eq!( ::std::mem::size_of::<Type>(), 1usize, concat!("Size of: ", stringify!(Type)) ); assert_eq!( ::std::mem::align_of::<Type>(), 1usize, concat!("Alignment of ", stringify!(Ty...
bindgen_test_layout_Type
identifier_name
issue-888-enum-var-decl-jump.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] use self::super::root; pub mod Halide { #[allow(unused_imports)] use self::supe...
fn bindgen_test_layout_Type() { assert_eq!( ::std::mem::size_of::<Type>(), 1usize, concat!("Size of: ", stringify!(Type)) ); assert_eq!( ::std::mem::align_of::<Type>(), 1usize, con...
} #[test]
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/. */ #[cfg(not(target_os = "android"))] use std::env; use std::fs::File; use std::io::{self, Read}; use std::path::{Pat...
// FIXME: Find a way to not rely on the executable being // under `<servo source>[/$target_triple]/target/debug` // or `<servo source>[/$target_triple]/target/release`. let mut path = env::current_exe().expect("can't get exe path"); // Follow symlink path = path.canonicalize().expect("path doe...
{ return PathBuf::from(path); }
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/. */ #[cfg(not(target_os = "android"))] use std::env; use std::fs::File; use std::io::{self, Read}; use std::path::{Pat...
{ let mut path = resources_dir_path(); path.push(relative_path); let mut file = try!(File::open(&path)); let mut data = Vec::new(); try!(file.read_to_end(&mut data)); Ok(data) }
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/. */ #[cfg(not(target_os = "android"))] use std::env; use std::fs::File; use std::io::{self, Read}; use std::path::{Pat...
pub fn read_resource_file<P: AsRef<Path>>(relative_path: P) -> io::Result<Vec<u8>> { let mut path = resources_dir_path(); path.push(relative_path); let mut file = try!(File::open(&path)); let mut data = Vec::new(); try!(file.read_to_end(&mut data)); Ok(data) }
*dir = Some(path.to_str().unwrap().to_owned()); path }
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/. */ #[cfg(not(target_os = "android"))] use std::env; use std::fs::File; use std::io::{self, Read}; use std::path::{Pat...
() -> PathBuf { let mut dir = CMD_RESOURCE_DIR.lock().unwrap(); if let Some(ref path) = *dir { return PathBuf::from(path); } // FIXME: Find a way to not rely on the executable being // under `<servo source>[/$target_triple]/target/debug` // or `<servo source>[/$target_triple]/target/re...
resources_dir_path
identifier_name
action.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::error::*; use anyhow::Result; use log::{error, info}; use std::path::Path; use std::process::{Command, Stdio}; use std::time::Inst...
} Ok(()) } }
{ info!("{} Cloud Sync was successful", sid); return Ok(()); }
conditional_block
action.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::error::*; use anyhow::Result; use log::{error, info}; use std::path::Path; use std::process::{Command, Stdio}; use std::time::Inst...
info!( "{} Fire `hg cloud sync` attempt {}, spawned process id '{}'", sid, i, child.id() ); let output = child.wait_with_output()?; info!( "{} stdout: \n{}", sid, ...
{ let mut workspace_args = vec!["--raw-workspace-name".to_owned(), workspace]; if let Some(version) = version { workspace_args.append(&mut vec![ "--workspace-version".to_owned(), version.to_string(), ]); } for i in 0..retries { ...
identifier_body
action.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::error::*; use anyhow::Result; use log::{error, info};
use std::path::Path; use std::process::{Command, Stdio}; use std::time::Instant; pub struct CloudSyncTrigger; impl CloudSyncTrigger { pub fn fire<P: AsRef<Path>>( sid: &String, path: P, retries: u32, version: Option<u64>, workspace: String, ) -> Result<()> { let...
random_line_split
action.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use crate::error::*; use anyhow::Result; use log::{error, info}; use std::path::Path; use std::process::{Command, Stdio}; use std::time::Inst...
<P: AsRef<Path>>( sid: &String, path: P, retries: u32, version: Option<u64>, workspace: String, ) -> Result<()> { let mut workspace_args = vec!["--raw-workspace-name".to_owned(), workspace]; if let Some(version) = version { workspace_args.append(&m...
fire
identifier_name
guts.rs
// Copyright 2019 The CryptoCorrosion Contributors // Copyright 2020 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This...
#[inline(always)] fn pos64<M: Machine>(&self, m: M) -> u64 { let d: M::u32x4 = m.unpack(self.d); ((d.extract(1) as u64) << 32) | d.extract(0) as u64 } /// Produce 4 blocks of output, advancing the state #[inline(always)] pub fn refill4(&mut self, drounds: u32, out: &mut [u8; B...
{ init_chacha(key, nonce) }
identifier_body
guts.rs
// Copyright 2019 The CryptoCorrosion Contributors // Copyright 2020 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This...
let d3 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); pos = pos.wrapping_add(1); let d4 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); let (a, b, c, d) = ( x.a.to_lanes(), x.b.to_lanes(), x.c.to_lanes(), x.d.to_lanes(), ); let sb = m.unpack(...
pos = pos.wrapping_add(1); let d1 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); pos = pos.wrapping_add(1); let d2 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); pos = pos.wrapping_add(1);
random_line_split
guts.rs
// Copyright 2019 The CryptoCorrosion Contributors // Copyright 2020 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This...
(&mut self, drounds: u32, out: &mut [u8; BUFSZ]) { refill_wide(self, drounds, out) } #[inline(always)] pub fn set_stream_param(&mut self, param: u32, value: u64) { set_stream_param(self, param, value) } #[inline(always)] pub fn get_stream_param(&self, param: u32) -> u64 { ...
refill4
identifier_name
rt.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
pub fn error_trap_push() { unsafe { ffi::gdk_error_trap_push() } } pub fn error_trap_pop() { unsafe { ffi::gdk_error_trap_pop() } } pub fn error_trap_pop_ignored() { unsafe { ffi::gdk_error_trap_pop_ignored() } }
unsafe { ffi::gdk_flush() } }
identifier_body
rt.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
unsafe { FromGlibPtr::borrow( ffi::gdk_get_display_arg_name()) } } pub fn notify_startup_complete() { unsafe { ffi::gdk_notify_startup_complete() } } pub fn notify_startup_complete_with_id(startup_id: &str) { unsafe { ffi::gdk_notify_startup_complete_with_id(startup_id.borr...
pub fn get_display_arg_name() -> Option<String> {
random_line_split
rt.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
{ unsafe { ffi::gdk_error_trap_pop() } } pub fn error_trap_pop_ignored() { unsafe { ffi::gdk_error_trap_pop_ignored() } }
ror_trap_pop()
identifier_name
operands.rs
// This example shows how to get operands details.
use capstone_rust::capstone as cs; fn main() { // Buffer of code. let code = vec![0x01, 0xc0, 0x33, 0x19, 0x66, 0x83, 0xeb, 0x0a, 0xe8, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x5c, 0xca, 0xfd]; let dec = cs::Capstone::new(cs::cs_arch::CS_ARCH_X86, cs::cs_mode::CS_MODE_32).unwrap(); // Enab...
extern crate capstone_rust;
random_line_split
operands.rs
// This example shows how to get operands details. extern crate capstone_rust; use capstone_rust::capstone as cs; fn
() { // Buffer of code. let code = vec![0x01, 0xc0, 0x33, 0x19, 0x66, 0x83, 0xeb, 0x0a, 0xe8, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x5c, 0xca, 0xfd]; let dec = cs::Capstone::new(cs::cs_arch::CS_ARCH_X86, cs::cs_mode::CS_MODE_32).unwrap(); // Enable detail mode. This is needed if you want t...
main
identifier_name
operands.rs
// This example shows how to get operands details. extern crate capstone_rust; use capstone_rust::capstone as cs; fn main()
// Get the current operand. let op: cs::cs_x86_op = arch.operands[i as usize]; match op.type_ { cs::x86_op_type::X86_OP_REG => { let reg: &cs::x86_reg = op.reg(); println!(" Register operand: {}", dec.r...
{ // Buffer of code. let code = vec![0x01, 0xc0, 0x33, 0x19, 0x66, 0x83, 0xeb, 0x0a, 0xe8, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x5c, 0xca, 0xfd]; let dec = cs::Capstone::new(cs::cs_arch::CS_ARCH_X86, cs::cs_mode::CS_MODE_32).unwrap(); // Enable detail mode. This is needed if you want to g...
identifier_body
macros.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 file = try!(File::create("my_best_friends.txt")); /// try!(file.write_all(b"This is a list of my best friends.")); /// println!("I wrote to the file"); /// Ok(()) /// } /// // This is equivalent to: /// fn write_to_file_using_match() -> Result<(), io::Error> { /// let mut file = try!(Fil...
/// use std::fs::File; /// use std::io::prelude::*; /// /// fn write_to_file_using_try() -> Result<(), io::Error> {
random_line_split
edit_message_reply_markup.rs
use crate::requests::*; use crate::types::*; /// Use this method to edit only the reply markup of messages sent by the bot. #[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)] #[must_use = "requests do nothing unless sent"] pub struct EditMessageReplyMarkup { chat_id: ChatRef, message_id: MessageId, ...
} impl EditMessageReplyMarkup { pub fn new<C, M, R>(chat: C, message_id: M, reply_markup: Option<R>) -> Self where C: ToChatRef, M: ToMessageId, R: Into<ReplyMarkup>, { EditMessageReplyMarkup { chat_id: chat.to_chat_ref(), message_id: message_id.to_m...
{ Self::Type::serialize(RequestUrl::method("editMessageReplyMarkup"), self) }
identifier_body
edit_message_reply_markup.rs
use crate::requests::*; use crate::types::*; /// Use this method to edit only the reply markup of messages sent by the bot. #[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)] #[must_use = "requests do nothing unless sent"] pub struct
{ chat_id: ChatRef, message_id: MessageId, #[serde(skip_serializing_if = "Option::is_none")] reply_markup: Option<ReplyMarkup>, } impl Request for EditMessageReplyMarkup { type Type = JsonRequestType<Self>; type Response = JsonIdResponse<Message>; fn serialize(&self) -> Result<HttpRequest...
EditMessageReplyMarkup
identifier_name
edit_message_reply_markup.rs
use crate::requests::*; use crate::types::*; /// Use this method to edit only the reply markup of messages sent by the bot. #[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)] #[must_use = "requests do nothing unless sent"] pub struct EditMessageReplyMarkup { chat_id: ChatRef, message_id: MessageId, ...
{ EditMessageReplyMarkup::new(self.to_source_chat(), self.to_message_id(), reply_markup) } }
random_line_split
push_error.rs
// Copyright 2017 ThetaSinner // // This file is part of Osmium. // Osmium is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Osmi...
{ /// This error occurs when an attempt is made to create a new push promise but /// the allowed limit for concurrent promises has already been reached. TooManyActiveStreams }
PushError
identifier_name
push_error.rs
// Copyright 2017 ThetaSinner // // This file is part of Osmium. // Osmium is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Osmi...
}
random_line_split
data_loader.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value}; use mime_classifier::MIMEClassifier; use net_traits::Pro...
} // ";base64" must come at the end of the content type, per RFC 2397. // rust-http will fail to parse it because there's no =value part. let mut is_base64 = false; let mut ct_str = parts[0].to_owned(); if ct_str.ends_with(";base64") { is_base64 = true; let end_index = ct_str.le...
{ let url = load_data.url; assert!(&*url.scheme == "data"); // Split out content type and data. let mut scheme_data = match url.scheme_data { SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(), _ => panic!("Expected a non-relative scheme URL.") }; match url.query { ...
identifier_body
data_loader.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value}; use mime_classifier::MIMEClassifier; use net_traits::Pro...
} // Parse the content type using rust-http. // FIXME: this can go into an infinite loop! (rust-http #25) let mut content_type: Option<Mime> = ct_str.parse().ok(); if content_type == None { content_type = Some(Mime(TopLevel::Text, SubLevel::Plain, vec!((Attr...
ct_str = format!("text/plain{}", ct_str);
random_line_split
data_loader.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value}; use mime_classifier::MIMEClassifier; use net_traits::Pro...
(load_data: LoadData, senders: LoadConsumer, classifier: Arc<MIMEClassifier>) { // NB: we don't spawn a new task. // Hypothesis: data URLs are too small for parallel base64 etc. to be worth it. // Should be tested at some point. // Left in separate function to allow easy moving to a task, if desired. ...
factory
identifier_name
spsc_queue.rs
// Copyright 2017 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 smoke_bound() { unsafe { let q = Queue::with_additions(0, (), ()); q.push(1); q.push(2); assert_eq!(q.pop(), Some(1)); assert_eq!(q.pop(), Some(2)); assert_eq!(q.pop(), None); q.push(3); q.push(4...
{ unsafe { let q: Queue<Box<_>> = Queue::with_additions(0, (), ()); q.push(box 1); q.push(box 2); } }
identifier_body
spsc_queue.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
unsafe { // The `tail` node is not actually a used node, but rather a // sentinel from where we should start popping from. Hence, look at // tail's next field and see if we can use it. If we do a pop, then // the current tail node is a candidate for going into the...
} /// Attempts to pop a value from this queue. Remember that to use this type /// safely you must ensure that there is only one popper at a time. pub fn pop(&self) -> Option<T> {
random_line_split
spsc_queue.rs
// Copyright 2017 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) -> &ProducerAddition { &self.producer.addition } pub fn consumer_addition(&self) -> &ConsumerAddition { &self.consumer.addition } } impl<T, ProducerAddition, ConsumerAddition> Drop for Queue<T, ProducerAddition, ConsumerAddition> { fn drop(&mut self) { unsafe { ...
producer_addition
identifier_name
num.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `Finite<T>` struct. use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use num_traits::Float; use std::...
impl<T: Float> Finite<T> { /// Create a new `Finite<T: Float>` safely. pub fn new(value: T) -> Option<Finite<T>> { if value.is_finite() { Some(Finite(value)) } else { None } } /// Create a new `Finite<T: Float>`. #[inline] pub fn wrap(value: T) ->...
random_line_split
num.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `Finite<T>` struct. use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use num_traits::Float; use std::...
<T: Float>(T); impl<T: Float> Finite<T> { /// Create a new `Finite<T: Float>` safely. pub fn new(value: T) -> Option<Finite<T>> { if value.is_finite() { Some(Finite(value)) } else { None } } /// Create a new `Finite<T: Float>`. #[inline] pub fn w...
Finite
identifier_name
num.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `Finite<T>` struct. use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use num_traits::Float; use std::...
} impl<T: Float> Deref for Finite<T> { type Target = T; fn deref(&self) -> &T { let &Finite(ref value) = self; value } } impl<T: Float + MallocSizeOf> MallocSizeOf for Finite<T> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { (**self).size_of(ops) } } impl<T: F...
{ assert!(value.is_finite(), "Finite<T> doesn't encapsulate unrestricted value."); Finite(value) }
identifier_body
num.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `Finite<T>` struct. use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use num_traits::Float; use std::...
} /// Create a new `Finite<T: Float>`. #[inline] pub fn wrap(value: T) -> Finite<T> { assert!(value.is_finite(), "Finite<T> doesn't encapsulate unrestricted value."); Finite(value) } } impl<T: Float> Deref for Finite<T> { type Target = T; fn deref(&self) -...
{ None }
conditional_block
alloc_support.rs
// Copyright 2021 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 ...
<'frame>( self, storage: DroppingSlot<'frame, Self::Storage>, ) -> MoveRef<'frame, Self::Target> where Self: 'frame, { let cast = unsafe { Box::from_raw(Box::into_raw(self).cast::<MaybeUninit<T>>()) }; let (storage, drop_flag) = storage.put(cast); unsafe { MoveRef::new_unchecked(sto...
deref_move
identifier_name
alloc_support.rs
// Copyright 2021 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 uninit = Arc::new(MaybeUninit::<T>::uninit()); unsafe { let pinned = Pin::new_unchecked(&mut *(Arc::as_ptr(&uninit) as *mut _)); n.try_new(pinned)?; Ok(Pin::new_unchecked(Arc::from_raw( Arc::into_raw(uninit).cast::<T>(), ))) } }
identifier_body
alloc_support.rs
// Copyright 2021 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 ...
unsafe { Box::from_raw(Box::into_raw(self).cast::<MaybeUninit<T>>()) }; let (storage, drop_flag) = storage.put(cast); unsafe { MoveRef::new_unchecked(storage.assume_init_mut(), drop_flag) } } } impl<T> EmplaceUnpinned<T> for Pin<Box<T>> { fn try_emplace<N: TryNew<Output = T>>(n: N) -> Result<Self, N...
Self: 'frame, { let cast =
random_line_split
vscalefsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn
() { run_test(&Instruction { mnemonic: Mnemonic::VSCALEFSD, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM5)), operand3: Some(Direct(XMM2)), operand4: None, lock: false, rounding_mode: Some(RoundingMode::Zero), merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::K6), broadcast: None }, &[98,...
vscalefsd_1
identifier_name
vscalefsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vscalefsd_1() { run_test(&Instruction { mnemonic: Mnemonic::VSCALEFSD, operand1: Some(Direct(XMM6)), operand2: Some(Dir...
fn vscalefsd_2() { run_test(&Instruction { mnemonic: Mnemonic::VSCALEFSD, operand1: Some(Direct(XMM1)), operand2: Some(Direct(XMM7)), operand3: Some(Indirect(ECX, Some(OperandSize::Qword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::K...
random_line_split
vscalefsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vscalefsd_1()
fn vscalefsd_2() { run_test(&Instruction { mnemonic: Mnemonic::VSCALEFSD, operand1: Some(Direct(XMM1)), operand2: Some(Direct(XMM7)), operand3: Some(Indirect(ECX, Some(OperandSize::Qword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::...
{ run_test(&Instruction { mnemonic: Mnemonic::VSCALEFSD, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM5)), operand3: Some(Direct(XMM2)), operand4: None, lock: false, rounding_mode: Some(RoundingMode::Zero), merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::K6), broadcast: None }, &[98, 24...
identifier_body
fetch.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::find_root_manifest_for_cwd; #[derive(RustcDecodable)] struct
{ flag_manifest_path: Option<String>, flag_verbose: bool, flag_quiet: bool, flag_color: Option<String>, } pub const USAGE: &'static str = " Fetch dependencies of a package from the network. Usage: cargo fetch [options] Options: -h, --help Print this message --manifest-path ...
Options
identifier_name
fetch.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::find_root_manifest_for_cwd; #[derive(RustcDecodable)] struct Options { flag_manifest_path: Option<String>, flag_verbose: bool, flag_quiet: bool, flag_color: Option<String>, } pub const USAGE: &'static str...
{ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); try!(ops::fetch(&root, config).map_err(|e| { CliError::from...
identifier_body
fetch.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::find_root_manifest_for_cwd; #[derive(RustcDecodable)] struct Options { flag_manifest_path: Option<String>, flag_verbose: bool, flag_quiet: bool, flag_color: Option<String>, } pub const USAGE: &'static str...
available. The network is never touched after a `cargo fetch` unless the lockfile changes. If the lockfile is not available, then this is the equivalent of `cargo generate-lockfile`. A lockfile is generated and dependencies are also all updated. "; pub fn execute(options: Options, config: &Config) -> CliResult<Option...
--color WHEN Coloring: auto, always, never If a lockfile is available, this command will ensure that all of the git dependencies and/or registries dependencies are downloaded and locally
random_line_split
mod.rs
#![stable(feature = "futures_api", since = "1.36.0")] //! Asynchronous values. use crate::{ ops::{Generator, GeneratorState}, pin::Pin, ptr::NonNull, task::{Context, Poll}, }; mod future; mod into_future; mod pending; mod poll_fn; mod ready; #[stable(feature = "futures_api", since = "1.36.0")] pub u...
<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> { // SAFETY: the caller must guarantee that `cx.0` is a valid pointer // that fulfills all the requirements for a mutable reference. unsafe { &mut *cx.0.as_ptr().cast() } }
get_context
identifier_name
mod.rs
#![stable(feature = "futures_api", since = "1.36.0")] //! Asynchronous values. use crate::{ ops::{Generator, GeneratorState}, pin::Pin, ptr::NonNull, task::{Context, Poll}, }; mod future; mod into_future; mod pending; mod poll_fn; mod ready; #[stable(feature = "futures_api", since = "1.36.0")] pub u...
}
unsafe { &mut *cx.0.as_ptr().cast() }
random_line_split
mod.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
} /// A wrapper around std::stringstream to build a diagnostic. pub struct DiagnosticBuilder { /// The level. pub level: DiagnosticLevel, /// The span of the diagnostic. pub span: Span, /// The in progress message. pub message: String, } impl DiagnosticBuilder { pub fn new(level: Diagno...
{ DiagnosticBuilder::new(DiagnosticLevel::Help, span) }
identifier_body
mod.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
{ /// The level. pub level: DiagnosticLevel, /// The span of the diagnostic. pub span: Span, /// The in progress message. pub message: String, } impl DiagnosticBuilder { pub fn new(level: DiagnosticLevel, span: Span) -> DiagnosticBuilder { DiagnosticBuilder { level, ...
DiagnosticBuilder
identifier_name
mod.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Warning = 30, Note = 40, Help = 50, } /// A compiler diagnostic. #[repr(C)] #[derive(Object, Debug)] #[ref_name = "Diagnostic"] #[type_key = "Diagnostic"] pub struct DiagnosticNode { pub base: Object, /// The level. pub level: DiagnosticLevel, /// The span at which to report an error. p...
pub enum DiagnosticLevel { Bug = 10, Error = 20,
random_line_split
config.rs
#![allow(dead_code)] extern crate clap; use helper::Log; use self::clap::{Arg, App};
pub const APP_VERSION: &'static str = "1.0.34"; pub const MAX_API_VERSION: u32 = 1000; pub struct NodeConfig { pub value: u64, pub token: String, pub api_version: u32, pub network: NetworkingConfig, pub parent_address: String } pub struct NetworkingConfig { pub tcp_server_host: String, pu...
use std::process; use std::error::Error;
random_line_split
config.rs
#![allow(dead_code)] extern crate clap; use helper::Log; use self::clap::{Arg, App}; use std::process; use std::error::Error; pub const APP_VERSION: &'static str = "1.0.34"; pub const MAX_API_VERSION: u32 = 1000; pub struct NodeConfig { pub value: u64, pub token: String, pub api_version: u32, pub n...
{ pub tcp_server_host: String, pub concurrency: usize } pub fn parse_args() -> NodeConfig { let matches = App::new("TreeScale Node Service") .version(APP_VERSION) .author("TreeScale Inc. <hello@treescale.com>") .about("TreeScale technology endpoint ...
NetworkingConfig
identifier_name
coherence.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 ...
/// 1. All type parameters in `Self` must be "covered" by some local type constructor. /// 2. Some local type must appear in `Self`. pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>, impl_def_id: ast::DefId) -> Result<(), OrphanCheckErr<'tcx>> { debug!("orphan_check...
/// Checks the coherence orphan rules. `impl_def_id` should be the /// def-id of a trait impl. To pass, either the trait must be local, or else /// two conditions must be satisfied: ///
random_line_split
coherence.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 ...
<'tcx> { NoLocalInputType, UncoveredTy(Ty<'tcx>), } /// Checks the coherence orphan rules. `impl_def_id` should be the /// def-id of a trait impl. To pass, either the trait must be local, or else /// two conditions must be satisfied: /// /// 1. All type parameters in `Self` must be "covered" by some local type...
OrphanCheckErr
identifier_name
coherence.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 ...
infer::Misc(DUMMY_SP), a_trait_ref.to_poly_trait_ref(), b_trait_ref.to_poly_trait_ref()) { return false; } debug!("overlap: subtraitref check succeeded")...
{ debug!("overlap(a_def_id={}, b_def_id={})", a_def_id.repr(selcx.tcx()), b_def_id.repr(selcx.tcx())); let (a_trait_ref, a_obligations) = impl_trait_ref_and_oblig(selcx, a_def_id, ...
identifier_body
diverging_sub_expression.rs
#![warn(clippy::diverging_sub_expression)] #![allow(clippy::match_same_arms, clippy::logic_bug)] #[allow(clippy::empty_loop)] fn diverge() ->! { loop {} } struct A; impl A { fn foo(&self) ->! { diverge() } } #[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)...
_ => true || break, }; } }
3 => true || diverge(), 10 => match 42 { 99 => return, _ => true || panic!("boo"), },
random_line_split
diverging_sub_expression.rs
#![warn(clippy::diverging_sub_expression)] #![allow(clippy::match_same_arms, clippy::logic_bug)] #[allow(clippy::empty_loop)] fn diverge() ->! { loop {} } struct
; impl A { fn foo(&self) ->! { diverge() } } #[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)] fn main() { let b = true; b || diverge(); b || A.foo(); } #[allow(dead_code, unused_variables)] fn foobar() { loop { let x = match 5 { ...
A
identifier_name
diverging_sub_expression.rs
#![warn(clippy::diverging_sub_expression)] #![allow(clippy::match_same_arms, clippy::logic_bug)] #[allow(clippy::empty_loop)] fn diverge() ->!
struct A; impl A { fn foo(&self) ->! { diverge() } } #[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)] fn main() { let b = true; b || diverge(); b || A.foo(); } #[allow(dead_code, unused_variables)] fn foobar() { loop { let x = match ...
{ loop {} }
identifier_body
lzss.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use error::Error; const WINDOW_BITS: usize = 12; const LENGTH_BITS: usize = 4; cons...
const WINDOW_SIZE: usize = 1 << WINDOW_BITS; const HASHTAB_SIZE: usize = 1 << 10; /// Writer for LZSS compressed streams. pub struct Writer<W> { inner: W, window: [u8; WINDOW_SIZE], hashtab: [usize; HASHTAB_SIZE], position: usize, look_ahead_bytes: usize, out_flags: u8, out_count: usize,...
random_line_split
lzss.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use error::Error; const WINDOW_BITS: usize = 12; const LENGTH_BITS: usize = 4; cons...
(&mut self) -> io::Result<()> { let search_pos = self.position; let hsh = self.hash_at(search_pos); let match_pos = self.hashtab[hsh]; let ofs = if match_pos < self.position { self.position - match_pos } else { sel...
process
identifier_name
lzss.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use error::Error; const WINDOW_BITS: usize = 12; const LENGTH_BITS: usize = 4; cons...
#[test] fn compress_aaa() { cmp_test(b"aaaaaaaaa", &[128, 97, 96, 1]); } #[test] fn compress_abc() { cmp_test(b"abcdefgabcdefgabcabcabcdefg", &[254, 97, 98, 99, 100, 101, 102, 103, 128, 7, 0, 16, 10, 16, 3, 32, 20]); } fn decmp_test(com...
{ cmp_test(b"a", &[128, b'a']); }
identifier_body
lzss.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the // top-level directory of this distribution for license information. //! Simple implementation of an LZSS compressor. use std::io::{Read, Write, Bytes}; use std::io; use error::Error; const WINDOW_BITS: usize = 12; const LENGTH_BITS: usize = 4; cons...
else { self.process(output) } } } pub fn compress<R: Read, W: Write>(mut input: R, output: W) -> Result<W, Error> { let mut cw = Writer::new(output); try!(io::copy(&mut input, &mut cw)); try!(cw.flush()); Ok(cw.into_inner()) } pub fn decompress<R: Read, W: Write>(input: R, mut...
{ Ok(0) }
conditional_block
shader.rs
use vecmath::Matrix4; use gfx; use gfx::{Device, DeviceHelper, ToSlice}; use device; use device::draw::CommandBuffer; use render; static VERTEX: gfx::ShaderSource = shaders! { GLSL_120: b" #version 120 uniform mat4 projection, view; attribute vec2 tex_coord; attribute vec3 color, position; varyin...
Renderer { graphics: graphics, params: params, frame: frame, cd: gfx::ClearData { color: [0.81, 0.8, 1.0, 1.0], depth: 1.0, stencil: 0, }, prog: prog, drawstate: drawstate, ...
drawstate.primitive.front_face = gfx::state::Clockwise;
random_line_split