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 |
|---|---|---|---|---|
types.rs | use game::{Position, Move, Score, NumPlies, NumMoves};
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)]
pub struct NumNodes(pub u64);
#[derive(Clone, Debug)]
pub struct State {
pub pos: Position,
pub prev_pos: Option<Position>,
pub prev_move: Option<Move>,
pub param: Param,
}
#[derive(C... | pub hash_size: usize,
}
impl Param {
pub fn new(hash_size: usize) -> Self {
Param {
ponder: false,
search_moves: None,
depth: None,
nodes: None,
mate: None,
hash_size: hash_size,
}
}
}
#[derive(PartialEq, Eq, Copy, Clon... | pub mate: Option<NumMoves>, | random_line_split |
progressevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | (&self) -> u64 {
self.loaded
}
// https://xhr.spec.whatwg.org/#dom-progressevent-total
fn Total(&self) -> u64 {
self.total
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.event.IsTrusted()
}
}
| Loaded | identifier_name |
progressevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | type_: Atom,
can_bubble: EventBubbles,
cancelable: EventCancelable,
length_computable: bool,
loaded: u64,
total: u64,
) -> DomRoot<ProgressEvent> {
let ev = reflect_dom_object(
Box::new(ProgressEvent::new_inherited(
length_computabl... | }
}
pub fn new(
global: &GlobalScope, | random_line_split |
assembunny.rs | use std::io::prelude::*;
use std::fs::File;
struct Registers {
a: i32,
b: i32,
c: i32,
d: i32
}
impl Registers {
fn new() -> Registers {
Registers{a: 0, b: 0, c: 0, d: 0}
}
fn get(&self, name: &str) -> i32 |
fn inc(&mut self, name: &str) {
let curr_val = self.get(name);
self.set(name, curr_val + 1);
}
fn dec(&mut self, name: &str) {
let curr_val = self.get(name);
self.set(name, curr_val - 1);
}
fn set(&mut self, name: &str, val: i32) {
match name {
... | {
match name {
"a" => self.a,
"b" => self.b,
"c" => self.c,
"d" => self.d,
_ => panic!("invalid register {}!", name),
}
} | identifier_body |
assembunny.rs | use std::io::prelude::*;
use std::fs::File;
struct Registers {
a: i32,
b: i32,
c: i32,
d: i32
}
impl Registers {
fn new() -> Registers {
Registers{a: 0, b: 0, c: 0, d: 0}
}
fn get(&self, name: &str) -> i32 {
match name {
"a" => self.a,
"b" => self.b... | (&mut self, name: &str) {
let curr_val = self.get(name);
self.set(name, curr_val + 1);
}
fn dec(&mut self, name: &str) {
let curr_val = self.get(name);
self.set(name, curr_val - 1);
}
fn set(&mut self, name: &str, val: i32) {
match name {
"a" => self... | inc | identifier_name |
assembunny.rs | use std::io::prelude::*;
use std::fs::File;
struct Registers {
a: i32,
b: i32,
c: i32,
d: i32
}
impl Registers {
fn new() -> Registers {
Registers{a: 0, b: 0, c: 0, d: 0}
}
fn get(&self, name: &str) -> i32 {
match name {
"a" => self.a,
"b" => self.b... | let mut data = String::new();
f.read_to_string(&mut data).expect("unable to read file");
let mut instructions: Vec<&str> = data.split("\n").collect();
instructions.pop();
let mut regs = Registers::new();
let mut current_ins: i32 = 0;
loop {
if current_ins < 0 || current_ins as usiz... | }
}
fn main() {
let mut f = File::open("data.txt").expect("unable to open file"); | random_line_split |
serde.rs | // Copyright 2017 TiKV Project Authors. Licensed under Apache-2.0.
use serde::de::{self, Deserialize, Deserializer, MapAccess, SeqAccess, Visitor};
use serde::ser::{Error as SerError, Serialize, SerializeMap, SerializeTuple, Serializer};
use std::collections::BTreeMap;
use std::fmt;
use std::str::FromStr;
use std::str... |
}
struct JsonVisitor;
impl<'de> Visitor<'de> for JsonVisitor {
type Value = Json;
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "a json value")
}
fn visit_unit<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
{
Ok(Json... | {
match serde_json::from_str(s) {
Ok(value) => Ok(value),
Err(e) => Err(invalid_type!("Illegal Json text: {:?}", e)),
}
} | identifier_body |
serde.rs | // Copyright 2017 TiKV Project Authors. Licensed under Apache-2.0.
use serde::de::{self, Deserialize, Deserializer, MapAccess, SeqAccess, Visitor};
use serde::ser::{Error as SerError, Serialize, SerializeMap, SerializeTuple, Serializer};
use std::collections::BTreeMap;
use std::fmt;
use std::str::FromStr;
use std::str... | }
}
}
impl ToString for Json {
fn to_string(&self) -> String {
serde_json::to_string(&self.as_ref()).unwrap()
}
}
impl FromStr for Json {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match serde_json::from_str(s) {
Ok(value) => Ok(value),
... | }
tup.end()
} | random_line_split |
serde.rs | // Copyright 2017 TiKV Project Authors. Licensed under Apache-2.0.
use serde::de::{self, Deserialize, Deserializer, MapAccess, SeqAccess, Visitor};
use serde::ser::{Error as SerError, Serialize, SerializeMap, SerializeTuple, Serializer};
use std::collections::BTreeMap;
use std::fmt;
use std::str::FromStr;
use std::str... | <E>(self, v: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
if v > (std::i64::MAX as u64) {
Ok(Json::from_f64(v as f64).map_err(de::Error::custom)?)
} else {
Ok(Json::from_i64(v as i64).map_err(de::Error::custom)?)
}
}
fn visit_f64<E>(self, ... | visit_u64 | identifier_name |
list.rs |
use super::{print_size, io, Header, Operation, App, Arg, ArgMatches, SubCommand, PathBuf, Regex,
RegexFault};
fn valid_path(x: String) -> Result<(), String> {
let p = PathBuf::from(&x);
match (p.exists(), p.is_file()) {
(true, true) => Ok(()),
(false, _) => Err(format!("Cannot pro... | (x: &ArgMatches) -> Operation {
Operation::List(
PathBuf::from(x.value_of("file").unwrap()),
match x.value_of("regex") {
Option::None => None,
Option::Some(r) => Regex::new(&r).ok(),
},
x.is_present("group"),
x.is_present("user"),
x.is_present(... | get | identifier_name |
list.rs |
use super::{print_size, io, Header, Operation, App, Arg, ArgMatches, SubCommand, PathBuf, Regex,
RegexFault};
fn valid_path(x: String) -> Result<(), String> {
let p = PathBuf::from(&x);
match (p.exists(), p.is_file()) {
(true, true) => Ok(()),
(false, _) => Err(format!("Cannot pro... | .takes_value(false)
.next_line_help(true)
.help("display uid"),
)
.arg(
Arg::with_name("gid")
.long("gid")
.takes_value(false)
.next_line_help(true)
.help("display gid"),
)
... | {
SubCommand::with_name("list")
.about("lists contents of a regex")
.arg(
Arg::with_name("group")
.long("groupname")
.takes_value(false)
.next_line_help(true)
.help("display group name"),
)
.arg(
... | identifier_body |
list.rs | use super::{print_size, io, Header, Operation, App, Arg, ArgMatches, SubCommand, PathBuf, Regex,
RegexFault};
fn valid_path(x: String) -> Result<(), String> {
let p = PathBuf::from(&x);
match (p.exists(), p.is_file()) {
(true, true) => Ok(()),
(false, _) => Err(format!("Cannot proce... | .takes_value(true)
.multiple(false)
.value_name("REGEX")
.validator(valid_regex)
.next_line_help(true)
.help("regex to filter list by"),
)
}
/// print data
pub fn exec(
header: &Header,
regex: &Option<Regex>,
... | Arg::with_name("regex")
.short("r")
.long("regex") | random_line_split |
long-live-the-unsized-temporary.rs | #![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)]
use std::fmt;
fn gen_foo() -> Box<fmt::Display> {
Box::new(Box::new("foo"))
}
fn foo(x: fmt::Display) {
assert_eq!(x.to_string(), "foo");
}
fn foo_indirect(x: fmt::Display) {
foo(x);
}
fn main() | if cnt == 0 {
break x;
} else {
cnt -= 1;
}
};
foo(x);
}
{
let x: fmt::Display = *gen_foo();
let x = if true { x } else { *gen_foo() };
foo(x);
}
}
| {
foo(*gen_foo());
foo_indirect(*gen_foo());
{
let x: fmt::Display = *gen_foo();
foo(x);
}
{
let x: fmt::Display = *gen_foo();
let y: fmt::Display = *gen_foo();
foo(x);
foo(y);
}
{
let mut cnt: usize = 3;
let x = loop {
... | identifier_body |
long-live-the-unsized-temporary.rs | #![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)]
use std::fmt;
fn gen_foo() -> Box<fmt::Display> {
Box::new(Box::new("foo"))
}
fn foo(x: fmt::Display) {
assert_eq!(x.to_string(), "foo");
} | fn foo_indirect(x: fmt::Display) {
foo(x);
}
fn main() {
foo(*gen_foo());
foo_indirect(*gen_foo());
{
let x: fmt::Display = *gen_foo();
foo(x);
}
{
let x: fmt::Display = *gen_foo();
let y: fmt::Display = *gen_foo();
foo(x);
foo(y);
}
{
... | random_line_split | |
long-live-the-unsized-temporary.rs | #![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)]
use std::fmt;
fn gen_foo() -> Box<fmt::Display> {
Box::new(Box::new("foo"))
}
fn foo(x: fmt::Display) {
assert_eq!(x.to_string(), "foo");
}
fn foo_indirect(x: fmt::Display) {
foo(x);
}
fn main() {
foo(*gen_foo());
foo... |
};
foo(x);
}
{
let x: fmt::Display = *gen_foo();
let x = if true { x } else { *gen_foo() };
foo(x);
}
}
| {
cnt -= 1;
} | conditional_block |
long-live-the-unsized-temporary.rs | #![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)]
use std::fmt;
fn gen_foo() -> Box<fmt::Display> {
Box::new(Box::new("foo"))
}
fn | (x: fmt::Display) {
assert_eq!(x.to_string(), "foo");
}
fn foo_indirect(x: fmt::Display) {
foo(x);
}
fn main() {
foo(*gen_foo());
foo_indirect(*gen_foo());
{
let x: fmt::Display = *gen_foo();
foo(x);
}
{
let x: fmt::Display = *gen_foo();
let y: fmt::Displa... | foo | identifier_name |
mod.rs | //! Sends an email using the client
use std::string::String;
use std::net::{SocketAddr, ToSocketAddrs};
use openssl::ssl::{SslContext, SslMethod};
use transport::error::{EmailResult, Error};
use transport::smtp::extension::{Extension, ServerInfo};
use transport::smtp::client::Client;
use transport::smtp::authenticat... | (mut self, enable: bool) -> SmtpTransportBuilder {
self.connection_reuse = enable;
self
}
/// Set the maximum number of emails sent using one connection
pub fn connection_reuse_count_limit(mut self, limit: u16) -> SmtpTransportBuilder {
self.connection_reuse_count_limit = limit;
... | connection_reuse | identifier_name |
mod.rs | //! Sends an email using the client
use std::string::String;
use std::net::{SocketAddr, ToSocketAddrs};
use openssl::ssl::{SslContext, SslMethod};
use transport::error::{EmailResult, Error};
use transport::smtp::extension::{Extension, ServerInfo};
use transport::smtp::client::Client;
use transport::smtp::authenticat... |
/// Require SSL/TLS using STARTTLS
///
/// Incompatible with `ssl_wrapper()``
pub fn encrypt(mut self) -> SmtpTransportBuilder {
self.security_level = SecurityLevel::AlwaysEncrypt;
self
}
/// Require SSL/TLS using STARTTLS
///
/// Incompatible with `encrypt()`
pub ... | {
self.security_level = level;
self
} | identifier_body |
mod.rs | //! Sends an email using the client
use std::string::String;
use std::net::{SocketAddr, ToSocketAddrs};
use openssl::ssl::{SslContext, SslMethod};
use transport::error::{EmailResult, Error};
use transport::smtp::extension::{Extension, ServerInfo};
use transport::smtp::client::Client;
use transport::smtp::authenticat... | pub mod client;
// Registrated port numbers:
// https://www.iana.
// org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
/// Default smtp port
pub static SMTP_PORT: u16 = 25;
/// Default submission port
pub static SUBMISSION_PORT: u16 = 587;
// Useful strings and characters
/// The word sep... | random_line_split | |
mod.rs | //! Sends an email using the client
use std::string::String;
use std::net::{SocketAddr, ToSocketAddrs};
use openssl::ssl::{SslContext, SslMethod};
use transport::error::{EmailResult, Error};
use transport::smtp::extension::{Extension, ServerInfo};
use transport::smtp::client::Client;
use transport::smtp::authenticat... |
result
}
/// Closes the inner connection
fn close(&mut self) {
self.client.close();
}
}
| {
self.reset();
} | conditional_block |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::time::Duration;
use std::{mem, thread};
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_rafts... | (
cluster: &mut Cluster<NodeCluster>,
key: &[u8],
value: &[u8],
read_quorum: bool,
old_region: &Region,
old_leader: &Peer,
new_region: &Region,
new_leader: &Peer,
) {
let value1 = read_on_peer(
cluster,
old_leader.clone(),
old_region.clone(),
key,
... | must_not_eq_on_key | identifier_name |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::time::Duration;
use std::{mem, thread};
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_rafts... | ;
// Get the new region.
let region2 = cluster.get_region_with(stale_key, |region| region!= ®ion1);
// Get the leader of the new region.
let leader2 = cluster.leader_of_region(region2.get_id()).unwrap();
assert_ne!(leader1.get_store_id(), leader2.get_store_id());
must_not_stale_read(
... | { key2 } | conditional_block |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::time::Duration;
use std::{mem, thread};
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_rafts... | .get_peers()
.iter()
.find(|p| p.get_id() == 3)
.unwrap()
.clone();
cluster.must_transfer_leader(region1.get_id(), peer3.clone());
// Get the current leader.
let leader1 = peer3;
// Pause the apply worker of peer 3.
let apply_split = "apply_before_split_1_3";
... | let region1 = region_left;
assert_eq!(region1.get_id(), 1);
let peer3 = region1 | random_line_split |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::time::Duration;
use std::{mem, thread};
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_rafts... | pd_client.must_remove_peer(r1, new_peer(1, 1));
sleep_ms(300);
// Try writing k2 to peer3
let mut request = new_request(
r1,
cluster.pd_client.get_region_epoch(r1),
vec![new_get_cmd(b"k1")],
false,
);
request.mut_header().set_peer(new_peer(1, 1));
let (cb, rx... | {
let mut cluster = new_node_cluster(0, 3);
let pd_client = cluster.pd_client.clone();
// Disable default max peer number check.
pd_client.disable_default_operator();
let r1 = cluster.run_conf_change();
// Add 2 peers.
for i in 2..4 {
pd_client.must_add_peer(r1, new_peer(i, i));
... | identifier_body |
schedule.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.... | () {
let s1 = Schedule::new_frontier();
let s2 = Schedule::new_homestead();
// To optimize division we assume 2**9 for quad_coeff_div
assert_eq!(s1.quad_coeff_div, 512);
assert_eq!(s2.quad_coeff_div, 512);
}
| schedule_evm_assumptions | identifier_name |
schedule.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.... | ,
sha3_gas: 30,
sha3_word_gas: 6,
sload_gas: 200,
sstore_set_gas: 20000,
sstore_reset_gas: 5000,
sstore_refund_gas: 15000,
jumpdest_gas: 1,
log_gas: 375,
log_data_gas: 8,
log_topic_gas: 375,
create_gas: 32000,
call_gas: 700,
call_stipend: 2300,
call_value_transfer_gas: 9000,
... | {10} | conditional_block |
schedule.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.... | /// If Some(x): let limit = GAS * (x - 1) / x; let CALL's gas = min(requested, limit). let CREATE's gas = limit.
/// If None: let CALL's gas = (requested > GAS? [OOG] : GAS). let CREATE's gas = GAS
pub sub_gas_cap_divisor: Option<usize>,
/// Don't ever make empty accounts; contracts start with nonce=1. Also, don't ... | /// Amount of additional gas to pay when SUICIDE credits a non-existant account
pub suicide_to_new_account_cost: usize, | random_line_split |
schedule.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.... | call_gas: 40,
call_stipend: 2300,
call_value_transfer_gas: 9000,
call_new_account_gas: 25000,
suicide_refund_gas: 24000,
memory_gas: 3,
quad_coeff_div: 512,
create_data_gas: 200,
create_data_limit: usize::max_value(),
tx_gas: 21000,
tx_create_gas: tcg,
tx_data_zero_gas: 4,
tx_data... | {
Schedule {
exceptional_failed_code_deposit: efcd,
have_delegate_call: hdc,
stack_limit: 1024,
max_depth: 1024,
tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0],
exp_gas: 10,
exp_byte_gas: 10,
sha3_gas: 30,
sha3_word_gas: 6,
sload_gas: 50,
sstore_set_gas: 20000,
sstore_reset_gas: 5000,
... | identifier_body |
lib.rs | #[derive(Debug)]
pub struct Rectangle {
length: u32,
width: u32,
}
impl Rectangle {
pub fn can_hold(&self, other: &Rectangle) -> bool {
self.length > other.length && self.width > other.width
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn | () {
let larger = Rectangle {
length: 8,
width: 7,
};
let smaller = Rectangle {
length: 5,
width: 1,
};
assert!(larger.can_hold(&smaller));
}
#[test]
fn smaller_can_hold_larger() {
let larger = Rectangle {
... | larger_can_hold_smaller | identifier_name |
lib.rs | #[derive(Debug)]
pub struct Rectangle {
length: u32,
width: u32,
}
impl Rectangle {
pub fn can_hold(&self, other: &Rectangle) -> bool {
self.length > other.length && self.width > other.width
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn larger_can_hold_smaller() {
... | width: 7,
};
let smaller = Rectangle {
length: 5,
width: 1,
};
assert!(!smaller.can_hold(&larger));
}
} | random_line_split | |
test.rs | extern crate couch;
extern crate http;
extern crate serialize;
#[cfg(test)]
mod test {
use couch::{Server,Document};
#[deriving(Encodable,Decodable)]
struct TestDocument {
_id: String,
body: String
}
impl Document for TestDocument {
fn id(&self) -> String |
}
#[test]
fn speak_to_the_couch() {
let server = Server::new(String::from_str("http://localhost:5984"));
let info = server.info();
assert_eq!(info.message(), "Welcome".to_owned());
}
#[test]
fn create_database() {
let mut server = Server::new(String::from_str("http://localhost:5984"));
... | {
self._id.clone()
} | identifier_body |
test.rs | extern crate couch;
extern crate http;
extern crate serialize;
#[cfg(test)]
mod test {
use couch::{Server,Document};
#[deriving(Encodable,Decodable)]
struct TestDocument {
_id: String,
body: String
}
impl Document for TestDocument {
fn id(&self) -> String {
self._id.clone()
}
}
#... | () {
let mut server = Server::new(String::from_str("http://localhost:5984"));
server.delete_database("created_by_couch".to_owned());
let database = server.create_database("created_by_couch".to_owned());
assert_eq!(database.name(), "created_by_couch".to_owned());
}
#[test]
fn create_document() {
... | create_database | identifier_name |
test.rs | extern crate couch;
extern crate http;
extern crate serialize;
|
#[deriving(Encodable,Decodable)]
struct TestDocument {
_id: String,
body: String
}
impl Document for TestDocument {
fn id(&self) -> String {
self._id.clone()
}
}
#[test]
fn speak_to_the_couch() {
let server = Server::new(String::from_str("http://localhost:5984"));
let info... | #[cfg(test)]
mod test {
use couch::{Server,Document}; | random_line_split |
objpool.rs | /*
Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
th... |
}
pub struct ObjPoolMutIdxIterator<'a, T: 'a> {
inner_iter: IterMut<'a, T>,
current_idx: usize,
}
impl<'a, T> Iterator for ObjPoolMutIdxIterator<'a, T> {
type Item = (ObjPoolIndex<T>, &'a mut T);
fn next(&mut self) -> Option<Self::Item> {
let next = self.inner_iter.next();
match next... | {
if self.current_idx == self.pool.storage.len() {
None
} else {
let ret = ObjPoolIndex::<T> {i: self.current_idx, type_marker: PhantomData};
self.current_idx += 1;
Some(ret)
}
} | identifier_body |
objpool.rs | /*
Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
th... |
}
}
pub struct ObjPoolMutIdxIterator<'a, T: 'a> {
inner_iter: IterMut<'a, T>,
current_idx: usize,
}
impl<'a, T> Iterator for ObjPoolMutIdxIterator<'a, T> {
type Item = (ObjPoolIndex<T>, &'a mut T);
fn next(&mut self) -> Option<Self::Item> {
let next = self.inner_iter.next();
matc... | {
let ret = ObjPoolIndex::<T> {i: self.current_idx, type_marker: PhantomData};
self.current_idx += 1;
Some(ret)
} | conditional_block |
objpool.rs | /*
Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
th... | (&self, other: &ObjPoolIndex<T>) -> bool {
self.i == other.i
}
}
impl<T> Eq for ObjPoolIndex<T> { }
impl<T> Hash for ObjPoolIndex<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.i.hash(state);
}
}
impl<T> ObjPoolIndex<T> {
pub fn get_raw_i(&self) -> usize {
self.i
}
}... | eq | identifier_name |
objpool.rs | /*
Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
th... | let next = self.inner_iter.next();
match next {
None => None,
Some(x) => {
let ret = ObjPoolIndex::<T> {i: self.current_idx, type_marker: PhantomData};
self.current_idx += 1;
Some((ret, x))
}
}
}
}
#[cfg(tes... |
fn next(&mut self) -> Option<Self::Item> { | random_line_split |
trait-inheritance2.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | trait Bar { fn g(&self) -> int; }
trait Baz { fn h(&self) -> int; }
trait Quux: Foo + Bar + Baz { }
struct A { x: int }
impl Foo for A { fn f(&self) -> int { 10 } }
impl Bar for A { fn g(&self) -> int { 20 } }
impl Baz for A { fn h(&self) -> int { 30 } }
impl Quux for A {}
fn f<T:Quux + Foo + Bar + Baz>(a: &T) {
... | // option. This file may not be copied, modified, or distributed
// except according to those terms.
trait Foo { fn f(&self) -> int; } | random_line_split |
trait-inheritance2.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 ... | (&self) -> int { 30 } }
impl Quux for A {}
fn f<T:Quux + Foo + Bar + Baz>(a: &T) {
assert_eq!(a.f(), 10);
assert_eq!(a.g(), 20);
assert_eq!(a.h(), 30);
}
pub fn main() {
let a = &A { x: 3 };
f(a);
}
| h | identifier_name |
trait-inheritance2.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 ... | }
impl Bar for A { fn g(&self) -> int { 20 } }
impl Baz for A { fn h(&self) -> int { 30 } }
impl Quux for A {}
fn f<T:Quux + Foo + Bar + Baz>(a: &T) {
assert_eq!(a.f(), 10);
assert_eq!(a.g(), 20);
assert_eq!(a.h(), 30);
}
pub fn main() {
let a = &A { x: 3 };
f(a);
}
| { 10 } | identifier_body |
benchmarks.rs | /*
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at | * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#[macro_use]
extern crate bencher;
extern crate flatbuffers;
exte... | *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software | random_line_split |
lib.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
use std::hash::Hasher;
let mut hasher = hash::SipHasher::new();
x.hash(&mut hasher);
hasher.finish()
} | identifier_body | |
lib.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | //! ```
//! extern crate num;
//! # #[cfg(all(feature = "bigint", feature="rational"))]
//! # mod test {
//!
//! use num::FromPrimitive;
//! use num::bigint::BigInt;
//! use num::rational::{Ratio, BigRational};
//!
//! # pub
//! fn approx_sqrt(number: u64, iterations: usize) -> BigRational {
//! let start: Ratio<Bi... | //! This example uses the BigRational type and [Newton's method][newt] to
//! approximate a square root to arbitrary precision:
//! | random_line_split |
lib.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
while exp & 1 == 0 {
base = base.clone() * base;
exp >>= 1;
}
if exp == 1 { return base }
let mut acc = base.clone();
while exp > 1 {
exp >>= 1;
base = base.clone() * base;
if exp & 1 == 1 {
acc = acc * base.clone();
}
}
acc
}
#... | { return T::one() } | conditional_block |
lib.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T: One>() -> T { One::one() }
/// Computes the absolute value.
///
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`
///
/// For signed integers, `::MIN` will be returned if the number is `::MIN`.
#[inline(always)]
pub fn abs<T: Signed>(value: T) -> T {
value.abs()
}
/// The positive differe... | one | identifier_name |
main.rs | extern crate serenity;
use serenity::prelude::*;
use serenity::model::*;
use std::env;
struct Handler;
impl EventHandler for Handler {
// Set a handler for the `on_message` event - so that whenever a new message
// is received - the closure (or function) passed will be called.
//
// Event handlers ar... |
}
// Set a handler to be called on the `on_ready` event. This is called when a
// shard is booted, and a READY payload is sent by Discord. This payload
// contains data like the current user's guild Ids, current user data,
// private channels, and more.
//
// In this case, just print what ... | {
// Sending a message can fail, due to a network error, an
// authentication error, or lack of permissions to post in the
// channel, so log to stdout when some error happens, with a
// description of it.
if let Err(why) = msg.channel_id.say("Pong!") {
... | conditional_block |
main.rs | extern crate serenity;
use serenity::prelude::*;
use serenity::model::*;
use std::env;
struct Handler;
impl EventHandler for Handler {
// Set a handler for the `on_message` event - so that whenever a new message
// is received - the closure (or function) passed will be called.
//
// Event handlers ar... | (&self, _: Context, msg: Message) {
if msg.content == "!ping" {
// Sending a message can fail, due to a network error, an
// authentication error, or lack of permissions to post in the
// channel, so log to stdout when some error happens, with a
// description of ... | on_message | identifier_name |
main.rs | extern crate serenity;
use serenity::prelude::*;
use serenity::model::*;
use std::env;
struct Handler;
impl EventHandler for Handler {
// Set a handler for the `on_message` event - so that whenever a new message
// is received - the closure (or function) passed will be called.
//
// Event handlers ar... |
// Set a handler to be called on the `on_ready` event. This is called when a
// shard is booted, and a READY payload is sent by Discord. This payload
// contains data like the current user's guild Ids, current user data,
// private channels, and more.
//
// In this case, just print what the cu... | {
if msg.content == "!ping" {
// Sending a message can fail, due to a network error, an
// authentication error, or lack of permissions to post in the
// channel, so log to stdout when some error happens, with a
// description of it.
if let Err(why) = ... | identifier_body |
main.rs | extern crate serenity;
use serenity::prelude::*;
use serenity::model::*;
use std::env;
struct Handler;
impl EventHandler for Handler {
// Set a handler for the `on_message` event - so that whenever a new message
// is received - the closure (or function) passed will be called.
//
// Event handlers ar... | // Set a handler to be called on the `on_ready` event. This is called when a
// shard is booted, and a READY payload is sent by Discord. This payload
// contains data like the current user's guild Ids, current user data,
// private channels, and more.
//
// In this case, just print what the curr... | random_line_split | |
bin.rs | #[macro_use]
extern crate malachite_base_test_util;
extern crate malachite_nz;
extern crate malachite_nz_test_util;
extern crate malachite_q;
extern crate serde;
extern crate serde_json;
use crate::demo_and_bench::register;
use malachite_base_test_util::runner::cmd::read_command_line_arguments;
use malachite_base_test... |
mod demo_and_bench; | } | random_line_split |
bin.rs | #[macro_use]
extern crate malachite_base_test_util;
extern crate malachite_nz;
extern crate malachite_nz_test_util;
extern crate malachite_q;
extern crate serde;
extern crate serde_json;
use crate::demo_and_bench::register;
use malachite_base_test_util::runner::cmd::read_command_line_arguments;
use malachite_base_test... | () {
let args = read_command_line_arguments("malachite-q test utils");
let mut runner = Runner::new();
register(&mut runner);
if let Some(demo_key) = args.demo_key {
runner.run_demo(&demo_key, args.generation_mode, args.config, args.limit);
} else if let Some(bench_key) = args.bench_key {
... | main | identifier_name |
bin.rs | #[macro_use]
extern crate malachite_base_test_util;
extern crate malachite_nz;
extern crate malachite_nz_test_util;
extern crate malachite_q;
extern crate serde;
extern crate serde_json;
use crate::demo_and_bench::register;
use malachite_base_test_util::runner::cmd::read_command_line_arguments;
use malachite_base_test... | else {
panic!();
}
}
mod demo_and_bench;
| {
runner.run_bench(
&bench_key,
args.generation_mode,
args.config,
args.limit,
&args.out,
);
} | conditional_block |
bin.rs | #[macro_use]
extern crate malachite_base_test_util;
extern crate malachite_nz;
extern crate malachite_nz_test_util;
extern crate malachite_q;
extern crate serde;
extern crate serde_json;
use crate::demo_and_bench::register;
use malachite_base_test_util::runner::cmd::read_command_line_arguments;
use malachite_base_test... |
mod demo_and_bench;
| {
let args = read_command_line_arguments("malachite-q test utils");
let mut runner = Runner::new();
register(&mut runner);
if let Some(demo_key) = args.demo_key {
runner.run_demo(&demo_key, args.generation_mode, args.config, args.limit);
} else if let Some(bench_key) = args.bench_key {
... | identifier_body |
length_expr.rs | // Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com> | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: Only field names, constants, integers, basic arithmetic expressions (+ - * / %) and parentheses are allowed in the "length" attribute
#![feature(custom_attribute, plugin)]
#![plugin(pnet_macros)]
ex... | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
length_expr.rs | // Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or... | {} | identifier_body | |
length_expr.rs | // Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or... | () {}
| main | identifier_name |
lib.rs | // =================================================================
//
// * WARNING *
//
// This file is generated!
//
// Changes made to this file will be overwritten. If changes are | // must be updated to generate the changes.
//
// =================================================================
#![doc(html_logo_url = "https://raw.githubusercontent.com/rusoto/rusoto/master/assets/logo-square.png")]
//! <p>Use the AWS Elemental MediaTailor SDK to configure scalable ad insertion for your live and... | // required to the generated code, the service_crategen project | random_line_split |
issue-17913.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. | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: too big for the current architecture
#![feature(box_syntax)]
#[cfg(target_pointer_width = "64")]
fn main() {
let n = 0_usize;
let a: Box<_> = box [&n; 0xF000000000000000_usize];
println... | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
issue-17913.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 ... |
#[cfg(target_pointer_width = "32")]
fn main() {
let n = 0_usize;
let a: Box<_> = box [&n; 0xFFFFFFFF_usize];
println!("{}", a[0xFFFFFF_usize]);
}
| {
let n = 0_usize;
let a: Box<_> = box [&n; 0xF000000000000000_usize];
println!("{}", a[0xFFFFFF_usize]);
} | identifier_body |
issue-17913.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 n = 0_usize;
let a: Box<_> = box [&n; 0xF000000000000000_usize];
println!("{}", a[0xFFFFFF_usize]);
}
#[cfg(target_pointer_width = "32")]
fn main() {
let n = 0_usize;
let a: Box<_> = box [&n; 0xFFFFFFFF_usize];
println!("{}", a[0xFFFFFF_usize]);
}
| main | identifier_name |
traversal.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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | (&self, node: LayoutNode) {
// Initialize layout data.
//
// FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML
// parser.
node.initialize_layout_data();
// Get the parent node.
let parent_opt = node.layout_parent_node(self.layout... | process | identifier_name |
traversal.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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | old_generation == layout_context.shared.generation {
// Hey, the cached parent is our parent! We can reuse the bloom filter.
debug!("[{}] Parent matches (={}). Reusing bloom filter.", tid(), old_node.0);
} else {
// Oh no. t... | if old_node == layout_node_to_unsafe_layout_node(&parent) && | random_line_split |
issue-20727-2.rs | // aux-build:issue-20727.rs
// ignore-cross-compile
extern crate issue_20727;
| // @has - '//*[@class="rust trait"]' 'trait Add<RHS = Self> {'
// @has - '//*[@class="rust trait"]' 'type Output;'
type Output;
// @has - '//*[@class="rust trait"]' 'fn add(self, rhs: RHS) -> Self::Output;'
fn add(self, rhs: RHS) -> Self::Output;
}
// @has issue_20727_2/reexport/trait.Add.html
pub... | // @has issue_20727_2/trait.Add.html
pub trait Add<RHS = Self> { | random_line_split |
text_box.rs | use super::behaviors::{TextAction, TextBehavior};
use crate::{api::prelude::*, prelude::*, proc_macros::*, themes::theme_orbtk::*};
// --- KEYS --
pub static STYLE_TEXT_BOX: &str = "text_box";
static ID_CURSOR: &str = "id_cursor";
// --- KEYS --
widget!(
/// The `TextBox` widget represents a single line text inp... | (self, id: Entity, ctx: &mut BuildContext) -> Self {
let text_block = TextBlock::new()
.v_align("center")
.h_align("start")
.foreground(id)
.text(id)
.water_mark(id)
.font(id)
.font_size(id)
.localizable(false)
.b... | template | identifier_name |
text_box.rs | use super::behaviors::{TextAction, TextBehavior};
use crate::{api::prelude::*, prelude::*, proc_macros::*, themes::theme_orbtk::*};
// --- KEYS --
pub static STYLE_TEXT_BOX: &str = "text_box";
static ID_CURSOR: &str = "id_cursor";
// --- KEYS --
widget!(
/// The `TextBox` widget represents a single line text inp... | .v_align("center")
.h_align("start")
.foreground(id)
.text(id)
.water_mark(id)
.font(id)
.font_size(id)
.localizable(false)
.build(ctx);
let cursor = Cursor::new().id(ID_CURSOR).selection(id).build(ctx);
... | fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
let text_block = TextBlock::new() | random_line_split |
text_box.rs | use super::behaviors::{TextAction, TextBehavior};
use crate::{api::prelude::*, prelude::*, proc_macros::*, themes::theme_orbtk::*};
// --- KEYS --
pub static STYLE_TEXT_BOX: &str = "text_box";
static ID_CURSOR: &str = "id_cursor";
// --- KEYS --
widget!(
/// The `TextBox` widget represents a single line text inp... | .font_size(id)
.lose_focus_on_activation(id)
.select_all_on_focus(id)
.request_focus(id)
.text(id)
.selection(id)
.build(ctx);
self.name("TextBox")
.style(STYLE_TEXT_BOX)
.background(colors::LYNCH_COLOR)
... | {
let text_block = TextBlock::new()
.v_align("center")
.h_align("start")
.foreground(id)
.text(id)
.water_mark(id)
.font(id)
.font_size(id)
.localizable(false)
.build(ctx);
let cursor = Cursor::n... | identifier_body |
spawn_task.rs | use super::*;
use crate::ok_or_shutdown;
use crate::state_helper::{pause_on_failure, save_state, LockedState};
impl TaskHandler {
/// See if we can start a new queued task.
pub fn spawn_new(&mut self) {
let cloned_state_mutex = self.state.clone();
let mut state = cloned_state_mutex.lock().unwr... | let (stdout_log, stderr_log) = match create_log_file_handles(task_id, &self.pueue_directory)
{
Ok((out, err)) => (out, err),
Err(err) => {
panic!("Failed to create child log files: {err:?}");
}
};
// Get all necessary info for starting... | {
// Check if the task exists and can actually be spawned. Otherwise do an early return.
match state.tasks.get(&task_id) {
Some(task) => {
if !matches!(
&task.status,
TaskStatus::Stashed { .. } | TaskStatus::Queued | TaskStatus::Paused
... | identifier_body |
spawn_task.rs | use super::*;
use crate::ok_or_shutdown;
use crate::state_helper::{pause_on_failure, save_state, LockedState};
impl TaskHandler {
/// See if we can start a new queued task.
pub fn | (&mut self) {
let cloned_state_mutex = self.state.clone();
let mut state = cloned_state_mutex.lock().unwrap();
// Check whether a new task can be started.
// Spawn tasks until we no longer have free slots available.
while let Some(id) = self.get_next_task_id(&state) {
... | spawn_new | identifier_name |
spawn_task.rs | use super::*;
use crate::ok_or_shutdown;
use crate::state_helper::{pause_on_failure, save_state, LockedState};
impl TaskHandler {
/// See if we can start a new queued task.
pub fn spawn_new(&mut self) {
let cloned_state_mutex = self.state.clone();
let mut state = cloned_state_mutex.lock().unwr... | return false;
}
// Get the currently running tasks by looking at the actually running processes.
// They're sorted by group, which makes this quite convenient.
let running_tasks = match self.children.0.get(&task.group) {
... | }
};
// Let's check if the group is running. If it isn't, simply return false.
if group.status != GroupStatus::Running { | random_line_split |
const-contents.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 ... | () {
assert_eq!(lsl, 4);
assert_eq!(add, 3);
assert_eq!(addf, 3.0);
assert_eq!(not, -1);
assert_eq!(notb, false);
assert_eq!(neg, -1);
}
| main | identifier_name |
const-contents.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 ... | {
assert_eq!(lsl, 4);
assert_eq!(add, 3);
assert_eq!(addf, 3.0);
assert_eq!(not, -1);
assert_eq!(notb, false);
assert_eq!(neg, -1);
} | identifier_body | |
const-contents.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Issue #570
s... | random_line_split | |
common.rs | use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};
use std::io::{self, Read, Write};
pub enum | {
Connect(u32),
Connected(u32),
Data(u32, Vec<u8>),
Disconnect(u32),
Disconnected(u32), // Really want FIN ACK?
}
/*
impl SimpleFwdOp {
pub fn write_to<A: Write + Sized>(&self, os: &mut A) -> io::Result<()> {
use SimpleFwdOp::*;
match self {
&Connect(id) => {
... | SimpleFwdOp | identifier_name |
common.rs | use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};
use std::io::{self, Read, Write};
pub enum SimpleFwdOp {
Connect(u32),
Connected(u32),
Data(u32, Vec<u8>),
Disconnect(u32),
Disconnected(u32), // Really want FIN ACK?
}
/*
impl SimpleFwdOp {
pub fn write_to<A: Write + Sized>(&self, os: ... |
pub fn write_frame<A: Write + Sized>(stream: &mut A, buf: &[u8]) -> io::Result<()> {
try!(stream.write_u32::<BigEndian>(buf.len() as u32));
try!(stream.write_all(buf));
stream.flush()
}
#[cfg(test)]
mod tests {
use super::*;
use std::io::Cursor;
fn check_write_read(bs: &[u8]) {
let m... | {
let length = try!(stream.read_u32::<BigEndian>());
let mut buf = vec![0; length as usize];
try!(read_exact(stream, &mut buf));
Ok(buf)
} | identifier_body |
common.rs | use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};
use std::io::{self, Read, Write};
pub enum SimpleFwdOp {
Connect(u32),
Connected(u32),
Data(u32, Vec<u8>),
Disconnect(u32),
Disconnected(u32), // Really want FIN ACK?
}
/*
impl SimpleFwdOp {
pub fn write_to<A: Write + Sized>(&self, os: ... | }
} | random_line_split | |
vec_delete_left.rs | use malachite_base::vecs::vec_delete_left;
use malachite_base_test_util::bench::bucketers::pair_1_vec_len_bucketer;
use malachite_base_test_util::bench::{run_benchmark, BenchmarkType};
use malachite_base_test_util::generators::common::{GenConfig, GenMode};
use malachite_base_test_util::generators::unsigned_vec_unsigned... | {
run_benchmark(
"vec_delete_left(&mut [T], usize)",
BenchmarkType::Single,
unsigned_vec_unsigned_pair_gen_var_1::<u8>().get(gm, &config),
gm.name(),
limit,
file_name,
&pair_1_vec_len_bucketer("xs"),
&mut [("Malachite", &mut |(mut xs, amount)| {
... | identifier_body | |
vec_delete_left.rs | use malachite_base::vecs::vec_delete_left;
use malachite_base_test_util::bench::bucketers::pair_1_vec_len_bucketer;
use malachite_base_test_util::bench::{run_benchmark, BenchmarkType};
use malachite_base_test_util::generators::common::{GenConfig, GenMode};
use malachite_base_test_util::generators::unsigned_vec_unsigned... | vec_delete_left(&mut xs, amount);
println!(
"xs := {:?}; vec_delete_left(&mut xs, {}); xs = {:?}",
old_xs, amount, xs
);
}
}
fn benchmark_vec_delete_left(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) {
run_benchmark(
"vec_delete_left(&mut... | for (mut xs, amount) in unsigned_vec_unsigned_pair_gen_var_1::<u8>()
.get(gm, &config)
.take(limit)
{
let old_xs = xs.clone(); | random_line_split |
vec_delete_left.rs | use malachite_base::vecs::vec_delete_left;
use malachite_base_test_util::bench::bucketers::pair_1_vec_len_bucketer;
use malachite_base_test_util::bench::{run_benchmark, BenchmarkType};
use malachite_base_test_util::generators::common::{GenConfig, GenMode};
use malachite_base_test_util::generators::unsigned_vec_unsigned... | (gm: GenMode, config: GenConfig, limit: usize, file_name: &str) {
run_benchmark(
"vec_delete_left(&mut [T], usize)",
BenchmarkType::Single,
unsigned_vec_unsigned_pair_gen_var_1::<u8>().get(gm, &config),
gm.name(),
limit,
file_name,
&pair_1_vec_len_bucketer("xs... | benchmark_vec_delete_left | 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/. */
#![feature(plugin)]
#![cfg_attr(test, feature(core_intrinsics))]
#![plugin(plugins)]
extern crate app_units;
exte... |
}
| {
assert_eq!(get_writing_mode(INITIAL_VALUES.get_inheritedbox()), WritingMode::empty())
} | identifier_body |
lib.rs | #![cfg_attr(test, feature(core_intrinsics))]
#![plugin(plugins)]
extern crate app_units;
extern crate cssparser;
extern crate euclid;
extern crate selectors;
#[macro_use(atom, ns)] extern crate string_cache;
extern crate style;
extern crate style_traits;
extern crate url;
extern crate util;
#[cfg(test)] mod styleshe... | /* 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(plugin)] | 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/. */
#![feature(plugin)]
#![cfg_attr(test, feature(core_intrinsics))]
#![plugin(plugins)]
extern crate app_units;
exte... | () {
assert_eq!(get_writing_mode(INITIAL_VALUES.get_inheritedbox()), WritingMode::empty())
}
}
| initial_writing_mode_is_empty | identifier_name |
issue-33537.rs | // Copyright 2016 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 ... | } | assert_eq!(bar(), 2); | random_line_split |
issue-33537.rs | // Copyright 2016 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 ... | () -> i32 {
*&{(1, 2, 3).1}
}
fn main() {
assert_eq!(foo(), b"foo" as *const _ as *const i8);
assert_eq!(bar(), 2);
}
| bar | identifier_name |
issue-33537.rs | // Copyright 2016 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() {
assert_eq!(foo(), b"foo" as *const _ as *const i8);
assert_eq!(bar(), 2);
}
| {
*&{(1, 2, 3).1}
} | identifier_body |
uart.rs | use core::fmt;
use core::str::StrExt;
use core::result::Result;
use hw::HW;
pub trait Uart<W : HW> {
fn put(&self, &mut W, ch : u8);
}
pub trait UartWriter : fmt::Write { }
pub struct | ;
impl UartWriter for DummyUartWriter { }
impl fmt::Write for DummyUartWriter {
fn write_str(&mut self, _: &str) -> fmt::Result {
Result::Ok(())
}
}
pub struct BlockingUartWriter<H :'static+HW> {
uart : &'static Uart<H>,
hw : &'static mut H,
}
impl<H : HW> UartWriter for BlockingUartWriter<H... | DummyUartWriter | identifier_name |
uart.rs | use core::fmt;
use core::str::StrExt;
use core::result::Result;
|
pub trait UartWriter : fmt::Write { }
pub struct DummyUartWriter;
impl UartWriter for DummyUartWriter { }
impl fmt::Write for DummyUartWriter {
fn write_str(&mut self, _: &str) -> fmt::Result {
Result::Ok(())
}
}
pub struct BlockingUartWriter<H :'static+HW> {
uart : &'static Uart<H>,
hw : &... | use hw::HW;
pub trait Uart<W : HW> {
fn put(&self, &mut W, ch : u8);
} | random_line_split |
uart.rs | use core::fmt;
use core::str::StrExt;
use core::result::Result;
use hw::HW;
pub trait Uart<W : HW> {
fn put(&self, &mut W, ch : u8);
}
pub trait UartWriter : fmt::Write { }
pub struct DummyUartWriter;
impl UartWriter for DummyUartWriter { }
impl fmt::Write for DummyUartWriter {
fn write_str(&mut self, _: ... |
}
impl<H> fmt::Write for BlockingUartWriter<H>
where H : HW {
fn write_str(&mut self, s: &str) -> fmt::Result {
for ch in s.bytes() {
self.uart.put(self.hw, ch);
}
Result::Ok(())
}
}
| {
BlockingUartWriter { uart: uart, hw: hw }
} | identifier_body |
connecting.rs | extern crate ftp;
use std::str;
use std::io::Cursor;
use ftp::FtpStream;
fn | () {
let mut ftp_stream = match FtpStream::connect("127.0.0.1", 21) {
Ok(s) => s,
Err(e) => panic!("{}", e)
};
match ftp_stream.login("username", "password") {
Ok(_) => (),
Err(e) => panic!("{}", e)
}
match ftp_stream.current_dir() {
Ok(dir) => println!("{}", d... | main | identifier_name |
connecting.rs | extern crate ftp;
use std::str;
use std::io::Cursor;
use ftp::FtpStream;
fn main() |
//An easy way to retreive a file
let remote_file = match ftp_stream.simple_retr("ftpext-charter.txt") {
Ok(file) => file,
Err(e) => panic!("{}", e)
};
match str::from_utf8(&remote_file.into_inner()) {
Ok(s) => print!("{}", s),
Err(e) => panic!("Error reading file data: ... | {
let mut ftp_stream = match FtpStream::connect("127.0.0.1", 21) {
Ok(s) => s,
Err(e) => panic!("{}", e)
};
match ftp_stream.login("username", "password") {
Ok(_) => (),
Err(e) => panic!("{}", e)
}
match ftp_stream.current_dir() {
Ok(dir) => println!("{}", dir)... | identifier_body |
connecting.rs | extern crate ftp;
use std::str;
use std::io::Cursor;
use ftp::FtpStream;
fn main() {
let mut ftp_stream = match FtpStream::connect("127.0.0.1", 21) {
Ok(s) => s,
Err(e) => panic!("{}", e)
};
match ftp_stream.login("username", "password") {
Ok(_) => (),
Err(e) => panic!("{}", ... | let _ = ftp_stream.quit();
} | }
| random_line_split |
users.rs | #![crate_name = "users"]
/*
* This file is part of the uutils coreutils package.
*
* (c) KokaKiwi <kokakiwi@kokakiwi.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: whoami (GNU coreutils) 8.22 */
// All... | }
}
endutxent();
}
if users.len() > 0 {
users.sort();
println!("{}", users.join(" "));
}
}
#[allow(dead_code)]
fn main() {
std::process::exit(uumain(std::env::args().collect()));
}
| {
unsafe {
utmpxname(CString::new(filename).unwrap().as_ptr());
}
let mut users = vec!();
unsafe {
setutxent();
loop {
let line = getutxent();
if line == ptr::null() {
break;
}
if (*line).ut_type == USER_PROCESS... | identifier_body |
users.rs | #![crate_name = "users"]
/*
* This file is part of the uutils coreutils package.
*
* (c) KokaKiwi <kokakiwi@kokakiwi.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: whoami (GNU coreutils) 8.22 */
// All... | () {
std::process::exit(uumain(std::env::args().collect()));
}
| main | identifier_name |
users.rs | #![crate_name = "users"]
/*
* This file is part of the uutils coreutils package.
*
* (c) KokaKiwi <kokakiwi@kokakiwi.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: whoami (GNU coreutils) 8.22 */
// All... |
let filename = if matches.free.len() > 0 {
matches.free[0].as_ref()
} else {
DEFAULT_FILE
};
exec(filename);
0
}
fn exec(filename: &str) {
unsafe {
utmpxname(CString::new(filename).unwrap().as_ptr());
}
let mut users = vec!();
unsafe {
setutxent... | {
println!("{} {}", NAME, VERSION);
return 0;
} | conditional_block |
users.rs | #![crate_name = "users"]
/*
* This file is part of the uutils coreutils package.
*
* (c) KokaKiwi <kokakiwi@kokakiwi.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: whoami (GNU coreutils) 8.22 */
// All... | extern crate libc;
#[macro_use]
extern crate uucore;
use getopts::Options;
use std::ffi::{CStr, CString};
use std::mem;
use std::ptr;
use uucore::utmpx::*;
extern {
fn getutxent() -> *const c_utmp;
fn getutxid(ut: *const c_utmp) -> *const c_utmp;
fn getutxline(ut: *const c_utmp) -> *const c_utmp;
fn... | extern crate getopts; | random_line_split |
cmd_isready_test.rs | // Raven is a high performance UCI chess engine
// Copyright (C) 2015-2015 Nam Pham
//
// This program 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) ... | () {
let r = Command::parse("isready param1 param2");
assert!(r.is_err());
}
| test_create_good_isready_command_but_with_extra_params | identifier_name |
cmd_isready_test.rs | // Raven is a high performance UCI chess engine
// Copyright (C) 2015-2015 Nam Pham
//
// This program 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) ... |
#[test]
fn test_create_good_isready_command_but_with_extra_params() {
let r = Command::parse("isready param1 param2");
assert!(r.is_err());
}
| {
let r = Command::parse("nonexistence");
assert!(r.is_err());
} | identifier_body |
cmd_isready_test.rs | // Raven is a high performance UCI chess engine
// Copyright (C) 2015-2015 Nam Pham
// | //
// This program 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... | // This program 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. | random_line_split |
single-line-if-else.rs | // rustfmt-single_line_if_else_max_width: 100
// Format if-else expressions on a single line, when possible.
| fn main() {
let a = if 1 > 2 {
unreachable!()
} else {
10
};
let a = if x { 1 } else if y { 2 } else { 3 };
let b = if cond() {
5
} else {
// Brief comment.
10
};
let c = if cond() {
statement();
5
} else {
10
};... | random_line_split | |
single-line-if-else.rs | // rustfmt-single_line_if_else_max_width: 100
// Format if-else expressions on a single line, when possible.
fn main() | } else {
10
};
let d = if let Some(val) = turbo
{ "cool" } else {
"beans" };
if cond() { statement(); } else { other_statement(); }
if true {
do_something()
}
let x = if veeeeeeeeery_loooooong_condition() { aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa } else { bbbbbbbb... | {
let a = if 1 > 2 {
unreachable!()
} else {
10
};
let a = if x { 1 } else if y { 2 } else { 3 };
let b = if cond() {
5
} else {
// Brief comment.
10
};
let c = if cond() {
statement();
5 | identifier_body |
single-line-if-else.rs | // rustfmt-single_line_if_else_max_width: 100
// Format if-else expressions on a single line, when possible.
fn | () {
let a = if 1 > 2 {
unreachable!()
} else {
10
};
let a = if x { 1 } else if y { 2 } else { 3 };
let b = if cond() {
5
} else {
// Brief comment.
10
};
let c = if cond() {
statement();
5
} else {
10
};
l... | main | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.