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 |
|---|---|---|---|---|
dns_sd.rs | // Copyright 2015-2018 Benjamin Fry <benjaminfry@me.com>
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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... | (TxtLookup);
impl ServiceInfo {
/// Returns this as a map, this allocates a new hashmap
///
/// This converts the DNS-SD TXT record into a map following the rules specified in https://tools.ietf.org/html/rfc6763#section-6.4
pub fn to_map<'s>(&'s self) -> HashMap<Cow<'s, str>, Option<Cow<'s, str>>> {
... | ServiceInfo | identifier_name |
lto-unwind.rs | // needs-unwind
// no-prefer-dynamic
// ignore-emscripten no processes
// ignore-sgx no processes
use std::process::Command;
use std::env;
struct Bomb;
impl Drop for Bomb {
fn drop(&mut self) {
println!("hurray you ran me");
}
}
fn main() {
let mut args = env::args_os();
let me = args.next()... | // run-pass
#![allow(unused_variables)]
// compile-flags:-C lto -C panic=unwind | random_line_split | |
lto-unwind.rs | // run-pass
#![allow(unused_variables)]
// compile-flags:-C lto -C panic=unwind
// needs-unwind
// no-prefer-dynamic
// ignore-emscripten no processes
// ignore-sgx no processes
use std::process::Command;
use std::env;
struct Bomb;
impl Drop for Bomb {
fn drop(&mut self) {
println!("hurray you ran me");... | {
let mut args = env::args_os();
let me = args.next().unwrap();
if let Some(s) = args.next() {
if &*s == "foo" {
let _bomb = Bomb;
panic!("try to catch me");
}
}
let s = Command::new(env::args_os().next().unwrap()).arg("foo").output();
let s = s.unwrap(... | identifier_body | |
lto-unwind.rs | // run-pass
#![allow(unused_variables)]
// compile-flags:-C lto -C panic=unwind
// needs-unwind
// no-prefer-dynamic
// ignore-emscripten no processes
// ignore-sgx no processes
use std::process::Command;
use std::env;
struct Bomb;
impl Drop for Bomb {
fn | (&mut self) {
println!("hurray you ran me");
}
}
fn main() {
let mut args = env::args_os();
let me = args.next().unwrap();
if let Some(s) = args.next() {
if &*s == "foo" {
let _bomb = Bomb;
panic!("try to catch me");
}
}
let s = Command::new(en... | drop | identifier_name |
lto-unwind.rs | // run-pass
#![allow(unused_variables)]
// compile-flags:-C lto -C panic=unwind
// needs-unwind
// no-prefer-dynamic
// ignore-emscripten no processes
// ignore-sgx no processes
use std::process::Command;
use std::env;
struct Bomb;
impl Drop for Bomb {
fn drop(&mut self) {
println!("hurray you ran me");... |
let s = Command::new(env::args_os().next().unwrap()).arg("foo").output();
let s = s.unwrap();
assert!(!s.status.success());
assert!(String::from_utf8_lossy(&s.stdout).contains("hurray you ran me"));
}
| {
if &*s == "foo" {
let _bomb = Bomb;
panic!("try to catch me");
}
} | 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 ... | mod ptr;
mod result;
mod slice;
mod str;
mod tuple; | mod ops;
mod option; | random_line_split |
test_expr.rs | use common::util::*;
#[test]
fn test_simple_arithmetic() {
new_ucmd!().args(&["1", "+", "1"]).run().stdout_is("2\n");
new_ucmd!().args(&["1", "-", "1"]).run().stdout_is("0\n");
new_ucmd!().args(&["3", "*", "2"]).run().stdout_is("6\n");
new_ucmd!().args(&["4", "/", "2"]).run().stdout_is("2\n");
} | fn test_parenthesis() {
new_ucmd!().args(&["(", "1", "+", "1", ")", "*", "2"]).run().stdout_is("4\n");
}
#[test]
fn test_or() {
new_ucmd!().args(&["0", "|", "foo"]).run().stdout_is("foo\n");
new_ucmd!().args(&["foo", "|", "bar"]).run().stdout_is("foo\n");
}
#[test]
fn test_and() {
new_ucmd!().args(&[... |
#[test] | random_line_split |
test_expr.rs | use common::util::*;
#[test]
fn | () {
new_ucmd!().args(&["1", "+", "1"]).run().stdout_is("2\n");
new_ucmd!().args(&["1", "-", "1"]).run().stdout_is("0\n");
new_ucmd!().args(&["3", "*", "2"]).run().stdout_is("6\n");
new_ucmd!().args(&["4", "/", "2"]).run().stdout_is("2\n");
}
#[test]
fn test_parenthesis() {
new_ucmd!().args(&["(... | test_simple_arithmetic | identifier_name |
test_expr.rs | use common::util::*;
#[test]
fn test_simple_arithmetic() {
new_ucmd!().args(&["1", "+", "1"]).run().stdout_is("2\n");
new_ucmd!().args(&["1", "-", "1"]).run().stdout_is("0\n");
new_ucmd!().args(&["3", "*", "2"]).run().stdout_is("6\n");
new_ucmd!().args(&["4", "/", "2"]).run().stdout_is("2\n");
}
#... |
#[test]
fn test_and() {
new_ucmd!().args(&["foo", "&", "1"]).run().stdout_is("foo\n");
new_ucmd!().args(&["", "&", "1"]).run().stdout_is("0\n");
}
| {
new_ucmd!().args(&["0", "|", "foo"]).run().stdout_is("foo\n");
new_ucmd!().args(&["foo", "|", "bar"]).run().stdout_is("foo\n");
} | identifier_body |
mod.rs | //! Abstraction of different session APIs.
//!
//! Sessions provide a way for multiple graphical systems to run in parallel by providing
//! mechanisms to switch between and handle device access and permissions for every running
//! instance. They are crucial to allow unprivileged processes to use graphical or input
//... | /// Major number identifying the device
major: u32,
/// Minor number identifying the device
minor: u32,
},
/// The whole session has been activated
ActivateSession,
/// A given device has been activated
ActivateDevice {
/// Major number identifying the device
... | PauseSession,
/// A given device has been paused
PauseDevice { | random_line_split |
mod.rs | //! Abstraction of different session APIs.
//!
//! Sessions provide a way for multiple graphical systems to run in parallel by providing
//! mechanisms to switch between and handle device access and permissions for every running
//! instance. They are crucial to allow unprivileged processes to use graphical or input
//... | (&mut self, path: &Path, flags: OFlag) -> Result<RawFd, Self::Error> {
self.lock().unwrap().open(path, flags)
}
fn close(&mut self, fd: RawFd) -> Result<(), Self::Error> {
self.lock().unwrap().close(fd)
}
fn change_vt(&mut self, vt: i32) -> Result<(), Self::Error> {
self.lock()... | open | identifier_name |
mod.rs | //! Abstraction of different session APIs.
//!
//! Sessions provide a way for multiple graphical systems to run in parallel by providing
//! mechanisms to switch between and handle device access and permissions for every running
//! instance. They are crucial to allow unprivileged processes to use graphical or input
//... |
fn is_active(&self) -> bool {
self.borrow().is_active()
}
fn seat(&self) -> String {
self.borrow().seat()
}
}
impl<S: Session> Session for Arc<Mutex<S>> {
type Error = S::Error;
fn open(&mut self, path: &Path, flags: OFlag) -> Result<RawFd, Self::Error> {
self.lock()... | {
self.borrow_mut().change_vt(vt)
} | identifier_body |
mod.rs | mod time;
pub use self::time::Time;
use crate::switch::{Packet, Status, Switch};
use std::iter::Iterator;
pub struct Simulator<I: Iterator<Item = Packet>> {
input: I,
switch: Switch,
current_time: Time,
next_packet: Option<Packet>,
}
impl<I: Iterator<Item = Packet>> Iterator for Simulator<I> {
ty... |
}
impl<I: Iterator<Item = Packet>> Simulator<I> {
pub fn new(hyst: Time, idle: Time, input: I) -> Simulator<I> {
let switch = Switch::new(hyst, idle);
Simulator::new_internal(input, switch)
}
pub fn new_explicit(
hyst: Time,
idle: Time,
input: I,
ts: Time,... | {
match self.next_packet {
Some(packet) => {
let arrival_time = packet.arrival();
let res = self.process();
if self.current_time >= arrival_time {
self.next_packet = self.input.next();
if self.next_packet.is_som... | identifier_body |
mod.rs | mod time;
pub use self::time::Time;
use crate::switch::{Packet, Status, Switch};
use std::iter::Iterator;
pub struct Simulator<I: Iterator<Item = Packet>> {
input: I,
switch: Switch,
current_time: Time,
next_packet: Option<Packet>,
}
impl<I: Iterator<Item = Packet>> Iterator for Simulator<I> {
ty... |
}
Some(res)
}
None if self.switch.is_empty() => None,
None => Some(self.process()),
}
}
}
impl<I: Iterator<Item = Packet>> Simulator<I> {
pub fn new(hyst: Time, idle: Time, input: I) -> Simulator<I> {
let switch = Switch::new... | {
self.switch.add_packet(&self.next_packet.unwrap());
} | conditional_block |
mod.rs | mod time;
pub use self::time::Time;
use crate::switch::{Packet, Status, Switch};
use std::iter::Iterator;
pub struct Simulator<I: Iterator<Item = Packet>> {
input: I,
switch: Switch,
current_time: Time,
next_packet: Option<Packet>,
}
impl<I: Iterator<Item = Packet>> Iterator for Simulator<I> {
ty... | ts: Time,
tw: Time,
capacity: f64,
) -> Simulator<I> {
let switch = Switch::new_explicit(hyst, idle, ts, tw, capacity);
Simulator::new_internal(input, switch)
}
fn new_internal(mut input: I, switch: Switch) -> Simulator<I> {
let packet = input.next();
... | input: I, | random_line_split |
mod.rs | mod time;
pub use self::time::Time;
use crate::switch::{Packet, Status, Switch};
use std::iter::Iterator;
pub struct Simulator<I: Iterator<Item = Packet>> {
input: I,
switch: Switch,
current_time: Time,
next_packet: Option<Packet>,
}
impl<I: Iterator<Item = Packet>> Iterator for Simulator<I> {
ty... | (mut input: I, switch: Switch) -> Simulator<I> {
let packet = input.next();
let mut s = Simulator {
input,
current_time: Time(0),
switch,
next_packet: packet,
};
if s.next_packet.is_some() {
s.switch.add_packet(&s.next_packet.u... | new_internal | identifier_name |
im_context_simple.rs | // Copyright 2018, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use IMContextSimple;
use IsA;
use ffi;
use glib::translate::*;
use std::path::Path;
pub trait I... |
/*fn add_table(&self, data: &[u16], max_seq_len: u32, n_seqs: u32) {
assert!(max_seq_len * n_seqs < data.len() as u32);
unsafe {
ffi::gtk_im_context_simple_add_table(self.to_glib_none().0,
data.to_glib_none().0,
... | {
unsafe {
let compose_file = compose_file.as_ref();
ffi::gtk_im_context_simple_add_compose_file(self.to_glib_none().0, compose_file.to_glib_none().0);
}
} | identifier_body |
im_context_simple.rs | // Copyright 2018, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use IMContextSimple;
use IsA;
use ffi;
use glib::translate::*;
use std::path::Path;
pub trait I... | <P: AsRef<Path>>(&self, compose_file: P) {
unsafe {
let compose_file = compose_file.as_ref();
ffi::gtk_im_context_simple_add_compose_file(self.to_glib_none().0, compose_file.to_glib_none().0);
}
}
/*fn add_table(&self, data: &[u16], max_seq_len: u32, n_seqs: u32) {
... | add_compose_file | identifier_name |
im_context_simple.rs | // Copyright 2018, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use IMContextSimple;
use IsA;
use ffi;
use glib::translate::*;
use std::path::Path;
| impl<O: IsA<IMContextSimple>> IMContextSimpleExtManual for O {
fn add_compose_file<P: AsRef<Path>>(&self, compose_file: P) {
unsafe {
let compose_file = compose_file.as_ref();
ffi::gtk_im_context_simple_add_compose_file(self.to_glib_none().0, compose_file.to_glib_none().0);
}... | pub trait IMContextSimpleExtManual {
fn add_compose_file<P: AsRef<Path>>(&self, compose_file: P);
//fn add_table(&self, data: &[u16], max_seq_len: u32, n_seqs: u32);
}
| random_line_split |
self_named_constructors.rs | #![warn(clippy::self_named_constructors)]
struct | ;
struct ShouldNotSpawn;
impl ShouldSpawn {
pub fn should_spawn() -> ShouldSpawn {
ShouldSpawn
}
fn should_not_spawn() -> ShouldNotSpawn {
ShouldNotSpawn
}
}
impl ShouldNotSpawn {
pub fn new() -> ShouldNotSpawn {
ShouldNotSpawn
}
}
struct ShouldNotSpawnWithTrait;
tra... | ShouldSpawn | identifier_name |
self_named_constructors.rs | #![warn(clippy::self_named_constructors)]
struct ShouldSpawn;
struct ShouldNotSpawn;
impl ShouldSpawn {
pub fn should_spawn() -> ShouldSpawn {
ShouldSpawn
}
| }
impl ShouldNotSpawn {
pub fn new() -> ShouldNotSpawn {
ShouldNotSpawn
}
}
struct ShouldNotSpawnWithTrait;
trait ShouldNotSpawnTrait {
type Item;
}
impl ShouldNotSpawnTrait for ShouldNotSpawnWithTrait {
type Item = Self;
}
impl ShouldNotSpawnWithTrait {
pub fn should_not_spawn_with_tra... | fn should_not_spawn() -> ShouldNotSpawn {
ShouldNotSpawn
} | random_line_split |
blob.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::InheritTypes::FileDerived;
use dom::bindings::global::GlobalRef;
use dom::bindings::js... | {
BlobTypeId,
FileTypeId
}
#[dom_struct]
pub struct Blob {
reflector_: Reflector,
type_: BlobType
}
impl Blob {
pub fn new_inherited() -> Blob {
Blob {
reflector_: Reflector::new(),
type_: BlobTypeId
}
}
pub fn new(global: &GlobalRef) -> Temporary<... | BlobType | identifier_name |
blob.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::InheritTypes::FileDerived;
use dom::bindings::global::GlobalRef;
use dom::bindings::js... |
#[dom_struct]
pub struct Blob {
reflector_: Reflector,
type_: BlobType
}
impl Blob {
pub fn new_inherited() -> Blob {
Blob {
reflector_: Reflector::new(),
type_: BlobTypeId
}
}
pub fn new(global: &GlobalRef) -> Temporary<Blob> {
reflect_dom_object(b... | random_line_split | |
htmlsourceelement.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::Bindings::HTMLSourceElementBinding;
use dom::bindings::js::Root;
use dom::document::Do... |
}
| {
let element = HTMLSourceElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLSourceElementBinding::Wrap)
} | identifier_body |
htmlsourceelement.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::Bindings::HTMLSourceElementBinding;
use dom::bindings::js::Root;
use dom::document::Do... | }
#[allow(unrooted_must_root)]
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLSourceElement> {
let element = HTMLSourceElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLSo... | document: &Document) -> HTMLSourceElement {
HTMLSourceElement {
htmlelement:
HTMLElement::new_inherited(localName, prefix, document)
} | random_line_split |
htmlsourceelement.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::Bindings::HTMLSourceElementBinding;
use dom::bindings::js::Root;
use dom::document::Do... | {
htmlelement: HTMLElement
}
impl HTMLSourceElement {
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLSourceElement {
HTMLSourceElement {
htmlelement:
HTMLElement::new_inherited(localName, pr... | HTMLSourceElement | identifier_name |
table.rs | use std::fs::{File, OpenOptions, metadata};
use std::path::{Path, PathBuf};
use bincode::SizeLimit;
use bincode::rustc_serialize::{encode, encode_into, decode_from};
use super::Error;
use super::database::Database;
use super::column::Column;
use super::rows::Rows;
use super::super::identifier::Identifier;
pub struc... | impl<'a> Table<'a> {
/// Create table in database
pub fn create<'b>(name: &str,
engine_id: u8,
columns: Vec<Column>,
db: &'b Database)
-> Result<Table<'b>, Error> {
info!("creating table: {}", name);
// TODO... | /// Table representation | random_line_split |
table.rs | use std::fs::{File, OpenOptions, metadata};
use std::path::{Path, PathBuf};
use bincode::SizeLimit;
use bincode::rustc_serialize::{encode, encode_into, decode_from};
use super::Error;
use super::database::Database;
use super::column::Column;
use super::rows::Rows;
use super::super::identifier::Identifier;
pub struc... |
pub fn get_table_header_offset(&self) -> u32 {
let bytes: Vec<u8> = encode(&self.meta_data, SizeLimit::Infinite).unwrap();
bytes.len() as u32
}
pub fn get_cols_offset(&self) -> u32 {
let mut size = 0;
for v in &self.meta_data.columns {
size += v.size();
... | {
let mut column_sizes = Vec::<u32>::new();
for v in &self.meta_data.columns {
column_sizes.push(v.size());
}
column_sizes
} | identifier_body |
table.rs | use std::fs::{File, OpenOptions, metadata};
use std::path::{Path, PathBuf};
use bincode::SizeLimit;
use bincode::rustc_serialize::{encode, encode_into, decode_from};
use super::Error;
use super::database::Database;
use super::column::Column;
use super::rows::Rows;
use super::super::identifier::Identifier;
pub struc... | (&self) -> u8 {
self.meta_data.engine_id
}
}
#[cfg(test)]
mod test {
use super::Table;
use super::super::database::*;
use std::fs::metadata;
use super::super::column::Column;
use super::super::types::Types;
#[test]
fn create_table() {
let path = "/tmp/test1/";
l... | get_engine_id | identifier_name |
table.rs | use std::fs::{File, OpenOptions, metadata};
use std::path::{Path, PathBuf};
use bincode::SizeLimit;
use bincode::rustc_serialize::{encode, encode_into, decode_from};
use super::Error;
use super::database::Database;
use super::column::Column;
use super::rows::Rows;
use super::super::identifier::Identifier;
pub struc... | else {
error!("could not load table: {} at {}",
&name,
&path.to_str().unwrap());
Err(Error::LoadTable)
}
}
// TODO: write table delete static function
/// Returns a vector of the sizes of the columns
pub fn get_cols_sizes(&self) ->... | {
let mut file = try!(OpenOptions::new()
.read(true)
.open(&path));
let metadata: TableMetadata = try!(decode_from(&mut file, SizeLimit::Infinite));
info!("loaded table: {}", &name);
Ok(Table {
... | conditional_block |
notificator.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... |
}
}
| {
let mut n = RustNotification::new();
n.appname("imag");
n.summary(&self.0.summary);
n.urgency(self.0.urgency.clone().into());
n.body(&format!("{}: {:?}", &self.0.message, item));
let _ = n.finalize().show(); // Ignoring error here
Ok(... | identifier_body |
notificator.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | fn into(self) -> NotificationUrgency {
match self {
Urgency::Low => NotificationUrgency::Low,
Urgency::Normal => NotificationUrgency::Normal,
Urgency::High => NotificationUrgency::Critical,
}
}
}
#[derive(Debug, Defau... |
impl Into<NotificationUrgency> for Urgency {
| random_line_split |
notificator.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | (Notification);
impl From<Notification> for DebugNotification {
fn from(n: Notification) -> DebugNotification {
DebugNotification(n)
}
}
impl<T: Debug> Notificator<T> for DebugNotification {
/// A default implementation for all Types that implement Display
fn n... | DebugNotification | identifier_name |
query15.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
use ::Collections;
use ::types::create_date;
// -- $ID$
// -- TPC-... | // do a hierarchical min, to improve update perf.
.map(|key| ((key % 1000) as u16, key))
.group_u(|_k, s, t| {
let max = s.iter().map(|x| x.1).max().unwrap();
t.extend(s.iter().filter(|x| x.1 == max));
})
.map(|(_,key)| ((key % 100... | .as_collection();
// suppliers with maximum revenue
let top_suppliers =
revenue | random_line_split |
query15.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
use ::Collections;
use ::types::create_date;
// -- $ID$
// -- TPC-... | // do a hierarchical min, to improve update perf.
.map(|key| ((key % 1000) as u16, key))
.group_u(|_k, s, t| {
let max = s.iter().map(|x| x.1).max().unwrap();
t.extend(s.iter().filter(|x| x.1 == max));
})
.map(|(_,key)| ((key % 100... | {
println!("TODO: query 15 takes a global aggregate with key 0u8, instead of ().");
// revenue by supplier
let revenue =
collections
.lineitems()
.inner
.flat_map(|(item, time, diff)|
if create_date(1996, 1, 1) <= item.ship_date && item.ship_da... | identifier_body |
query15.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
use ::Collections;
use ::types::create_date;
// -- $ID$
// -- TPC-... |
else { None }
)
.as_collection();
// suppliers with maximum revenue
let top_suppliers =
revenue
// do a hierarchical min, to improve update perf.
.map(|key| ((key % 1000) as u16, key))
.group_u(|_k, s, t| {
let ma... | {
Some((item.supp_key, time, (item.extended_price * (100 - item.discount) / 100) as isize * diff))
} | conditional_block |
query15.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
use ::Collections;
use ::types::create_date;
// -- $ID$
// -- TPC-... | <G: Scope>(collections: &mut Collections<G>) -> ProbeHandle<G::Timestamp>
where G::Timestamp: Lattice+Ord {
println!("TODO: query 15 takes a global aggregate with key 0u8, instead of ().");
// revenue by supplier
let revenue =
collections
.lineitems()
.inner
.fla... | query | identifier_name |
rs_stepdown.rs | /* Copyright 2013 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writi... |
};
}
let x = val.unwrap();
if x as f32!= t as f32 { // possible round-off err
fail!("expected %?, found %?", t, x);
}
}
Err(e) => println(fmt!("%?", e)),
}
debug!("requesting status until good");
let mut done... | {
match ptr {
&Double(ref value) => Some(*value),
_ => None,
}
} | conditional_block |
rs_stepdown.rs | /* Copyright 2013 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writi... | i += 1;
debug!("switching primary");
let time = MONGO_TIMEOUT_SECS + 10;
// freeze everything...
match rs.get_config() {
Ok(conf) => {
let mut hosts = ~[];
for conf.members.iter().advance |&member| {
hosts.push(member.host);
}
... | {
let mut i = 0;
let client = @Client::new();
let seed = [(~"127.0.0.1", 27018),
(~"127.0.0.1", 27019),
(~"127.0.0.1", 27020)];
debug!("connecting");
match client.connect_to_rs(seed) {
Ok(_) => (),
Err(e) => fail!("%s", e.to_str()),
}
let rs ... | identifier_body |
rs_stepdown.rs | /* Copyright 2013 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writi... | fail!("expected %?, found %?", t, x);
}
}
Err(e) => println(fmt!("%?", e)),
}
debug!("requesting status until good");
let mut done = false;
while!done {
debug!(fmt!("___status (%?)___", i));
debug!(fmt!("%s\n________________",
matc... | let x = val.unwrap();
if x as f32 != t as f32 { // possible round-off err | random_line_split |
rs_stepdown.rs | /* Copyright 2013 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writi... | () {
let mut i = 0;
let client = @Client::new();
let seed = [(~"127.0.0.1", 27018),
(~"127.0.0.1", 27019),
(~"127.0.0.1", 27020)];
debug!("connecting");
match client.connect_to_rs(seed) {
Ok(_) => (),
Err(e) => fail!("%s", e.to_str()),
}
let ... | test_rs_stepdown | identifier_name |
stdio-is-blocking.rs | // run-pass
// ignore-emscripten no processes
// ignore-sgx no processes
use std::env;
use std::io::prelude::*;
use std::process::Command;
use std::thread;
const THREADS: usize = 20;
const WRITES: usize = 100;
const WRITE_SIZE: usize = 1024 * 32;
fn main() {
let args = env::args().collect::<Vec<_>>();
if arg... | assert_eq!(output.stderr.len(), 0);
assert_eq!(output.stdout.len(), WRITES * THREADS * WRITE_SIZE);
for byte in output.stdout.iter() {
assert_eq!(*byte, b'a');
}
}
fn child() {
let threads = (0..THREADS).map(|_| {
thread::spawn(|| {
let buf = [b'a'; WRITE_SIZE];
... | let mut cmd = Command::new(me);
cmd.arg("run-the-test");
let output = cmd.output().unwrap();
assert!(output.status.success()); | random_line_split |
stdio-is-blocking.rs | // run-pass
// ignore-emscripten no processes
// ignore-sgx no processes
use std::env;
use std::io::prelude::*;
use std::process::Command;
use std::thread;
const THREADS: usize = 20;
const WRITES: usize = 100;
const WRITE_SIZE: usize = 1024 * 32;
fn main() {
let args = env::args().collect::<Vec<_>>();
if arg... |
fn child() {
let threads = (0..THREADS).map(|_| {
thread::spawn(|| {
let buf = [b'a'; WRITE_SIZE];
for _ in 0..WRITES {
write_all(&buf);
}
})
}).collect::<Vec<_>>();
for thread in threads {
thread.join().unwrap();
}
}
#[cfg(... | {
let me = env::current_exe().unwrap();
let mut cmd = Command::new(me);
cmd.arg("run-the-test");
let output = cmd.output().unwrap();
assert!(output.status.success());
assert_eq!(output.stderr.len(), 0);
assert_eq!(output.stdout.len(), WRITES * THREADS * WRITE_SIZE);
for byte in output.st... | identifier_body |
stdio-is-blocking.rs | // run-pass
// ignore-emscripten no processes
// ignore-sgx no processes
use std::env;
use std::io::prelude::*;
use std::process::Command;
use std::thread;
const THREADS: usize = 20;
const WRITES: usize = 100;
const WRITE_SIZE: usize = 1024 * 32;
fn main() {
let args = env::args().collect::<Vec<_>>();
if arg... | () {
let threads = (0..THREADS).map(|_| {
thread::spawn(|| {
let buf = [b'a'; WRITE_SIZE];
for _ in 0..WRITES {
write_all(&buf);
}
})
}).collect::<Vec<_>>();
for thread in threads {
thread.join().unwrap();
}
}
#[cfg(unix)]
fn ... | child | identifier_name |
stdio-is-blocking.rs | // run-pass
// ignore-emscripten no processes
// ignore-sgx no processes
use std::env;
use std::io::prelude::*;
use std::process::Command;
use std::thread;
const THREADS: usize = 20;
const WRITES: usize = 100;
const WRITE_SIZE: usize = 1024 * 32;
fn main() {
let args = env::args().collect::<Vec<_>>();
if arg... | else {
child();
}
}
fn parent() {
let me = env::current_exe().unwrap();
let mut cmd = Command::new(me);
cmd.arg("run-the-test");
let output = cmd.output().unwrap();
assert!(output.status.success());
assert_eq!(output.stderr.len(), 0);
assert_eq!(output.stdout.len(), WRITES * TH... | {
parent();
} | conditional_block |
example.rs | use std::convert::AsRef;
#[derive(PartialEq, Eq, Debug)]
pub struct RibonucleicAcid {
nucleotides: String
}
impl RibonucleicAcid {
pub fn new(nucleotides: &str) -> RibonucleicAcid |
}
impl AsRef<str> for RibonucleicAcid {
fn as_ref(&self) -> &str {
self.nucleotides.as_ref()
}
}
#[derive(PartialEq, Eq, Debug)]
pub struct DeoxyribonucleicAcid {
nucleotides: String
}
fn transcribe_dna_rna(c: char) -> char {
match c {
'C' => 'G',
'G' => 'C',
'A' => '... | {
RibonucleicAcid { nucleotides: nucleotides.to_string() }
} | identifier_body |
example.rs | use std::convert::AsRef;
#[derive(PartialEq, Eq, Debug)]
pub struct RibonucleicAcid {
nucleotides: String
}
impl RibonucleicAcid {
pub fn new(nucleotides: &str) -> RibonucleicAcid {
RibonucleicAcid { nucleotides: nucleotides.to_string() }
}
}
impl AsRef<str> for RibonucleicAcid {
fn as_ref(&s... | pub fn to_rna(&self) -> RibonucleicAcid {
let rna_nucleotides = self.nucleotides.chars().map(transcribe_dna_rna).collect();
RibonucleicAcid { nucleotides: rna_nucleotides }
}
} | random_line_split | |
example.rs | use std::convert::AsRef;
#[derive(PartialEq, Eq, Debug)]
pub struct RibonucleicAcid {
nucleotides: String
}
impl RibonucleicAcid {
pub fn | (nucleotides: &str) -> RibonucleicAcid {
RibonucleicAcid { nucleotides: nucleotides.to_string() }
}
}
impl AsRef<str> for RibonucleicAcid {
fn as_ref(&self) -> &str {
self.nucleotides.as_ref()
}
}
#[derive(PartialEq, Eq, Debug)]
pub struct DeoxyribonucleicAcid {
nucleotides: String
}
... | new | identifier_name |
modify.rs | use clap::ArgMatches;
use common::*;
use colored::*;
use io::*;
use libhupa::*;
/// Modify subcommand
pub fn | (mut hupas: Vec<Hupa>, config: &Config, sub_m: &ArgMatches) {
let hupas_to_modify = if let Some(hupas_names) = sub_m.values_of("hupa") {
let hupas_names: Vec<String> = hupas_names.map(|s| s.to_string()).collect();
resolve_names(&hupas_names, &hupas)
} else {
select_hupas(&hupas, "Select ... | modify_subcommand | identifier_name |
modify.rs | use clap::ArgMatches;
use common::*;
use colored::*;
use io::*;
use libhupa::*;
/// Modify subcommand
pub fn modify_subcommand(mut hupas: Vec<Hupa>, config: &Config, sub_m: &ArgMatches) {
let hupas_to_modify = if let Some(hupas_names) = sub_m.values_of("hupa") {
let hupas_names: Vec<String> = hupas_names.m... | hupa.set_category(category.split('/').map(|s| s.to_string()).collect())
.expect("Cannot reset category");
}
4 => {
println!(
"Current backup parent: {}",
hupa.get_backup_parent(... | .iter()
.map(|s| format!("{}/", s))
.collect::<String>()
);
let category = read_line("New category (ex: os/linux): ", true); | random_line_split |
modify.rs | use clap::ArgMatches;
use common::*;
use colored::*;
use io::*;
use libhupa::*;
/// Modify subcommand
pub fn modify_subcommand(mut hupas: Vec<Hupa>, config: &Config, sub_m: &ArgMatches) {
let hupas_to_modify = if let Some(hupas_names) = sub_m.values_of("hupa") {
let hupas_names: Vec<String> = hupas_names.m... |
4 => {
println!(
"Current backup parent: {}",
hupa.get_backup_parent().display()
);
hupa.set_backup_parent(read_line("New backup parent: ", true))
.expect("Cannot reset bac... | {
println!(
"Current category: {}",
hupa.get_category()
.iter()
.map(|s| format!("{}/", s))
.collect::<String>()
);
let category... | conditional_block |
modify.rs | use clap::ArgMatches;
use common::*;
use colored::*;
use io::*;
use libhupa::*;
/// Modify subcommand
pub fn modify_subcommand(mut hupas: Vec<Hupa>, config: &Config, sub_m: &ArgMatches) | let idxs = read_line_usize("Select action [1-8]: ", false, 8);
for i in idxs {
match i {
1 => {
println!("Current name: {}", hupa.get_name());
hupa.set_name(read_line("New name: ", true)).expect(
"Cannot rename h... | {
let hupas_to_modify = if let Some(hupas_names) = sub_m.values_of("hupa") {
let hupas_names: Vec<String> = hupas_names.map(|s| s.to_string()).collect();
resolve_names(&hupas_names, &hupas)
} else {
select_hupas(&hupas, "Select hupas to modify")
};
for hupa in &mut hupas {
... | identifier_body |
lib.rs | #![feature(box_syntax)]
#[macro_use] extern crate serde_derive;
extern crate serde_json;
extern crate hyper;
pub mod dictionaries;
pub mod thesaureses;
pub use dictionaries::{Definition, Dictionary};
pub use thesaureses::Thesaurus;
mod error {
use std::error;
use std::error::Error as ErrorT;
use std::fmt;
... | (val: ::std::io::Error) -> Self {
Error::Error(Box::new(val))
}
}
}
pub use error::Error;
pub type Result<T> = std::result::Result<T, Error>;
| from | identifier_name |
lib.rs | #![feature(box_syntax)]
#[macro_use] extern crate serde_derive;
extern crate serde_json;
extern crate hyper;
pub mod dictionaries;
pub mod thesaureses;
pub use dictionaries::{Definition, Dictionary};
pub use thesaureses::Thesaurus;
mod error {
use std::error;
use std::error::Error as ErrorT;
use std::fmt;
... | Hyper(::hyper::Error),
Serde(::serde_json::Error),
Error(Box<error::Error>)
}
impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::Hyper(ref hyper) => hyper.description(),
Error::Serde(ref serde) => serde.d... | pub enum Error { | random_line_split |
lib.rs | #![feature(box_syntax)]
#[macro_use] extern crate serde_derive;
extern crate serde_json;
extern crate hyper;
pub mod dictionaries;
pub mod thesaureses;
pub use dictionaries::{Definition, Dictionary};
pub use thesaureses::Thesaurus;
mod error {
use std::error;
use std::error::Error as ErrorT;
use std::fmt;
... |
}
}
pub use error::Error;
pub type Result<T> = std::result::Result<T, Error>;
| {
Error::Error(Box::new(val))
} | identifier_body |
parametric_polymorphism.rs | // http://rosettacode.org/wiki/Parametric_polymorphism
struct TreeNode<T> {
value: T,
left: Option<Box<TreeNode<T>>>,
right: Option<Box<TreeNode<T>>>,
}
impl<T> TreeNode<T> {
fn my_map<U, F>(&self, f: &F) -> TreeNode<U>
where F: Fn(&T) -> U
|
}
fn main() {
let root = TreeNode {
value: 3,
left: Some(Box::new(TreeNode {
value: 55,
left: None,
right: None,
})),
right: Some(Box::new(TreeNode {
value: 234,
left: Some(Box::new(TreeNode {
value: 0,
... | {
TreeNode {
value: f(&self.value),
left: match self.left {
None => None,
Some(ref n) => Some(Box::new(n.my_map(f))),
},
right: match self.right {
None => None,
Some(ref n) => Some(Box::new(n.my_map(f... | identifier_body |
parametric_polymorphism.rs | // http://rosettacode.org/wiki/Parametric_polymorphism
struct TreeNode<T> {
value: T,
left: Option<Box<TreeNode<T>>>,
right: Option<Box<TreeNode<T>>>,
}
impl<T> TreeNode<T> {
fn my_map<U, F>(&self, f: &F) -> TreeNode<U>
where F: Fn(&T) -> U
{
TreeNode {
value: f(&self.v... | left: None,
right: None,
})),
right: Some(Box::new(TreeNode {
value: 234,
left: Some(Box::new(TreeNode {
value: 0,
left: None,
right: None,
})),
right: None,
})),
};
ro... | left: Some(Box::new(TreeNode {
value: 55, | random_line_split |
parametric_polymorphism.rs | // http://rosettacode.org/wiki/Parametric_polymorphism
struct TreeNode<T> {
value: T,
left: Option<Box<TreeNode<T>>>,
right: Option<Box<TreeNode<T>>>,
}
impl<T> TreeNode<T> {
fn my_map<U, F>(&self, f: &F) -> TreeNode<U>
where F: Fn(&T) -> U
{
TreeNode {
value: f(&self.v... | () {
let root = TreeNode {
value: 3,
left: Some(Box::new(TreeNode {
value: 55,
left: None,
right: None,
})),
right: Some(Box::new(TreeNode {
value: 234,
left: Some(Box::new(TreeNode {
value: 0,
... | main | identifier_name |
wrapping_from.rs | use malachite_base::num::basic::integers::PrimitiveInt;
use malachite_base::num::basic::signeds::PrimitiveSigned;
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned;
use malachite_base::num::conversion::traits::{OverflowingFrom, WrappingFrom};
use malachite_base_test_util::generators::{signed_gen, unsigned_ge... |
test_double(0u8, 0u16);
test_double(1000u16, 1000i32);
test_double(-5i16, -5i8);
test_double(255u8, 255u64);
test_double(-1i8, u32::MAX);
test_double(u32::MAX, u16::MAX);
test_double(i32::MIN, 0x80000000u32);
test_double(i32::MIN, 0u16);
test_double(i32::MIN, 0i16);
test_double... | {
assert_eq!(U::wrapping_from(n_in), n_out);
} | identifier_body |
wrapping_from.rs | use malachite_base::num::basic::integers::PrimitiveInt;
use malachite_base::num::basic::signeds::PrimitiveSigned;
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned;
use malachite_base::num::conversion::traits::{OverflowingFrom, WrappingFrom};
use malachite_base_test_util::generators::{signed_gen, unsigned_ge... | <
T: OverflowingFrom<U> + WrappingFrom<U> + PrimitiveInt,
U: PrimitiveSigned,
>() {
signed_gen::<U>().test_properties(|i| {
let result = T::wrapping_from(i);
assert_eq!(result, T::overflowing_from(i).0)
});
}
#[test]
fn wrapping_from_properties() {
apply_fn_to_primitive_ints_and_uns... | wrapping_from_helper_primitive_int_signed | identifier_name |
wrapping_from.rs | use malachite_base::num::basic::integers::PrimitiveInt;
use malachite_base::num::basic::signeds::PrimitiveSigned;
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned;
use malachite_base::num::conversion::traits::{OverflowingFrom, WrappingFrom};
use malachite_base_test_util::generators::{signed_gen, unsigned_ge... |
fn wrapping_from_helper_primitive_int_unsigned<
T: OverflowingFrom<U> + WrappingFrom<U> + PrimitiveInt,
U: PrimitiveUnsigned,
>() {
unsigned_gen::<U>().test_properties(|u| {
let result = T::wrapping_from(u);
assert_eq!(result, T::overflowing_from(u).0)
});
}
fn wrapping_from_helper_pri... | random_line_split | |
multiple-ref-self.rs | // check-pass
#![feature(arbitrary_self_types)]
#![allow(non_snake_case)]
use std::marker::PhantomData;
use std::ops::Deref;
use std::pin::Pin;
struct Struct { }
struct Wrap<T, P>(T, PhantomData<P>);
impl<T, P> Deref for Wrap<T, P> {
type Target = T;
fn deref(&self) -> &T { &self.0 }
}
impl Struct {
/... | () { }
| main | identifier_name |
multiple-ref-self.rs | // check-pass
#![feature(arbitrary_self_types)]
#![allow(non_snake_case)]
use std::marker::PhantomData;
use std::ops::Deref;
use std::pin::Pin;
struct Struct { }
struct Wrap<T, P>(T, PhantomData<P>);
impl<T, P> Deref for Wrap<T, P> {
type Target = T;
fn deref(&self) -> &T { &self.0 }
}
impl Struct {
/... | { } | identifier_body | |
multiple-ref-self.rs | // check-pass
#![feature(arbitrary_self_types)] |
use std::marker::PhantomData;
use std::ops::Deref;
use std::pin::Pin;
struct Struct { }
struct Wrap<T, P>(T, PhantomData<P>);
impl<T, P> Deref for Wrap<T, P> {
type Target = T;
fn deref(&self) -> &T { &self.0 }
}
impl Struct {
// Test using multiple `&Self`:
fn wrap_ref_Self_ref_Self(self: Wrap<&S... | #![allow(non_snake_case)] | random_line_split |
coherence-overlap-messages.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
| main | identifier_name |
coherence-overlap-messages.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
impl<T> Bar for (T, u8) {}
impl<T> Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`:
trait Baz<T> { fn baz() {} }
impl<T> Baz<u8> for T {}
impl<T> Baz<T> for u8 {} //~ ERROR conflicting implementations of trait `Baz<u8>` for type `u8`:
trait Quux<U, V> { fn quux() {} }
... | {} | identifier_body |
coherence-overlap-messages.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | trait Bar { fn bar() {} }
impl<T> Bar for (T, u8) {}
impl<T> Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`:
trait Baz<T> { fn baz() {} }
impl<T> Baz<u8> for T {}
impl<T> Baz<T> for u8 {} //~ ERROR conflicting implementations of trait `Baz<u8>` for type `u8`:
trait Quux<... | impl<U> Foo for U {} //~ ERROR conflicting implementations of trait `Foo`:
| random_line_split |
lev_distance.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (me: &str, t: &str) -> uint {
if me.is_empty() { return t.chars().count(); }
if t.is_empty() { return me.chars().count(); }
let mut dcol: Vec<_> = range(0, t.len() + 1).collect();
let mut t_last = 0;
for (i, sc) in me.chars().enumerate() {
let mut current = i;
dcol[0] = current + ... | lev_distance | identifier_name |
lev_distance.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
if t.is_empty() { return me.chars().count(); }
let mut dcol: Vec<_> = range(0, t.len() + 1).collect();
let mut t_last = 0;
for (i, sc) in me.chars().enumerate() {
let mut current = i;
dcol[0] = current + 1;
for (j, tc) in t.chars().enumerate() {
let next = dcol[... | { return t.chars().count(); } | conditional_block |
lev_distance.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | }
dcol[t_last + 1]
}
#[test]
fn test_lev_distance() {
use std::char::{ from_u32, MAX };
// Test bytelength agnosticity
for c in range(0u32, MAX as u32)
.filter_map(|i| from_u32(i))
.map(|i| i.to_string()) {
assert_eq!(lev_distance(&c[], &c[]), 0);
}
let a =... | random_line_split | |
lev_distance.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | dcol[j + 1] = cmp::min(dcol[j + 1], dcol[j]) + 1;
}
current = next;
t_last = j;
}
}
dcol[t_last + 1]
}
#[test]
fn test_lev_distance() {
use std::char::{ from_u32, MAX };
// Test bytelength agnosticity
for c in range(0u32, MAX as u32)
... | {
if me.is_empty() { return t.chars().count(); }
if t.is_empty() { return me.chars().count(); }
let mut dcol: Vec<_> = range(0, t.len() + 1).collect();
let mut t_last = 0;
for (i, sc) in me.chars().enumerate() {
let mut current = i;
dcol[0] = current + 1;
for (j, tc) in t... | identifier_body |
many-digits.rs | extern crate rand;
use rand::distributions::{Range, Sample};
use rand::{IsaacRng, Rng, SeedableRng};
use std::char;
use test_float_parse::{validate, SEED};
fn | () {
let mut rnd = IsaacRng::from_seed(&SEED);
let mut range = Range::new(0, 10);
for _ in 0..5_000_000u64 {
let num_digits = rnd.gen_range(100, 400);
let digits = gen_digits(num_digits, &mut range, &mut rnd);
validate(&digits);
}
}
fn gen_digits<R: Rng>(n: u32, range: &mut Rang... | main | identifier_name |
many-digits.rs | extern crate rand;
use rand::distributions::{Range, Sample};
use rand::{IsaacRng, Rng, SeedableRng};
use std::char;
use test_float_parse::{validate, SEED};
fn main() {
let mut rnd = IsaacRng::from_seed(&SEED);
let mut range = Range::new(0, 10);
for _ in 0..5_000_000u64 {
let num_digits = rnd.gen_r... | {
let mut s = String::new();
for _ in 0..n {
let digit = char::from_digit(range.sample(rnd), 10).unwrap();
s.push(digit);
}
s
} | identifier_body | |
many-digits.rs | extern crate rand;
use rand::distributions::{Range, Sample};
use rand::{IsaacRng, Rng, SeedableRng};
use std::char;
use test_float_parse::{validate, SEED};
fn main() {
let mut rnd = IsaacRng::from_seed(&SEED);
let mut range = Range::new(0, 10);
for _ in 0..5_000_000u64 {
let num_digits = rnd.gen_r... | } | let digit = char::from_digit(range.sample(rnd), 10).unwrap();
s.push(digit);
}
s | random_line_split |
day14.rs | #[cfg(target_family = "unix")]
extern crate cursive;
#[cfg(target_family = "unix")]
use cursive::Cursive;
#[cfg(target_family = "unix")]
use cursive::traits::*;
#[cfg(target_family = "unix")]
use cursive::views::{Dialog, DummyView, LinearLayout, SelectView, TextView};
#[cfg(target_family = "unix")]
use std::fs::{self... | text_view.set_content(content);
}
#[cfg(target_family = "unix")]
fn main() {
println!("24 Days of Rust vol. 2 - cursive");
let mut app = Cursive::new();
let mut panes = LinearLayout::horizontal();
let picker = file_picker(".");
panes.add_child(picker.fixed_size((30, 25)));
panes.add_child(D... | random_line_split | |
day14.rs | #[cfg(target_family = "unix")]
extern crate cursive;
#[cfg(target_family = "unix")]
use cursive::Cursive;
#[cfg(target_family = "unix")]
use cursive::traits::*;
#[cfg(target_family = "unix")]
use cursive::views::{Dialog, DummyView, LinearLayout, SelectView, TextView};
#[cfg(target_family = "unix")]
use std::fs::{self... |
#[cfg(target_family = "unix")]
fn update_status(app: &mut Cursive, entry: &DirEntry) {
let mut status_bar = app.find_id::<TextView>("status").unwrap();
let file_name = entry.file_name().into_string().unwrap();
let file_size = entry.metadata().unwrap().len();
let content = format!("{}: {} bytes", file_... | {
let mut view = SelectView::new();
for entry in fs::read_dir(directory).expect("can't read directory") {
if let Ok(e) = entry {
let file_name = e.file_name().into_string().unwrap();
view.add_item(file_name, e);
}
}
view.on_select(update_status).on_submit(load_con... | identifier_body |
day14.rs | #[cfg(target_family = "unix")]
extern crate cursive;
#[cfg(target_family = "unix")]
use cursive::Cursive;
#[cfg(target_family = "unix")]
use cursive::traits::*;
#[cfg(target_family = "unix")]
use cursive::views::{Dialog, DummyView, LinearLayout, SelectView, TextView};
#[cfg(target_family = "unix")]
use std::fs::{self... | else {
let mut buf = String::new();
let _ = File::open(entry.file_name())
.and_then(|mut f| f.read_to_string(&mut buf))
.map_err(|e| buf = format!("Error: {}", e));
buf
};
text_view.set_content(content);
}
#[cfg(target_family = "unix")]
fn main() {
println!("2... | {
"<DIR>".to_string()
} | conditional_block |
day14.rs | #[cfg(target_family = "unix")]
extern crate cursive;
#[cfg(target_family = "unix")]
use cursive::Cursive;
#[cfg(target_family = "unix")]
use cursive::traits::*;
#[cfg(target_family = "unix")]
use cursive::views::{Dialog, DummyView, LinearLayout, SelectView, TextView};
#[cfg(target_family = "unix")]
use std::fs::{self... | <D>(directory: D) -> SelectView<DirEntry>
where
D: AsRef<Path>,
{
let mut view = SelectView::new();
for entry in fs::read_dir(directory).expect("can't read directory") {
if let Ok(e) = entry {
let file_name = e.file_name().into_string().unwrap();
view.add_item(file_name, e);
... | file_picker | identifier_name |
destructured-local.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
a: i64,
b: i32
}
enum Univariant {
Unit(i32)
}
struct TupleStruct (f64, int);
fn main() {
// simple tuple
let (a, b) : (int, bool) = (1, false);
// nested tuple
let (c, (d, e)) : (int, (u16, u16)) = (2, (3, 4));
// bind tuple-typed value to one name (destructure only first level... | Struct | identifier_name |
destructured-local.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | // gdb-command:print e
// gdb-check:$5 = 4
// gdb-command:print f
// gdb-check:$6 = 5
// gdb-command:print g
// gdb-check:$7 = {6, 7}
// gdb-command:print h
// gdb-check:$8 = 8
// gdb-command:print i
// gdb-check:$9 = {a = 9, b = 10}
// gdb-command:print j
// gdb-check:$10 = 11
// gdb-command:print k
// gdb-check:$1... | random_line_split | |
pat-lt-bracket-3.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T>(T, T);
impl<T> Foo<T> {
fn foo(&self) {
match *self {
Foo<T>(x, y) => {
//~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<`
println!("Goodbye, World!")
}
}
}
}
| Foo | identifier_name |
pat-lt-bracket-3.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
| {
match *self {
Foo<T>(x, y) => {
//~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<`
println!("Goodbye, World!")
}
}
} | identifier_body |
pat-lt-bracket-3.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | match *self {
Foo<T>(x, y) => {
//~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<`
println!("Goodbye, World!")
}
}
}
} |
impl<T> Foo<T> {
fn foo(&self) { | random_line_split |
pat-lt-bracket-3.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
}
}
| {
//~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<`
println!("Goodbye, World!")
} | conditional_block |
borrowck-multiple-captures.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 x = box 1is;
drop(x);
Thread::spawn(move|| {
drop(x); //~ ERROR capture of moved value: `x`
drop(x); //~ ERROR use of moved value: `x`
});
}
fn main() {
different_vars_after_borrows();
different_vars_after_moves();
same_var_after_borrow();
same_var_after_move();... | same_var_after_move | identifier_name |
borrowck-multiple-captures.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 ... | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed
drop(x); //~ ERROR use of moved value: `x`
});
borrow(&*p);
}
fn same_var_after_move() {
let x = box 1is;
drop(x);
Thread::spawn(move|| {
drop(x); //~ ERROR capture of moved value: `x`
drop(x); //... | fn same_var_after_borrow() {
let x = box 1is;
let p = &x;
Thread::spawn(move|| { | random_line_split |
borrowck-multiple-captures.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 different_vars_after_moves() {
let x1 = box 1is;
drop(x1);
let x2 = box 2is;
drop(x2);
Thread::spawn(move|| {
drop(x1); //~ ERROR capture of moved value: `x1`
drop(x2); //~ ERROR capture of moved value: `x2`
});
}
fn same_var_after_borrow() {
let x = box 1is;
let p ... | {
let x1 = box 1is;
let p1 = &x1;
let x2 = box 2is;
let p2 = &x2;
Thread::spawn(move|| {
drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed
drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed
});
borrow(&*p1);
borrow(&*p2);
} | identifier_body |
zombie.rs | use game::*;
use behaviour::LeafResolution;
use direction::Direction;
pub fn zombie_step<K: KnowledgeRenderer>() -> BehaviourLeaf<K> {
BehaviourLeaf::new(move |input| {
let position = input.entity.position().unwrap();
let knowledge = input.entity.simple_npc_knowledge_borrow().unwrap();
let ... | })
} | random_line_split | |
zombie.rs | use game::*;
use behaviour::LeafResolution;
use direction::Direction;
pub fn | <K: KnowledgeRenderer>() -> BehaviourLeaf<K> {
BehaviourLeaf::new(move |input| {
let position = input.entity.position().unwrap();
let knowledge = input.entity.simple_npc_knowledge_borrow().unwrap();
let level_knowledge = knowledge.level(input.level_id);
let action = if let Some(targ... | zombie_step | identifier_name |
zombie.rs | use game::*;
use behaviour::LeafResolution;
use direction::Direction;
pub fn zombie_step<K: KnowledgeRenderer>() -> BehaviourLeaf<K> {
BehaviourLeaf::new(move |input| {
let position = input.entity.position().unwrap();
let knowledge = input.entity.simple_npc_knowledge_borrow().unwrap();
let ... | else {
ActionArgs::Null
};
LeafResolution::Yield(MetaAction::ActionArgs(action))
})
}
| {
if position == target {
ActionArgs::Null
} else {
let delta = target - position;
if delta.x.abs() > delta.y.abs() {
if delta.x > 0 {
ActionArgs::Walk(input.entity.id(), Direction::East)
... | conditional_block |
zombie.rs | use game::*;
use behaviour::LeafResolution;
use direction::Direction;
pub fn zombie_step<K: KnowledgeRenderer>() -> BehaviourLeaf<K> | } else {
ActionArgs::Walk(input.entity.id(), Direction::North)
}
}
}
} else {
ActionArgs::Null
};
LeafResolution::Yield(MetaAction::ActionArgs(action))
})
}
| {
BehaviourLeaf::new(move |input| {
let position = input.entity.position().unwrap();
let knowledge = input.entity.simple_npc_knowledge_borrow().unwrap();
let level_knowledge = knowledge.level(input.level_id);
let action = if let Some(target) = level_knowledge.any_target() {
... | identifier_body |
buffer.rs | /*
* This file is part of the uutils coreutils package.
*
* (c) Rolf Morel <rolfmorel@gmail.com>
* (c) kwantam <kwantam@gmail.com>
* substantially rewritten to use the stdlib BufReader trait
* rather than re-implementing it here.
*
* For the full copyright and license information, please view the LICENS... |
#[derive(Debug)]
pub struct ByteReader<R> where R: Read {
inner: BufReader<R>,
}
impl<R: Read> ByteReader<R> {
pub fn new(read: R) -> ByteReader<R> {
ByteReader {
inner: BufReader::with_capacity(4096, read),
}
}
}
impl<R: Read> Read for ByteReader<R> {
fn read(&mut self, b... | } | random_line_split |
buffer.rs | /*
* This file is part of the uutils coreutils package.
*
* (c) Rolf Morel <rolfmorel@gmail.com>
* (c) kwantam <kwantam@gmail.com>
* substantially rewritten to use the stdlib BufReader trait
* rather than re-implementing it here.
*
* For the full copyright and license information, please view the LICENS... | (&mut self) -> IoResult<&[u8]> {
self.inner.fill_buf()
}
fn consume(&mut self, amt: usize) {
self.inner.consume(amt)
}
}
impl<R: Read> ByteReader<R> {
pub fn consume_line(&mut self) -> usize {
let mut bytes_consumed = 0;
let mut consume_val;
loop {
... | fill_buf | identifier_name |
tuple_alignment.rs | enum Foo {
Bazlooooooooooong(i32, i32,
i32, i32,
i32, i32),
}
fn | () {
let long_tuple: (u8, u16, u32, u64, u128,
i8, i16, i32, i64, i128,
f32, f64,
char, bool) = (1u8, 2u16, 3u32, 4u64, 5u128,
-1i8, -2i16, -3i32, -4i64, -5i128,
0.1f32, 0.2f64,
'a', true);
... | main | identifier_name |
tuple_alignment.rs | enum Foo {
Bazlooooooooooong(i32, i32,
i32, i32,
i32, i32),
}
fn main() {
let long_tuple: (u8, u16, u32, u64, u128,
i8, i16, i32, i64, i128,
f32, f64,
char, bool) = (1u8, 2u16, 3u32, 4u64, 5u128, | 'a', true);
match 1 {
FooSome(1234, true,
5678, false,
91011, "foobar") => 10
}
} | -1i8, -2i16, -3i32, -4i64, -5i128,
0.1f32, 0.2f64, | random_line_split |
borrowck-move-error-with-note.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_synt... | random_line_split | |
borrowck-move-error-with-note.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 move_in_match() {
match (S {f: "foo".to_string(), g: "bar".to_string()}) {
S { //~ ERROR cannot move out of type `S`, which defines the `Drop` trait
f: _s, //~ NOTE attempting to move value to here
g: _t //~ NOTE and here
} => {}
}
}
// from issue-8064
... | { println!("{}", self.f); } | identifier_body |
borrowck-move-error-with-note.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 ... |
}
}
// from issue-8064
struct A {
a: Box<isize>,
}
fn free<T>(_: T) {}
fn blah2() {
let a = &A { a: box 1 };
match a.a { //~ ERROR cannot move out of
n => { //~ NOTE attempting to move value to here
free(n)
}
}
free(a)
}
fn main() {}
| {} | conditional_block |
borrowck-move-error-with-note.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) { println!("{}", self.f); }
}
fn move_in_match() {
match (S {f: "foo".to_string(), g: "bar".to_string()}) {
S { //~ ERROR cannot move out of type `S`, which defines the `Drop` trait
f: _s, //~ NOTE attempting to move value to here
g: _t //~ NOTE and here
... | drop | identifier_name |
mod.rs | //! A buffer is a memory location accessible to the video card.
//!
//! The purpose of buffers is to serve as a space where the GPU can read from or write data to.
//! It can contain a list of vertices, indices, uniform data, etc.
//!
//! # Buffers management in glium
//!
//! There are three levels of abstraction in gl... | fn read<F, E>(size: usize, f: F) -> Result<T, E> where F: FnOnce(&mut T) -> Result<(), E> {
assert!(size == mem::size_of::<T>());
let mut value = unsafe { mem::uninitialized() };
try!(f(&mut value));
Ok(value)
}
#[inline]
fn get_elements_size() -> usize {
mem::si... | type Owned = T;
#[inline] | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.