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
advapi32.rs
// Copyright © 2015, Peter Atashian // Licensed under the MIT License <LICENSE.md> #![feature(test)] #![cfg(windows)] extern crate advapi32; extern crate test; use advapi32::*; use test::black_box as bb; #[test] fn functions() {
bb(QueryServiceStatusEx); bb(RegCloseKey); bb(RegConnectRegistryA); bb(RegConnectRegistryW); bb(RegCopyTreeA); bb(RegCopyTreeW); bb(RegCreateKeyExA); bb(RegCreateKeyExW); bb(RegDeleteKeyA); bb(RegDeleteKeyExA); bb(RegDeleteKeyExW); bb(RegDeleteKeyValueA); bb(RegDelete...
bb(AdjustTokenPrivileges); bb(CloseServiceHandle); bb(ControlService); bb(CreateServiceA); bb(CreateServiceW); bb(CryptAcquireContextA); bb(CryptAcquireContextW); bb(CryptCreateHash); bb(CryptDestroyHash); bb(CryptGetHashParam); bb(CryptHashData); bb(CryptReleaseContext)...
identifier_body
advapi32.rs
// Copyright © 2015, Peter Atashian // Licensed under the MIT License <LICENSE.md> #![feature(test)] #![cfg(windows)] extern crate advapi32; extern crate test; use advapi32::*; use test::black_box as bb; #[test] fn functions() { bb(AdjustTokenPrivileges); bb(CloseServiceHandle); bb(ControlService); bb(C...
bb(RegQueryMultipleValuesA); bb(RegQueryMultipleValuesW); bb(RegQueryReflectionKey); bb(RegQueryValueExA); bb(RegQueryValueExW); bb(RegSetKeyValueA); bb(RegSetValueExA); bb(RegSetValueExW); bb(RegSetKeyValueW); bb(RegisterServiceCtrlHandlerA); bb(RegisterServiceCtrlHandlerExA...
bb(RegQueryInfoKeyA); bb(RegQueryInfoKeyW);
random_line_split
basic.rs
#![feature(core)] extern crate cql_ffi_safe; extern crate cql_ffi; use cql_ffi_safe::*; #[derive(Debug,Copy,PartialEq)] struct Basic { bln:bool, flt:f32, dbl:f64, i32:i32, i64:i64, } static INSERT_QUERY_CMD:&'static str = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?,?,?,?,...
future.wait(); try!(future.error_code()); Ok(()) } fn select_from_basic(session:&mut CassSession, key:&str) -> Result<Basic,CassError> { let query = SELECT_QUERY_CMD; let mut statement = CassStatement::new(query, 1); try!(statement.bind_string(0, key)); let result_iter = session.execute(sta...
I64(basic.i64) ))); let mut future = session.execute(statement);
random_line_split
basic.rs
#![feature(core)] extern crate cql_ffi_safe; extern crate cql_ffi; use cql_ffi_safe::*; #[derive(Debug,Copy,PartialEq)] struct
{ bln:bool, flt:f32, dbl:f64, i32:i32, i64:i64, } static INSERT_QUERY_CMD:&'static str = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?,?,?,?,?,?);"; static SELECT_QUERY_CMD:&'static str = "SELECT * FROM examples.basic WHERE key =?"; static CREATE_KEYSPACE_CMD:&'static str = ...
Basic
identifier_name
basic.rs
#![feature(core)] extern crate cql_ffi_safe; extern crate cql_ffi; use cql_ffi_safe::*; #[derive(Debug,Copy,PartialEq)] struct Basic { bln:bool, flt:f32, dbl:f64, i32:i32, i64:i64, } static INSERT_QUERY_CMD:&'static str = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?,?,?,?,...
} session.close().wait(); } } }
{ match CassCluster::new().set_contact_points(CONTACT_POINTS) { Err(err) => panic!("err: {:?}", err), Ok(cluster) => { let mut session = CassSession::new(); let input = Basic{bln:true, flt:0.001f32, dbl:0.0002f64, i32:1, i64:2 }; session.connect(cluster).wait(); ...
identifier_body
buffer.rs
use std::default::Default; #[derive(Default)] pub struct Cursor { x: u32, y: u32, } #[derive(Default)] pub struct Buffer { x: u32, y: u32, contents: Vec<String>, } impl Buffer { pub fn new() -> Buffer {Buffer{x: 0, y: 0, contents: vec![String::new()]}} pub fn insert(&mut self, character...
(&self) -> i32 {self.x as i32} pub fn get_y(&self) -> i32 {self.y as i32} pub fn get_contents(&self) -> String {self.contents.connect("\n")} pub fn insert_line(&mut self) { self.contents.insert(self.y as usize, String::new()); self.move_down(); } pub fn move_up(&mut self) { ...
get_x
identifier_name
buffer.rs
use std::default::Default; #[derive(Default)] pub struct Cursor { x: u32, y: u32, } #[derive(Default)] pub struct Buffer { x: u32, y: u32, contents: Vec<String>, }
pub fn insert(&mut self, character: char) { self.contents[self.y as usize].insert(self.x as usize, character); self.move_right(); } pub fn back_space(&mut self) { self.contents[self.y as usize].remove(self.x as usize); self.move_left(); } pub fn get_x(&self) -> i32...
impl Buffer { pub fn new() -> Buffer {Buffer{x: 0, y: 0, contents: vec![String::new()]}}
random_line_split
buffer.rs
use std::default::Default; #[derive(Default)] pub struct Cursor { x: u32, y: u32, } #[derive(Default)] pub struct Buffer { x: u32, y: u32, contents: Vec<String>, } impl Buffer { pub fn new() -> Buffer {Buffer{x: 0, y: 0, contents: vec![String::new()]}} pub fn insert(&mut self, character...
} pub fn move_down(&mut self) { let length = self.contents.len().to_string(); self.contents[0].push_str(&length); if self.y + 1 < self.contents.len() as u32 { self.y += 1; } } pub fn move_left(&mut self) { if self.x > 0 {self.x -= 1} } pub ...
{ self.y -= 1; }
conditional_block
buffer.rs
use std::default::Default; #[derive(Default)] pub struct Cursor { x: u32, y: u32, } #[derive(Default)] pub struct Buffer { x: u32, y: u32, contents: Vec<String>, } impl Buffer { pub fn new() -> Buffer {Buffer{x: 0, y: 0, contents: vec![String::new()]}} pub fn insert(&mut self, character...
pub fn move_up(&mut self) { if self.y > 0 { self.y -= 1; } } pub fn move_down(&mut self) { let length = self.contents.len().to_string(); self.contents[0].push_str(&length); if self.y + 1 < self.contents.len() as u32 { self.y += 1; } ...
{ self.contents.insert(self.y as usize, String::new()); self.move_down(); }
identifier_body
cfile.rs
use crate::SBError; use std::fs::File; use cpp::cpp; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(windows)] use std::os::windows::prelude::*; #[repr(C)] pub struct FILE; // The returned FILE takes ownership of file's descriptor. pub fn cfile_from_file(file: File, write: bool) -> Result<*mut FILE, SBError> { ...
else { Err(error) } }
{ Ok(cfile) }
conditional_block
cfile.rs
use crate::SBError; use std::fs::File; use cpp::cpp; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(windows)] use std::os::windows::prelude::*; #[repr(C)]
#[cfg(unix)] let fd = file.into_raw_fd() as isize; #[cfg(windows)] let fd = file.into_raw_handle() as isize; let mut error = SBError::new(); let cfile = cpp!(unsafe [fd as "intptr_t", write as "bool", mut error as "SBError"] -> *mut FILE as "FILE*" { FILE* cfile; #ifdef _WIN32 ...
pub struct FILE; // The returned FILE takes ownership of file's descriptor. pub fn cfile_from_file(file: File, write: bool) -> Result<*mut FILE, SBError> {
random_line_split
cfile.rs
use crate::SBError; use std::fs::File; use cpp::cpp; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(windows)] use std::os::windows::prelude::*; #[repr(C)] pub struct
; // The returned FILE takes ownership of file's descriptor. pub fn cfile_from_file(file: File, write: bool) -> Result<*mut FILE, SBError> { #[cfg(unix)] let fd = file.into_raw_fd() as isize; #[cfg(windows)] let fd = file.into_raw_handle() as isize; let mut error = SBError::new(); let cfile = ...
FILE
identifier_name
cfile.rs
use crate::SBError; use std::fs::File; use cpp::cpp; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(windows)] use std::os::windows::prelude::*; #[repr(C)] pub struct FILE; // The returned FILE takes ownership of file's descriptor. pub fn cfile_from_file(file: File, write: bool) -> Result<*mut FILE, SBError>
} else { error.SetErrorToErrno(); return nullptr; } }); if!cfile.is_null() { Ok(cfile) } else { Err(error) } }
{ #[cfg(unix)] let fd = file.into_raw_fd() as isize; #[cfg(windows)] let fd = file.into_raw_handle() as isize; let mut error = SBError::new(); let cfile = cpp!(unsafe [fd as "intptr_t", write as "bool", mut error as "SBError"] -> *mut FILE as "FILE*" { FILE* cfile; #ifdef _WIN32...
identifier_body
object-one-type-two-traits.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 wrap(self: Box<int>) -> Box<Any+'static> { self as Box<Any+'static> } } fn is<T:'static>(x: &Any) -> bool { x.is::<T>() } fn main() { let x = box 22i as Box<Wrap>; println!("x={}", x.get()); let y = x.wrap(); }
fn get(&self) -> int { *self }
random_line_split
object-one-type-two-traits.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 x = box 22i as Box<Wrap>; println!("x={}", x.get()); let y = x.wrap(); }
{ x.is::<T>() }
identifier_body
object-one-type-two-traits.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:'static>(x: &Any) -> bool { x.is::<T>() } fn main() { let x = box 22i as Box<Wrap>; println!("x={}", x.get()); let y = x.wrap(); }
is
identifier_name
changelg.rs
extern crate git2; extern crate regex; use self::git2::{Repository, Commit}; use self::regex::Regex; macro_rules! filter_option { ($e:expr) => (match $e { Ok(t) => t, Err(e) => return Some(Err(e)) }) } macro_rules! option_match { ($e:expr) => (match $e { Ok(t) => t, Err(e) => panic!("err! - {}", e) }) } // ...
() { fn something_bad_happens<T>() -> Result<T, &'static str> { Err("Fail") }; match something_bad_happens() { Ok(t) => t, Err(e) => panic!("err! - {}", e) } } #[test] fn it_should_return_result_on_ok_in_option_match() { fn something_good_happens() -> Result<&'static...
it_should_panic_on_error_in_option_match
identifier_name
changelg.rs
extern crate git2; extern crate regex; use self::git2::{Repository, Commit}; use self::regex::Regex; macro_rules! filter_option { ($e:expr) => (match $e { Ok(t) => t, Err(e) => return Some(Err(e)) })
} macro_rules! option_match { ($e:expr) => (match $e { Ok(t) => t, Err(e) => panic!("err! - {}", e) }) } // Todo: Return revwalk and defer iterating over comits to another function pub fn get_commits(args: Vec<String>) { let repo = option_match!(Repository::open("./")); let mut revwalk = option_match!(rep...
random_line_split
changelg.rs
extern crate git2; extern crate regex; use self::git2::{Repository, Commit}; use self::regex::Regex; macro_rules! filter_option { ($e:expr) => (match $e { Ok(t) => t, Err(e) => return Some(Err(e)) }) } macro_rules! option_match { ($e:expr) => (match $e { Ok(t) => t, Err(e) => panic!("err! - {}", e) }) } // ...
#[test] fn it_should_return_true_when_a_string_is_tagged_changelog_(){ let result = match_changelog_identifier("#changelog Hello World"); assert_eq!(result, true); } #[test] fn it_should_return_false_when_a_string_is_not_tagged_changelog_(){ let result = match_changelog_identifier("Hello World"); ass...
{ let commit_range = commit_range("377d686351969f27f288dec2fb09d0d5431fcde1", "3763e0e3ff218cbdfbf99c68109a04d666e81abeto"); assert_eq!(commit_range, "377d686351969f27f288dec2fb09d0d5431fcde1..3763e0e3ff218cbdfbf99c68109a04d666e81abeto"); }
identifier_body
vec-tail-matching.rs
struct Foo { string: ~str } pub fn main()
} _ => { unreachable!(); } } } _ => { unreachable!(); } } }
{ let x = ~[ Foo { string: ~"foo" }, Foo { string: ~"bar" }, Foo { string: ~"baz" } ]; match x { [ref first, ..tail] => { assert!(first.string == ~"foo"); assert_eq!(tail.len(), 2); assert!(tail[0].string == ~"bar"); assert!(tai...
identifier_body
vec-tail-matching.rs
struct Foo { string: ~str } pub fn main() { let x = ~[ Foo { string: ~"foo" }, Foo { string: ~"bar" }, Foo { string: ~"baz" } ]; match x { [ref first,..tail] => { assert!(first.string == ~"foo"); assert_eq!(tail.len(), 2); assert!(tail...
unreachable!(); } } } _ => { unreachable!(); } } }
random_line_split
vec-tail-matching.rs
struct
{ string: ~str } pub fn main() { let x = ~[ Foo { string: ~"foo" }, Foo { string: ~"bar" }, Foo { string: ~"baz" } ]; match x { [ref first,..tail] => { assert!(first.string == ~"foo"); assert_eq!(tail.len(), 2); assert!(tail[0].string...
Foo
identifier_name
lib.rs
use std::iter::DoubleEndedIterator; use std::ops::{Index, IndexMut}; pub struct VecMultiMap<T>(Vec<Vec<T>>); pub struct VecMultiMapAdapter<'a, T>(pub &'a mut Vec<Vec<T>>); impl<'a, T> VecMultiMapAdapter<'a, T> { fn pad_to(&mut self, index: usize) { if index >= self.0.len() { self.0.resize_with...
pub fn get(&mut self, index: usize) -> &Vec<T> { self.pad_to(index); unsafe { self.0.get_unchecked(index) } } pub fn get_or_fail(&self, index: usize) -> Option<&Vec<T>> { self.0.get(index) } pub fn get_mut(&mut self, index: usize) -> &mut Vec<T> { self.pad_to(inde...
{ self.pad_to(index); self.0[index].push(value); }
identifier_body
lib.rs
use std::iter::DoubleEndedIterator; use std::ops::{Index, IndexMut}; pub struct VecMultiMap<T>(Vec<Vec<T>>); pub struct VecMultiMapAdapter<'a, T>(pub &'a mut Vec<Vec<T>>); impl<'a, T> VecMultiMapAdapter<'a, T> { fn pad_to(&mut self, index: usize) { if index >= self.0.len() { self.0.resize_with...
} pub fn get_or_fail(&self, index: usize) -> Option<&Vec<T>> { self.0.get(index) } pub fn get_mut(&mut self, index: usize) -> &mut Vec<T> { self.pad_to(index); unsafe { self.0.get_unchecked_mut(index) } } } impl<T> VecMultiMap<T> { pub fn new() -> Self { VecMul...
pub fn get(&mut self, index: usize) -> &Vec<T> { self.pad_to(index); unsafe { self.0.get_unchecked(index) }
random_line_split
lib.rs
use std::iter::DoubleEndedIterator; use std::ops::{Index, IndexMut}; pub struct VecMultiMap<T>(Vec<Vec<T>>); pub struct VecMultiMapAdapter<'a, T>(pub &'a mut Vec<Vec<T>>); impl<'a, T> VecMultiMapAdapter<'a, T> { fn pad_to(&mut self, index: usize) { if index >= self.0.len() { self.0.resize_with...
} pub fn push_to(&mut self, index: usize, value: T) { self.pad_to(index); self.0[index].push(value); } pub fn get(&mut self, index: usize) -> &Vec<T> { self.pad_to(index); unsafe { self.0.get_unchecked(index) } } pub fn get_or_fail(&self, index: usize) -> Opti...
{ self.0.resize_with(index + 1, Vec::new) }
conditional_block
lib.rs
use std::iter::DoubleEndedIterator; use std::ops::{Index, IndexMut}; pub struct VecMultiMap<T>(Vec<Vec<T>>); pub struct VecMultiMapAdapter<'a, T>(pub &'a mut Vec<Vec<T>>); impl<'a, T> VecMultiMapAdapter<'a, T> { fn pad_to(&mut self, index: usize) { if index >= self.0.len() { self.0.resize_with...
(v: &'a mut Vec<Vec<T>>) -> Self { Self(v) } } impl<T> Into<Vec<Vec<T>>> for VecMultiMap<T> { fn into(self) -> Vec<Vec<T>> { // find greatest index with non-empty vector if let Some((last_filled_index, _)) = self.0.iter().enumerate().rfind(|(_, v)| v.len() > 0) { sel...
from
identifier_name
main.rs
extern crate clap; extern crate csv; extern crate xmler; use clap::{App, Arg}; use std::collections::HashSet; use std::process; fn main() { let matches = App::new("xmler") .version("0.1.0") .author("Daniel Gregoire <daniel.l.gregoire@gmail.com>") .about("TBD") .arg( Arg::wi...
Err(e) => { eprintln!("Error creating writer for {}: {:?}", file_path, e); process::exit(1); } } } }
}
random_line_split
main.rs
extern crate clap; extern crate csv; extern crate xmler; use clap::{App, Arg}; use std::collections::HashSet; use std::process; fn main()
.get_matches(); // Required by options ^^^, so by here it will have a value. let glob_pattern = matches.value_of("glob_pattern").unwrap(); let mut report = xmler::fresh_report(); println!("Processing all files that match your glob pattern..."); xmler::process(glob_pattern, &mut report); ...
{ let matches = App::new("xmler") .version("0.1.0") .author("Daniel Gregoire <daniel.l.gregoire@gmail.com>") .about("TBD") .arg( Arg::with_name("glob_pattern") .value_name("GLOB_PATTERN") .required(true) .index(1) ...
identifier_body
main.rs
extern crate clap; extern crate csv; extern crate xmler; use clap::{App, Arg}; use std::collections::HashSet; use std::process; fn
() { let matches = App::new("xmler") .version("0.1.0") .author("Daniel Gregoire <daniel.l.gregoire@gmail.com>") .about("TBD") .arg( Arg::with_name("glob_pattern") .value_name("GLOB_PATTERN") .required(true) .index(1) ...
main
identifier_name
common.rs
use lexer; use parser; use codegen; use std::io::{stderr, Write}; extern crate regex; use self::regex::Regex; extern crate ansi_term; use self::ansi_term::Colour; use CODEGEN; // parse -> codegen -> write llvm bitcode to output file pub fn run_file<'a>(filename: &'a str) { // parser::Parser::new(&mut lexer).run...
// DEBUG: println!("\nllvm-ir test output:"); unsafe { let mut nodes = Vec::new(); let mut lexer = lexer::Lexer::new(filename.to_string()); let mut parser = parser::Parser::new(&mut lexer); loop { match parser.read_toplevel(&mut nodes) { Err(parser::...
// DEBUG: for node in &ast { // DEBUG: node.show(); // DEBUG: }
random_line_split
common.rs
use lexer; use parser; use codegen; use std::io::{stderr, Write}; extern crate regex; use self::regex::Regex; extern crate ansi_term; use self::ansi_term::Colour; use CODEGEN; // parse -> codegen -> write llvm bitcode to output file pub fn run_file<'a>(filename: &'a str)
Ok(_) => {} // TODO: implement err handler for codegen Err(codegen::Error::MsgWithPos(msg, pos)) => { writeln!( &mut stderr(), "{}: {} {}: {}", parser.lexer.get_filename(), ...
{ // parser::Parser::new(&mut lexer).run(&mut nodes); // DEBUG: for node in &ast { // DEBUG: node.show(); // DEBUG: } // DEBUG: println!("\nllvm-ir test output:"); unsafe { let mut nodes = Vec::new(); let mut lexer = lexer::Lexer::new(filename.to_string()); let mut ...
identifier_body
common.rs
use lexer; use parser; use codegen; use std::io::{stderr, Write}; extern crate regex; use self::regex::Regex; extern crate ansi_term; use self::ansi_term::Colour; use CODEGEN; // parse -> codegen -> write llvm bitcode to output file pub fn
<'a>(filename: &'a str) { // parser::Parser::new(&mut lexer).run(&mut nodes); // DEBUG: for node in &ast { // DEBUG: node.show(); // DEBUG: } // DEBUG: println!("\nllvm-ir test output:"); unsafe { let mut nodes = Vec::new(); let mut lexer = lexer::Lexer::new(filename.to_str...
run_file
identifier_name
common.rs
use lexer; use parser; use codegen; use std::io::{stderr, Write}; extern crate regex; use self::regex::Regex; extern crate ansi_term; use self::ansi_term::Colour; use CODEGEN; // parse -> codegen -> write llvm bitcode to output file pub fn run_file<'a>(filename: &'a str) { // parser::Parser::new(&mut lexer).run...
// TODO: implement err handler for codegen Err(codegen::Error::MsgWithPos(msg, pos)) => { writeln!( &mut stderr(), "{}: {} {}: {}", parser.lexer.get_filename(), Colour::Re...
{}
conditional_block
children.rs
use std::ops::{Deref, DerefMut}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{thread, time}; use nix::sys::signal; use nix::unistd::getpgid; use nix::unistd::Pid; use tokio::process::{Child, Command}; // We keep this relatively low to start to encourage interactivity. If users end up needing longer gracef...
} impl DerefMut for ManagedChild { fn deref_mut(&mut self) -> &mut Child { &mut self.child } } /// Implements drop by killing the process group. impl Drop for ManagedChild { fn drop(&mut self) { if!self.killed.load(Ordering::SeqCst) { let _ = self.graceful_shutdown_sync(); } } }
{ &self.child }
identifier_body
children.rs
use std::ops::{Deref, DerefMut}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{thread, time}; use nix::sys::signal; use nix::unistd::getpgid; use nix::unistd::Pid; use tokio::process::{Child, Command}; // We keep this relatively low to start to encourage interactivity. If users end up needing longer gracef...
fn get_pgid(&self) -> Result<Pid, String> { let pid = self.id().ok_or_else(|| "Process had no PID.".to_owned())?; let pgid = getpgid(Some(Pid::from_raw(pid as i32))) .map_err(|e| format!("Could not get process group id of child process: {}", e))?; Ok(pgid) } /// Send a signal to the child proce...
Ok(Self { child, killed: AtomicBool::new(false), }) }
random_line_split
children.rs
use std::ops::{Deref, DerefMut}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{thread, time}; use nix::sys::signal; use nix::unistd::getpgid; use nix::unistd::Pid; use tokio::process::{Child, Command}; // We keep this relatively low to start to encourage interactivity. If users end up needing longer gracef...
(&self) -> &Child { &self.child } } impl DerefMut for ManagedChild { fn deref_mut(&mut self) -> &mut Child { &mut self.child } } /// Implements drop by killing the process group. impl Drop for ManagedChild { fn drop(&mut self) { if!self.killed.load(Ordering::SeqCst) { let _ = self.graceful_s...
deref
identifier_name
children.rs
use std::ops::{Deref, DerefMut}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{thread, time}; use nix::sys::signal; use nix::unistd::getpgid; use nix::unistd::Pid; use tokio::process::{Child, Command}; // We keep this relatively low to start to encourage interactivity. If users end up needing longer gracef...
Err(e) => { log::warn!("An error occurred while waiting for graceful shutdown of process group ({}). Will try SIGKILL instead.", e); self.kill_pgid() } } } /// Kill the process's unique PGID or return an error if we don't have a PID or cannot kill. fn kill_pgid(&mut self) -> Resu...
{ // we timed out waiting for the child to exit, so we need to kill it. log::warn!( "Timed out waiting for graceful shutdown of process group. Will try SIGKILL instead." ); self.kill_pgid() }
conditional_block
autogen.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 may n...
/// simply because the Thrift protocol encodes sequence numbers as `i32` on /// the wire. fn sequence_number(&self) -> i32; // FIXME: consider returning a u32 /// Increments the sequence number, indicating that a message with that /// number has been sent to the Thrift server. fn increment_seque...
/// server. Returns `0` if no messages have been written. Sequence /// numbers should *never* be negative, and this method returns an `i32`
random_line_split
inline.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId, mutable: bool) -> clean::Static { clean::Static { type_: ty::lookup_item_type(tcx, did).ty.clean(cx), mutability: if mutable {clean::Mutable} else {clean::Immutable}, expr: "\n\n\n".to_string(), // trigger the...
build_static
identifier_name
inline.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
did: ast::DefId, mutable: bool) -> clean::Static { clean::Static { type_: ty::lookup_item_type(tcx, did).ty.clean(cx), mutability: if mutable {clean::Mutable} else {clean::Immutable}, expr: "\n\n\n".to_string(), // trigger the "[definition]" links } }
} } fn build_static(cx: &DocContext, tcx: &ty::ctxt,
random_line_split
inline.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Function { let t = ty::lookup_item_type(tcx, did); let (decl, style) = match t.ty.sty { ty::ty_bare_fn(_, ref f) => ((did, &f.sig).clean(cx), f.unsafety), _ => panic!("bad function"), }; let predicat...
{ let def = ty::lookup_trait_def(tcx, did); let trait_items = ty::trait_items(tcx, did).clean(cx); let predicates = ty::lookup_predicates(tcx, did); clean::Trait { unsafety: def.unsafety, generics: (&def.generics, &predicates, subst::TypeSpace).clean(cx), items: trait_items, ...
identifier_body
login.rs
use std::io::{Read, Write}; use std::io; use std::fs::File; use std::error::Error; use hyper; use hyper::net::Fresh; use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use hyper::Url; use hyper::header::{Headers,ContentType,Location,SetCookie}; use hyper::header; use cookie::Cookie; use mime::M...
fn read_file_bytes(filename: &str) -> Vec<u8> { let mut file = File::open(&filename).unwrap(); let mut contents: Vec<u8> = Vec::new(); file.read_to_end(&mut contents).unwrap(); contents } fn file_exists(path: &str) -> bool { let path_obj = Path::new(path); path_obj.is_file() && path_obj.exist...
{ // TODO high thread-count is a workaround for https://github.com/hyperium/hyper/issues/368 Server::http("0.0.0.0:8080").unwrap().handle_threads(login, 100).unwrap(); }
identifier_body
login.rs
use std::io::{Read, Write}; use std::io; use std::fs::File; use std::error::Error; use hyper; use hyper::net::Fresh; use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use hyper::Url; use hyper::header::{Headers,ContentType,Location,SetCookie}; use hyper::header; use cookie::Cookie; use mime::M...
let referer = format!("{}",req.headers.get::<hyper::header::Referer>().unwrap()); let referer_url = Url::parse(&*referer).unwrap(); let pairs = query_pairs.clone().unwrap(); match &pairs[..] { [(_, ref page), (ref t...
println!("Authenticating User");
random_line_split
login.rs
use std::io::{Read, Write}; use std::io; use std::fs::File; use std::error::Error; use hyper; use hyper::net::Fresh; use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use hyper::Url; use hyper::header::{Headers,ContentType,Location,SetCookie}; use hyper::header; use cookie::Cookie; use mime::M...
{ custom: Custom, id: String, realm_id: String, username: String, state: String, user_type: String, reference: Option<String>, name: String, email: String, object: String, last_login_at: f64, last_login_on: f64, created_at: f64, first_name: Option<String>, la...
User
identifier_name
eventfd.rs
use std::os::unix::io::RawFd; use std::mem::transmute; use nix::sys::eventfd::{eventfd, EFD_CLOEXEC, EFD_NONBLOCK}; use nix::poll::{poll, PollFd, POLLIN, EventFlags}; use nix::unistd::{read, write}; use nix::Error; use nix::Errno::EINTR; #[derive(Debug)] pub struct Async(RawFd); impl Async { pub fn new() -> As...
(&self) -> bool { let mut buf = [0u8; 8]; loop { match read(self.0, &mut buf) { Ok(_) => return true, Err(Error::Sys(EINTR)) => continue, Err(_) => return false, } } } /// Wait (blocking) for notification, doesn't re...
check
identifier_name
eventfd.rs
use std::os::unix::io::RawFd; use std::mem::transmute; use nix::sys::eventfd::{eventfd, EFD_CLOEXEC, EFD_NONBLOCK};
use nix::unistd::{read, write}; use nix::Error; use nix::Errno::EINTR; #[derive(Debug)] pub struct Async(RawFd); impl Async { pub fn new() -> Async { Async(eventfd(0, EFD_CLOEXEC|EFD_NONBLOCK).expect("create eventfd")) } pub fn notify(&self) { let buf: [u8; 8] = unsafe { transmute(1u64) ...
use nix::poll::{poll, PollFd, POLLIN, EventFlags};
random_line_split
eventfd.rs
use std::os::unix::io::RawFd; use std::mem::transmute; use nix::sys::eventfd::{eventfd, EFD_CLOEXEC, EFD_NONBLOCK}; use nix::poll::{poll, PollFd, POLLIN, EventFlags}; use nix::unistd::{read, write}; use nix::Error; use nix::Errno::EINTR; #[derive(Debug)] pub struct Async(RawFd); impl Async { pub fn new() -> As...
pub unsafe fn export_fd(&self) -> RawFd { self.0 } }
{ let mut pollfd = [PollFd { fd: self.0, events: POLLIN, revents: EventFlags::empty() }]; poll(&mut pollfd, -1).is_ok() }
identifier_body
constant.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/. */ //! WebIDL constants. use js::jsapi::{HandleObject, JSContext, JSPROP_ENUMERATE, JSPROP_PERMANENT}; use js::jsapi...
pub struct ConstantSpec { /// name of the constant. pub name: &'static [u8], /// value of the constant. pub value: ConstantVal, } /// Representation of an IDL constant value. #[derive(Clone)] #[allow(dead_code)] pub enum ConstantVal { /// `long` constant. IntVal(i32), /// `unsigned long` co...
#[derive(Clone)]
random_line_split
constant.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/. */ //! WebIDL constants. use js::jsapi::{HandleObject, JSContext, JSPROP_ENUMERATE, JSPROP_PERMANENT}; use js::jsapi...
{ for spec in constants { rooted!(in(cx) let value = spec.get_value()); assert!(JS_DefineProperty(cx, obj, spec.name.as_ptr() as *const libc::c_char, value.handle(), ...
identifier_body
constant.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/. */ //! WebIDL constants. use js::jsapi::{HandleObject, JSContext, JSPROP_ENUMERATE, JSPROP_PERMANENT}; use js::jsapi...
( cx: *mut JSContext, obj: HandleObject, constants: &[ConstantSpec]) { for spec in constants { rooted!(in(cx) let value = spec.get_value()); assert!(JS_DefineProperty(cx, obj, spec.name.as_ptr() as *const lib...
define_constants
identifier_name
main.rs
extern crate iron_oxide_browser; use iron_oxide_browser::{command, css, css_parse, dom, html_parse, layout, render, style}; use std::env; use std::fs::File; use std::io::{Read, BufReader}; fn main() { let nodes = test_html(); for node in nodes.iter() { dom::pretty_print(node, 0); } let ref nod...
fn test_css() -> css::Stylesheet { let mut path = env::current_dir().unwrap(); path.push("tests/parserTestFiles/blockTypeTest.css"); let mut file_reader = match File::open(&path) { Ok(f) => BufReader::new(f), Err(e) => panic!("file: {}\nerror: {}", path.display(), e) }; let mut c...
{ let mut path = env::current_dir().unwrap(); path.push("tests/parserTestFiles/blockTypeTest.html"); let mut file_reader = match File::open(&path) { Ok(f) => BufReader::new(f), Err(e) => panic!("file: {}\nerror: {}", path.display(), e) }; let mut html_input = String::new(); fil...
identifier_body
main.rs
extern crate iron_oxide_browser; use iron_oxide_browser::{command, css, css_parse, dom, html_parse, layout, render, style}; use std::env; use std::fs::File; use std::io::{Read, BufReader}; fn main() { let nodes = test_html(); for node in nodes.iter() { dom::pretty_print(node, 0); } let ref nod...
() -> Vec<dom::Node> { let mut path = env::current_dir().unwrap(); path.push("tests/parserTestFiles/blockTypeTest.html"); let mut file_reader = match File::open(&path) { Ok(f) => BufReader::new(f), Err(e) => panic!("file: {}\nerror: {}", path.display(), e) }; let mut html_input = S...
test_html
identifier_name
main.rs
extern crate iron_oxide_browser; use iron_oxide_browser::{command, css, css_parse, dom, html_parse, layout, render, style}; use std::env; use std::fs::File; use std::io::{Read, BufReader}; fn main() { let nodes = test_html(); for node in nodes.iter() { dom::pretty_print(node, 0); } let ref nod...
let mut viewport = layout::Dimensions::default(); viewport.content.width = 1024.0; viewport.content.height = 768.0; let layout_tree = layout::layout_tree(&style_tree_root, viewport); layout::pretty_print(&layout_tree, 0); let display_commands = command::build_display_commands(&layout_tree); ...
println!("");
random_line_split
main.rs
use std::ops::Add; use std::ops::Mul; fn main() { // Rust allows limited operators overloading // There are special traits for overloadng operators #[derive(Debug)] struct Point { x: i32, y: i32, } impl Add for Point { type Output = Point; fn add(self, other: Point) -> Point { ...
<T> { _x: T, _y: T, side: T, } impl<T> HasArea<T> for Square<T> where T: Mul<Output=T> + Copy { fn area(&self) -> T { self.side * self.side // Copy is important here, Rust would try to move self.side to return value then } } let s = Square { _x: 0.0f64, _y: 0.0...
Square
identifier_name
main.rs
use std::ops::Add; use std::ops::Mul; fn main() { // Rust allows limited operators overloading // There are special traits for overloadng operators #[derive(Debug)] struct Point { x: i32, y: i32, } impl Add for Point { type Output = Point; fn add(self, other: Point) -> Point { ...
} let s = Square { _x: 0.0f64, _y: 0.0f64, side: 12.0f64 }; println!("square (side = {}) area is {}", s.side, s.area()); }
{ self.side * self.side // Copy is important here, Rust would try to move self.side to return value then }
identifier_body
main.rs
use std::ops::Add; use std::ops::Mul; fn main() { // Rust allows limited operators overloading // There are special traits for overloadng operators #[derive(Debug)] struct Point { x: i32, y: i32, } impl Add for Point { type Output = Point; fn add(self, other: Point) -> Point {
Point { x: self.x + other.x, y: self.y + other.y } } } let p1 = Point { x: 1, y: 0 }; let p2 = Point { x: 2, y: 3 }; let p3 = p1 + p2; println!("{:?}", p3); // not clear why ops trait require to move args // using operator overloads is traits for generic structs tr...
random_line_split
cast_size_32bit.rs
// ignore-64bit #[warn( clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless )] #[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { // Casting from *size 1isize as i8; let x0 = 1isize; ...
1i64 as usize; 1u64 as isize; 1u64 as usize; 1u32 as isize; 1u32 as usize; // Should not trigger any lint 1i32 as isize; // Neither should this 1i32 as usize; // Big integer literal to float 999_999_999 as f32; 3_999_999_999usize as f64; }
random_line_split
cast_size_32bit.rs
// ignore-64bit #[warn( clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless )] #[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main()
1i32 as isize; // Neither should this 1i32 as usize; // Big integer literal to float 999_999_999 as f32; 3_999_999_999usize as f64; }
{ // Casting from *size 1isize as i8; let x0 = 1isize; let x1 = 1usize; x0 as f64; x1 as f64; x0 as f32; x1 as f32; 1isize as i32; 1isize as u32; 1usize as u32; 1usize as i32; // Casting to *size 1i64 as isize; 1i64 as usize; 1u64 as isize; 1u64 as usi...
identifier_body
cast_size_32bit.rs
// ignore-64bit #[warn( clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless )] #[allow(clippy::no_effect, clippy::unnecessary_operation)] fn
() { // Casting from *size 1isize as i8; let x0 = 1isize; let x1 = 1usize; x0 as f64; x1 as f64; x0 as f32; x1 as f32; 1isize as i32; 1isize as u32; 1usize as u32; 1usize as i32; // Casting to *size 1i64 as isize; 1i64 as usize; 1u64 as isize; 1u64 as ...
main
identifier_name
constructor-tp.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { pub _addr...
#[inline] pub unsafe fn new() -> Self { let mut __bindgen_tmp = ::std::mem::uninitialized(); Bar_Bar(&mut __bindgen_tmp); __bindgen_tmp } }
pub fn Bar_Bar(this: *mut Bar); } impl Bar {
random_line_split
constructor-tp.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { pub _addr...
() -> Self { let mut __bindgen_tmp = ::std::mem::uninitialized(); Bar_Bar(&mut __bindgen_tmp); __bindgen_tmp } }
new
identifier_name
constructor-tp.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { pub _addr...
extern "C" { #[link_name = "\u{1}_ZN3BarC1Ev"] pub fn Bar_Bar(this: *mut Bar); } impl Bar { #[inline] pub unsafe fn new() -> Self { let mut __bindgen_tmp = ::std::mem::uninitialized(); Bar_Bar(&mut __bindgen_tmp); __bindgen_tmp } }
{ assert_eq!( ::std::mem::size_of::<Bar>(), 1usize, concat!("Size of: ", stringify!(Bar)) ); assert_eq!( ::std::mem::align_of::<Bar>(), 1usize, concat!("Alignment of ", stringify!(Bar)) ); }
identifier_body
model.rs
use z3_sys::*; use Solver; use Optimize; use Model; use Ast; use Z3_MUTEX; impl<'ctx> Model<'ctx> { pub fn of_solver(slv: &Solver<'ctx>) -> Model<'ctx> { Model { ctx: slv.ctx, z3_mdl: unsafe { let guard = Z3_MUTEX.lock().unwrap(); let m = Z3_solver_ge...
impl<'ctx> Drop for Model<'ctx> { fn drop(&mut self) { unsafe { let guard = Z3_MUTEX.lock().unwrap(); Z3_model_dec_ref(self.ctx.z3_ctx, self.z3_mdl); } } }
random_line_split
model.rs
use z3_sys::*; use Solver; use Optimize; use Model; use Ast; use Z3_MUTEX; impl<'ctx> Model<'ctx> { pub fn of_solver(slv: &Solver<'ctx>) -> Model<'ctx> { Model { ctx: slv.ctx, z3_mdl: unsafe { let guard = Z3_MUTEX.lock().unwrap(); let m = Z3_solver_ge...
} } } impl<'ctx> Drop for Model<'ctx> { fn drop(&mut self) { unsafe { let guard = Z3_MUTEX.lock().unwrap(); Z3_model_dec_ref(self.ctx.z3_ctx, self.z3_mdl); } } }
{ None }
conditional_block
model.rs
use z3_sys::*; use Solver; use Optimize; use Model; use Ast; use Z3_MUTEX; impl<'ctx> Model<'ctx> { pub fn of_solver(slv: &Solver<'ctx>) -> Model<'ctx> { Model { ctx: slv.ctx, z3_mdl: unsafe { let guard = Z3_MUTEX.lock().unwrap(); let m = Z3_solver_ge...
}
{ unsafe { let guard = Z3_MUTEX.lock().unwrap(); Z3_model_dec_ref(self.ctx.z3_ctx, self.z3_mdl); } }
identifier_body
model.rs
use z3_sys::*; use Solver; use Optimize; use Model; use Ast; use Z3_MUTEX; impl<'ctx> Model<'ctx> { pub fn
(slv: &Solver<'ctx>) -> Model<'ctx> { Model { ctx: slv.ctx, z3_mdl: unsafe { let guard = Z3_MUTEX.lock().unwrap(); let m = Z3_solver_get_model(slv.ctx.z3_ctx, slv.z3_slv); Z3_model_inc_ref(slv.ctx.z3_ctx, m); m }...
of_solver
identifier_name
xrinputsourceevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::...
source: &XRInputSource, ) -> DomRoot<XRInputSourceEvent> { let trackevent = reflect_dom_object( Box::new(XRInputSourceEvent::new_inherited(frame, source)), global, ); { let event = trackevent.upcast::<Event>(); event.init_event(type_, b...
cancelable: bool, frame: &XRFrame,
random_line_split
xrinputsourceevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::...
// https://dom.spec.whatwg.org/#dom-event-istrusted fn IsTrusted(&self) -> bool { self.event.IsTrusted() } }
{ DomRoot::from_ref(&*self.source) }
identifier_body
xrinputsourceevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::...
{ event: Event, frame: Dom<XRFrame>, source: Dom<XRInputSource>, } impl XRInputSourceEvent { #[allow(unrooted_must_root)] fn new_inherited(frame: &XRFrame, source: &XRInputSource) -> XRInputSourceEvent { XRInputSourceEvent { event: Event::new_inherited(), frame: Dom...
XRInputSourceEvent
identifier_name
bios_boot_device.rs
use tag::{TagType, VerifyTag}; const UNUSED_PARTITION_NUMBER: u32 = 0xFFFFFFFF; const BIOS_BOOT_DEVICE_TAG_SIZE: usize = 20; #[repr(C, packed)] pub struct BIOSBootDeviceTag { tag_type: u32, size: u32, pub biosdev: u32, pub partition: u32, pub sub_partition: u32 } impl BIOSBootDeviceTag { fn ...
} } impl VerifyTag for BIOSBootDeviceTag { fn is_valid(&self) -> bool { (self.size_bytes() == BIOS_BOOT_DEVICE_TAG_SIZE) && (self.tag_type == TagType::BIOSBootDevice as u32) } } #[derive(Debug, Copy, Clone)] pub struct BootDevice { biosdev: u32, partition: u32, sub_partiti...
random_line_split
bios_boot_device.rs
use tag::{TagType, VerifyTag}; const UNUSED_PARTITION_NUMBER: u32 = 0xFFFFFFFF; const BIOS_BOOT_DEVICE_TAG_SIZE: usize = 20; #[repr(C, packed)] pub struct BIOSBootDeviceTag { tag_type: u32, size: u32, pub biosdev: u32, pub partition: u32, pub sub_partition: u32 } impl BIOSBootDeviceTag { fn ...
fn is_valid_sub_partition(&self) -> bool { self.sub_partition!= UNUSED_PARTITION_NUMBER } fn size_bytes(&self) -> usize { self.size as usize } } impl VerifyTag for BIOSBootDeviceTag { fn is_valid(&self) -> bool { (self.size_bytes() == BIOS_BOOT_DEVICE_TAG_SIZE) ...
{ self.partition != UNUSED_PARTITION_NUMBER }
identifier_body
bios_boot_device.rs
use tag::{TagType, VerifyTag}; const UNUSED_PARTITION_NUMBER: u32 = 0xFFFFFFFF; const BIOS_BOOT_DEVICE_TAG_SIZE: usize = 20; #[repr(C, packed)] pub struct BIOSBootDeviceTag { tag_type: u32, size: u32, pub biosdev: u32, pub partition: u32, pub sub_partition: u32 } impl BIOSBootDeviceTag { fn ...
{ biosdev: u32, partition: u32, sub_partition: u32, } impl BootDevice { pub fn new(biosdev: u32, partition: u32, sub_partition: u32) -> BootDevice { BootDevice { biosdev: biosdev, partition: partition, sub_partition: sub_partition } } pub fn...
BootDevice
identifier_name
thread.rs
use std::thread; use std::sync::mpsc; pub struct CancelSender(mpsc::Sender<()>); impl CancelSender { pub fn cancel_thread(self) { let CancelSender(sender) = self; let _ = sender.send(()); } } pub struct CancelReceiver(mpsc::Receiver<()>); impl CancelReceiver { pub fn has_been_canceled(&sel...
} // Wraps the standard thread::spawn, creating a channel to be used for canceling the thread. // Note that is_canceled will automatically become true if the cancel sender is lost, so be sure to // hold onto it! pub fn spawn_cancelable<F>(to_execute: F) -> CancelSender where F: FnOnce(CancelReceiver), F: Send...
{ let &CancelReceiver(ref receiver) = self; match receiver.try_recv() { Ok(_) | Err(mpsc::TryRecvError::Disconnected) => return true, Err(mpsc::TryRecvError::Empty) => return false, } }
identifier_body
thread.rs
use std::thread; use std::sync::mpsc; pub struct CancelSender(mpsc::Sender<()>); impl CancelSender { pub fn
(self) { let CancelSender(sender) = self; let _ = sender.send(()); } } pub struct CancelReceiver(mpsc::Receiver<()>); impl CancelReceiver { pub fn has_been_canceled(&self) -> bool { let &CancelReceiver(ref receiver) = self; match receiver.try_recv() { Ok(_) | Err(mps...
cancel_thread
identifier_name
thread.rs
use std::thread; use std::sync::mpsc; pub struct CancelSender(mpsc::Sender<()>); impl CancelSender { pub fn cancel_thread(self) { let CancelSender(sender) = self; let _ = sender.send(()); } } pub struct CancelReceiver(mpsc::Receiver<()>); impl CancelReceiver {
pub fn has_been_canceled(&self) -> bool { let &CancelReceiver(ref receiver) = self; match receiver.try_recv() { Ok(_) | Err(mpsc::TryRecvError::Disconnected) => return true, Err(mpsc::TryRecvError::Empty) => return false, } } } // Wraps the standard thread::spaw...
random_line_split
main.rs
// TODO: many items from tokio-core::io have been deprecated in favour of tokio-io #![allow(deprecated)] #[macro_use] extern crate log; extern crate env_logger; extern crate futures; extern crate getopts; extern crate librespot; extern crate tokio_core; extern crate tokio_signal; use env_logger::LogBuilder; use futur...
let use_audio_cache =!matches.opt_present("disable-audio-cache"); let cache = matches.opt_str("c").map(|cache_location| { Cache::new(PathBuf::from(cache_location), use_audio_cache) }); let credentials = { let cached_credentials = cache.as_ref().and_then(Cache::credentials); ge...
let mixer = mixer::find(mixer_name.as_ref()) .expect("Invalid mixer"); let name = matches.opt_str("name").unwrap();
random_line_split
main.rs
// TODO: many items from tokio-core::io have been deprecated in favour of tokio-io #![allow(deprecated)] #[macro_use] extern crate log; extern crate env_logger; extern crate futures; extern crate getopts; extern crate librespot; extern crate tokio_core; extern crate tokio_signal; use env_logger::LogBuilder; use futur...
builder.init().unwrap(); } } } fn list_backends() { println!("Available Backends : "); for (&(name, _), idx) in BACKENDS.iter().zip(0..) { if idx == 0 { println!("- {} (default)", name); } else { println!("- {}", name); } } } #[deriv...
{ builder.parse("mdns=info,librespot=info"); }
conditional_block
main.rs
// TODO: many items from tokio-core::io have been deprecated in favour of tokio-io #![allow(deprecated)] #[macro_use] extern crate log; extern crate env_logger; extern crate futures; extern crate getopts; extern crate librespot; extern crate tokio_core; extern crate tokio_signal; use env_logger::LogBuilder; use futur...
(program: &str, opts: &getopts::Options) -> String { let brief = format!("Usage: {} [options]", program); opts.usage(&brief) } fn setup_logging(verbose: bool) { let mut builder = LogBuilder::new(); match env::var("RUST_LOG") { Ok(config) => { builder.parse(&config); buil...
usage
identifier_name
mod.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn last_error() -> IoError { decode_error_detailed(os::errno() as i32) } pub fn last_net_error() -> IoError { last_error() } extern "system" { fn gai_strerror(errcode: libc::c_int) -> *const libc::c_char; } pub fn last_gai_error(s: libc::c_int) -> IoError { let mut err = decode_error(s); e...
{ let _ = libc::close(sock); }
identifier_body
mod.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 ...
() -> IoError { last_error() } extern "system" { fn gai_strerror(errcode: libc::c_int) -> *const libc::c_char; } pub fn last_gai_error(s: libc::c_int) -> IoError { let mut err = decode_error(s); err.detail = Some(unsafe { let data = CStr::from_ptr(gai_strerror(s)); str::from_utf8(data...
last_net_error
identifier_name
mod.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn init_net() {}
// nothing needed on unix platforms
random_line_split
size_big.rs
//! The GC can work with objects that take up most of a page. extern crate cell_gc; #[macro_use] extern crate cell_gc_derive; type Big32 = (u64, u64, u64, u64); type Big128 = (Big32, Big32, Big32, Big32); type Big512 = (Big128, Big128, Big128, Big128); type Big2560 = (Big512, Big512, Big512, Big512, Big512); #[deriv...
<'h> { bits: Big2560, next: Option<BigRef<'h>>, } #[test] fn size_big() { cell_gc::with_heap(|hs| { hs.set_page_limit::<Big>(Some(1)); let n = cell_gc::page_capacity::<Big>(); assert_eq!(n, 1); // see comment in size_medium.rs let a = (5, 6, 7, 8); let b = (a, a, a...
Big
identifier_name
size_big.rs
//! The GC can work with objects that take up most of a page. extern crate cell_gc; #[macro_use] extern crate cell_gc_derive; type Big32 = (u64, u64, u64, u64); type Big128 = (Big32, Big32, Big32, Big32); type Big512 = (Big128, Big128, Big128, Big128); type Big2560 = (Big512, Big512, Big512, Big512, Big512); #[deriv...
#[test] fn size_big() { cell_gc::with_heap(|hs| { hs.set_page_limit::<Big>(Some(1)); let n = cell_gc::page_capacity::<Big>(); assert_eq!(n, 1); // see comment in size_medium.rs let a = (5, 6, 7, 8); let b = (a, a, a, a); let c = (b, b, b, b); let d = (c, c, ...
}
random_line_split
stdio.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} /// Creates an unbuffered handle to the stderr of the current process /// /// See notes in `stdout()` for more information. pub fn stderr_raw() -> StdWriter { src(libc::STDERR_FILENO, false, |src| StdWriter { inner: src }) } /// Resets the task-local stdout handle to the specified writer /// /// This will repla...
LineBufferedWriter::new(stderr_raw())
random_line_split
stdio.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self, nbytes: uint) -> IoResult<u64> { self.inner.lock().read_be_uint_n(nbytes) } } /// Creates a new handle to the stdin of the current process. /// /// The returned handle is a wrapper around a global `BufferedReader` shared /// by all threads. If buffered access is not desired, the `stdin_raw` fun...
read_be_uint_n
identifier_name
stdio.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// We have to manually delegate all of these because the default impls call // read more than once and we don't want those calls to interleave (or // incur the costs of repeated locking). fn read_at_least(&mut self, min: uint, buf: &mut [u8]) -> IoResult<uint> { self.inner.lock().read_at_leas...
{ self.inner.lock().read(buf) }
identifier_body
normalize_erasing_regions.rs
//! Methods for normalizing when you don't care about regions (and //! aren't doing type inference). If either of those things don't //! apply to you, use `infcx.normalize(...)`. //! //! The methods in this file use a `TypeFolder` to recursively process //! contents, invoking the underlying //! `normalize_generic_arg_a...
( &self, arg: ty::GenericArg<'tcx>, ) -> ty::GenericArg<'tcx> { let arg = self.param_env.and(arg); self.tcx.normalize_generic_arg_after_erasing_regions(arg) } } impl TypeFolder<'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self....
normalize_generic_arg_after_erasing_regions
identifier_name
normalize_erasing_regions.rs
//! Methods for normalizing when you don't care about regions (and //! aren't doing type inference). If either of those things don't //! apply to you, use `infcx.normalize(...)`. //! //! The methods in this file use a `TypeFolder` to recursively process //! contents, invoking the underlying //! `normalize_generic_arg_a...
/// Monomorphizes a type from the AST by first applying the /// in-scope substitutions and then normalizing any associated /// types. pub fn subst_and_normalize_erasing_regions<T>( self, param_substs: SubstsRef<'tcx>, param_env: ty::ParamEnv<'tcx>, value: T, ) -> T ...
{ let value = self.erase_late_bound_regions(value); self.normalize_erasing_regions(param_env, value) }
identifier_body
normalize_erasing_regions.rs
//! Methods for normalizing when you don't care about regions (and //! aren't doing type inference). If either of those things don't //! apply to you, use `infcx.normalize(...)`. //! //! The methods in this file use a `TypeFolder` to recursively process //! contents, invoking the underlying //! `normalize_generic_arg_a...
else { value .fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env }) .into_ok() } } /// If you have a `Binder<'tcx, T>`, you can do this to strip out the /// late-bound regions and then normalize the result, yielding up /// a `T` (...
{ value }
conditional_block
normalize_erasing_regions.rs
//! Methods for normalizing when you don't care about regions (and //! aren't doing type inference). If either of those things don't //! apply to you, use `infcx.normalize(...)`. //! //! The methods in this file use a `TypeFolder` to recursively process //! contents, invoking the underlying //! `normalize_generic_arg_a...
use crate::mir; use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::ty::subst::{Subst, SubstsRef}; use crate::ty::{self, Ty, TyCtxt}; impl<'tcx> TyCtxt<'tcx> { /// Erase the regions in `value` and then fully normalize all the /// types found within. The result will also have regions erased. /// ...
//! or constant found within. (This underlying query is what is cached.)
random_line_split
pyext.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::slice; use cpython::PyBytes;
use cpython::PyModule; use cpython::PyObject; use cpython::PyResult; use cpython::Python; use cpython_ext::ResultPyErrExt; use cpython_ext::SimplePyBuf; use revlogindex::nodemap::empty_index_buffer; use revlogindex::NodeRevMap; use revlogindex::RevlogEntry; pub fn init_module(py: Python, package: &str) -> PyResult<PyM...
random_line_split
pyext.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::slice; use cpython::PyBytes; use cpython::PyModule; use cpython::PyObject; use cpython::PyResult; use cpython::Python; use cpytho...
py_class!(class nodemap |py| { data nodemap: NodeRevMap<SimplePyBuf<RevlogEntry>, SimplePyBuf<u32>>; def __new__(_cls, changelog: &PyObject, index: &PyObject) -> PyResult<nodemap> { let changelog_buf = SimplePyBuf::new(py, changelog); let index_buf = SimplePyBuf::new(py, index); let n...
{ let name = [package, "indexes"].join("."); let m = PyModule::new(py, &name)?; m.add_class::<nodemap>(py)?; Ok(m) }
identifier_body
pyext.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::slice; use cpython::PyBytes; use cpython::PyModule; use cpython::PyObject; use cpython::PyResult; use cpython::Python; use cpytho...
(py: Python, package: &str) -> PyResult<PyModule> { let name = [package, "indexes"].join("."); let m = PyModule::new(py, &name)?; m.add_class::<nodemap>(py)?; Ok(m) } py_class!(class nodemap |py| { data nodemap: NodeRevMap<SimplePyBuf<RevlogEntry>, SimplePyBuf<u32>>; def __new__(_cls, changelo...
init_module
identifier_name
client_mock_tcp.rs
#![feature(default_type_params)] extern crate curl; extern crate http; extern crate hyper; extern crate test; use std::fmt::{mod, Show}; use std::str::from_str; use std::io::{IoResult, MemReader}; use std::io::net::ip::{SocketAddr, ToSocketAddr}; use std::os; use std::path::BytesContainer; use http::connecter::Conne...
} impl hyper::header::HeaderFormat for Foo { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { "Bar".fmt(fmt) } } impl net::NetworkStream for MockStream { fn peer_name(&mut self) -> IoResult<SocketAddr> { Ok(from_str("127.0.0.1:1337").unwrap()) } } impl net::NetworkConn...
{ None }
identifier_body
client_mock_tcp.rs
#![feature(default_type_params)] extern crate curl; extern crate http; extern crate hyper; extern crate test; use std::fmt::{mod, Show}; use std::str::from_str; use std::io::{IoResult, MemReader}; use std::io::net::ip::{SocketAddr, ToSocketAddr}; use std::os; use std::path::BytesContainer; use http::connecter::Conne...
(_: &[Vec<u8>]) -> Option<Foo> { None } } impl hyper::header::HeaderFormat for Foo { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { "Bar".fmt(fmt) } } impl net::NetworkStream for MockStream { fn peer_name(&mut self) -> IoResult<SocketAddr> { Ok(from_str("127.0....
parse_header
identifier_name
client_mock_tcp.rs
#![feature(default_type_params)] extern crate curl; extern crate http; extern crate hyper; extern crate test; use std::fmt::{mod, Show}; use std::str::from_str; use std::io::{IoResult, MemReader}; use std::io::net::ip::{SocketAddr, ToSocketAddr}; use std::os; use std::path::BytesContainer; use http::connecter::Conne...
self.read.read(buf) } } impl Writer for MockStream { fn write(&mut self, _msg: &[u8]) -> IoResult<()> { // we're mocking, what do we care. Ok(()) } } #[bench] fn bench_mock_curl(b: &mut test::Bencher) { let mut cwd = os::getcwd().unwrap(); cwd.push("README.md"); let s =...
impl Reader for MockStream { fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
random_line_split
regions-escape-via-trait-or-not.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 ...
trait Deref { fn get(self) -> isize; } impl<'a> Deref for &'a isize { fn get(self) -> isize { *self } } fn with<R:Deref, F>(f: F) -> isize where F: FnOnce(&isize) -> R { f(&3).get() } fn return_it() -> isize { with(|o| o) //~ ERROR cannot infer } fn main() { }
#![allow(dead_code)]
random_line_split
regions-escape-via-trait-or-not.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 ...
() -> isize { with(|o| o) //~ ERROR cannot infer } fn main() { }
return_it
identifier_name
regions-escape-via-trait-or-not.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { }
{ with(|o| o) //~ ERROR cannot infer }
identifier_body
lib.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
#[phase(plugin, link)] extern crate log; pub use self::serialize::{Decoder, Encoder, Decodable, Encodable, DecoderHelpers, EncoderHelpers}; mod serialize; mod collection_impls; pub mod base64; pub mod ebml; pub mod hex; pub mod json;
#[cfg(test)] extern crate test;
random_line_split