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 |
|---|---|---|---|---|
mod.rs | use std::fs;
use std::io;
pub mod cgroup_reader;
pub mod ns_reader;
pub mod process;
fn load_cgroups(procs: Vec<process::Process>) -> Vec<cgroup_reader::Reader> {
let cgroups = Vec::<cgroup_reader::Reader>::new();
for p in procs {
cgroups.push(cgroup_reader::new(p.pid));
}
cgroups
}
pub struc... | (group: ns_reader::NS_Group) -> Container {
let (namespaces, process) = group;
return Container{
processes: process,
namespaces: namespaces,
cgroups: load_cgroups(process),
update_intv: 1,
}
}
| new | identifier_name |
mod.rs | use std::fs;
use std::io;
pub mod cgroup_reader;
pub mod ns_reader;
pub mod process;
fn load_cgroups(procs: Vec<process::Process>) -> Vec<cgroup_reader::Reader> {
let cgroups = Vec::<cgroup_reader::Reader>::new();
for p in procs {
cgroups.push(cgroup_reader::new(p.pid));
}
cgroups
}
pub struc... | pub fn new(group: ns_reader::NS_Group) -> Container {
let (namespaces, process) = group;
return Container{
processes: process,
namespaces: namespaces,
cgroups: load_cgroups(process),
update_intv: 1,
}
} | }
}
}
| random_line_split |
regions-infer-invariance-due-to-decl.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 ... | {
} | identifier_body | |
regions-infer-invariance-due-to-decl.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | // <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.
use std::marker;
struct invariant<'a> {
marker: marker::PhantomData<*mut &'a()>
}
fn to_same_lifetime<'r>(b_isize: invariant<'r>) {
let bj: inva... | // 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 | random_line_split |
regions-infer-invariance-due-to-decl.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 ... | () {
}
| main | identifier_name |
menubutton.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... |
impl_drop!(MenuButton)
impl_TraitWidget!(MenuButton)
impl gtk::ContainerTrait for MenuButton {}
impl gtk::ButtonTrait for MenuButton {}
impl gtk::ToggleButtonTrait for MenuButton {}
impl_widget_events!(MenuButton)
| unsafe {
ffi::gtk_menu_button_set_align_widget(GTK_MENUBUTTON(self.pointer), align_widget.get_widget())
}
}
} | identifier_body |
menubutton.rs | // This file is part of rgtk. | // rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hope that it will be useful,
// but ... | // | random_line_split |
menubutton.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | -> Option<MenuButton> {
let tmp_pointer = unsafe { ffi::gtk_menu_button_new() };
check_pointer!(tmp_pointer, MenuButton)
}
pub fn set_popup<T: gtk::WidgetTrait>(&mut self, popup: &T) -> () {
unsafe {
ffi::gtk_menu_button_set_popup(GTK_MENUBUTTON(self.pointer), popup.get_wid... | w() | identifier_name |
error.rs | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// 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 r... | #[derive(Debug, Fail)]
pub enum Error {
#[fail(display = "Invalid bind specification '{}'", _0)]
InvalidBindSpec(String),
#[fail(display = "Invalid topology '{}'. Possible values: standalone, leader", _0)]
InvalidTopology(String),
#[fail(display = "Invalid binding \"{}\", must be of the form <NAME>:... | // See the License for the specific language governing permissions and
// limitations under the License.
use hcore;
| random_line_split |
error.rs | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// 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 r... | (err: hcore::Error) -> Error {
Error::HabitatCore(err)
}
}
| from | identifier_name |
fold.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
use clean::*;
use std::iter::Extendable;
use std::mem::{replace, swap};
pub trait DocFolder {
fn fold_item(&mut self, item: Item) -> Option<Item> {
self.fold_item_recur(item)
}
/// don't override!
fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
let Item { attrs, name, sour... | // except according to those terms. | random_line_split |
fold.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | ,
VariantItem(i) => {
let i2 = i.clone(); // this clone is small
match i.kind {
StructVariant(mut j) => {
let mut foo = Vec::new(); swap(&mut foo, &mut j.fields);
let num_fields = foo.len();
... | {
let mut foo = Vec::new(); swap(&mut foo, &mut i.methods);
i.methods.extend(foo.move_iter().filter_map(|x| self.fold_item(x)));
ImplItem(i)
} | conditional_block |
fold.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn fold_crate(&mut self, mut c: Crate) -> Crate {
c.module = match replace(&mut c.module, None) {
Some(module) => self.fold_item(module), None => None
};
return c;
}
}
| {
Module {
is_crate: m.is_crate,
items: m.items.move_iter().filter_map(|i| self.fold_item(i)).collect()
}
} | identifier_body |
fold.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | <T: DocFolder>(this: &mut T, trm: TraitMethod) -> Option<TraitMethod> {
match trm {
Required(it) => {
match this.fold_item(it) {
Some(x) => return Some(Required(x)),
None => return Non... | vtrm | identifier_name |
issue-17718-static-unsafe-interior.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::kinds::marker;
use std::cell::UnsafeCell;
struct MyUnsafe<T> {
value: UnsafeCell<T>
}
impl<T> MyUnsafe<T> {
fn forbidden(&self) {}
}
enum UnsafeEnum<T> {
VariantSafe,
VariantUnsafe(UnsafeCel... | // 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 | random_line_split |
issue-17718-static-unsafe-interior.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> {
VariantSafe,
VariantUnsafe(UnsafeCell<T>)
}
static STATIC1: UnsafeEnum<int> = VariantSafe;
static STATIC2: UnsafeCell<int> = UnsafeCell { value: 1 };
const CONST: UnsafeCell<int> = UnsafeCell { value: 1 };
static STATIC3: MyUnsafe<int> = MyUnsafe{value: CONST};
static STATIC4: &'static UnsafeCell<int> ... | UnsafeEnum | identifier_name |
main.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
use bytecode_source_map::utils::{remap_owned_loc_to_loc, source_map_from_file, OwnedLoc};
use move_bytecode_viewer::{
bytecode_viewer::BytecodeViewer, source_viewer::ModuleViewer,
tui::tui_interface::sta... | () {
let args = Args::from_args();
let source_map_extension = "mvsm";
let bytecode_bytes = fs::read(&args.module_binary_path).expect("Unable to read bytecode file");
let compiled_module =
CompiledModule::deserialize(&bytecode_bytes).expect("Module blob can't be deserialized");
let source_m... | main | identifier_name |
main.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
use bytecode_source_map::utils::{remap_owned_loc_to_loc, source_map_from_file, OwnedLoc};
use move_bytecode_viewer::{
bytecode_viewer::BytecodeViewer, source_viewer::ModuleViewer,
tui::tui_interface::sta... | start_tui_with_interface(interface).unwrap();
}
| {
let args = Args::from_args();
let source_map_extension = "mvsm";
let bytecode_bytes = fs::read(&args.module_binary_path).expect("Unable to read bytecode file");
let compiled_module =
CompiledModule::deserialize(&bytecode_bytes).expect("Module blob can't be deserialized");
let source_map ... | identifier_body |
main.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
use bytecode_source_map::utils::{remap_owned_loc_to_loc, source_map_from_file, OwnedLoc};
use move_bytecode_viewer::{
bytecode_viewer::BytecodeViewer, source_viewer::ModuleViewer,
tui::tui_interface::sta... | use structopt::StructOpt;
use vm::file_format::CompiledModule;
#[derive(Debug, StructOpt)]
#[structopt(
name = "Move Bytecode Explorer",
about = "Explore Move bytecode and how the source code compiles to it"
)]
struct Args {
/// The path to the module binary
#[structopt(long = "module-path", short = "b... | use std::{fs, path::Path}; | random_line_split |
manual_flatten.rs | use super::utils::make_iterator_snippet;
use super::MANUAL_FLATTEN;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::higher;
use clippy_utils::visitors::is_local_used;
use clippy_utils::{is_lang_ctor, path_to_local_id};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::LangItem... | else {
None
}
} else if block.stmts.is_empty() {
block.expr
} else {
None
};
if_chain! {
if let Some(inner_expr) = inner_expr;
if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else: None })
... | {
Some(inner_expr)
} | conditional_block |
manual_flatten.rs | use super::utils::make_iterator_snippet;
use super::MANUAL_FLATTEN;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::higher;
use clippy_utils::visitors::is_local_used;
use clippy_utils::{is_lang_ctor, path_to_local_id};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::LangItem... | if!is_local_used(cx, if_then, pat_hir_id);
then {
let if_let_type = if some_ctor { "Some" } else { "Ok" };
// Prepare the error message
let msg = format!("unnecessary `if let` since only the `{}` variant of the iterator element is used", if_let_typ... | let ok_ctor = is_lang_ctor(cx, qpath, ResultOk);
if some_ctor || ok_ctor;
// Ensure epxr in `if let` is not used afterwards | random_line_split |
manual_flatten.rs | use super::utils::make_iterator_snippet;
use super::MANUAL_FLATTEN;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::higher;
use clippy_utils::visitors::is_local_used;
use clippy_utils::{is_lang_ctor, path_to_local_id};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::LangItem... | <'tcx>(
cx: &LateContext<'tcx>,
pat: &'tcx Pat<'_>,
arg: &'tcx Expr<'_>,
body: &'tcx Expr<'_>,
span: Span,
) {
if let ExprKind::Block(block, _) = body.kind {
// Ensure the `if let` statement is the only expression or statement in the for-loop
let inner_expr = if block.stmts.len()... | check | identifier_name |
manual_flatten.rs | use super::utils::make_iterator_snippet;
use super::MANUAL_FLATTEN;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::higher;
use clippy_utils::visitors::is_local_used;
use clippy_utils::{is_lang_ctor, path_to_local_id};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::LangItem... | // Ensure match_expr in `if let` statement is the same as the pat from the for-loop
if let PatKind::Binding(_, pat_hir_id, _, _) = pat.kind;
if path_to_local_id(let_expr, pat_hir_id);
// Ensure the `if let` statement is for the `Some` variant of `Option` or the `Ok` varia... | {
if let ExprKind::Block(block, _) = body.kind {
// Ensure the `if let` statement is the only expression or statement in the for-loop
let inner_expr = if block.stmts.len() == 1 && block.expr.is_none() {
let match_stmt = &block.stmts[0];
if let StmtKind::Semi(inner_expr) = mat... | identifier_body |
repl.rs | extern crate readline;
use std::process;
use storage;
use jobs;
use cluster;
pub fn start() {
loop {
match readline::readline(">>> ") {
Ok(input) => {
let input = input.replace("\n", "");
if input.len() > 0 {
readline::add_history(input.as_re... | storage.list();
}
else if "exit" == input || "quit" == input {
process::exit(0);
}
}
},
Err(e) => {
println!("{}", e);
... | }
else if "storage" == input {
let storage = storage::bootstrap(); | random_line_split |
repl.rs | extern crate readline;
use std::process;
use storage;
use jobs;
use cluster;
pub fn start() |
}
else if "exit" == input || "quit" == input {
process::exit(0);
}
}
},
Err(e) => {
println!("{}", e);
//panic!("{}", e);
}
... | {
loop {
match readline::readline(">>> ") {
Ok(input) => {
let input = input.replace("\n", "");
if input.len() > 0 {
readline::add_history(input.as_ref());
println!("{:?}", input);
if "help" == input {
... | identifier_body |
repl.rs | extern crate readline;
use std::process;
use storage;
use jobs;
use cluster;
pub fn start() {
loop {
match readline::readline(">>> ") {
Ok(input) => {
let input = input.replace("\n", "");
if input.len() > 0 {
readline::add_history(input.as_re... |
}
}
}
| {
println!("{}", e);
//panic!("{}", e);
} | conditional_block |
repl.rs | extern crate readline;
use std::process;
use storage;
use jobs;
use cluster;
pub fn | () {
loop {
match readline::readline(">>> ") {
Ok(input) => {
let input = input.replace("\n", "");
if input.len() > 0 {
readline::add_history(input.as_ref());
println!("{:?}", input);
if "help" == input {... | start | identifier_name |
ptx.rs | Set};
use std::default::Default;
use std::fs::File;
use getopts::{Options, Matches};
use std::io::{stdin, stdout, BufReader, BufWriter, BufRead, Read, Write};
use regex::Regex;
use std::cmp;
#[path = "../common/util.rs"]
#[macro_use]
mod util;
static NAME: &'static str = "ptx";
static VERSION: &'static str = "1.0.0"... | else {
(false, HashSet::new())
};
let (i, iset): (bool, HashSet<String>) =
if matches.opt_present("i") {
(true, read_word_filter_file(matches, "i"))
} else {
(false, HashSet::new())
};
if matches.opt_presen... | {
(true, read_word_filter_file(matches, "o"))
} | conditional_block |
ptx.rs | Set};
use std::default::Default;
use std::fs::File;
use getopts::{Options, Matches};
use std::io::{stdin, stdout, BufReader, BufWriter, BufRead, Read, Write};
use regex::Regex;
use std::cmp;
#[path = "../common/util.rs"]
#[macro_use]
mod util;
static NAME: &'static str = "ptx";
static VERSION: &'static str = "1.0.0"... | {
Dumb,
Roff,
Tex,
}
#[derive(Debug)]
struct Config {
format : OutFormat,
gnu_ext : bool,
auto_ref : bool,
input_ref : bool,
right_ref : bool,
ignore_case : bool,
macro_name : String,
trunc_str : String,
context_regex : String,
line_width : usize,
gap_size : u... | OutFormat | identifier_name |
ptx.rs | Set};
use std::default::Default;
use std::fs::File;
use getopts::{Options, Matches};
use std::io::{stdin, stdout, BufReader, BufWriter, BufRead, Read, Write};
use regex::Regex;
use std::cmp;
#[path = "../common/util.rs"]
#[macro_use]
mod util;
static NAME: &'static str = "ptx";
static VERSION: &'static str = "1.0.0"... |
#[derive(Debug)]
struct WordFilter {
only_specified: bool,
ignore_specified: bool,
only_set: HashSet<String>,
ignore_set: HashSet<String>,
word_regex: String,
}
impl WordFilter {
fn new(matches: &Matches, config: &Config) -> WordFilter {
let (o, oset): (bool, HashSet<String>) =
... | {
let filename = matches.opt_str(option).expect("parsing options failed!");
let reader = BufReader::new(crash_if_err!(1, File::open(filename)));
let mut words: HashSet<String> = HashSet::new();
for word in reader.lines() {
words.insert(crash_if_err!(1, word));
}
words
} | identifier_body |
ptx.rs | TreeSet};
use std::default::Default;
use std::fs::File;
use getopts::{Options, Matches};
use std::io::{stdin, stdout, BufReader, BufWriter, BufRead, Read, Write};
use regex::Regex;
use std::cmp;
#[path = "../common/util.rs"]
#[macro_use]
mod util;
static NAME: &'static str = "ptx";
static VERSION: &'static str = "1.... | crash!(1, "-S not implemented yet");
}
config.auto_ref = matches.opt_present("A");
config.input_ref = matches.opt_present("r");
config.right_ref &= matches.opt_present("R");
config.ignore_case = matches.opt_present("f");
if matches.opt_present("M") {
config.macro_name =
... | crash!(1, "GNU extensions not implemented yet");
}
if matches.opt_present("S") { | random_line_split |
parser.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/. */
//! The context within which CSS code is parsed.
#![deny(missing_docs)]
use cssparser::{Parser, SourcePosition, ... |
}
/// Parse a non-empty space-separated or comma-separated list of objects parsed by parse_one
pub fn parse_space_or_comma_separated<F, T>(input: &mut Parser, mut parse_one: F)
-> Result<Vec<T>, ()>
where F: FnMut(&mut Parser) -> Result<T, ()> {
let first = parse_one(input)?;
let mut vec = vec... | {
input.parse_comma_separated(|input| T::parse(context, input))
} | identifier_body |
parser.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/. */
//! The context within which CSS code is parsed.
#![deny(missing_docs)]
use cssparser::{Parser, SourcePosition, ... | else {
break
}
}
Ok(vec)
}
impl Parse for UnicodeRange {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
UnicodeRange::parse(input)
}
}
| {
vec.push(val)
} | conditional_block |
parser.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/. */
//! The context within which CSS code is parsed.
#![deny(missing_docs)]
use cssparser::{Parser, SourcePosition, ... | impl ParserContextExtraData {
/// Construct from a GeckoParserExtraData
///
/// GeckoParserExtraData must live longer than this call
pub unsafe fn new(data: *const ::gecko_bindings::structs::GeckoParserExtraData) -> Self {
// the to_safe calls are safe since we trust that we have references to
... | }
#[cfg(feature = "gecko")] | random_line_split |
parser.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/. */
//! The context within which CSS code is parsed.
#![deny(missing_docs)]
use cssparser::{Parser, SourcePosition, ... | {
/// The base URI.
pub base: Option<GeckoArcURI>,
/// The referrer URI.
pub referrer: Option<GeckoArcURI>,
/// The principal that loaded this stylesheet.
pub principal: Option<GeckoArcPrincipal>,
}
#[cfg(not(feature = "gecko"))]
impl Default for ParserContextExtraData {
fn default() -> Se... | ParserContextExtraData | identifier_name |
compress.rs | //! An example of offloading work to a thread pool instead of doing work on the
//! main event loop.
//!
//! In this example the server will act as a form of echo server except that
//! it'll echo back gzip-compressed data. Each connected client will have the
//! data written streamed back as the compressed version is ... |
/// The main workhorse of this example. This'll compress all data read from
/// `socket` on the `pool` provided, writing it back out to `socket` as it's
/// available.
fn compress(socket: TcpStream, pool: &CpuPool)
-> Box<Future<Item = (u64, u64), Error = io::Error> + Send>
{
use tokio_io::io;
// The gene... | Ok(())
});
core.run(server).unwrap();
} | random_line_split |
compress.rs | //! An example of offloading work to a thread pool instead of doing work on the
//! main event loop.
//!
//! In this example the server will act as a form of echo server except that
//! it'll echo back gzip-compressed data. Each connected client will have the
//! data written streamed back as the compressed version is ... | (socket: TcpStream, pool: &CpuPool)
-> Box<Future<Item = (u64, u64), Error = io::Error> + Send>
{
use tokio_io::io;
// The general interface that `CpuPool` provides is that we'll *spawn a
// future* onto it. All execution of the future will occur on the `CpuPool`
// and we'll get back a handle repr... | compress | identifier_name |
compress.rs | //! An example of offloading work to a thread pool instead of doing work on the
//! main event loop.
//!
//! In this example the server will act as a form of echo server except that
//! it'll echo back gzip-compressed data. Each connected client will have the
//! data written streamed back as the compressed version is ... |
}
impl<T: AsyncWrite> AsyncWrite for Count<T> {
fn shutdown(&mut self) -> Poll<(), io::Error> {
self.io.shutdown()
}
}
| {
self.io.flush()
} | identifier_body |
dir_info.rs | use std::env;
use std::path::Path;
struct DirInfo {
size: u64,
depth: u32
}
const EMPTY: DirInfo = DirInfo {size: 0, depth: 0};
fn main() {
let arg = env::args_os().nth(1).expect("Please, provide a file as argument");
let path = Path::new(&arg);
if path.is_dir() {
let info = dir_info(path... | {
match std::fs::read_dir(path) {
Err(_) => EMPTY,
Ok(entries) =>
entries.fold(EMPTY,
|info, entry| update_info(info, &entry.unwrap().path()))
}
} | identifier_body | |
dir_info.rs | use std::env;
use std::path::Path;
struct DirInfo {
size: u64,
depth: u32
}
const EMPTY: DirInfo = DirInfo {size: 0, depth: 0};
fn main() {
let arg = env::args_os().nth(1).expect("Please, provide a file as argument");
let path = Path::new(&arg);
if path.is_dir() {
let info = dir_info(path... | (path: &Path) -> DirInfo {
if path.is_file() {
file_info(path)
} else if path.is_dir() {
dir_info(path)
} else {
EMPTY
}
}
fn file_info(path: &Path) -> DirInfo {
let metadata = path.metadata().ok().expect("Cannot get file metadata");
DirInfo {size: metadata.len(), depth:... | dir_entry_info | identifier_name |
dir_info.rs | use std::env;
use std::path::Path;
struct DirInfo {
size: u64,
depth: u32
}
const EMPTY: DirInfo = DirInfo {size: 0, depth: 0};
fn main() {
let arg = env::args_os().nth(1).expect("Please, provide a file as argument");
let path = Path::new(&arg);
if path.is_dir() {
let info = dir_info(path... | else if path.is_dir() {
dir_info(path)
} else {
EMPTY
}
}
fn file_info(path: &Path) -> DirInfo {
let metadata = path.metadata().ok().expect("Cannot get file metadata");
DirInfo {size: metadata.len(), depth: 0}
}
fn dir_info(path: &Path) -> DirInfo {
match std::fs::read_dir(path) ... | {
file_info(path)
} | conditional_block |
dir_info.rs | use std::env;
use std::path::Path;
struct DirInfo {
size: u64,
depth: u32
}
const EMPTY: DirInfo = DirInfo {size: 0, depth: 0};
fn main() {
let arg = env::args_os().nth(1).expect("Please, provide a file as argument");
let path = Path::new(&arg);
if path.is_dir() {
let info = dir_info(path... | |info, entry| update_info(info, &entry.unwrap().path()))
}
} | entries.fold(EMPTY, | random_line_split |
shootout-fasta.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | ('t', 0.27), ('B', 0.02), ('D', 0.02),
('H', 0.02), ('K', 0.02), ('M', 0.02),
('N', 0.02), ('R', 0.02), ('S', 0.02),
('V', 0.02), ('W', 0.02), ('Y', 0.02)];
let homosapiens = &[('a', 0.3029549426680),
('c', 0.1979883004921),
... | {
let args = os::args();
let n = if os::getenv("RUST_BENCH").is_some() {
25000000
} else if args.len() <= 1u {
1000
} else {
from_str(args[1]).unwrap()
};
let rng = &mut MyRandom::new();
let alu =
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG\
GAGGCCGAG... | identifier_body |
shootout-fasta.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
writer.flush();
}
fn main() {
if os::getenv("RUST_BENCH").is_some() {
let mut file = BufferedWriter::new(File::create(&Path::new("./shootout-fasta.data")));
run(&mut file);
} else {
run(&mut BufferedWriter::new(io::stdout()));
}
} | AAGen::new(rng, homosapiens), n * 5); | random_line_split |
shootout-fasta.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | else if args.len() <= 1u {
1000
} else {
from_str(args[1]).unwrap()
};
let rng = &mut MyRandom::new();
let alu =
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG\
GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA\
CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT\
ACAAAAAT... | {
25000000
} | conditional_block |
shootout-fasta.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&mut self) -> u32 {
self.last = (self.last * 3877 + 29573) % IM;
self.last
}
}
struct AAGen<'a> {
rng: &'a mut MyRandom,
data: ~[(u32, u8)]
}
impl<'a> AAGen<'a> {
fn new<'b>(rng: &'b mut MyRandom, aa: &[(char, f32)]) -> AAGen<'b> {
let mut cum = 0.;
let data = aa.iter()... | gen | identifier_name |
player.rs | extern crate serde_redis;
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Player {
#[serde(skip_serializing)]
pub addr: String,
pub name: Option<String>,
pub state: PlayerState
}
impl Player {
pub fn new(addr: String, name: Option<String>) -> Player {
Player {
addr: ... |
pub fn format_hand_key(addr: &str, game_id: &str) -> String {
format!("HAND:{}:{}", addr, game_id)
}
pub fn state_key(&self) -> String {
Player::format_state_key(&self.addr)
}
pub fn hand_key(&self, game_id: &str) -> String {
Player::format_hand_key(&self.addr, game_id)
... | pub fn format_state_key(addr: &str) -> String {
format!("STATE:{}", addr)
} | random_line_split |
player.rs | extern crate serde_redis;
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Player {
#[serde(skip_serializing)]
pub addr: String,
pub name: Option<String>,
pub state: PlayerState
}
impl Player {
pub fn new(addr: String, name: Option<String>) -> Player {
Player {
addr: ... | (&self, game_id: &str) -> String {
Player::format_hand_key(&self.addr, game_id)
}
}
// States
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(tag = "type")]
pub enum PlayerState {
Watching,
Playing,
Judging,
TimeOut,
Banned,
}
// Transitions | hand_key | identifier_name |
curve.rs | /// (c) David Alan Gilbert <dave@treblig.org> 2016
/// Licensed under GPLv3, see the LICENSE file for a full copy
// A curve to interpolate between points
// This is currently a Quadratic Bezier; pretty simple.
use point_line::Pointf;
pub struct | {
pub start : Pointf,
pub control : Pointf,
pub end : Pointf,
}
// From https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Quadratic_B.C3.A9zier_curves
fn quad_interp(t: f64, s: f64, c: f64, e: f64) -> f64 {
(1.0-t)*(1.0-t)*s + 2.0*(1.0-t)*t*c + t*t*e
}
// Reworking the above to give c as the answer and specify... | Bezierq | identifier_name |
curve.rs | /// (c) David Alan Gilbert <dave@treblig.org> 2016
/// Licensed under GPLv3, see the LICENSE file for a full copy
// A curve to interpolate between points
// This is currently a Quadratic Bezier; pretty simple.
use point_line::Pointf;
pub struct Bezierq {
pub start : Pointf,
pub control : Pointf,
pub end : Poi... | } | x: find_control(s.x, m.x, e.x, mid_t),
y: find_control(s.y, m.y, e.y, mid_t) } }
} | random_line_split |
gpu.rs | use maplit::hashmap;
use crate::GpuState;
use std::{collections::HashMap, mem};
#[repr(C)]
#[derive(Copy, Clone)]
pub(crate) struct GenHeightmapsUniforms {
pub position: [i32; 2],
pub origin: [i32; 2],
pub spacing: f32,
pub in_slot: i32,
pub out_slot: i32,
pub level_resolution: i32,
pub fa... | dimensions: (u32, u32, u32),
uniforms: &U,
) {
if self.uniforms.is_none() {
self.uniforms = Some(device.create_buffer(&wgpu::BufferDescriptor {
size: mem::size_of::<U>() as u64,
usage: wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::UNIFORM,
... | state: &GpuState, | random_line_split |
gpu.rs | use maplit::hashmap;
use crate::GpuState;
use std::{collections::HashMap, mem};
#[repr(C)]
#[derive(Copy, Clone)]
pub(crate) struct GenHeightmapsUniforms {
pub position: [i32; 2],
pub origin: [i32; 2],
pub spacing: f32,
pub in_slot: i32,
pub out_slot: i32,
pub level_resolution: i32,
pub fa... | (&mut self) -> bool {
if self.shader.refresh() {
self.bindgroup_pipeline = None;
true
} else {
false
}
}
pub fn run(
&mut self,
device: &wgpu::Device,
encoder: &mut wgpu::CommandEncoder,
state: &GpuState,
dimens... | refresh | identifier_name |
gpu.rs | use maplit::hashmap;
use crate::GpuState;
use std::{collections::HashMap, mem};
#[repr(C)]
#[derive(Copy, Clone)]
pub(crate) struct GenHeightmapsUniforms {
pub position: [i32; 2],
pub origin: [i32; 2],
pub spacing: f32,
pub in_slot: i32,
pub out_slot: i32,
pub level_resolution: i32,
pub fa... |
}
pub fn run(
&mut self,
device: &wgpu::Device,
encoder: &mut wgpu::CommandEncoder,
state: &GpuState,
dimensions: (u32, u32, u32),
uniforms: &U,
) {
if self.uniforms.is_none() {
self.uniforms = Some(device.create_buffer(&wgpu::BufferDescr... | {
false
} | conditional_block |
mod.rs | //! Data structures related to the `/proc/<pid>/*` files
//!
//! The `Process` struct can load everything about a running process, and
//! provides some aggregate data about them.
mod cmd_line;
mod stat;
use std::fmt;
use crate::linux::{Jiffies, Ratio, PAGESIZE};
use crate::procfs::Result;
pub use self::cmd_line::C... | else {
cmd
}
}
/// What percent this process is using
///
/// First argument should be in bytes.
pub fn percent_ram(&self, of_bytes: usize) -> f64 {
pages_to_bytes(self.stat.rss) as f64 / of_bytes as f64 * 100.0
}
/// Compare this processes cpu utilization sinc... | {
self.stat.comm.clone()
} | conditional_block |
mod.rs | //! Data structures related to the `/proc/<pid>/*` files
//!
//! The `Process` struct can load everything about a running process, and
//! provides some aggregate data about them.
mod cmd_line;
mod stat;
| use crate::procfs::Result;
pub use self::cmd_line::CmdLine;
pub use self::stat::{Stat, State};
/// Information about a running process
#[derive(Clone, PartialEq, Eq, Debug, Default)]
pub struct Process {
/// The stat info for a process
pub stat: Stat,
/// The command line, as revealed by the /proc fs
... | use std::fmt;
use crate::linux::{Jiffies, Ratio, PAGESIZE}; | random_line_split |
mod.rs | //! Data structures related to the `/proc/<pid>/*` files
//!
//! The `Process` struct can load everything about a running process, and
//! provides some aggregate data about them.
mod cmd_line;
mod stat;
use std::fmt;
use crate::linux::{Jiffies, Ratio, PAGESIZE};
use crate::procfs::Result;
pub use self::cmd_line::C... | <'a>(
&'a self,
start_process: &'a Process,
total_cpu: Jiffies,
) -> ProcessCpuUsage<'a> {
let (start_ps, end_ps) = (&start_process.stat, &self.stat);
if end_ps.utime < start_ps.utime || end_ps.stime < start_ps.stime {
panic!("End process is before start process (... | cpu_utilization_since | identifier_name |
struct-partial-move-1.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 ... | // `..p` moves all fields *except* `p.y` in this context.
Partial { y: f(p.y),..p }
}
pub fn main() {
let p = f((S::new(3), S::new(4)), |S { val: z }| S::new(z+1));
assert_eq!(p, Partial { x: S::new(3), y: S::new(5) });
} |
pub fn f<T, F>((b1, b2): (T, T), mut f: F) -> Partial<T> where F: FnMut(T) -> T {
let p = Partial { x: b1, y: b2 };
// Move of `p` is legal even though we are also moving `p.y`; the | random_line_split |
struct-partial-move-1.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 ... | (v: int) -> S { S { val: v } } }
impl Drop for S { fn drop(&mut self) { } }
pub fn f<T, F>((b1, b2): (T, T), mut f: F) -> Partial<T> where F: FnMut(T) -> T {
let p = Partial { x: b1, y: b2 };
// Move of `p` is legal even though we are also moving `p.y`; the
// `..p` moves all fields *except* `p.y` in this... | new | identifier_name |
struct-partial-move-1.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {
let p = f((S::new(3), S::new(4)), |S { val: z }| S::new(z+1));
assert_eq!(p, Partial { x: S::new(3), y: S::new(5) });
}
| {
let p = Partial { x: b1, y: b2 };
// Move of `p` is legal even though we are also moving `p.y`; the
// `..p` moves all fields *except* `p.y` in this context.
Partial { y: f(p.y), ..p }
} | identifier_body |
main.rs | extern crate feroxide;
use feroxide::data_atoms::*;
use feroxide::data_molecules::*;
use feroxide::data_sef::*;
use feroxide::data_sep::*;
use feroxide::*;
fn main() | let _name = carbondioxide.name();
//... or the symbol
let symbol = carbondioxide.symbol();
// You can calculate the mass per mole
let mass_per_mole = carbondioxide.mass();
// Multiply that with your amount of moles
let weight = mass_per_mole * 10.0;
// To get your data
println!("... | {
// You can create digital molecules with ease on two ways:
// ... the easy way
let carbondioxide = Molecule::from_string("CO2").unwrap();
// ... and the fast way
let carbonmonoxide = Molecule {
compounds: vec![
MoleculeCompound {
atom: CARBON,
a... | identifier_body |
main.rs | extern crate feroxide;
use feroxide::data_atoms::*;
use feroxide::data_molecules::*;
use feroxide::data_sef::*;
use feroxide::data_sep::*;
use feroxide::*;
fn | () {
// You can create digital molecules with ease on two ways:
//... the easy way
let carbondioxide = Molecule::from_string("CO2").unwrap();
//... and the fast way
let carbonmonoxide = Molecule {
compounds: vec![
MoleculeCompound {
atom: CARBON,
... | main | identifier_name |
main.rs | extern crate feroxide;
use feroxide::data_atoms::*;
use feroxide::data_molecules::*;
use feroxide::data_sef::*;
use feroxide::data_sep::*;
use feroxide::*;
fn main() {
// You can create digital molecules with ease on two ways:
//... the easy way
let carbondioxide = Molecule::from_string("CO2").unwrap();
... |
let fe2 = ContainerCompound::<Ion>::ion_from_string("Fe;2+").unwrap();
while redox_container.contains(&fe2) {
redox_container.react(&rust);
}
println!("\n");
println!("After all {} is gone:", fe2.symbol());
println!("Container: {}", redox_container);
... | println!("\n\n");
println!("Container: {}", redox_container);
println!("\tcan have the following reaction:");
println!("Redox reaction: \n{}", redox.symbol());
println!("Total reaction: {}", redox.elem_reaction().symbol());
for _ in 0..100 {
redox_container.react(&re... | conditional_block |
main.rs | extern crate feroxide;
use feroxide::data_atoms::*;
use feroxide::data_molecules::*;
use feroxide::data_sef::*;
use feroxide::data_sep::*;
use feroxide::*;
fn main() {
// You can create digital molecules with ease on two ways:
//... the easy way
let carbondioxide = Molecule::from_string("CO2").unwrap();
... | element: ion_from_atom!(OXYGEN.clone()),
moles: Moles::from(10000000000.0),
},
],
available_energy: Energy::from(100_000f64), // in Joules
};
// Specify the reaction that will occur
// H₂O + CO₂ ⇌ H₂CO₃
let reaction = ElemReaction {
l... | ContainerCompound { | random_line_split |
read_file.rs | /*
* How to read a file.
* Future work: as a variant, we may use the C bindings to call mmap/munmap
*/
use std::io;
use std::result;
/* read the file path by calling the read_whole_file_str function */
fn | (path: ~str) -> ~str {
let res = io::read_whole_file_str(&Path(path));
if result::is_err(&res) {
fail!(~"file_reader error: " + result::get_err(&res));
}
res.get()
}
/* read the file path line by line */
fn read_file_lines(path: ~str) -> ~str {
let res = io::file_reader(&Path(path));
if result:... | read_file_whole | identifier_name |
read_file.rs | /*
* How to read a file.
* Future work: as a variant, we may use the C bindings to call mmap/munmap
*/
use std::io;
use std::result;
/* read the file path by calling the read_whole_file_str function */
fn read_file_whole(path: ~str) -> ~str {
let res = io::read_whole_file_str(&Path(path));
if result::is_err(... |
fn main() {
let filename = ~"read_file.rs";
//let content = read_file_whole(copy filename);
let content = read_file_lines(copy filename);
io::println("the content of " + filename + " is [\n" + content + "]");
}
| {
let res = io::file_reader(&Path(path));
if result::is_err(&res) {
fail!(~"file_reader error: " + result::get_err(&res));
}
let mut content = ~"";
let reader = res.get();
loop {
let line = reader.read_line();
if reader.eof() {
break;
}
// read_line does not ret... | identifier_body |
read_file.rs | /*
* How to read a file. |
use std::io;
use std::result;
/* read the file path by calling the read_whole_file_str function */
fn read_file_whole(path: ~str) -> ~str {
let res = io::read_whole_file_str(&Path(path));
if result::is_err(&res) {
fail!(~"file_reader error: " + result::get_err(&res));
}
res.get()
}
/* read the file... | * Future work: as a variant, we may use the C bindings to call mmap/munmap
*/ | random_line_split |
read_file.rs | /*
* How to read a file.
* Future work: as a variant, we may use the C bindings to call mmap/munmap
*/
use std::io;
use std::result;
/* read the file path by calling the read_whole_file_str function */
fn read_file_whole(path: ~str) -> ~str {
let res = io::read_whole_file_str(&Path(path));
if result::is_err(... |
let mut content = ~"";
let reader = res.get();
loop {
let line = reader.read_line();
if reader.eof() {
break;
}
// read_line does not return the '\n', so we add it
content = content + line + "\n";
}
content
}
fn main() {
let filename = ~"read_file.rs";
//l... | {
fail!(~"file_reader error: " + result::get_err(&res));
} | 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... | else {
dcol[j + 1] = cmp::min(current, next);
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 ... | {
dcol[j + 1] = current;
} | 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... |
let mut dcol: Vec<_> = (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[j + 1];
if sc == tc {
dcol[j... | if me.is_empty() { return t.chars().count(); }
if t.is_empty() { return me.chars().count(); } | 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... | {
use std::char::{ from_u32, MAX };
// Test bytelength agnosticity
for c in (0..MAX as u32)
.filter_map(|i| from_u32(i))
.map(|i| i.to_string()) {
assert_eq!(lev_distance(&c[..], &c[..]), 0);
}
let a = "\nMäry häd ä little lämb\n\nLittle lämb\n";
let b = "\nMar... | identifier_body | |
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... | () {
use std::char::{ from_u32, MAX };
// Test bytelength agnosticity
for c in (0..MAX as u32)
.filter_map(|i| from_u32(i))
.map(|i| i.to_string()) {
assert_eq!(lev_distance(&c[..], &c[..]), 0);
}
let a = "\nMäry häd ä little lämb\n\nLittle lämb\n";
let b = "\nMa... | test_lev_distance | identifier_name |
modules.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.... | (io_path: &str, sync_cfg: SyncConfig, net_cfg: NetworkConfiguration, log_settings: &LogConfig) -> BootArgs {
let service_config = ServiceConfiguration {
sync: sync_cfg,
net: net_cfg,
io_path: io_path.to_owned(),
};
// initialisation payload is passed via stdin
let service_payload = serialize(&service_config)... | sync_arguments | identifier_name |
modules.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.... |
#[cfg(feature="ipc")]
fn sync_arguments(io_path: &str, sync_cfg: SyncConfig, net_cfg: NetworkConfiguration, log_settings: &LogConfig) -> BootArgs {
let service_config = ServiceConfiguration {
sync: sync_cfg,
net: net_cfg,
io_path: io_path.to_owned(),
};
// initialisation payload is passed via stdin
let ser... | {
None
} | identifier_body |
modules.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.... | pub use ipc::IpcSocket;
pub use ipc::binary::serialize;
}
#[cfg(feature="ipc")]
pub fn hypervisor(base_path: &Path) -> Option<Hypervisor> {
Some(Hypervisor
::with_url(&service_urls::with_base(base_path.to_str().unwrap(), HYPERVISOR_IPC_URL))
.io_path(base_path.to_str().unwrap()))
}
#[cfg(not(feature="ipc"))]
p... | random_line_split | |
modules.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.... |
BootArgs::new().stdin(service_payload).cli(cli_args)
}
#[cfg(feature="ipc")]
pub fn sync
(
hypervisor_ref: &mut Option<Hypervisor>,
sync_cfg: SyncConfig,
net_cfg: NetworkConfiguration,
_client: Arc<BlockChainClient>,
_snapshot_service: Arc<SnapshotService>,
log_settings: &LogConfig,
)
-> Result<SyncM... | {
cli_args.push("--log-file".to_owned());
cli_args.push(file.to_owned());
} | conditional_block |
reflector.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/. */
//! The `Reflector` struct.
use dom::bindings::conversions::DerivedFrom;
use dom::bindings::root::DomRoot;
use do... |
impl DomObject for Reflector {
fn reflector(&self) -> &Self {
self
}
}
/// A trait to initialize the `Reflector` for a DOM object.
pub trait MutDomObject: DomObject {
/// Initializes the Reflector
fn init_reflector(&mut self, obj: *mut JSObject);
}
impl MutDomObject for Reflector {
fn ini... | random_line_split | |
reflector.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/. */
//! The `Reflector` struct.
use dom::bindings::conversions::DerivedFrom;
use dom::bindings::root::DomRoot;
use do... | (&self) -> HandleObject {
// We're rooted, so it's safe to hand out a handle to object in Heap
unsafe { self.object.handle() }
}
/// Initialize the reflector. (May be called only once.)
pub fn set_jsobject(&mut self, object: *mut JSObject) {
assert!(self.object.get().is_null());
... | get_jsobject | identifier_name |
reflector.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/. */
//! The `Reflector` struct.
use dom::bindings::conversions::DerivedFrom;
use dom::bindings::root::DomRoot;
use do... |
}
| {
self.set_jsobject(obj)
} | identifier_body |
main.rs | use std::env;
struct LwzDict {
words: Vec<String>
}
impl LwzDict {
pub fn | (&mut self, s: &str) {
if s.len() < 1 {
return;
}
let next = match self.find(s) {
Some(c) => {
self.words.push(
format!("{}{}", c, s)
);
s[c.len()..s.len()]
},
None => {
... | add_chain | identifier_name |
main.rs | use std::env;
struct LwzDict {
words: Vec<String>
}
impl LwzDict {
pub fn add_chain(&mut self, s: &str) {
if s.len() < 1 {
return;
}
let next = match self.find(s) {
Some(c) => {
self.words.push(
format!("{}{}", c, s) | s[1..s.len()]
}
};
self.add_chain(&next);
}
fn find(&self, s: &str) -> Option<String> {
for word in self.words {
if(word == s) {
Some(word.clone())
}
}
None
}
}
impl From<String> for LwzDict {
... | );
s[c.len()..s.len()]
},
None => {
self.words.push(s[0..1].to_string()); | random_line_split |
main.rs | use std::env;
struct LwzDict {
words: Vec<String>
}
impl LwzDict {
pub fn add_chain(&mut self, s: &str) |
fn find(&self, s: &str) -> Option<String> {
for word in self.words {
if(word == s) {
Some(word.clone())
}
}
None
}
}
impl From<String> for LwzDict {
fn from(from: String) -> Self {
}
}
fn main() {
let sentence = env::args().nth(1).... | {
if s.len() < 1 {
return;
}
let next = match self.find(s) {
Some(c) => {
self.words.push(
format!("{}{}", c, s)
);
s[c.len()..s.len()]
},
None => {
self.words.pus... | identifier_body |
build.rs | extern crate curl;
extern crate env_logger;
extern crate flate2;
extern crate krpc_build;
extern crate prost_build;
extern crate tar;
use std::env;
use std::io::Cursor;
use std::path::PathBuf;
use curl::easy::Easy; | const VERSION: &'static str = "1.7.1";
fn main() {
env_logger::init();
let target = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR environment variable not set"));
let dir = target.join(format!("kudu-{}", VERSION));
// Download the Kudu source tarball.
if!dir.exists() {
let mut data = V... | use flate2::bufread::GzDecoder;
use tar::Archive;
| random_line_split |
build.rs | extern crate curl;
extern crate env_logger;
extern crate flate2;
extern crate krpc_build;
extern crate prost_build;
extern crate tar;
use std::env;
use std::io::Cursor;
use std::path::PathBuf;
use curl::easy::Easy;
use flate2::bufread::GzDecoder;
use tar::Archive;
const VERSION: &'static str = "1.7.1";
fn | () {
env_logger::init();
let target = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR environment variable not set"));
let dir = target.join(format!("kudu-{}", VERSION));
// Download the Kudu source tarball.
if!dir.exists() {
let mut data = Vec::new();
let mut handle = Easy::new()... | main | identifier_name |
build.rs | extern crate curl;
extern crate env_logger;
extern crate flate2;
extern crate krpc_build;
extern crate prost_build;
extern crate tar;
use std::env;
use std::io::Cursor;
use std::path::PathBuf;
use curl::easy::Easy;
use flate2::bufread::GzDecoder;
use tar::Archive;
const VERSION: &'static str = "1.7.1";
fn main() | transfer
.write_function(|new_data| {
data.extend_from_slice(new_data);
Ok(new_data.len())
}).expect("failed to write download data");
transfer
.perform()
.expect("failed to download Kudu source ... | {
env_logger::init();
let target = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR environment variable not set"));
let dir = target.join(format!("kudu-{}", VERSION));
// Download the Kudu source tarball.
if !dir.exists() {
let mut data = Vec::new();
let mut handle = Easy::new();
... | identifier_body |
build.rs | extern crate curl;
extern crate env_logger;
extern crate flate2;
extern crate krpc_build;
extern crate prost_build;
extern crate tar;
use std::env;
use std::io::Cursor;
use std::path::PathBuf;
use curl::easy::Easy;
use flate2::bufread::GzDecoder;
use tar::Archive;
const VERSION: &'static str = "1.7.1";
fn main() {
... | .perform()
.expect("failed to download Kudu source tarball");
}
Archive::new(GzDecoder::new(Cursor::new(data)))
.unpack(target)
.expect("failed to unpack Kudu source tarball");
}
prost_build::Config::new()
.service_generator(Box::new(... | {
let mut data = Vec::new();
let mut handle = Easy::new();
handle
.url(&format!(
"https://github.com/apache/kudu/archive/{}.tar.gz",
VERSION
)).expect("failed to configure Kudu tarball URL");
handle
.follow_location(tru... | conditional_block |
generate-mod.rs | // Modules generated by transparent proc macros still acts as barriers for names (issue #50504).
// aux-build:generate-mod.rs
extern crate generate_mod;
struct FromOutside;
generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope
//~| ERROR cannot find type `Outer` in t... | ;
}
#[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
struct W;
fn main() {}
| InnerZ | identifier_name |
generate-mod.rs | // Modules generated by transparent proc macros still acts as barriers for names (issue #50504).
// aux-build:generate-mod.rs
| struct FromOutside;
generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope
//~| ERROR cannot find type `Outer` in this scope
#[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope
//~| ERROR cannot find type `Outer... | extern crate generate_mod;
| random_line_split |
21.rs | use std::fs::File;
use std::io::prelude::*;
use std::iter;
mod intcode;
use intcode::*;
#[derive(Debug, Clone)]
enum DroidResult {
Fail(String),
Success(i64)
}
fn get_input() -> std::io::Result<String> {
let mut file = File::open("21.txt")?;
let mut contents = String::new();
file.read_to_string(&mut conten... | # E and F are not holes
OR E T
AND F T
# )
OR T J
OR H J
# (
# There's a hole in ABC
NOT A T
NOT T T
AND B T
AND C T
NOT T T
# and D is not a hole
AND D T
# )
AND T J
RUN
";
let result = run_springdroid(&mut ProgramS... | # ( | random_line_split |
21.rs | use std::fs::File;
use std::io::prelude::*;
use std::iter;
mod intcode;
use intcode::*;
#[derive(Debug, Clone)]
enum DroidResult {
Fail(String),
Success(i64)
}
fn | () -> std::io::Result<String> {
let mut file = File::open("21.txt")?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
Ok(contents)
}
fn run_springdroid(state: &mut ProgramState, script: &str) -> DroidResult {
let inputs = script.lines()
.map(|line| line.trim())
.filter(|line| li... | get_input | identifier_name |
21.rs | use std::fs::File;
use std::io::prelude::*;
use std::iter;
mod intcode;
use intcode::*;
#[derive(Debug, Clone)]
enum DroidResult {
Fail(String),
Success(i64)
}
fn get_input() -> std::io::Result<String> {
let mut file = File::open("21.txt")?;
let mut contents = String::new();
file.read_to_string(&mut conten... | ,
_ => {
DroidResult::Fail(
outputs.iter()
.map(|&c| c as u8 as char)
.fold(String::new(), |mut acc, c| {
acc.push(c);
acc
})
)
}
}
}
fn main() {
let input = get_input().unwrap();
let program = input.split(',')
.filter_map(|x| x.trim().pars... | {
DroidResult::Success(x)
} | conditional_block |
dont_promote_unstable_const_fn.rs | // Copyright 2018 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 _: &'static u32 = &meh(); //~ ERROR does not live long enough
let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
//~^ ERROR does not live long enough
}
| main | identifier_name |
dont_promote_unstable_const_fn.rs | // Copyright 2018 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: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
//~^ ERROR does not live long enough
} | random_line_split | |
dont_promote_unstable_const_fn.rs | // Copyright 2018 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 `foo` is not yet stable as a const fn
fn a() {
let _: &'static u32 = &foo(); //~ ERROR does not live long enough
}
fn main() {
let _: &'static u32 = &meh(); //~ ERROR does not live long enough
let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
//~^ ERROR does not liv... | { foo() } | identifier_body |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. 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,
* this list of con... |
Inconsistent | Data(..) => panic!()
}
let (tx, rx) = channel();
let q = Arc::new(q);
for _ in 0..nthreads {
let tx = tx.clone();
let q = q.clone();
thread::spawn(move|| {
for i in 0..nmsgs {
q.push(i);
... | {} | conditional_block |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. 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,
* this list of con... |
}
impl<T> Queue<T> {
/// Creates a new queue that is safe to share among multiple producers and
/// one consumer.
pub fn new() -> Queue<T> {
let stub = unsafe { Node::new(None) };
Queue {
head: AtomicPtr::new(stub),
tail: UnsafeCell::new(stub),
}
}
... | {
Box::into_raw(box Node {
next: AtomicPtr::new(ptr::null_mut()),
value: v,
})
} | identifier_body |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. 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,
* this list of con... | (&self) -> PopResult<T> {
unsafe {
let tail = *self.tail.get();
let next = (*tail).next.load(Ordering::Acquire);
if!next.is_null() {
*self.tail.get() = next;
assert!((*tail).value.is_none());
assert!((*next).value.is_some());
... | pop | identifier_name |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. 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,
* this list of con... | Box::into_raw(box Node {
next: AtomicPtr::new(ptr::null_mut()),
value: v,
})
}
}
impl<T> Queue<T> {
/// Creates a new queue that is safe to share among multiple producers and
/// one consumer.
pub fn new() -> Queue<T> {
let stub = unsafe { Node::new(None)... |
impl<T> Node<T> {
unsafe fn new(v: Option<T>) -> *mut Node<T> { | 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(box_syntax)]
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#!... | () {}
pub fn init_service_workers(sw_senders: SWManagerSenders) {
// Spawn the service worker manager passing the constellation sender
ServiceWorkerManager::spawn_manager(sw_senders);
}
#[allow(unsafe_code)]
pub fn init() {
unsafe {
proxyhandler::init();
// Create the global vtables used ... | perform_platform_specific_initialization | 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(box_syntax)]
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#!... | #[macro_use]
extern crate bitflags;
extern crate bluetooth_traits;
extern crate byteorder;
extern crate canvas_traits;
extern crate caseless;
extern crate cookie as cookie_rs;
extern crate core;
#[macro_use] extern crate cssparser;
#[macro_use] extern crate deny_public_fields;
extern crate devtools_traits;
extern crate... | extern crate atomic_refcell;
extern crate audio_video_metadata; | 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(box_syntax)]
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#!... | {
unsafe {
proxyhandler::init();
// Create the global vtables used by the (generated) DOM
// bindings to implement JS proxies.
RegisterBindings::RegisterProxyHandlers();
}
perform_platform_specific_initialization();
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.