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 |
|---|---|---|---|---|
udp-multicast.rs | use std::{env, str};
use std::net::{UdpSocket, Ipv4Addr};
fn main() {
let mcast_group: Ipv4Addr = "239.0.0.1".parse().unwrap();
let port: u16 = 6000;
let any = "0.0.0.0".parse().unwrap();
let mut buffer = [0u8; 1600];
if env::args().count() > 1 | else {
let socket = UdpSocket::bind((any, 0)).expect("Could not bind socket");
socket.send_to("Hello world!".as_bytes(), &(mcast_group, port)).expect("Failed to write data");
}
}
| {
let socket = UdpSocket::bind((any, port)).expect("Could not bind client socket");
socket.join_multicast_v4(&mcast_group, &any).expect("Could not join multicast group");
socket.recv_from(&mut buffer).expect("Failed to write to server");
print!("{}", str::from_utf8(&buffe... | conditional_block |
udp-multicast.rs | use std::{env, str};
use std::net::{UdpSocket, Ipv4Addr};
fn main() | {
let mcast_group: Ipv4Addr = "239.0.0.1".parse().unwrap();
let port: u16 = 6000;
let any = "0.0.0.0".parse().unwrap();
let mut buffer = [0u8; 1600];
if env::args().count() > 1 {
let socket = UdpSocket::bind((any, port)).expect("Could not bind client socket");
socket.join_mul... | identifier_body | |
mod.rs | //! Messaging primitives for discovering devices and services.
use std::io;
#[cfg(windows)]
use std::net;
use std::net::SocketAddr;
use net::connector::UdpConnector;
use net::IpVersionMode;
mod notify;
mod search;
mod ssdp;
pub mod listen;
pub mod multicast;
pub use message::multicast::Multicast;
pub use message::s... |
}
// Filter all loopback and global IPv6 addresses
SocketAddr::V6(n) if!n.ip().is_loopback() &&!n.ip().is_global() => {
if let Some(x) = try!(f(&addr)) {
obj_list.push(x);
}
}
_ => (),
}
}
O... | {
obj_list.push(x);
} | conditional_block |
mod.rs | //! Messaging primitives for discovering devices and services.
use std::io;
#[cfg(windows)]
use std::net;
use std::net::SocketAddr;
use net::connector::UdpConnector;
use net::IpVersionMode;
mod notify;
mod search;
mod ssdp;
pub mod listen;
pub mod multicast;
pub use message::multicast::Multicast;
pub use message::s... | self.ttl = value;
self
}
pub fn set_mode(mut self, value: IpVersionMode) -> Self {
self.mode = value;
self
}
}
impl Default for Config {
fn default() -> Self {
Config {
ipv4_addr: UPNP_MULTICAST_IPV4_ADDR.to_string(),
ipv6_addr: UPNP_MULT... | }
pub fn set_ttl(mut self, value: u32) -> Self { | random_line_split |
mod.rs | //! Messaging primitives for discovering devices and services.
use std::io;
#[cfg(windows)]
use std::net;
use std::net::SocketAddr;
use net::connector::UdpConnector;
use net::IpVersionMode;
mod notify;
mod search;
mod ssdp;
pub mod listen;
pub mod multicast;
pub use message::multicast::Multicast;
pub use message::s... |
pub fn set_ipv6_addr<S: Into<String>>(mut self, value: S) -> Self {
self.ipv6_addr = value.into();
self
}
pub fn set_port(mut self, value: u16) -> Self {
self.port = value;
self
}
pub fn set_ttl(mut self, value: u32) -> Self {
self.ttl = value;
sel... | {
self.ipv4_addr = value.into();
self
} | identifier_body |
mod.rs | //! Messaging primitives for discovering devices and services.
use std::io;
#[cfg(windows)]
use std::net;
use std::net::SocketAddr;
use net::connector::UdpConnector;
use net::IpVersionMode;
mod notify;
mod search;
mod ssdp;
pub mod listen;
pub mod multicast;
pub use message::multicast::Multicast;
pub use message::s... | () -> io::Result<Vec<SocketAddr>> {
let iface_iter = try!(ifaces::Interface::get_all()).into_iter();
Ok(iface_iter.filter(|iface| iface.kind!= ifaces::Kind::Packet)
.filter_map(|iface| iface.addr)
.collect())
}
| get_local_addrs | identifier_name |
win.rs | use std::fs;
use std::path::Path;
use app_dirs::{self, AppDataType};
use util::*;
const CG_MN_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cg.dll";
const CG_GL_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgGL.dll";
const CG_D9_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgD3D9.dll";
#[c... | tempdir::TempDir;
let target = TempDir::new("lolupdater-cg-target").unwrap();
download_cg(&target.path().join("cg")).unwrap();
}
fn backup_cg() -> Result<()> {
let cg_backup = app_dirs::get_app_dir(AppDataType::UserData, &APP_INFO, "Backups/Cg")?;
if cg_backup.exists() {
info!("Skipping NVIDIA... | works() {
use | identifier_name |
win.rs | use std::fs;
use std::path::Path;
use app_dirs::{self, AppDataType};
use util::*;
const CG_MN_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cg.dll";
const CG_GL_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgGL.dll";
const CG_D9_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgD3D9.dll";
#[c... | nfo!("Restoring Nvidia Cg…");
update_cg(&cg_backup_path)?;
fs::remove_dir_all(&cg_backup_path)?;
info!("Removing Nvidia Cg backup…");
let cg_cache_path = app_dirs::get_app_dir(AppDataType::UserCache, &APP_INFO, "Cg")?;
if cg_cache_path.exists() {
info!("Removing Nvidia Cg download cache…");... | return Err("No Cg backup found!".into());
}
i | conditional_block |
win.rs | use std::fs;
use std::path::Path;
use app_dirs::{self, AppDataType};
use util::*;
const CG_MN_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cg.dll";
const CG_GL_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgGL.dll";
const CG_D9_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgD3D9.dll";
#[c... | &LOLSLN_GC_PATH.with(|k| k.clone()).join("cgD3D9.dll"),
)?;
Ok(())
} | random_line_split | |
win.rs | use std::fs;
use std::path::Path;
use app_dirs::{self, AppDataType};
use util::*;
const CG_MN_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cg.dll";
const CG_GL_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgGL.dll";
const CG_D9_DLL_DL: &str = "https://mobasuite.com/downloads/macos/cgD3D9.dll";
#[c... |
fn update_
cg(cg_dir: &Path) -> Result<()> {
update_file(
&cg_dir.join("Cg.dll"),
&LOLP_GC_PATH.with(|k| k.clone()).join("Cg.dll"),
)?;
update_file(
&cg_dir.join("CgGL.dll"),
&LOLP_GC_PATH.with(|k| k.clone()).join("CgGL.dll"),
)?;
update_file(
&cg_dir.join("c... | _backup = app_dirs::get_app_dir(AppDataType::UserData, &APP_INFO, "Backups/Cg")?;
if cg_backup.exists() {
info!("Skipping NVIDIA Cg backup! (Already exists)");
} else {
fs::create_dir(&cg_backup)?;
update_file(
&LOLP_GC_PATH.with(|k| k.clone()).join("Cg.dll"),
&cg... | identifier_body |
guess-the-number.rs | use std::string::String;
use std::fs::File;
use std::io::{Read, BufRead};
static mut TRIES_LEFT: i32 = 5;
static mut RAND_INT: i32 = -1;
static mut GUESS: i32 = -1;
fn main() {
unsafe {
// Open /dev/random
let mut devrandom = File::open("/dev/random").unwrap();
// Create a 1 byte large buffer
let ... | TRIES_LEFT -= 1;
if GUESS == RAND_INT {
println!("🎉 YOU WIN 🎉");
break;
} else if GUESS > RAND_INT {
println!("Too high, guy.");
} else {
println!("Too low, bro.");
}
}
}
} | random_line_split | |
guess-the-number.rs | use std::string::String;
use std::fs::File;
use std::io::{Read, BufRead};
static mut TRIES_LEFT: i32 = 5;
static mut RAND_INT: i32 = -1;
static mut GUESS: i32 = -1;
fn main() | println!("The number you wanted was {}", RAND_INT);
break;
}
println!("Make a guess: ");
input.truncate(0); // clear any previous input
handle.read_line(&mut input).unwrap();
GUESS = match input.trim().parse() {
Ok(integer) => integer,
... | {
unsafe {
// Open /dev/random
let mut devrandom = File::open("/dev/random").unwrap();
// Create a 1 byte large buffer
let mut randombyte: [u8; 1] = [0];
// Read exactly 1 byte from /dev/random1 byte wide buffer
devrandom.read_exact(&mut randombyte).unwrap();
// Clamp it to 0-100 with mo... | identifier_body |
guess-the-number.rs | use std::string::String;
use std::fs::File;
use std::io::{Read, BufRead};
static mut TRIES_LEFT: i32 = 5;
static mut RAND_INT: i32 = -1;
static mut GUESS: i32 = -1;
fn | () {
unsafe {
// Open /dev/random
let mut devrandom = File::open("/dev/random").unwrap();
// Create a 1 byte large buffer
let mut randombyte: [u8; 1] = [0];
// Read exactly 1 byte from /dev/random1 byte wide buffer
devrandom.read_exact(&mut randombyte).unwrap();
// Clamp it to 0-100 with... | main | identifier_name |
account.rs | // Copyright 2015-2017 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 lat... | (&self) -> Account {
Account {
balance: self.balance.clone(),
nonce: self.nonce.clone(),
storage_root: self.storage_root.clone(),
storage_cache: Self::empty_storage_cache(),
storage_changes: HashMap::new(),
code_hash: self.code_hash.clone(),
code_size: self.code_size.clone(),
code_cache: self.... | clone_basic | identifier_name |
account.rs | // Copyright 2015-2017 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 lat... |
/// Increase account balance.
pub fn add_balance(&mut self, x: &U256) {
self.balance = self.balance + *x;
}
/// Decrease account balance.
/// Panics if balance is less than `x`
pub fn sub_balance(&mut self, x: &U256) {
assert!(self.balance >= *x);
self.balance = self.balance - *x;
}
/// Commit the `st... | {
self.nonce = self.nonce + U256::from(1u8);
} | identifier_body |
account.rs | // Copyright 2015-2017 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 lat... | let mut a = Account::new_contract(69.into(), 0.into());
a.set_storage(H256::from(&U256::from(0x00u64)), H256::from(&U256::from(0x1234u64)));
a.commit_storage(&Default::default(), &mut db);
a.init_code(vec![]);
a.commit_code(&mut db);
a.rlp()
};
let a = Account::from_rlp(&rlp);
assert_eq!(a.stor... | fn storage_at() {
let mut db = MemoryDB::new();
let mut db = AccountDBMut::new(&mut db, &Address::new());
let rlp = { | random_line_split |
account.rs | // Copyright 2015-2017 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 lat... | ,
_ => {
warn!("Failed reverse get of {}", self.code_hash);
None
},
}
}
/// Provide code to cache. For correctness, should be the correct code for the
/// account.
pub fn cache_given_code(&mut self, code: Arc<Bytes>) {
trace!("Account::cache_given_code: ic={}; self.code_hash={:?}, self.code_cache... | {
self.code_size = Some(x.len());
self.code_cache = Arc::new(x.to_vec());
Some(self.code_cache.clone())
} | conditional_block |
fsu-moves-and-copies.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... | let b = MoveFoo {moved: box 13,..f};
let c = MoveFoo {copied: 14,..f};
assert_eq!(b.copied, 11);
assert_eq!(*b.moved, 13);
assert_eq!(c.copied, 14);
assert_eq!(*c.moved, 12);
}
fn test2() {
// move non-copyable field
let f = NoFoo::new(21, 22);
let b = NoFoo {nocopy: nci... | // copying move-by-default fields from `f`, so it moves:
let f = MoveFoo::new(11, 12);
| random_line_split |
fsu-moves-and-copies.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... |
}
impl Drop for DropMoveFoo { fn drop(&mut self) { } }
fn test0() {
// just copy implicitly copyable fields from `f`, no moves
// (and thus it is okay that these are Drop; compare against
// compile-fail test: borrowck-struct-update-with-dtor.rs).
// Case 1: Nocopyable
let f = DropNoFoo::new(1, ... | { DropMoveFoo { inner: MoveFoo::new(x,y) } } | identifier_body |
fsu-moves-and-copies.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... | (x:int,y:int) -> MoveFoo { MoveFoo { copied: x, moved: box y } }
}
struct DropNoFoo { inner: NoFoo }
impl DropNoFoo {
fn new(x:int,y:int) -> DropNoFoo { DropNoFoo { inner: NoFoo::new(x,y) } }
}
impl Drop for DropNoFoo { fn drop(&mut self) { } }
struct DropMoveFoo { inner: MoveFoo }
impl DropMoveFoo {
fn new(x... | new | identifier_name |
tiles.rs | use super::Tile;
use colors;
use pixset;
use pixset::PixLike;
use units;
pub struct Tiles<P: PixLike> {
size: units::Size2D,
pub tiles: Vec<Tile<P>>, // TODO impl Index
}
impl<P> Tiles<P>
where
P: pixset::PixLike,
{
pub fn new(size: units::Size2D) -> Self {
let tiles = {
// TODO ar... | (&mut self, loc: units::ScreenTile2D, pix: P, fg: colors::Rgb, bg: colors::Rgb) {
// TODO asserts
let idx = (self.size.width * loc.y + loc.x) as usize;
self.tiles[idx].pix = pix;
self.tiles[idx].fg = fg;
self.tiles[idx].bg = bg;
}
}
| set | identifier_name |
tiles.rs | use super::Tile;
use colors;
use pixset;
use pixset::PixLike;
use units;
pub struct Tiles<P: PixLike> {
size: units::Size2D,
pub tiles: Vec<Tile<P>>, // TODO impl Index
}
impl<P> Tiles<P>
where
P: pixset::PixLike,
{
pub fn new(size: units::Size2D) -> Self {
let tiles = {
// TODO ar... | }
}
pub fn set(&mut self, loc: units::ScreenTile2D, pix: P, fg: colors::Rgb, bg: colors::Rgb) {
// TODO asserts
let idx = (self.size.width * loc.y + loc.x) as usize;
self.tiles[idx].pix = pix;
self.tiles[idx].fg = fg;
self.tiles[idx].bg = bg;
}
} | #[allow(dead_code)]
pub fn clear(&mut self) {
for t in self.tiles.iter_mut() {
t.clear(); | random_line_split |
ffi.rs | //! Useful tools for C FFI
use std::ffi::CString;
use std::os::raw::{c_char, c_int};
use std::ptr;
/// Call a main-like function with an argument vector
///
/// # Safety
///
/// Safety depends on the safety of the target FFI function.
pub unsafe fn run_with_args<S: AsRef<str>, Argv: IntoIterator<Item = S>>(
func:... | }
c_char_buffer.push(ptr::null_mut());
let c_argv = c_char_buffer.as_mut_ptr();
// 4. Now call the function
func(argc, c_argv) as i32
} | c_char_buffer.push(cstring.as_bytes_with_nul().as_ptr() as *mut c_char); | random_line_split |
ffi.rs | //! Useful tools for C FFI
use std::ffi::CString;
use std::os::raw::{c_char, c_int};
use std::ptr;
/// Call a main-like function with an argument vector
///
/// # Safety
///
/// Safety depends on the safety of the target FFI function.
pub unsafe fn run_with_args<S: AsRef<str>, Argv: IntoIterator<Item = S>>(
func:... | func(argc, c_argv) as i32
}
| {
// 1. First clone the string values into safe storage.
let cstring_buffer: Vec<_> = args
.into_iter()
.map(|arg| CString::new(arg.as_ref()).expect("String to CString conversion failed"))
.collect();
// 2. Total number of args is fixed.
let argc = cstring_buffer.len() as c_int;... | identifier_body |
ffi.rs | //! Useful tools for C FFI
use std::ffi::CString;
use std::os::raw::{c_char, c_int};
use std::ptr;
/// Call a main-like function with an argument vector
///
/// # Safety
///
/// Safety depends on the safety of the target FFI function.
pub unsafe fn | <S: AsRef<str>, Argv: IntoIterator<Item = S>>(
func: unsafe extern "C" fn(c_int, *mut *mut c_char) -> c_int,
args: Argv,
) -> i32 {
// 1. First clone the string values into safe storage.
let cstring_buffer: Vec<_> = args
.into_iter()
.map(|arg| CString::new(arg.as_ref()).expect("String to ... | run_with_args | identifier_name |
translate_to_glib.rs | use crate::{
analysis::{function_parameters::TransformationType, ref_mode::RefMode},
library::Transfer,
};
pub trait TranslateToGlib {
fn translate_to_glib(&self) -> String;
}
impl TranslateToGlib for TransformationType {
fn translate_to_glib(&self) -> String {
use self::TransformationType::*;... | }
}
Full => ("".into(), ".to_glib_full()"),
Container => ("".into(), ".to_glib_container().0"),
}
}
| {
use self::Transfer::*;
match transfer {
None => {
match ref_mode {
RefMode::None => ("".into(), ".to_glib_none_mut().0"), //unreachable!(),
RefMode::ByRef => {
if explicit_target_type.is_empty() {
("".into(), ".to_... | identifier_body |
translate_to_glib.rs | use crate::{
analysis::{function_parameters::TransformationType, ref_mode::RefMode},
library::Transfer,
};
pub trait TranslateToGlib {
fn translate_to_glib(&self) -> String;
}
impl TranslateToGlib for TransformationType {
fn translate_to_glib(&self) -> String {
use self::TransformationType::*;... | format!(".map(|p| p{})", to_glib_extra)
} else {
to_glib_extra.clone()
};
if instance_parameter {
format!(
"{}self{}{}{}",
left,
if in_trai... | let (left, right) = to_glib_xxx(transfer, ref_mode, explicit_target_type);
let to_glib_extra = if nullable && !to_glib_extra.is_empty() { | random_line_split |
translate_to_glib.rs | use crate::{
analysis::{function_parameters::TransformationType, ref_mode::RefMode},
library::Transfer,
};
pub trait TranslateToGlib {
fn translate_to_glib(&self) -> String;
}
impl TranslateToGlib for TransformationType {
fn translate_to_glib(&self) -> String {
use self::TransformationType::*;... | (
transfer: Transfer,
ref_mode: RefMode,
explicit_target_type: &str,
) -> (String, &'static str) {
use self::Transfer::*;
match transfer {
None => {
match ref_mode {
RefMode::None => ("".into(), ".to_glib_none_mut().0"), //unreachable!(),
RefMode::... | to_glib_xxx | identifier_name |
weak.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 ... |
}
#[unsafe_destructor]
impl<T> Drop for Strong<T> {
fn drop(&mut self) {
unsafe {
if self.ptr!= 0 as *mut RcBox<T> {
(*self.ptr).strong -= 1;
if (*self.ptr).strong == 0 {
read_ptr(self.borrow()); // destroy the contained object
... | {
unsafe {
(*self.ptr).weak += 1;
Weak { ptr: self.ptr }
}
} | identifier_body |
weak.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 ... |
}
}
}
#[unsafe_destructor]
impl<T> Drop for Weak<T> {
fn drop(&mut self) {
unsafe {
if self.ptr!= 0 as *mut RcBox<T> {
(*self.ptr).weak -= 1;
if (*self.ptr).weak == 0 {
free(self.ptr as *mut u8)
}
}
... | {
(*self.ptr).strong += 1;
Some(Strong { ptr: self.ptr })
} | conditional_block |
weak.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 ... | #[inline]
fn deep_clone(&self) -> Strong<T> {
Strong::new(self.borrow().deep_clone())
}
}
impl<T: Eq> Eq for Strong<T> {
#[inline(always)]
fn eq(&self, other: &Strong<T>) -> bool { *self.borrow() == *other.borrow() }
#[inline(always)]
fn ne(&self, other: &Strong<T>) -> bool { *self... | }
impl<T: DeepClone> DeepClone for Strong<T> { | random_line_split |
weak.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 ... | (&self, other: &Strong<T>) -> bool { *self.borrow() > *other.borrow() }
#[inline(always)]
fn ge(&self, other: &Strong<T>) -> bool { *self.borrow() >= *other.borrow() }
}
#[unsafe_no_drop_flag]
pub struct Weak<T> {
ptr: *mut RcBox<T>
}
impl<T> Weak<T> {
pub fn upgrade(&self) -> Option<Strong<T>> {
... | gt | identifier_name |
adt-tuple-struct.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
fn annot_underscore() {
let c = 66;
SomeStruct::<_>(&c);
}
fn annot_reference_any_lifetime() {
let c = 66;
SomeStruct::<&u32>(&c);
}
fn annot_reference_static_lifetime() {
let c = 66;
SomeStruct::<&'static u32>(&c); //~ ERROR
}
fn annot_reference_named_lifetime<'a>(_d: &'a u32) {
let c... | random_line_split | |
adt-tuple-struct.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn annot_reference_any_lifetime() {
let c = 66;
SomeStruct::<&u32>(&c);
}
fn annot_reference_static_lifetime() {
let c = 66;
SomeStruct::<&'static u32>(&c); //~ ERROR
}
fn annot_reference_named_lifetime<'a>(_d: &'a u32) {
let c = 66;
SomeStruct::<&'a u32>(&c); //~ ERROR
}
fn annot_reference... | {
let c = 66;
SomeStruct::<_>(&c);
} | identifier_body |
adt-tuple-struct.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T>(T);
fn no_annot() {
let c = 66;
SomeStruct(&c);
}
fn annot_underscore() {
let c = 66;
SomeStruct::<_>(&c);
}
fn annot_reference_any_lifetime() {
let c = 66;
SomeStruct::<&u32>(&c);
}
fn annot_reference_static_lifetime() {
let c = 66;
SomeStruct::<&'static u32>(&c); //~ ERROR
}
f... | SomeStruct | identifier_name |
main.rs | /*
--- Day 5: How About a Nice Game of Chess? ---
You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking movies.
The eight-character password for the door is generated one character at a time by finding the MD5 hash of some... | }
// we got em. 😏
let pass_string : String = pass.iter().map(|c| c.unwrap()).collect();
println!("[PART B] cracked the pass: {:?}", pass_string);
}
fn main() {
const PUZZLE_INPUT : &'static str = "reyedfim";
solve_part_a(PUZZLE_INPUT);
solve_part_b(PUZZLE_INPUT);
}
| break;
}
| conditional_block |
main.rs | /*
--- Day 5: How About a Nice Game of Chess? ---
You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking movies.
| The eight-character password for the door is generated one character at a time by finding the MD5 hash of some Door ID (your puzzle input) and an increasing integer index (starting with 0).
A hash indicates the next character in the password if its hexadecimal representation starts with five zeroes. If it does, the si... | random_line_split | |
main.rs | /*
--- Day 5: How About a Nice Game of Chess? ---
You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking movies.
The eight-character password for the door is generated one character at a time by finding the MD5 hash of some... | const PUZZLE_INPUT : &'static str = "reyedfim";
solve_part_a(PUZZLE_INPUT);
solve_part_b(PUZZLE_INPUT);
}
| identifier_body | |
main.rs | /*
--- Day 5: How About a Nice Game of Chess? ---
You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking movies.
The eight-character password for the door is generated one character at a time by finding the MD5 hash of some... | const PUZZLE_INPUT : &'static str = "reyedfim";
solve_part_a(PUZZLE_INPUT);
solve_part_b(PUZZLE_INPUT);
}
| {
| identifier_name |
htmlheadelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLHeadElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHeadElementDeriv... | } | random_line_split | |
htmlheadelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLHeadElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHeadElementDeriv... | {
htmlelement: HTMLElement
}
impl HTMLHeadElementDerived for EventTarget {
fn is_htmlheadelement(&self) -> bool {
match self.type_id {
NodeTargetTypeId(ElementNodeTypeId(HTMLHeadElementTypeId)) => true,
_ => false
}
}
}
impl HTMLHeadElement {
pub fn new_inherit... | HTMLHeadElement | identifier_name |
sort.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/. */
//! In-place sorting.
fn quicksort_helper<T:Ord + Eq + PartialOrd + PartialEq>(arr: &mut [T], left: int, right: i... |
#[cfg(test)]
pub mod test {
use std::rand;
use std::rand::Rng;
use sort;
#[test]
pub fn random() {
let mut rng = rand::task_rng();
for _ in range(0, 50000) {
let len: uint = rng.gen();
let mut v: Vec<int> = rng.gen_iter::<int>().take((len % 32) + 1).collec... | {
if arr.len() <= 1 {
return
}
let len = arr.len();
quicksort_helper(arr, 0, (len - 1) as int);
} | identifier_body |
sort.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/. */
//! In-place sorting.
fn | <T:Ord + Eq + PartialOrd + PartialEq>(arr: &mut [T], left: int, right: int) {
if right <= left {
return
}
let mut i: int = left - 1;
let mut j: int = right;
let mut p: int = i;
let mut q: int = j;
unsafe {
let v: *mut T = &mut arr[right as uint];
loop {
i... | quicksort_helper | identifier_name |
sort.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/. */
//! In-place sorting.
fn quicksort_helper<T:Ord + Eq + PartialOrd + PartialEq>(arr: &mut [T], left: int, right: i... |
arr.swap(i as uint, j as uint);
if arr[i as uint] == (*v) {
p += 1;
arr.swap(p as uint, i as uint)
}
if (*v) == arr[j as uint] {
q -= 1;
arr.swap(j as uint, q as uint)
}
}
}
arr.... | {
break
} | conditional_block |
sort.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/. */ |
fn quicksort_helper<T:Ord + Eq + PartialOrd + PartialEq>(arr: &mut [T], left: int, right: int) {
if right <= left {
return
}
let mut i: int = left - 1;
let mut j: int = right;
let mut p: int = i;
let mut q: int = j;
unsafe {
let v: *mut T = &mut arr[right as uint];
... |
//! In-place sorting. | random_line_split |
task-killjoin.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 ... |
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End:
| {
task::spawn_unlinked(supervisor)
} | identifier_body |
task-killjoin.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 ... | // currently not needed because the supervisor runs first, but I can
// imagine that changing.
task::yield();
fail!();
}
fn supervisor() {
// Unsupervise this task so the process doesn't return a failure status as
// a result of the main task being killed.
let f = supervised;
task::try(... | fn supervised() {
// Yield to make sure the supervisor joins before we fail. This is | random_line_split |
task-killjoin.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 ... | () {
// Yield to make sure the supervisor joins before we fail. This is
// currently not needed because the supervisor runs first, but I can
// imagine that changing.
task::yield();
fail!();
}
fn supervisor() {
// Unsupervise this task so the process doesn't return a failure status as
// a ... | supervised | identifier_name |
eval_assignment.rs | use crate::helpers::{values::*, *};
use ostrov::errors::RuntimeError::*;
#[test]
fn returns_expression() {
assert_eval_val(
"(define x 0)
(set! x (+ x 1))",
unspecified(),
);
}
#[test]
fn overwrites_variables() {
assert_eval(
"(define x 0)
(set! x (+ x 1))
... | () {
assert_eval(
"(define (gen-counter)
(define counter 0)
(lambda ()
(set! counter (+ counter 1))
counter))
(define count (gen-counter))
(count)
(count)
(count)",
"3",
);
}
#[test]
fn malformed_variable_name()... | overwrites_variables_in_captured_scopes | identifier_name |
eval_assignment.rs | use crate::helpers::{values::*, *};
use ostrov::errors::RuntimeError::*;
#[test]
fn returns_expression() {
assert_eval_val(
"(define x 0)
(set! x (+ x 1))",
unspecified(),
);
}
#[test]
fn overwrites_variables() {
assert_eval(
"(define x 0)
(set! x (+ x 1))
... | "3",
);
}
#[test]
fn malformed_variable_name() {
assert_eval_err("(set! 3 3)", MalformedExpression);
}
#[test]
fn unknown_variable() {
assert_eval_err("(set! x 3)", UnboundVariable("x".into()));
}
#[test]
fn wrong_arguments_number() {
assert_eval_err("(set!)", BadArity(Some("set!".into())));
... | random_line_split | |
eval_assignment.rs | use crate::helpers::{values::*, *};
use ostrov::errors::RuntimeError::*;
#[test]
fn returns_expression() {
assert_eval_val(
"(define x 0)
(set! x (+ x 1))",
unspecified(),
);
}
#[test]
fn overwrites_variables() {
assert_eval(
"(define x 0)
(set! x (+ x 1))
... |
#[test]
fn unknown_variable() {
assert_eval_err("(set! x 3)", UnboundVariable("x".into()));
}
#[test]
fn wrong_arguments_number() {
assert_eval_err("(set!)", BadArity(Some("set!".into())));
assert_eval_err("(set! x)", BadArity(Some("set!".into())));
assert_eval_err("(set! x 2 3)", BadArity(Some("set!... | {
assert_eval_err("(set! 3 3)", MalformedExpression);
} | identifier_body |
mcts.rs | use crate::actions::Action;
use crate::Role;
use mcts::{statistics, SearchSettings};
use rand::Rng;
use search_graph;
use std::{cmp, mem};
#[derive(Clone, Debug)]
pub struct Game {}
impl statistics::two_player::PlayerMapping for Role {
fn player_one() -> Self {
Role::Dwarf
}
fn player_two() -> Self {
Ro... | crate::state::State,
mcts::graph::VertexData,
mcts::graph::EdgeData<Game>,
>,
root: search_graph::view::NodeRef<'id>,
mut rng: R,
) -> search_graph::view::EdgeRef<'id> {
let mut children = view.children(root);
let mut best_child = children.next().unwrap();
let mut best_child_visits = view[best_c... | 'id, | random_line_split |
mcts.rs | use crate::actions::Action;
use crate::Role;
use mcts::{statistics, SearchSettings};
use rand::Rng;
use search_graph;
use std::{cmp, mem};
#[derive(Clone, Debug)]
pub struct Game {}
impl statistics::two_player::PlayerMapping for Role {
fn player_one() -> Self {
Role::Dwarf
}
fn player_two() -> Self {
Ro... | self.settings.clone(),
self.iterations,
self.action_select,
);
search_graph::view::of_graph(graph, |view| -> crate::agent::Result {
let mut rollout = mcts::RolloutPhase::initialize(rng, settings, state.clone(), view);
for _ in 0..iterations {
let scoring = match rollout.rol... | {
match self.graph_compact {
GraphCompact::Prune => {
if let Some(node) = self.graph.find_node_mut(state) {
search_graph::view::of_node(node, |view, node| {
view.retain_reachable_from(Some(node).into_iter());
});
} else {
mem::swap(&mut self.graph, &mu... | identifier_body |
mcts.rs | use crate::actions::Action;
use crate::Role;
use mcts::{statistics, SearchSettings};
use rand::Rng;
use search_graph;
use std::{cmp, mem};
#[derive(Clone, Debug)]
pub struct Game {}
impl statistics::two_player::PlayerMapping for Role {
fn | () -> Self {
Role::Dwarf
}
fn player_two() -> Self {
Role::Troll
}
fn resolve_player(&self) -> statistics::two_player::Player {
match *self {
Role::Dwarf => statistics::two_player::Player::One,
Role::Troll => statistics::two_player::Player::Two,
}
}
}
impl mcts::game::State for cr... | player_one | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public | #![feature(custom_derive)]
#![feature(plugin)]
#![feature(mpsc_select)]
#![feature(plugin)]
#![plugin(plugins)]
#![deny(unsafe_code)]
#![plugin(serde_macros)]
extern crate backtrace;
extern crate canvas;
extern crate canvas_traits;
extern crate compositing;
extern crate devtools_traits;
extern crate euclid;
#[cfg(not... | * 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/. */
#![feature(box_syntax)] | random_line_split |
const-vec-of-fns.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 ... |
static bare_fns: &'static [extern fn()] = &[f, f];
struct S<'self>(&'self fn());
static closures: &'static [S<'static>] = &[S(f), S(f)];
pub fn main() {
for &bare_fn in bare_fns.iter() { bare_fn() }
for &closure in closures.iter() { (*closure)() }
}
| { } | identifier_body |
const-vec-of-fns.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 ... | () {
for &bare_fn in bare_fns.iter() { bare_fn() }
for &closure in closures.iter() { (*closure)() }
}
| main | identifier_name |
const-vec-of-fns.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 ... | // FIXME: #7385: hits a codegen bug on OS X x86_64
/*!
* Try to double-check that static fns have the right size (with or
* without dummy env ptr, as appropriate) by iterating a size-2 array.
* If the static size differs from the runtime size, the second element
* should be read as a null or otherwise wrong pointe... | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test | random_line_split |
cfg.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 ... | // trailing comma is optional,.
p.expect(&token::COMMA);
}
// test_cfg searches for meta items looking like `cfg(foo,...)`
let in_cfg = &[cx.meta_list(sp, InternedString::new("cfg"), cfgs)];
let matches_cfg = attr::test_cfg(cx.cfg().as_slice(),
in_cfg.iter... | { break } | conditional_block |
cfg.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 ... | (cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-> Box<base::MacResult> {
let mut p = cx.new_parser_from_tts(tts);
let mut cfgs = Vec::new();
// parse `cfg!(meta_item, meta_item(x,y), meta_item="foo",...)`
while p.token!= token::EOF {
cfgs.push(p.parse_meta_item());
... | expand_cfg | identifier_name |
cfg.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 ... | use ast;
use codemap::Span;
use ext::base::*;
use ext::base;
use ext::build::AstBuilder;
use attr;
use attr::*;
use parse::attr::ParserAttr;
use parse::token::InternedString;
use parse::token;
pub fn expand_cfg(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-> Box<base::MacResult> {
let mut... | match the current compilation environment.
*/
| random_line_split |
cfg.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 ... | {
let mut p = cx.new_parser_from_tts(tts);
let mut cfgs = Vec::new();
// parse `cfg!(meta_item, meta_item(x,y), meta_item="foo", ...)`
while p.token != token::EOF {
cfgs.push(p.parse_meta_item());
if p.eat(&token::EOF) { break } // trailing comma is optional,.
p.expect(&token::CO... | identifier_body | |
main.rs | fn main() {
// var()
// control_flow()
let n = 45;
let big = fib(n);
println!("{}th fib: {}", n, big);
}
fn var() |
fn control_flow() {
let number = 3;
if number < 5 {
println!("condition was true");
} else {
println!("condition was false");
}
let a = [1, 2, 3, 4, 5];
for e in a.iter() {
println!("I'm looping {}", e)
}
for number in (1..4).rev() {
println!("{}!", n... | {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (_, y, _) = tup;
println!("The value of y is: {}", y);
println!("The value if x is: {}", tup.0);
} | identifier_body |
main.rs | fn main() {
// var()
// control_flow()
let n = 45;
let big = fib(n);
println!("{}th fib: {}", n, big);
}
fn var() {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (_, y, _) = tu... | (n: u32) -> u32 {
if n == 0 {
1
} else if n == 1 {
1
} else if n == 2 {
2
} else {
fib(n - 1) + fib(n - 2)
}
}
| fib | identifier_name |
main.rs | fn main() {
// var()
// control_flow()
let n = 45;
let big = fib(n);
println!("{}th fib: {}", n, big);
}
fn var() {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (_, y, _) = tu... |
fn control_flow() {
let number = 3;
if number < 5 {
println!("condition was true");
} else {
println!("condition was false");
}
let a = [1, 2, 3, 4, 5];
for e in a.iter() {
println!("I'm looping {}", e)
}
for number in (1..4).rev() {
println!("{}!", nu... | println!("The value of y is: {}", y);
println!("The value if x is: {}", tup.0);
} | random_line_split |
main.rs | fn main() {
// var()
// control_flow()
let n = 45;
let big = fib(n);
println!("{}th fib: {}", n, big);
}
fn var() {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (_, y, _) = tu... | else {
fib(n - 1) + fib(n - 2)
}
}
| {
2
} | conditional_block |
lib.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.
*/
#![deny(warnings)]
use fbinit::FacebookInit;
use futures_stats::{FutureStats, StreamStats};
use metadata::Metadata;
use nonzero_ext::nonze... | <K: Into<String>>(&mut self, key: K) -> Entry<String, ScubaValue> {
self.inner.entry(key)
}
pub fn flush(&self, timeout: Duration) {
self.inner.flush(timeout)
}
pub fn get_sample(&self) -> &ScubaSample {
self.inner.get_sample()
}
pub fn add_opt<K: Into<String>, V: Into... | entry | identifier_name |
lib.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.
*/
#![deny(warnings)]
use fbinit::FacebookInit;
use futures_stats::{FutureStats, StreamStats};
use metadata::Metadata;
use nonzero_ext::nonze... |
self.log()
}
pub fn add_common_server_data(&mut self) -> &mut Self {
self.inner.add_common_server_data();
self
}
pub fn sampling(&self) -> &Sampling {
self.inner.sampling()
}
pub fn add_mapped_common_server_data<F>(&mut self, mapper: F) -> &mut Self
where... | {
// Return value of the `log` function indicates whether
// the sample passed sampling. If it's too verbose, let's
// return false
return false;
} | conditional_block |
lib.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.
*/
#![deny(warnings)]
use fbinit::FacebookInit;
use futures_stats::{FutureStats, StreamStats};
use metadata::Metadata;
use nonzero_ext::nonze... |
pub fn add_stream_stats(&mut self, stats: &StreamStats) -> &mut Self {
self.inner
.add("poll_count", stats.poll_count)
.add("poll_time_us", stats.poll_time.as_micros_unchecked())
.add("count", stats.count)
.add(
"completion_time_us",
... | {
if !self.should_log_with_level(ScubaVerbosityLevel::Verbose) {
return;
}
self.log_with_msg(log_tag, msg)
} | identifier_body |
lib.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.
*/
#![deny(warnings)]
use fbinit::FacebookInit;
use futures_stats::{FutureStats, StreamStats};
use metadata::Metadata;
use nonzero_ext::nonze... | pub fn log_with_msg_verbose<S: Into<Option<String>>>(&mut self, log_tag: &str, msg: S) {
if!self.should_log_with_level(ScubaVerbosityLevel::Verbose) {
return;
}
self.log_with_msg(log_tag, msg)
}
pub fn add_stream_stats(&mut self, stats: &StreamStats) -> &mut Self {
... | }
/// Same as `log_with_msg`, but sample is assumed to be verbose and is only logged
/// if verbose logging conditions are met | random_line_split |
function.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::rc::Rc;
use std::cell::RefCell;
use value::*;
use ast;
use environment::Environment;
use runtime::Runtim... |
}
}
}
Ok(())
}
| {
return Err(RuntimeError::GeneralRuntimeError(
"http_server: threading error \
(could not send on reverse \
channel)"
.to_owned(),
));
} | conditional_block |
function.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::rc::Rc;
use std::cell::RefCell;
use value::*;
use ast;
use environment::Environment;
use runtime::Runtim... | {
NativeVoid(CallSign, fn(Vec<Value>) -> Result<(), RuntimeError>),
NativeReturning(CallSign, fn(Vec<Value>) -> Result<Value, RuntimeError>),
User {
call_sign: CallSign,
param_names: Vec<String>,
body: Box<ast::StmtNode>,
env: Rc<RefCell<Environment>>,
},
}
impl Functio... | Function | identifier_name |
function.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::rc::Rc;
use std::cell::RefCell;
use value::*;
use ast;
use environment::Environment;
use runtime::Runtim... | NativeVoid(CallSign, fn(Vec<Value>) -> Result<(), RuntimeError>),
NativeReturning(CallSign, fn(Vec<Value>) -> Result<Value, RuntimeError>),
User {
call_sign: CallSign,
param_names: Vec<String>,
body: Box<ast::StmtNode>,
env: Rc<RefCell<Environment>>,
},
}
impl Function {... | pub variadic: bool,
}
#[derive(Clone, Debug)]
pub enum Function { | random_line_split |
linkedlist.rs | #![feature(associated_type_defaults)]
#![warn(clippy::linkedlist)]
#![allow(dead_code, clippy::needless_pass_by_value)]
extern crate alloc;
use alloc::collections::linked_list::LinkedList;
const C: LinkedList<i32> = LinkedList::new();
static S: LinkedList<i32> = LinkedList::new();
trait Foo {
type Baz = LinkedLi... |
pub fn test(my_favourite_linked_list: LinkedList<u8>) {
println!("{:?}", my_favourite_linked_list)
}
pub fn test_ret() -> Option<LinkedList<u8>> {
unimplemented!();
}
pub fn test_local_not_linted() {
let _: LinkedList<u8>;
}
fn main() {
test(LinkedList::new());
test_local_not_linted();
}
|
} | identifier_body |
linkedlist.rs | #![feature(associated_type_defaults)]
#![warn(clippy::linkedlist)]
#![allow(dead_code, clippy::needless_pass_by_value)]
extern crate alloc;
use alloc::collections::linked_list::LinkedList;
const C: LinkedList<i32> = LinkedList::new();
static S: LinkedList<i32> = LinkedList::new();
trait Foo {
type Baz = LinkedLi... | test_local_not_linted();
} | let _: LinkedList<u8>;
}
fn main() {
test(LinkedList::new()); | random_line_split |
linkedlist.rs | #![feature(associated_type_defaults)]
#![warn(clippy::linkedlist)]
#![allow(dead_code, clippy::needless_pass_by_value)]
extern crate alloc;
use alloc::collections::linked_list::LinkedList;
const C: LinkedList<i32> = LinkedList::new();
static S: LinkedList<i32> = LinkedList::new();
trait Foo {
type Baz = LinkedLi... | {
let _: LinkedList<u8>;
}
fn main() {
test(LinkedList::new());
test_local_not_linted();
}
| st_local_not_linted() | identifier_name |
check_static_recursion.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 ... |
}
impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
fn visit_item(&mut self, it: &ast::Item) {
self.with_item_id_pushed(it.id, |v| visit::walk_item(v, it));
}
fn visit_trait_item(&mut self, ti: &ast::TraitItem) {
self.with_item_id_pushed(ti.id, |v| visit::walk_trait... | {
if self.idstack.iter().any(|x| x == &(id)) {
span_err!(self.sess, *self.root_span, E0265, "recursive constant");
return;
}
self.idstack.push(id);
f(self);
self.idstack.pop();
} | identifier_body |
check_static_recursion.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 visit_item(&mut self, it: &ast::Item) {
self.with_item_id_pushed(it.id, |v| visit::walk_item(v, it));
}
fn visit_trait_item(&mut self, ti: &ast::TraitItem) {
self.with_item_id_pushed(ti.id, |v| visit::walk_trait_item(v, ti));
}
fn visit_impl_item(&mut self, ii: &ast::ImplItem) {... | random_line_split | |
check_static_recursion.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 ... | (&mut self, ii: &ast::ImplItem) {
match ii.node {
ast::ConstImplItem(_, ref expr) => {
let mut recursion_visitor =
CheckItemRecursionVisitor::new(self, &ii.span);
recursion_visitor.visit_impl_item(ii);
visit::walk_expr(self, &*expr)... | visit_impl_item | identifier_name |
associated-types-ref-in-struct-literal.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 thing = Thing{a: 1, b: 2};
assert_eq!(thing.a + 1, thing.b);
}
| main | identifier_name |
associated-types-ref-in-struct-literal.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 | // except according to those terms.
// Test associated type references in a struct literal. Issue #20535.
pub trait Foo {
type Bar;
fn dummy(&self) { }
}
impl Foo for isize {
type Bar = isize;
}
struct Thing<F: Foo> {
a: F,
b: F::Bar,
}
fn main() {
let thing = Thing{a: 1, b: 2};
asser... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed | random_line_split |
associated-types-ref-in-struct-literal.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 thing = Thing{a: 1, b: 2};
assert_eq!(thing.a + 1, thing.b);
} | identifier_body | |
lib.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/. */ |
#![feature(box_syntax, int_uint)]
#![allow(unstable)]
#[macro_use] extern crate bitflags;
#[cfg(target_os="macos")]
extern crate cgl;
extern crate compositing;
extern crate geom;
extern crate gleam;
extern crate glutin;
extern crate layers;
extern crate libc;
extern crate msg;
extern crate time;
extern crate util;
ex... |
//! A simple application that uses glutin to open a window for Servo to display in. | random_line_split |
lib.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/. */
//! A simple application that uses glutin to open a window for Servo to display in.
#![feature(box_syntax, int_ui... | () -> Rc<Window> {
// Read command-line options.
let opts = opts::get();
let foreground = opts.output_file.is_none();
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
let size = opts.initial_window_size.as_f32() * scale_factor;
// Open a window.
Window::new(foregrou... | create_window | identifier_name |
lib.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/. */
//! A simple application that uses glutin to open a window for Servo to display in.
#![feature(box_syntax, int_ui... | {
// Read command-line options.
let opts = opts::get();
let foreground = opts.output_file.is_none();
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
let size = opts.initial_window_size.as_f32() * scale_factor;
// Open a window.
Window::new(foreground, size.as_uint(... | identifier_body | |
lib.rs | use std::io::ErrorKind;
use std::net::Ipv4Addr;
use std::net::TcpStream;
use spaceapi_server::api;
use spaceapi_server::{SpaceapiServer, SpaceapiServerBuilder};
/// Create a new status object containing test data.
fn | () -> api::Status {
api::StatusBuilder::new("ourspace")
.logo("https://example.com/logo.png")
.url("https://example.com/")
.location(api::Location {
address: Some("Street 1, Zürich, Switzerland".into()),
lat: 47.123,
lon: 8.88,
})
.contact(api:... | get_status | identifier_name |
lib.rs | use std::io::ErrorKind;
use std::net::Ipv4Addr;
use std::net::TcpStream;
use spaceapi_server::api;
use spaceapi_server::{SpaceapiServer, SpaceapiServerBuilder};
/// Create a new status object containing test data.
fn get_status() -> api::Status {
api::StatusBuilder::new("ourspace")
.logo("https://example.c... |
#[test]
fn server_starts() {
//! Test that the spaceapi server starts at all.
// Ip / port for test server
let ip = Ipv4Addr::new(127, 0, 0, 1);
let port = 3344;
// Test data
let status = get_status();
// Connection to port should fail right now
let connect_result = TcpStream::connec... |
SpaceapiServerBuilder::new(status)
.redis_connection_info("redis://127.0.0.1/")
.build()
.unwrap()
}
| identifier_body |
lib.rs | use std::io::ErrorKind;
use std::net::Ipv4Addr;
use std::net::TcpStream;
use spaceapi_server::api;
use spaceapi_server::{SpaceapiServer, SpaceapiServerBuilder};
/// Create a new status object containing test data.
fn get_status() -> api::Status {
api::StatusBuilder::new("ourspace")
.logo("https://example.c... | // Ip / port for test server
let ip = Ipv4Addr::new(127, 0, 0, 1);
let port = 3344;
// Test data
let status = get_status();
// Connection to port should fail right now
let connect_result = TcpStream::connect((ip, port));
assert!(connect_result.is_err());
assert_eq!(connect_result.u... | random_line_split | |
elf64.rs | use core::fmt;
use core::iter::Iterator;
use ::kern::console::LogLevel::*;
pub const SIZEOF_IDENT: usize = 16;
pub const SIZEOF_EHDR: usize = 64;
pub const ELFCLASS: u8 = ELFCLASS64;
#[repr(C)]
#[derive(Clone, Copy, Default, PartialEq)]
pub struct Header {
/// Magic number and other info
pub e_ident: [u8; SIZ... | (bytes: &'a [u8]) -> Elf64<'a> {
let h = &*(bytes.as_ptr() as *const Header);
Elf64 {
data: bytes,
header: h,
}
}
pub fn program_headers(&self) -> ProgramHeaderIter<'a> {
ProgramHeaderIter {
data: self.data,
header: self.header,
... | from | identifier_name |
elf64.rs | use core::fmt;
use core::iter::Iterator;
use ::kern::console::LogLevel::*;
pub const SIZEOF_IDENT: usize = 16;
pub const SIZEOF_EHDR: usize = 64;
pub const ELFCLASS: u8 = ELFCLASS64;
#[repr(C)]
#[derive(Clone, Copy, Default, PartialEq)]
pub struct Header {
/// Magic number and other info
pub e_ident: [u8; SIZ... | pub const PF_X: u32 = 1 << 0;
/// Segment is writable
pub const PF_W: u32 = 1 << 1;
/// Segment is readable
pub const PF_R: u32 = 1 << 2;
pub struct ProgramHeaderIter<'a> {
data: &'a [u8],
header: &'a Header,
next: usize
}
pub struct Elf64<'a> {
pub header: &'a Header,
pub data: &'a [u8]
}
impl<'... | /// Segment is executable | random_line_split |
elf64.rs | use core::fmt;
use core::iter::Iterator;
use ::kern::console::LogLevel::*;
pub const SIZEOF_IDENT: usize = 16;
pub const SIZEOF_EHDR: usize = 64;
pub const ELFCLASS: u8 = ELFCLASS64;
#[repr(C)]
#[derive(Clone, Copy, Default, PartialEq)]
pub struct Header {
/// Magic number and other info
pub e_ident: [u8; SIZ... |
}
/// No file type.
pub const ET_NONE: u16 = 0;
/// Relocatable file.
pub const ET_REL: u16 = 1;
/// Executable file.
pub const ET_EXEC: u16 = 2;
/// Shared object file.
pub const ET_DYN: u16 = 3;
/// Core file.
pub const ET_CORE: u16 = 4;
/// Number of defined types.
pub const ET_NUM: u16 = 5;
/// The ELF magic nu... | {
write!(f, "e_ident: {:?} e_type: {} e_machine: 0x{:x} e_version: 0x{:x} e_entry: 0x{:x} \
e_phoff: 0x{:x} e_shoff: 0x{:x} e_flags: {:x} e_ehsize: {} e_phentsize: {} \
e_phnum: {} e_shentsize: {} e_shnum: {} e_shstrndx: {}",
self.e_ident,
et_to_str(se... | identifier_body |
stream.rs | use metadata;
use frame;
use subframe;
use metadata::{Metadata, StreamInfo};
use frame::frame_parser;
use utility::{
ErrorKind, ByteStream, ReadStream, Sample, SampleSize, StreamProducer,
many_metadata,
};
use std::io;
use std::usize;
use std::fs::File;
/// FLAC stream that decodes and hold file information.
pub... | (filename: &str) -> Result<StreamReader<File>, ErrorKind> {
File::open(filename).map_err(|e| ErrorKind::IO(e.kind()))
.and_then(|file| {
let producer = ReadStream::new(file);
Stream::from_stream_producer(producer)
})
}
/// Constructs a decoder with the given buffer.
//... | from_file | identifier_name |
stream.rs | use metadata;
use frame;
use subframe;
use metadata::{Metadata, StreamInfo};
use frame::frame_parser;
use utility::{
ErrorKind, ByteStream, ReadStream, Sample, SampleSize, StreamProducer,
many_metadata,
};
use std::io;
use std::usize;
use std::fs::File;
/// FLAC stream that decodes and hold file information.
pub... |
/// Returns information for the current stream.
#[inline]
pub fn info(&self) -> StreamInfo {
self.info
}
/// Returns a slice of `Metadata`
///
/// This slice excludes `StreamInfo`, which is located in `Stream::info`.
/// Everything else is related to metadata for the FLAC stream is in the
/// s... | {
let producer = ReadStream::new(reader);
Stream::from_stream_producer(producer)
} | identifier_body |
stream.rs | use metadata;
use frame;
use subframe;
use metadata::{Metadata, StreamInfo};
use frame::frame_parser;
use utility::{
ErrorKind, ByteStream, ReadStream, Sample, SampleSize, StreamProducer,
many_metadata,
};
use std::io;
use std::usize;
use std::fs::File;
/// FLAC stream that decodes and hold file information.
pub... | stream_info = info;
} else {
metadata.push(block);
}
}).map(|_| {
Stream {
info: stream_info,
metadata: metadata,
producer: producer,
}
})
}
/// Returns an iterator over the decoded samples.
#[inline]
pub fn iter<S: SampleSize>(&mut self) ... |
many_metadata(&mut producer, |block| {
if let metadata::Data::StreamInfo(info) = block.data { | random_line_split |
glutin.rs | use glium::{
Frame,
IndexBuffer,
Surface,
VertexBuffer,
glutin,
program,
texture,
};
use glium::index::PrimitiveType;
use glium::backend::glutin_backend::GlutinFacade;
use super::super::gamestate::*;
use super::sound::{
Player,
PortAudio,
};
#[derive(Copy, Clone)]
// Non-snake case ... | () -> texture::RawImage2d<'static, (f32, f32, f32)> {
use std::cmp::min;
use std::mem;
use glium::texture::ClientFormat;
const TEXDIMENSION: u32 = 256;
const TEXBUFFSIZE: usize = (TEXDIMENSION*TEXDIMENSION) as usize;
let mut raw_data: Vec<(f32, f32, f32)> = Vec::new();
for i in 0..TEXDIMENSI... | gen_image | identifier_name |
glutin.rs | use glium::{
Frame,
IndexBuffer,
Surface,
VertexBuffer,
glutin,
program,
texture,
};
use glium::index::PrimitiveType;
use glium::backend::glutin_backend::GlutinFacade;
use super::super::gamestate::*;
use super::sound::{
Player,
PortAudio,
};
#[derive(Copy, Clone)]
// Non-snake case ... |
}
assert!(image.data.len() == image.width as usize * image.height as usize * image.format.get_size() / mem::size_of::<(f32, f32, f32)>(),
"size mismatch: len {:?}, width {:?}, height {:?}, get_size() {:?}, size_of {:?}",
image.data.len(), image.width, image.height, image.format.get_size... | {
println!("correcting wrong format: {:?}", image.format);
image.format = ClientFormat::F32F32F32;
} | conditional_block |
glutin.rs | use glium::{
Frame,
IndexBuffer,
Surface,
VertexBuffer,
glutin,
program,
texture,
};
use glium::index::PrimitiveType;
use glium::backend::glutin_backend::GlutinFacade;
use super::super::gamestate::*;
use super::sound::{
Player,
PortAudio,
};
#[derive(Copy, Clone)]
// Non-snake case ... | {
let data_mutex = data_mutex.clone();
let callback = move |field: Ref<field::Field>, current: &piece::Piece, ghost: Option<&piece::Piece>| {
let new_data = RenderData {
current: From::from(current),
field: field.clone(),
ghost: match ghost... | let image = gen_image();
let texture = texture::Texture2d::new(&display, image).unwrap();
let data_mutex: Arc<Mutex<Option<RenderData>>> = Arc::new(Mutex::new(None));
let mut game: game::Game; | random_line_split |
task-comm-11.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | // 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.
// xfail-fast
extern mod extra;
use std::comm;
use std::task;
fn start(c: &comm::Chan... | // 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 |
task-comm-11.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 (p, ch) = comm::stream();
let child = task::spawn(|| start(&ch) );
let c = p.recv();
} | identifier_body | |
task-comm-11.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 (p, ch) = comm::stream();
let child = task::spawn(|| start(&ch) );
let c = p.recv();
}
| main | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.