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
lint-dead-code-5.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 v = Enum1::Variant1(1); match v { Enum1::Variant1(_) => (), Enum1::Variant2 => () } let x = Enum2::Variant3(true); }
main
identifier_name
timeout.rs
extern crate desync; use std::thread; use std::time::*; use std::sync::mpsc::*; use desync::scheduler::*; pub fn timeout<TFn:'static+Send+FnOnce() -> ()>(action: TFn, millis: u64) { enum ThreadState { Ok, Timeout, Panic }; let (tx, rx) = channel(); let (tx1, tx2) = (tx.cl...
, ThreadState::Panic => { println!("{:?}", scheduler()); panic!("Timed thread panicked"); } } }
{ println!("{:?}", scheduler()); panic!("Timeout"); }
conditional_block
timeout.rs
extern crate desync; use std::thread; use std::time::*; use std::sync::mpsc::*; use desync::scheduler::*; pub fn timeout<TFn:'static+Send+FnOnce() -> ()>(action: TFn, millis: u64) { enum ThreadState { Ok, Timeout, Panic }; let (tx, rx) = channel(); let (tx1, tx2) = (tx.cl...
ThreadState::Ok => { // Stop the timer thread timer_done.send(()).expect("Stop timer"); timer.join().expect("Wait for timer to stop"); }, ThreadState::Timeout => { println!("{:?}", scheduler()); panic!("Timeout"); }, Thr...
match rx.recv().expect("Receive timeout status") {
random_line_split
timeout.rs
extern crate desync; use std::thread; use std::time::*; use std::sync::mpsc::*; use desync::scheduler::*; pub fn timeout<TFn:'static+Send+FnOnce() -> ()>(action: TFn, millis: u64) { enum
{ Ok, Timeout, Panic }; let (tx, rx) = channel(); let (tx1, tx2) = (tx.clone(), tx.clone()); thread::Builder::new() .name("test timeout thread".to_string()) .spawn(move || { struct DetectPanic(Sender<ThreadState>); impl Drop for Detect...
ThreadState
identifier_name
main.rs
/* diosix hypervisor main entry code * * (c) Chris Williams, 2019-2021. * * See LICENSE for usage and copying. */ /* let the compiler know we're on our own here in bare-metal world */ #![no_std] #![no_main] #![feature(asm)] #![allow(dead_code)] #![allow(unused_unsafe)] #![allow(improper_ctypes)] #![feature(type...
#[test_case] fn test_assertion() { assert_eq!(42, 42); }
random_line_split
main.rs
/* diosix hypervisor main entry code * * (c) Chris Williams, 2019-2021. * * See LICENSE for usage and copying. */ /* let the compiler know we're on our own here in bare-metal world */ #![no_std] #![no_main] #![feature(asm)] #![allow(dead_code)] #![allow(unused_unsafe)] #![allow(improper_ctypes)] #![feature(type...
{ assert_eq!(42, 42); }
identifier_body
main.rs
/* diosix hypervisor main entry code * * (c) Chris Williams, 2019-2021. * * See LICENSE for usage and copying. */ /* let the compiler know we're on our own here in bare-metal world */ #![no_std] #![no_main] #![feature(asm)] #![allow(dead_code)] #![allow(unused_unsafe)] #![allow(improper_ctypes)] #![feature(type...
(unit_tests: &[&dyn Fn()]) { /* run each test one by one */ for test in unit_tests { test(); } /* exit cleanly once tests are complete */ platform::test::end(Ok(0)); } #[test_case] fn test_assertion() { assert_eq!(42, 42); }
run_tests
identifier_name
generic-fn.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T>(x: T) -> T { return x; } #[derive(Copy)] struct Triple {x: int, y: int, z: int} pub fn main() { let mut x = 62; let mut y = 63; let a = 'a'; let mut b = 'b'; let p: Triple = Triple {x: 65, y: 66, z: 67}; let mut q: Triple = Triple {x: 68, y: 69, z: 70}; y = id::<int>(x); println!("...
id
identifier_name
generic-fn.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 ...
#[derive(Copy)] struct Triple {x: int, y: int, z: int} pub fn main() { let mut x = 62; let mut y = 63; let a = 'a'; let mut b = 'b'; let p: Triple = Triple {x: 65, y: 66, z: 67}; let mut q: Triple = Triple {x: 68, y: 69, z: 70}; y = id::<int>(x); println!("{}", y); assert_eq!(x, y...
{ return x; }
identifier_body
generic-fn.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 ...
let mut x = 62; let mut y = 63; let a = 'a'; let mut b = 'b'; let p: Triple = Triple {x: 65, y: 66, z: 67}; let mut q: Triple = Triple {x: 68, y: 69, z: 70}; y = id::<int>(x); println!("{}", y); assert_eq!(x, y); b = id::<char>(a); println!("{}", b); assert_eq!(a, b); ...
pub fn main() {
random_line_split
blob_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 filemanager_thread::{FileManager, UIProvider}; use hyper::header::{DispositionType, ContentDisposition, Dispos...
] }); } headers.set(ContentType(content_type.clone())); headers.set(ContentLength(blob_buf.size as u64)); let metadata = Metadata { final_url: load_data.url.clone(), cont...
random_line_split
blob_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 filemanager_thread::{FileManager, UIProvider}; use hyper::header::{DispositionType, ContentDisposition, Dispos...
<UI:'static + UIProvider> (load_data: LoadData, start_chan: LoadConsumer, classifier: Arc<MimeClassifier>, filemanager: Arc<FileManager<UI>>, cancel_listener: CancellationListener) { let (chan, recv) = ipc::channel().unwrap(); if let Ok((id, origin, _fragment))...
load_blob
identifier_name
blob_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 filemanager_thread::{FileManager, UIProvider}; use hyper::header::{DispositionType, ContentDisposition, Dispos...
fn load_blob<UI:'static + UIProvider> (load_data: LoadData, start_chan: LoadConsumer, classifier: Arc<MimeClassifier>, filemanager: Arc<FileManager<UI>>, cancel_listener: CancellationListener) { let (chan, recv) = ipc::channel().unwrap(); if let Ok((id, origi...
{ box move |load_data: LoadData, start_chan, classifier, cancel_listener| { spawn_named(format!("blob loader for {}", load_data.url), move || { load_blob(load_data, start_chan, classifier, filemanager, cancel_listener); }) } }
identifier_body
blob_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 filemanager_thread::{FileManager, UIProvider}; use hyper::header::{DispositionType, ContentDisposition, Dispos...
Err(e) => { let err = NetworkError::Internal(format!("{:?}", e)); send_error(load_data.url, err, start_chan); } } } else { let e = format!("Invalid blob URL format {:?}", load_data.url); let format_err = NetworkError::Internal(e); ...
{ let err = NetworkError::Internal("Invalid filemanager reply".to_string()); send_error(load_data.url, err, start_chan); }
conditional_block
helpers.rs
extern crate sodiumoxide; use sodiumoxide::crypto::asymmetricbox::{PublicKey, SecretKey, PUBLICKEYBYTES, NONCEBYTES, Nonce}; use std::vec::MutableCloneableVector; pub trait KeyBytes { fn key_bytes<'a>(&'a self) -> &'a [u8]; } impl KeyBytes for PublicKey { fn key_bytes<'a>(&'a self) -> &'a [u8] { match self { &...
PublicKey(buf) } pub fn bytes_to_nonce(bytes: &[u8]) -> Nonce { let mut buf: [u8,..NONCEBYTES] = [0,..NONCEBYTES]; buf.copy_from(bytes); Nonce(buf) } /*pub trait GetInner<T> { fn get_inner<'a>(&'a self) -> &'a T; } impl<Nonce> GetInner<Nonce> for consts::NonceWrap { fn get_inner<'a>(&'a self) -> &'a Nonce {...
random_line_split
helpers.rs
extern crate sodiumoxide; use sodiumoxide::crypto::asymmetricbox::{PublicKey, SecretKey, PUBLICKEYBYTES, NONCEBYTES, Nonce}; use std::vec::MutableCloneableVector; pub trait KeyBytes { fn key_bytes<'a>(&'a self) -> &'a [u8]; } impl KeyBytes for PublicKey { fn key_bytes<'a>(&'a self) -> &'a [u8] { match self { &...
(bytes: &[u8]) -> PublicKey { let mut buf: [u8,..PUBLICKEYBYTES] = [0,..PUBLICKEYBYTES]; buf.copy_from(bytes); PublicKey(buf) } pub fn bytes_to_nonce(bytes: &[u8]) -> Nonce { let mut buf: [u8,..NONCEBYTES] = [0,..NONCEBYTES]; buf.copy_from(bytes); Nonce(buf) } /*pub trait GetInner<T> { fn get_inner<'a>(&'a ...
bytes_to_pubkey
identifier_name
helpers.rs
extern crate sodiumoxide; use sodiumoxide::crypto::asymmetricbox::{PublicKey, SecretKey, PUBLICKEYBYTES, NONCEBYTES, Nonce}; use std::vec::MutableCloneableVector; pub trait KeyBytes { fn key_bytes<'a>(&'a self) -> &'a [u8]; } impl KeyBytes for PublicKey { fn key_bytes<'a>(&'a self) -> &'a [u8] { match self { &...
} impl KeyBytes for Nonce { fn key_bytes<'a>(&'a self) -> &'a [u8] { match self { &Nonce(ref bytes) => bytes.as_slice() } } } pub fn bytes_to_pubkey(bytes: &[u8]) -> PublicKey { let mut buf: [u8,..PUBLICKEYBYTES] = [0,..PUBLICKEYBYTES]; buf.copy_from(bytes); PublicKey(buf) } pub fn bytes_to_nonce(bytes:...
{ match self { &SecretKey(ref bytes) => bytes.as_slice() } }
identifier_body
memorydb.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
/// Return the internal map of hashes to data, clearing the current state. pub fn drain(&mut self) -> H256FastMap<(DBValue, i32)> { mem::replace(&mut self.data, H256FastMap::default()) } /// Grab the raw information associated with a key. Returns None if the key /// doesn't exist. /// /// Even when Some is ...
{ let empties: Vec<_> = self.data.iter() .filter(|&(_, &(_, rc))| rc == 0) .map(|(k, _)| k.clone()) .collect(); for empty in empties { self.data.remove(&empty); } }
identifier_body
memorydb.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
(&mut self) { let empties: Vec<_> = self.data.iter() .filter(|&(_, &(_, rc))| rc == 0) .map(|(k, _)| k.clone()) .collect(); for empty in empties { self.data.remove(&empty); } } /// Return the internal map of hashes to data, clearing the current state. pub fn drain(&mut self) -> H256FastMap<(DBValue, i3...
purge
identifier_name
memorydb.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
return; } match self.data.entry(key.clone()) { Entry::Occupied(mut entry) => if entry.get().1 == 1 { entry.remove(); } else { entry.get_mut().1 -= 1; }, Entry::Vacant(entry) => { entry.insert((DBValue::new(), -1)); } } } /// Consolidate all the entries of `other` into `sel...
random_line_split
memorydb.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
, None => true, }{ //... None falls through into... self.data.insert(key.clone(), (DBValue::from_slice(value), 1)); } key } fn emplace(&mut self, key: H256, value: DBValue) { if &*value == &NULL_RLP { return; } match self.data.get_mut(&key) { Some(&mut (ref mut old_value, ref mut rc @ -0x800...
{ *x += 1; false }
conditional_block
lib.rs
// Copyright (C) 2016 ParadoxSpiral // // This file is part of mpv-sys. // // This library 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 2.1 of the License, or (at your option) an...
include!(concat!(env!("OUT_DIR"), "/bindings.rs")); #[inline] /// Returns the associated error string. pub fn mpv_error_str(e: mpv_error) -> &'static str { let raw = unsafe { mpv_error_string(e) }; unsafe { ::std::ffi::CStr::from_ptr(raw) }.to_str().unwrap() }
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)]
random_line_split
lib.rs
// Copyright (C) 2016 ParadoxSpiral // // This file is part of mpv-sys. // // This library 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 2.1 of the License, or (at your option) an...
{ let raw = unsafe { mpv_error_string(e) }; unsafe { ::std::ffi::CStr::from_ptr(raw) }.to_str().unwrap() }
identifier_body
lib.rs
// Copyright (C) 2016 ParadoxSpiral // // This file is part of mpv-sys. // // This library 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 2.1 of the License, or (at your option) an...
(e: mpv_error) -> &'static str { let raw = unsafe { mpv_error_string(e) }; unsafe { ::std::ffi::CStr::from_ptr(raw) }.to_str().unwrap() }
mpv_error_str
identifier_name
resource-generic.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T> {val: T, fin: extern fn(T)} struct finish<T> { arg: Arg<T> } #[unsafe_destructor] impl<T:Copy> Drop for finish<T> { fn drop(&self) { unsafe { (self.arg.fin)(copy self.arg.val); } } } fn finish<T:Copy>(arg: Arg<T>) -> finish<T> { finish { arg: arg } } pub fn ...
Arg
identifier_name
resource-generic.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 ...
{ let _i = finish(Arg{val: box, fin: dec_box}); } assert_eq!(*box, 9); }
pub fn main() { let box = @mut 10; fn dec_box(i: @mut int) { *i -= 1; }
random_line_split
util.rs
use std::path::{Path, PathBuf}; use std::collections::BTreeMap; use unshare::{Command}; use crate::config::Container; use crate::config::command::Run; pub fn find_cmd(cmd: &str, env: &BTreeMap<String, String>) -> Result<PathBuf, String> { if cmd.contains("/") { return Ok(PathBuf::from(cmd)); } e...
pub fn gen_command(default_shell: &Vec<String>, cmdline: &Run, env: &BTreeMap<String, String>) -> Result<Command, String> { match *cmdline { Run::Shell(ref data) => { if default_shell.len() > 0 { let mut cmd = Command::new(&default_shell[0]); ...
{ if container_config.is_data_container() { warn!("You are trying to run command inside the data container. \ Data containers is designed to use as volumes inside other \ containers. Usually there are no system dirs at all."); } }
identifier_body
util.rs
use std::path::{Path, PathBuf}; use std::collections::BTreeMap; use unshare::{Command}; use crate::config::Container; use crate::config::command::Run; pub fn
(cmd: &str, env: &BTreeMap<String, String>) -> Result<PathBuf, String> { if cmd.contains("/") { return Ok(PathBuf::from(cmd)); } else { if let Some(paths) = env.get(&"PATH".to_string()) { for dir in paths[..].split(':') { let path = Path::new(dir); ...
find_cmd
identifier_name
util.rs
use std::path::{Path, PathBuf}; use std::collections::BTreeMap; use unshare::{Command}; use crate::config::Container; use crate::config::command::Run; pub fn find_cmd(cmd: &str, env: &BTreeMap<String, String>) -> Result<PathBuf, String> { if cmd.contains("/") { return Ok(PathBuf::from(cmd)); } e...
} Run::Command(ref cmdline) => { let cpath = find_cmd(&cmdline[0], &env)?; let mut cmd = Command::new(&cpath); cmd.args(&cmdline[1..]); return Ok(cmd); } } }
{ let mut cmd = Command::new("/bin/sh"); cmd.arg("-c"); cmd.arg(data); cmd.arg("--"); return Ok(cmd); }
conditional_block
util.rs
use std::path::{Path, PathBuf}; use std::collections::BTreeMap; use unshare::{Command}; use crate::config::Container; use crate::config::command::Run; pub fn find_cmd(cmd: &str, env: &BTreeMap<String, String>) -> Result<PathBuf, String> { if cmd.contains("/") { return Ok(PathBuf::from(cmd)); } e...
containers. Usually there are no system dirs at all."); } } pub fn gen_command(default_shell: &Vec<String>, cmdline: &Run, env: &BTreeMap<String, String>) -> Result<Command, String> { match *cmdline { Run::Shell(ref data) => { if default_shell.len() > 0 { ...
if container_config.is_data_container() { warn!("You are trying to run command inside the data container. \ Data containers is designed to use as volumes inside other \
random_line_split
debug_output.rs
use flowgger::config::Config; use flowgger::merger::Merger; use std::io::{stdout, Write}; use std::sync::mpsc::Receiver; use std::sync::{Arc, Mutex}; use std::thread; use super::Output; pub struct DebugOutput; impl DebugOutput { pub fn new(_config: &Config) -> DebugOutput { DebugOutput } } impl Outpu...
(&self, arx: Arc<Mutex<Receiver<Vec<u8>>>>, merger: Option<Box<Merger>>) { let merger = match merger { Some(merger) => Some(merger.clone_boxed()), None => None, }; thread::spawn(move || { loop { let mut bytes = match { arx.l...
start
identifier_name
debug_output.rs
use flowgger::config::Config; use flowgger::merger::Merger; use std::io::{stdout, Write}; use std::sync::mpsc::Receiver; use std::sync::{Arc, Mutex}; use std::thread; use super::Output; pub struct DebugOutput; impl DebugOutput { pub fn new(_config: &Config) -> DebugOutput { DebugOutput } } impl Outpu...
let _ = stdout().flush(); } }); } }
merger.frame(&mut bytes); } let out = String::from_utf8_lossy(&bytes); print!("{}", out);
random_line_split
debug_output.rs
use flowgger::config::Config; use flowgger::merger::Merger; use std::io::{stdout, Write}; use std::sync::mpsc::Receiver; use std::sync::{Arc, Mutex}; use std::thread; use super::Output; pub struct DebugOutput; impl DebugOutput { pub fn new(_config: &Config) -> DebugOutput
} impl Output for DebugOutput { fn start(&self, arx: Arc<Mutex<Receiver<Vec<u8>>>>, merger: Option<Box<Merger>>) { let merger = match merger { Some(merger) => Some(merger.clone_boxed()), None => None, }; thread::spawn(move || { loop { let...
{ DebugOutput }
identifier_body
extern-crosscrate.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let result = fact(10u); info2!("result = {}", result); assert_eq!(result, 3628800u); }
{ unsafe { info2!("n = {}", n); externcallback::rustrt::rust_dbg_call(externcallback::cb, n) } }
identifier_body
extern-crosscrate.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 ...
info2!("result = {}", result); assert_eq!(result, 3628800u); }
random_line_split
extern-crosscrate.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 ...
(n: uint) -> uint { unsafe { info2!("n = {}", n); externcallback::rustrt::rust_dbg_call(externcallback::cb, n) } } pub fn main() { let result = fact(10u); info2!("result = {}", result); assert_eq!(result, 3628800u); }
fact
identifier_name
line_reader.rs
use std::io::{self, Read}; use std::str::{self, Utf8Error}; #[derive(Debug)] struct ReaderBuf { vec: Vec<u8>, msg_start: usize, write_loc: usize } impl ReaderBuf { pub fn new(buffer_size: usize) -> ReaderBuf { let mut vec = Vec::with_capacity(buffer_size); unsafe { vec.set_len(buffer_s...
const TEXT: &'static str = "hello\nworld\nhow's\nit\ngoing?\n"; #[test] fn static_buffer_single_read() { let mut data = Cursor::new(TEXT); let mut line_reader = LineReader::new(1024); let bytes_read = line_reader.read(&mut data).unwrap(); assert_eq!(false, line_reader.is_em...
#[cfg(test)] mod tests { use std::io::Cursor; use super::LineReader;
random_line_split
line_reader.rs
use std::io::{self, Read}; use std::str::{self, Utf8Error}; #[derive(Debug)] struct ReaderBuf { vec: Vec<u8>, msg_start: usize, write_loc: usize } impl ReaderBuf { pub fn new(buffer_size: usize) -> ReaderBuf { let mut vec = Vec::with_capacity(buffer_size); unsafe { vec.set_len(buffer_s...
#[test] fn static_buffer_partial_read_follow_by_complete_read() { let mut string = TEXT.to_string(); string.push_str("ok"); let mut data = Cursor::new(&string); let mut line_reader = LineReader::new(1024); let bytes_read = line_reader.read(&mut data).unwrap(); a...
{ let mut data = Cursor::new(TEXT); let mut line_reader = LineReader::new(1024); let bytes_read = line_reader.read(&mut data).unwrap(); assert_eq!(false, line_reader.is_empty()); assert_eq!(TEXT.len(), bytes_read); assert_eq!(5, line_reader.iter_mut().count()); as...
identifier_body
line_reader.rs
use std::io::{self, Read}; use std::str::{self, Utf8Error}; #[derive(Debug)] struct ReaderBuf { vec: Vec<u8>, msg_start: usize, write_loc: usize } impl ReaderBuf { pub fn new(buffer_size: usize) -> ReaderBuf { let mut vec = Vec::with_capacity(buffer_size); unsafe { vec.set_len(buffer_s...
let slice = &self.buf.vec[self.buf.msg_start..self.buf.write_loc]; match slice.iter().position(|&c| c == '\n' as u8) { Some(index) => { self.buf.msg_start = self.buf.msg_start + index + 1; Some(str::from_utf8(&slice[0..index+1]).map(|s| s.to_string())) ...
{ self.buf.reset(); return None; }
conditional_block
line_reader.rs
use std::io::{self, Read}; use std::str::{self, Utf8Error}; #[derive(Debug)] struct ReaderBuf { vec: Vec<u8>, msg_start: usize, write_loc: usize } impl ReaderBuf { pub fn new(buffer_size: usize) -> ReaderBuf { let mut vec = Vec::with_capacity(buffer_size); unsafe { vec.set_len(buffer_s...
(&self) -> bool { self.write_loc == 0 } } /// An iterator over lines available from the current spot in the buffer pub struct Iter<'a> { buf: &'a mut ReaderBuf } impl<'a> Iterator for Iter<'a> { type Item = Result<String, Utf8Error>; fn next(&mut self) -> Option<Result<String, Utf8Error>> { ...
is_empty
identifier_name
pipe-sleep.rs
// xfail-fast // 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 // <...
{ use oneshot::client::*; let c = pipes::spawn_service(oneshot::init, |p| { recv(p); }); let iotask = &uv::global_loop::get(); sleep(iotask, 500); signal(c); }
identifier_body
pipe-sleep.rs
// xfail-fast // 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 // <...
signal(c); }
let iotask = &uv::global_loop::get(); sleep(iotask, 500);
random_line_split
pipe-sleep.rs
// xfail-fast // 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 // <...
() { use oneshot::client::*; let c = pipes::spawn_service(oneshot::init, |p| { recv(p); }); let iotask = &uv::global_loop::get(); sleep(iotask, 500); signal(c); }
main
identifier_name
svggraphicselement.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::inheritance::Castable; use crate::dom::document::Document; use crate::dom::svgelement::...
} impl VirtualMethods for SVGGraphicsElement { fn super_type(&self) -> Option<&dyn VirtualMethods> { Some(self.upcast::<SVGElement>() as &dyn VirtualMethods) } }
{ SVGGraphicsElement { svgelement: SVGElement::new_inherited_with_state(state, tag_name, prefix, document), } }
identifier_body
svggraphicselement.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::inheritance::Castable; use crate::dom::document::Document; use crate::dom::svgelement::...
} impl SVGGraphicsElement { pub fn new_inherited( tag_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> SVGGraphicsElement { SVGGraphicsElement::new_inherited_with_state( ElementState::empty(), tag_name, prefix, do...
#[dom_struct] pub struct SVGGraphicsElement { svgelement: SVGElement,
random_line_split
svggraphicselement.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::inheritance::Castable; use crate::dom::document::Document; use crate::dom::svgelement::...
{ svgelement: SVGElement, } impl SVGGraphicsElement { pub fn new_inherited( tag_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> SVGGraphicsElement { SVGGraphicsElement::new_inherited_with_state( ElementState::empty(), tag_name, ...
SVGGraphicsElement
identifier_name
cauchy.rs
// Copyright 2018 Developers of the Rand project. // Copyright 2016-2017 The Rust Project Developers. // // 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. Thi...
} #[test] #[should_panic] fn test_cauchy_invalid_scale_zero() { Cauchy::new(0.0, 0.0).unwrap(); } #[test] #[should_panic] fn test_cauchy_invalid_scale_neg() { Cauchy::new(0.0, -10.0).unwrap(); } #[test] fn value_stability() { fn gen_samples<F: Float...
// NOTE: given that the variance and mean are undefined, // this test does not have any rigorous statistical meaning. let cauchy = Cauchy::new(10.0, 5.0).unwrap(); let mut rng = crate::test::rng(123); let mut numbers: [f64; 1000] = [0.0; 1000]; let mut sum = 0.0; ...
identifier_body
cauchy.rs
// Copyright 2018 Developers of the Rand project. // Copyright 2016-2017 The Rust Project Developers. // // 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. Thi...
) { // NOTE: given that the variance and mean are undefined, // this test does not have any rigorous statistical meaning. let cauchy = Cauchy::new(10.0, 5.0).unwrap(); let mut rng = crate::test::rng(123); let mut numbers: [f64; 1000] = [0.0; 1000]; let mut sum = 0.0; ...
est_cauchy_averages(
identifier_name
cauchy.rs
// Copyright 2018 Developers of the Rand project. // Copyright 2016-2017 The Rust Project Developers. //
// 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 file may not be copied, modified, or distributed // except according to those terms. //! The Cauchy di...
random_line_split
table.rs
use std::cmp::max; use std::env; use std::ops::Deref; use std::sync::{Mutex, MutexGuard}; use datetime::TimeZone; use zoneinfo_compiled::{CompiledData, Result as TZResult}; use lazy_static::lazy_static; use log::*; use users::UsersCache; use crate::fs::{File, fields as f}; use crate::fs::feature::git::GitCache; use ...
Numeric, /// Show the name Name, } impl Default for SizeFormat { fn default() -> Self { Self::DecimalBytes } } /// The types of a file’s time fields. These three fields are standard /// across most (all?) operating systems. #[derive(PartialEq, Debug, Copy, Clone)] pub enum TimeType { ...
UID / GID
identifier_name
table.rs
use std::cmp::max; use std::env; use std::ops::Deref; use std::sync::{Mutex, MutexGuard}; use datetime::TimeZone; use zoneinfo_compiled::{CompiledData, Result as TZResult}; use lazy_static::lazy_static; use log::*; use users::UsersCache; use crate::fs::{File, fields as f}; use crate::fs::feature::git::GitCache; use ...
columns.push(Column::FileSize); } if self.blocks { columns.push(Column::Blocks); } if self.user { columns.push(Column::User); } if self.group { columns.push(Column::Group); } if self.time_types.modified {...
{ let mut columns = Vec::with_capacity(4); if self.inode { columns.push(Column::Inode); } if self.octal { columns.push(Column::Octal); } if self.permissions { columns.push(Column::Permissions); } if self.links { ...
identifier_body
table.rs
use std::cmp::max; use std::env; use std::ops::Deref; use std::sync::{Mutex, MutexGuard}; use datetime::TimeZone; use zoneinfo_compiled::{CompiledData, Result as TZResult}; use lazy_static::lazy_static; use log::*; use users::UsersCache; use crate::fs::{File, fields as f}; use crate::fs::feature::git::GitCache; use ...
if self.time_types.modified { columns.push(Column::Timestamp(TimeType::Modified)); } if self.time_types.changed { columns.push(Column::Timestamp(TimeType::Changed)); } if self.time_types.created { columns.push(Column::Timestamp(TimeType::Crea...
columns.push(Column::Group); }
random_line_split
auth_macros.rs
macro_rules! auth_module (($auth_name:ident, $verify_name:ident, $keybytes:expr, $tagbytes:expr) => ( use libc::{c_ulonglong}; use randombytes::randombytes_into; use rustc_serialize; pub const KEYBYTES: usize = $keybytes; pub const TAGBY...
$final_name(state, &mut tag); Tag(tag) } } } #[cfg(test)] mod test_s { use super::*; #[test] fn test_auth_eq_auth_state() { use randombytes::randombytes; for i in (0..256usize) { let k = gen_key(); let m = randombytes(i); ...
let mut tag = [0; $tagbytes as usize];
random_line_split
parity.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
use std::path::PathBuf; use {SafeAccount, Error}; use super::{KeyDirectory, DiskDirectory, DirectoryType}; fn parity_dir_path() -> PathBuf { let mut home = env::home_dir().expect("Failed to get home dir"); home.push(".parity"); home } fn parity_keystore(t: DirectoryType) -> PathBuf { let mut dir = parity_dir_path...
// along with Parity. If not, see <http://www.gnu.org/licenses/>. use std::env;
random_line_split
parity.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} dir } pub struct ParityDirectory { dir: DiskDirectory, } impl ParityDirectory { pub fn create(t: DirectoryType) -> Result<Self, Error> { let result = ParityDirectory { dir: DiskDirectory::create(parity_keystore(t))?, }; Ok(result) } pub fn open(t: DirectoryType) -> Self { ParityDirectory { di...
{ dir.push("keys"); }
conditional_block
parity.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
fn insert(&self, account: SafeAccount) -> Result<SafeAccount, Error> { self.dir.insert(account) } fn update(&self, account: SafeAccount) -> Result<SafeAccount, Error> { self.dir.update(account) } fn remove(&self, account: &SafeAccount) -> Result<(), Error> { self.dir.remove(account) } }
{ self.dir.load() }
identifier_body
parity.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
(&self, account: &SafeAccount) -> Result<(), Error> { self.dir.remove(account) } }
remove
identifier_name
minkowski_difference_test.rs
extern crate quickcheck; use TOLERANCE; use maths::{DotProduct, Transform, UnitQuat, UnitVec3D, Vec3D}; use collisions::CollisionData; use collisions::shapes::{Direction, SupportMap}; use collisions::shapes::convex_shapes::Cuboid; use collisions::shapes::behaviour::support_map_behaviour; use collisions::detection::gjk...
() { fn property(rotation: UnitQuat, random_direction: UnitVec3D) { let control = CollisionData::new( Box::new(Cuboid::cube(1.0)), Transform::identity(), ); let data = CollisionData::new( Box::new(Cuboid::cube(1.0)), Transform { ...
it_always_generates_a_valid_support_point
identifier_name
minkowski_difference_test.rs
extern crate quickcheck; use TOLERANCE; use maths::{DotProduct, Transform, UnitQuat, UnitVec3D, Vec3D}; use collisions::CollisionData; use collisions::shapes::{Direction, SupportMap}; use collisions::shapes::convex_shapes::Cuboid; use collisions::shapes::behaviour::support_map_behaviour; use collisions::detection::gjk...
let max_neg_data = data.vertices_iter() .max_by_key(|vertex| (-vertex.dot(direction) / TOLERANCE) as i32) .unwrap(); let support_point = diff.support_points_iter(Direction::from(direction)).next().unwrap(); let support_point_distance = support_point.dot(direction); ...
{ let control = CollisionData::new( Box::new(Cuboid::cube(1.0)), Transform::identity(), ); let data = CollisionData::new( Box::new(Cuboid::cube(1.0)), Transform { translation: Vec3D::zero(), rotation: rotation.into()...
identifier_body
minkowski_difference_test.rs
extern crate quickcheck; use TOLERANCE; use maths::{DotProduct, Transform, UnitQuat, UnitVec3D, Vec3D}; use collisions::CollisionData; use collisions::shapes::{Direction, SupportMap}; use collisions::shapes::convex_shapes::Cuboid; use collisions::shapes::behaviour::support_map_behaviour; use collisions::detection::gjk...
Box::new(Cuboid::cube(1.0)), Transform { translation: Vec3D::zero(), rotation: rotation.into(), }, ); let diff = MinkowskiDifference(&control, &data); let direction = Vec3D::from(random_direction); let max_control = co...
Transform::identity(), ); let data = CollisionData::new(
random_line_split
guard.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/. */ //! Machinery to conditionally expose things. use js::jsapi::JSContext; use js::rust::HandleObject; use servo_con...
/// The condition is satisfied if the function returns true. Func(unsafe fn(*mut JSContext, HandleObject) -> bool), /// The condition is satisfied if the preference is set. Pref(&'static str), /// The condition is always satisfied. Satisfied, } impl Condition { unsafe fn is_satisfied(&self,...
} /// A condition to expose things. pub enum Condition {
random_line_split
guard.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/. */ //! Machinery to conditionally expose things. use js::jsapi::JSContext; use js::rust::HandleObject; use servo_con...
} /// A condition to expose things. pub enum Condition { /// The condition is satisfied if the function returns true. Func(unsafe fn(*mut JSContext, HandleObject) -> bool), /// The condition is satisfied if the preference is set. Pref(&'static str), /// The condition is always satisfied. Satis...
{ if self.condition.is_satisfied(cx, obj) { Some(self.value) } else { None } }
identifier_body
guard.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/. */ //! Machinery to conditionally expose things. use js::jsapi::JSContext; use js::rust::HandleObject; use servo_con...
else { None } } } /// A condition to expose things. pub enum Condition { /// The condition is satisfied if the function returns true. Func(unsafe fn(*mut JSContext, HandleObject) -> bool), /// The condition is satisfied if the preference is set. Pref(&'static str), /// The ...
{ Some(self.value) }
conditional_block
guard.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/. */ //! Machinery to conditionally expose things. use js::jsapi::JSContext; use js::rust::HandleObject; use servo_con...
<T: Clone + Copy> { condition: Condition, value: T, } impl<T: Clone + Copy> Guard<T> { /// Construct a new guarded value. pub const fn new(condition: Condition, value: T) -> Self { Guard { condition: condition, value: value, } } /// Expose the value if t...
Guard
identifier_name
mod_power_of_2_is_reduced.rs
use malachite_base::num::arithmetic::traits::{ModIsReduced, ModPowerOf2IsReduced, PowerOf2}; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner; use malachite_nz::natural::Natural; use ...
fn benchmark_natural_mod_power_of_2_is_reduced_algorithms( gm: GenMode, config: GenConfig, limit: usize, file_name: &str, ) { run_benchmark( "limbs_mod_power_of_2_add_limb(&[Limb], Limb, u64)", BenchmarkType::Algorithms, natural_unsigned_pair_gen_var_4().get(gm, &config), ...
{ for (n, log_base) in natural_unsigned_pair_gen_var_4() .get(gm, &config) .take(limit) { if n.mod_power_of_2_is_reduced(log_base) { println!("{} is reduced mod 2^{}", n, log_base); } else { println!("{} is not reduced mod 2^{}", n, log_base); } ...
identifier_body
mod_power_of_2_is_reduced.rs
use malachite_base::num::arithmetic::traits::{ModIsReduced, ModPowerOf2IsReduced, PowerOf2}; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner; use malachite_nz::natural::Natural; use ...
(runner: &mut Runner) { register_demo!(runner, demo_natural_mod_power_of_2_is_reduced); register_bench!( runner, benchmark_natural_mod_power_of_2_is_reduced_algorithms ); } fn demo_natural_mod_power_of_2_is_reduced(gm: GenMode, config: GenConfig, limit: usize) { for (n, log_base) in na...
register
identifier_name
mod_power_of_2_is_reduced.rs
use malachite_base::num::arithmetic::traits::{ModIsReduced, ModPowerOf2IsReduced, PowerOf2}; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner;
register_demo!(runner, demo_natural_mod_power_of_2_is_reduced); register_bench!( runner, benchmark_natural_mod_power_of_2_is_reduced_algorithms ); } fn demo_natural_mod_power_of_2_is_reduced(gm: GenMode, config: GenConfig, limit: usize) { for (n, log_base) in natural_unsigned_pair_gen_...
use malachite_nz::natural::Natural; use malachite_nz_test_util::bench::bucketers::pair_1_natural_bit_bucketer; use malachite_nz_test_util::generators::natural_unsigned_pair_gen_var_4; pub(crate) fn register(runner: &mut Runner) {
random_line_split
mod_power_of_2_is_reduced.rs
use malachite_base::num::arithmetic::traits::{ModIsReduced, ModPowerOf2IsReduced, PowerOf2}; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner; use malachite_nz::natural::Natural; use ...
} } fn benchmark_natural_mod_power_of_2_is_reduced_algorithms( gm: GenMode, config: GenConfig, limit: usize, file_name: &str, ) { run_benchmark( "limbs_mod_power_of_2_add_limb(&[Limb], Limb, u64)", BenchmarkType::Algorithms, natural_unsigned_pair_gen_var_4().get(gm, &co...
{ println!("{} is not reduced mod 2^{}", n, log_base); }
conditional_block
file_reporter.rs
use super::{ErrorReporter, ReportKind, Message }; use std::fs::File; use std::io::{BufRead, BufReader, Write}; use std::cmp; use std::iter; use crate::common::{ constants::SPACES_PER_TAB, node_info::Span, }; /* Reports errors by printing/highlighting content from the given file */ pub struct F...
(span: &Span, report_kind: ReportKind, message: &String, lines: &[String]) { // may be called from multiple threads, at least in e2e tests. Prevent output from being garbled // when multiple threads attempt to print at the same time let stdout = std::io::stdout(); let stderr = std::io::stderr(); ...
write_highlight_message
identifier_name
file_reporter.rs
use super::{ErrorReporter, ReportKind, Message }; use std::fs::File; use std::io::{BufRead, BufReader, Write}; use std::cmp; use std::iter; use crate::common::{ constants::SPACES_PER_TAB, node_info::Span, }; /* Reports errors by printing/highlighting content from the given file */ pub struct F...
fn has_reports(&self) -> bool { self.messages.len() > 0 } fn errors(&self) -> i32 { self.errors } fn reports(&self) -> i32 { self.messages.len() as i32 } fn print_errors(&self) { let lines = self.read_lines(); for msg in self.mes...
{ self.errors != 0 }
identifier_body
file_reporter.rs
use super::{ErrorReporter, ReportKind, Message }; use std::fs::File; use std::io::{BufRead, BufReader, Write}; use std::cmp; use std::iter; use crate::common::{ constants::SPACES_PER_TAB, node_info::Span, }; /* Reports errors by printing/highlighting content from the given file */ pub struct F...
} } fn clear_reports(&mut self) { self.messages.clear(); } } fn write_highlight_message(span: &Span, report_kind: ReportKind, message: &String, lines: &[String]) { // may be called from multiple threads, at least in e2e tests. Prevent output from being garbled // when multi...
message, } => { write_highlight_message(span, *report_kind, message, lines.as_slice()) } }
random_line_split
unique-object-noncopyable.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() { let x = ~Bar { x: 10 }; let y: ~Foo = x as ~Foo; let _z = y.clone(); //~ ERROR does not implement any method in scope }
{ println!("hi"); }
identifier_body
unique-object-noncopyable.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 ...
(&mut self) {} } impl Foo for Bar { fn f(&self) { println!("hi"); } } fn main() { let x = ~Bar { x: 10 }; let y: ~Foo = x as ~Foo; let _z = y.clone(); //~ ERROR does not implement any method in scope }
drop
identifier_name
unique-object-noncopyable.rs
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait Foo { fn f(&self); } struct Bar { x: int, } impl Drop for Bar { fn d...
// 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
random_line_split
main.rs
extern crate rustc_serialize; extern crate docopt; #[macro_use] extern crate lust; use std::io::{self, Write, Read}; use std::path::Path; use std::fs::{File, metadata}; use docopt::Docopt; use lust::Parser; use lust::State; macro_rules! println_error { ($err:expr) => (println!("Whoops, error detected.\n{}.\n\ ...
() { let args = try_ok!(Docopt::new(USAGE).and_then(|d| d.decode::<CliArgs>())); let ref mut state = State::new("user".to_string()); let mut last_evaled = None; if let Some(ref flag_file) = args.flag_file { let path = Path::new(flag_file); let md = metadata(path); if is_file_exi...
main
identifier_name
main.rs
extern crate rustc_serialize; extern crate docopt; #[macro_use] extern crate lust; use std::io::{self, Write, Read}; use std::path::Path; use std::fs::{File, metadata}; use docopt::Docopt; use lust::Parser; use lust::State; macro_rules! println_error { ($err:expr) => (println!("Whoops, error detected.\n{}.\n\ ...
if args.flag_interactive { let stdin = io::stdin(); let mut stdout = io::stdout(); loop { print!("-> "); stdout.flush().ok(); let ref mut buf = String::new(); if try_ok!(stdin.read_line(buf)) > 0 { for expr in Parser::new(bu...
{ for parsed_expr in Parser::new(arg_expr.chars()) { last_evaled = Some(try_ok!(state.eval(&try_ok!(parsed_expr)))) } }
conditional_block
main.rs
extern crate rustc_serialize; extern crate docopt; #[macro_use] extern crate lust; use std::io::{self, Write, Read}; use std::path::Path; use std::fs::{File, metadata}; use docopt::Docopt; use lust::Parser; use lust::State; macro_rules! println_error { ($err:expr) => (println!("Whoops, error detected.\n{}.\n\ ...
return println_error!("File doesn't exist."); } } if let Some(ref arg_expr) = args.arg_expr { for parsed_expr in Parser::new(arg_expr.chars()) { last_evaled = Some(try_ok!(state.eval(&try_ok!(parsed_expr)))) } } if args.flag_interactive { let st...
{ let args = try_ok!(Docopt::new(USAGE).and_then(|d| d.decode::<CliArgs>())); let ref mut state = State::new("user".to_string()); let mut last_evaled = None; if let Some(ref flag_file) = args.flag_file { let path = Path::new(flag_file); let md = metadata(path); if is_file_exists...
identifier_body
main.rs
extern crate rustc_serialize; extern crate docopt; #[macro_use] extern crate lust; use std::io::{self, Write, Read}; use std::path::Path; use std::fs::{File, metadata}; use docopt::Docopt; use lust::Parser; use lust::State; macro_rules! println_error { ($err:expr) => (println!("Whoops, error detected.\n{}.\n\ ...
let ref mut state = State::new("user".to_string()); let mut last_evaled = None; if let Some(ref flag_file) = args.flag_file { let path = Path::new(flag_file); let md = metadata(path); if is_file_exists!(md) { if is_file!(md) { let mut file = try_ok!(File:...
let args = try_ok!(Docopt::new(USAGE).and_then(|d| d.decode::<CliArgs>()));
random_line_split
main.rs
#![feature(rustc_private)] extern crate rustc; extern crate rustc_back; extern crate rustc_metadata; extern crate rustc_llvm; extern crate flate; extern crate syntax_pos; extern crate serialize as rustc_serialize; #[macro_use] extern crate log; mod sectionreader; use rustc_serialize::{Encodable, Encoder, Decodabl...
dll_suffix: ".dll".to_string(), exe_suffix: ".exe".to_string(), staticlib_prefix: "".to_string(), staticlib_suffix: ".lib".to_string(), is_like_windows: true, is_like_msvc: true, pre_link_args: vec![ "/NOLOGO".to_string(), "/NXCOMPAT".to_st...
dynamic_linking: true, executables: true, dll_prefix: "".to_string(),
random_line_split
main.rs
#![feature(rustc_private)] extern crate rustc; extern crate rustc_back; extern crate rustc_metadata; extern crate rustc_llvm; extern crate flate; extern crate syntax_pos; extern crate serialize as rustc_serialize; #[macro_use] extern crate log; mod sectionreader; use rustc_serialize::{Encodable, Encoder, Decodabl...
(metadata_blob : MetadataBlob) -> KrateRut { let mut strins = Vec::new(); let crate_root = metadata_blob.get_root(); for (_, dep) in crate_root.crate_deps.decode(&metadata_blob).enumerate() { strins.push(format!("{}",dep.name)); }; KrateRut ...
new
identifier_name
main.rs
#![feature(rustc_private)] extern crate rustc; extern crate rustc_back; extern crate rustc_metadata; extern crate rustc_llvm; extern crate flate; extern crate syntax_pos; extern crate serialize as rustc_serialize; #[macro_use] extern crate log; mod sectionreader; use rustc_serialize::{Encodable, Encoder, Decodabl...
.. Default::default() } } fn target() -> TargetResult { let mut base = opts(); base.cpu = "x86-64".to_string(); base.max_atomic_width = Some(64); Ok(Target { llvm_target: "x86_64-pc-windows-msvc".to_string(), target_endian: "little".to_string(), target_pointer_width...
{ TargetOptions { function_sections: true, linker: "link.exe".to_string(), ar: "llvm-ar.exe".to_string(), dynamic_linking: true, executables: true, dll_prefix: "".to_string(), dll_suffix: ".dll".to_string(), exe_suffix: ".exe".to_string(), stat...
identifier_body
dropout.rs
use prelude::*; use kernels::ffi::*; use densearray::prelude::*; use operator::prelude::*; use rng::xorshift::{Xorshiftplus128Rng}; use rand::{Rng, thread_rng}; //use rand::distributions::{IndependentSample}; //use rand::distributions::range::{Range}; use std::cell::{RefCell}; use std::cmp::{max}; use std::rc::{Rc}; ...
self.node.pop(epoch); } fn _forward(&mut self, phase: OpPhase) { let batch_size = self.in_.batch_sz.get(); assert!(batch_size <= self.cfg.batch_sz); self.out.batch_sz.set(batch_size); match phase { OpPhase::Inference => { self.out.buf.borrow_mut()[.. batch_size * self.cfg.dim] ...
self.node.push(epoch); assert!(self.node.limit(1)); apply(self); self.in_op.borrow_mut()._traverse_bwd(epoch, apply);
random_line_split
dropout.rs
use prelude::*; use kernels::ffi::*; use densearray::prelude::*; use operator::prelude::*; use rng::xorshift::{Xorshiftplus128Rng}; use rand::{Rng, thread_rng}; //use rand::distributions::{IndependentSample}; //use rand::distributions::range::{Range}; use std::cell::{RefCell}; use std::cmp::{max}; use std::rc::{Rc}; ...
(&mut self) { let batch_size = self.out.batch_sz.get(); if let Some(in_grad) = self.in_.grad.as_ref() { let in_grad = &mut in_grad.borrow_mut()[.. batch_size * self.cfg.dim]; let out_grad = &self.out.grad.as_ref().unwrap().borrow()[.. batch_size * self.cfg.dim]; for p in 0.. batch_size * self....
_backward
identifier_name
dropout.rs
use prelude::*; use kernels::ffi::*; use densearray::prelude::*; use operator::prelude::*; use rng::xorshift::{Xorshiftplus128Rng}; use rand::{Rng, thread_rng}; //use rand::distributions::{IndependentSample}; //use rand::distributions::range::{Range}; use std::cell::{RefCell}; use std::cmp::{max}; use std::rc::{Rc}; ...
} impl<S, IoBuf:?Sized> Operator for DropoutOperator<S, IoBuf> { fn _next(&self) -> u64 { self.node._next() } } impl<S, IoBuf:?Sized> CommonOperator for DropoutOperator<S, IoBuf> { fn _output(&self, arm: usize) -> CommonOutput { assert_eq!(0, arm); self.out.clone() } } impl<S, IoBuf:?Sized> Diff...
{ let in_ = prev_op.borrow()._output(prev_arm); let out = CommonOutput::new(cfg.batch_sz, cfg.dim, cap); let mut mask = Vec::with_capacity(cfg.batch_sz * cfg.dim); mask.resize(cfg.batch_sz * cfg.dim, 0.0); Rc::new(RefCell::new(DropoutOperator{ cfg: cfg, node: OperatorNode::defau...
identifier_body
meta.rs
use error::ErrorKind::BadMetadataSyntax; use error::{InFile, Result}; use name::WadName; use regex::Regex; use rustc_serialize::{Decodable, Encodable}; use std::fs::File; use std::io::Read; use std::path::Path; use toml::{Decoder, Parser, Value}; use types::ThingType; #[derive(Debug, RustcDecodable, RustcEncodable)] p...
() { WadMetadata::from_text(r#" [[sky]] level_pattern = "MAP(0[1-9]|10|11)" texture_name = "SKY1" tiled_band_size = 0.15 [[sky]] level_pattern = "MAP(1[2-9]|20)" texture_name = "SKY2" tiled_ba...
test_wad_metadata
identifier_name
meta.rs
use error::ErrorKind::BadMetadataSyntax; use error::{InFile, Result}; use name::WadName; use regex::Regex; use rustc_serialize::{Decodable, Encodable}; use std::fs::File; use std::io::Read; use std::path::Path; use toml::{Decoder, Parser, Value}; use types::ThingType; #[derive(Debug, RustcDecodable, RustcEncodable)] p...
}) } pub fn find_thing(&self, thing_type: ThingType) -> Option<&ThingMetadata> { self.things .decorations .iter() .find(|t| t.thing_type == thing_type) .or_else(|| self.things.weapons.iter().find(|t| t.thing_type == thing_type)) .or_el...
{ error!("No sky metadata provided."); None }
conditional_block
meta.rs
use error::ErrorKind::BadMetadataSyntax; use error::{InFile, Result}; use name::WadName; use regex::Regex; use rustc_serialize::{Decodable, Encodable}; use std::fs::File; use std::io::Read; use std::path::Path; use toml::{Decoder, Parser, Value}; use types::ThingType; #[derive(Debug, RustcDecodable, RustcEncodable)] p...
pub fn sky_for(&self, name: &WadName) -> Option<&SkyMetadata> { self.sky .iter() .find(|sky| { Regex::new(&sky.level_pattern) .map(|r| r.is_match(name.as_ref())) .unwrap_or_else(|_| { warn!("Invalid level pa...
}) }
random_line_split
path_pass.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 ...
doc::ModDoc { item: (fold.fold_item)(fold, copy doc.item), .. doc } } fn fold_nmod(fold: &fold::Fold<Ctxt>, doc: doc::NmodDoc) -> doc::NmodDoc { fold.ctxt.path.push(doc.name()); let doc = fold::default_seq_fold_nmod(fold, doc); fold.ctxt.path.pop(); doc::NmodDoc { item...
{ fold.ctxt.path.pop(); }
conditional_block
path_pass.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 ...
() -> Pass { Pass { name: ~"path", f: run } } struct Ctxt { srv: astsrv::Srv, path: @mut ~[~str] } impl Clone for Ctxt { fn clone(&self) -> Ctxt { Ctxt { srv: self.srv.clone(), path: @mut copy *self.path } } } #[allow(non_implicitly_copy...
mk_pass
identifier_name
path_pass.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 ...
Pass { name: ~"path", f: run } } struct Ctxt { srv: astsrv::Srv, path: @mut ~[~str] } impl Clone for Ctxt { fn clone(&self) -> Ctxt { Ctxt { srv: self.srv.clone(), path: @mut copy *self.path } } } #[allow(non_implicitly_copyable_typarams...
#[cfg(test)] use extract; use syntax::ast; pub fn mk_pass() -> Pass {
random_line_split
path_pass.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 ...
} #[allow(non_implicitly_copyable_typarams)] fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc { let ctxt = Ctxt { srv: srv, path: @mut ~[] }; let fold = Fold { ctxt: ctxt.clone(), fold_item: fold_item, fold_mod: fold_mod, fold_nmod: fold_nmod, .. f...
{ Ctxt { srv: self.srv.clone(), path: @mut copy *self.path } }
identifier_body
star.rs
/* Copyright (c) 2015, 2016 Saurav Sachidanand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, di...
* `new_asc`: Right ascension at the different time *| in radians* * `new_dec`: Declination at the different time *| in radians* # Arguments * `asc0`: Right ascension of the star initially *| in radians* * `dec0`: Declination of the star initially *| in radians* * `r`: Distance of the...
`(new_asc, new_dec)`
random_line_split
star.rs
/* Copyright (c) 2015, 2016 Saurav Sachidanand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, di...
(asc0: f64, dec0: f64, r: f64, delta_r: f64, proper_motion_asc: f64, proper_motion_dec: f64, t: f64) -> (f64, f64) { let x = r * dec0.cos() * asc0.c...
eq_coords_frm_motion
identifier_name
star.rs
/* Copyright (c) 2015, 2016 Saurav Sachidanand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, di...
/** Computes the absolute magnitude of a star from its parallax # Arguments * `par`: Parallax of the star * `am`: Apparent magnitude of the star **/ #[inline] pub fn abs_mag_frm_parallax(par: f64, am: f64) -> f64 { am + 5.0 + 5.0*(par.to_degrees() * 3600.0).log10() } /** Computes the absolute magnitude of a st...
{ 2.5 * br.log10() }
identifier_body
struct-style-enum.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { // In order to avoid endianess trouble all of the following test values consist of a single // repeated byte. This way each interpretation of the union should look the same, no matter if // this is a big or little endian machine. // 0b01111100011111000111110001111100011111000111110001111100011111...
main
identifier_name
struct-style-enum.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// debugger:print univariant // check:$4 = {a = -1} #![allow(unused_variable)] #![feature(struct_variant)] // The first element is to ensure proper alignment, irrespective of the machines word size. Since // the size of the discriminant value is machine dependent, this has be taken into account when // datatype layou...
random_line_split
mod.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
// Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along w...
random_line_split
unused-attr.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 blah2(&self) {} } fn main() {}
trait Baz { #[foo] //~ ERROR unused attribute fn blah(&self); #[foo] //~ ERROR unused attribute
random_line_split
unused-attr.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() {}
main
identifier_name
unused-attr.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 ...
} } #[foo] //~ ERROR unused attribute struct Foo { #[foo] //~ ERROR unused attribute a: isize } #[foo] //~ ERROR unused attribute trait Baz { #[foo] //~ ERROR unused attribute fn blah(&self); #[foo] //~ ERROR unused attribute fn blah2(&self) {} } fn main() {}
{}
conditional_block