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 |
|---|---|---|---|---|
p041.rs | //! [Problem 41](https://projecteuler.net/problem=41) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
extern crate iter;
extern crate integer;
extern crate prime;
use iter::Permutations;
... |
fn solve() -> String {
compute().to_string()
}
problem!("7652413", solve);
| {
let radix = 10;
let ps = PrimeSet::new();
for (perm, _) in Permutations::new(&[7, 6, 5, 4, 3, 2, 1], 7) {
let n = Integer::from_digits(perm.iter().rev().map(|&x| x), radix);
if ps.contains(n) {
return n
}
}
unreachable!()
} | identifier_body |
p041.rs | //! [Problem 41](https://projecteuler.net/problem=41) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
extern crate iter;
extern crate integer;
extern crate prime;
use iter::Permutations;
... | }
unreachable!()
}
fn solve() -> String {
compute().to_string()
}
problem!("7652413", solve); | random_line_split | |
dedicatedworkerglobalscope.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use ... |
}
trait PrivateDedicatedWorkerGlobalScopeHelpers {
fn handle_event(self, msg: ScriptMsg);
fn dispatch_error_to_worker(self, JSRef<ErrorEvent>);
}
impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerGlobalScope> {
fn handle_event(self, msg: ScriptMsg) {
match msg {
... | {
box SendableWorkerScriptChan {
sender: self.own_sender.clone(),
worker: self.worker.borrow().as_ref().unwrap().clone(),
}
} | identifier_body |
dedicatedworkerglobalscope.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use ... | cx: Rc<Cx>,
resource_task: ResourceTask,
parent_sender: Box<ScriptChan+Send>,
own_sender: Sender<(TrustedWorkerAddress, ScriptMsg)>,
receiver: Receiver<(TrustedWorkerAddress, ScriptMsg)>)
-> Temporary<DedicatedWorkerGlobalScope> {... | }
}
pub fn new(worker_url: Url, | random_line_split |
dedicatedworkerglobalscope.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use ... |
_ => panic!("Unexpected message"),
}
}
fn dispatch_error_to_worker(self, errorevent: JSRef<ErrorEvent>) {
let msg = errorevent.Message();
let file_name = errorevent.Filename();
let line_num = errorevent.Lineno();
let col_num = errorevent.Colno();
let... | {
let scope: JSRef<WorkerGlobalScope> = WorkerGlobalScopeCast::from_ref(self);
scope.handle_fire_timer(timer_id);
} | conditional_block |
dedicatedworkerglobalscope.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use ... | (self) -> Box<ScriptChan+Send> {
box SendableWorkerScriptChan {
sender: self.own_sender.clone(),
worker: self.worker.borrow().as_ref().unwrap().clone(),
}
}
}
trait PrivateDedicatedWorkerGlobalScopeHelpers {
fn handle_event(self, msg: ScriptMsg);
fn dispatch_error_to... | script_chan | identifier_name |
sequence.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// 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... |
pub fn parser(seq: Vec<usize>) -> SequenceCompiler {
SequenceCompiler {
seq: seq,
compiler: parser_compiler
}
}
}
impl CompileExpr for SequenceCompiler
{
fn compile_expr<'a>(&self, context: &mut Context<'a>,
continuation: Continuation) -> syn::Expr
{
self.seq.clone().into_iter()
... | {
SequenceCompiler {
seq: seq,
compiler: recognizer_compiler
}
} | identifier_body |
sequence.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// 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... | } | .rev()
.fold(continuation, |continuation, idx|
continuation.compile_success(context, self.compiler, idx))
.unwrap_success()
} | random_line_split |
sequence.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// 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... | (seq: Vec<usize>) -> SequenceCompiler {
SequenceCompiler {
seq: seq,
compiler: recognizer_compiler
}
}
pub fn parser(seq: Vec<usize>) -> SequenceCompiler {
SequenceCompiler {
seq: seq,
compiler: parser_compiler
}
}
}
impl CompileExpr for SequenceCompiler
{
fn compile_ex... | recognizer | identifier_name |
lib.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2014, 2015 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your opti... |
mod disassembler;
pub use crate::disassembler::{Mos, Variant}; | mod semantic; | random_line_split |
const-cast.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 ... | () {}
static x: extern "C" fn() = foo;
static y: *libc::c_void = x as *libc::c_void;
static a: &'static int = &10;
static b: *int = a as *int;
pub fn main() {
assert_eq!(x as *libc::c_void, y);
assert_eq!(a as *int, b);
}
| foo | identifier_name |
const-cast.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. | // <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.
extern crate libc;
extern fn foo() {}
static x: extern "C" fn() = foo;
static y: *libc::c_void = x as *libc::c_void;
static a: &'static int = &10;
stati... | //
// 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 |
const-cast.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 ... |
static x: extern "C" fn() = foo;
static y: *libc::c_void = x as *libc::c_void;
static a: &'static int = &10;
static b: *int = a as *int;
pub fn main() {
assert_eq!(x as *libc::c_void, y);
assert_eq!(a as *int, b);
}
| {} | identifier_body |
static-mut-foreign.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (_: &'static libc::c_int) {}
fn static_bound_set(a: &'static mut libc::c_int) {
*a = 3;
}
unsafe fn run() {
assert!(rust_dbg_static_mut == 3);
rust_dbg_static_mut = 4;
assert!(rust_dbg_static_mut == 4);
rust_dbg_static_mut_check_four();
rust_dbg_static_mut += 1;
assert!(rust_dbg_static_mut... | static_bound | identifier_name |
static-mut-foreign.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn static_bound_set(a: &'static mut libc::c_int) {
*a = 3;
}
unsafe fn run() {
assert!(rust_dbg_static_mut == 3);
rust_dbg_static_mut = 4;
assert!(rust_dbg_static_mut == 4);
rust_dbg_static_mut_check_four();
rust_dbg_static_mut += 1;
assert!(rust_dbg_static_mut == 5);
rust_dbg_static_... | {} | identifier_body |
static-mut-foreign.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | rust_dbg_static_mut = 4;
assert!(rust_dbg_static_mut == 4);
rust_dbg_static_mut_check_four();
rust_dbg_static_mut += 1;
assert!(rust_dbg_static_mut == 5);
rust_dbg_static_mut *= 3;
assert!(rust_dbg_static_mut == 15);
rust_dbg_static_mut = -3;
assert!(rust_dbg_static_mut == -3);
s... | assert!(rust_dbg_static_mut == 3); | random_line_split |
project.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) an... | assert!(maybe_project.ok().is_some());
} | let maybe_project = Project::open(Path::new("../test-data/save.panop"));
| random_line_split |
project.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) an... | () {
let maybe_project = Project::open(Path::new("../test-data/save.panop"));
assert!(maybe_project.ok().is_some());
}
| project_open | identifier_name |
project.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) an... | {
let maybe_project = Project::open(Path::new("../test-data/save.panop"));
assert!(maybe_project.ok().is_some());
} | identifier_body | |
defer.rs | #![feature(test)]
extern crate test;
use crossbeam_epoch::{self as epoch, Owned};
use crossbeam_utils::thread::scope;
use test::Bencher;
#[bench]
fn single_alloc_defer_free(b: &mut Bencher) {
b.iter(|| {
let guard = &epoch::pin();
let p = Owned::new(1).into_shared(guard);
unsafe {
... | for _ in 0..STEPS {
let guard = &epoch::pin();
guard.defer(move || ());
}
});
}
})
.unwrap();
});
} | s.spawn(|_| { | random_line_split |
defer.rs | #![feature(test)]
extern crate test;
use crossbeam_epoch::{self as epoch, Owned};
use crossbeam_utils::thread::scope;
use test::Bencher;
#[bench]
fn single_alloc_defer_free(b: &mut Bencher) {
b.iter(|| {
let guard = &epoch::pin();
let p = Owned::new(1).into_shared(guard);
unsafe {
... |
#[bench]
fn multi_alloc_defer_free(b: &mut Bencher) {
const THREADS: usize = 16;
const STEPS: usize = 10_000;
b.iter(|| {
scope(|s| {
for _ in 0..THREADS {
s.spawn(|_| {
for _ in 0..STEPS {
let guard = &epoch::pin();
... | {
b.iter(|| {
let guard = &epoch::pin();
guard.defer(move || ());
});
} | identifier_body |
defer.rs | #![feature(test)]
extern crate test;
use crossbeam_epoch::{self as epoch, Owned};
use crossbeam_utils::thread::scope;
use test::Bencher;
#[bench]
fn single_alloc_defer_free(b: &mut Bencher) {
b.iter(|| {
let guard = &epoch::pin();
let p = Owned::new(1).into_shared(guard);
unsafe {
... | (b: &mut Bencher) {
const THREADS: usize = 16;
const STEPS: usize = 10_000;
b.iter(|| {
scope(|s| {
for _ in 0..THREADS {
s.spawn(|_| {
for _ in 0..STEPS {
let guard = &epoch::pin();
let p = Owned::new(1... | multi_alloc_defer_free | identifier_name |
syntax-extension-minor.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 ... | "use_mention_distinction");
} | let asdf_fdsa = ~"<.<";
assert_eq!(concat_idents!(asd, f_f, dsa), ~"<.<");
assert!(stringify!(use_mention_distinction) == | random_line_split |
syntax-extension-minor.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let asdf_fdsa = ~"<.<";
assert_eq!(concat_idents!(asd, f_f, dsa), ~"<.<");
assert!(stringify!(use_mention_distinction) ==
"use_mention_distinction");
} | identifier_body | |
syntax-extension-minor.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let asdf_fdsa = ~"<.<";
assert_eq!(concat_idents!(asd, f_f, dsa), ~"<.<");
assert!(stringify!(use_mention_distinction) ==
"use_mention_distinction");
}
| main | identifier_name |
trace_macros-format.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 ... |
// should be fine:
macro_rules! expando {
($x: ident) => { trace_macros!($x) }
}
expando!(true);
} | trace_macros!(false 1); //~ ERROR trace_macros! accepts only `true` or `false`
| random_line_split |
trace_macros-format.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 ... | {
trace_macros!(); //~ ERROR trace_macros! accepts only `true` or `false`
trace_macros!(1); //~ ERROR trace_macros! accepts only `true` or `false`
trace_macros!(ident); //~ ERROR trace_macros! accepts only `true` or `false`
trace_macros!(for); //~ ERROR trace_macros! accepts only `true` or `false`
t... | identifier_body | |
trace_macros-format.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 ... | () {
trace_macros!(); //~ ERROR trace_macros! accepts only `true` or `false`
trace_macros!(1); //~ ERROR trace_macros! accepts only `true` or `false`
trace_macros!(ident); //~ ERROR trace_macros! accepts only `true` or `false`
trace_macros!(for); //~ ERROR trace_macros! accepts only `true` or `false`
... | main | identifier_name |
namespaced_enum_emulate_flat.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 ... | D,
E(int),
F { a: int },
}
impl Bar {
pub fn foo() {}
}
} |
pub mod nest {
pub use self::Bar::*;
pub enum Bar { | random_line_split |
namespaced_enum_emulate_flat.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 ... | {
D,
E(int),
F { a: int },
}
impl Bar {
pub fn foo() {}
}
}
| Bar | identifier_name |
main.rs | // Copyright (C) 2015, Alberto Corona <ac@albertocorona.com>
// All rights reserved. This file is part of core-utils, distributed under the
// GPL v3 license. For full terms please see the LICENSE file.
#![crate_type = "bin"]
#![crate_name = "mkdir"]
static UTIL: Prog = Prog { name: "mkdir", vers: "0.1.0", yr: "2015"... | (opts: Options) {
print!("{}: {} {}... {}...\n\
Create DIRECTORY(ies) if they do not already exist.", "Usage".bold(),
UTIL.name.bold(), "[OPTION]".underline(), "DIRECTORY".underline());
println!("{}", opts.options());
}
fn main() {
let args: Vec<String> = env::args().collect();
let mut opts = ... | print_usage | identifier_name |
main.rs | // Copyright (C) 2015, Alberto Corona <ac@albertocorona.com>
// All rights reserved. This file is part of core-utils, distributed under the
// GPL v3 license. For full terms please see the LICENSE file.
#![crate_type = "bin"]
#![crate_name = "mkdir"]
static UTIL: Prog = Prog { name: "mkdir", vers: "0.1.0", yr: "2015"... | Err(e) => {
UTIL.error(e.to_string(), ExitStatus::Error);
}
};
}
}
fn print_usage(opts: Options) {
print!("{}: {} {}... {}...\n\
Create DIRECTORY(ies) if they do not already exist.", "Usage".bold(),
UTIL.name.bold(), "[OPTION]".underline(), "DIRECTORY".un... | }
}, | random_line_split |
main.rs | // Copyright (C) 2015, Alberto Corona <ac@albertocorona.com>
// All rights reserved. This file is part of core-utils, distributed under the
// GPL v3 license. For full terms please see the LICENSE file.
#![crate_type = "bin"]
#![crate_name = "mkdir"]
static UTIL: Prog = Prog { name: "mkdir", vers: "0.1.0", yr: "2015"... |
fn main() {
let args: Vec<String> = env::args().collect();
let mut opts = Options::new();
opts.optflag("v", "verbose", "Print the name of each created directory");
opts.optflag("p", "parents", "No error if existing, make parent directories as needed");
opts.optflag("h", "help", "Print help infor... | {
print!("{}: {} {}... {}...\n\
Create DIRECTORY(ies) if they do not already exist.", "Usage".bold(),
UTIL.name.bold(), "[OPTION]".underline(), "DIRECTORY".underline());
println!("{}", opts.options());
} | identifier_body |
ui.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 ... | .version(&version!()[..])
.author("Matthias Beyer <mail@beyermatthias.de>")
.about("Initialize a ~/.imag repository. Optionally with git")
.arg(Arg::with_name("devel")
.long("dev")
.takes_value(false)
.required(false)
.multiple(false)
... | App::new("imag-init") | random_line_split |
ui.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 ... | .arg(Arg::with_name("path")
.long("path")
.takes_value(true)
.required(false)
.multiple(false)
.help("Alternative path where to put the repository. Default: ~/.imag"))
}
| {
App::new("imag-init")
.version(&version!()[..])
.author("Matthias Beyer <mail@beyermatthias.de>")
.about("Initialize a ~/.imag repository. Optionally with git")
.arg(Arg::with_name("devel")
.long("dev")
.takes_value(false)
.required(false)
... | identifier_body |
ui.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 ... | <'a>() -> App<'a, 'a> {
App::new("imag-init")
.version(&version!()[..])
.author("Matthias Beyer <mail@beyermatthias.de>")
.about("Initialize a ~/.imag repository. Optionally with git")
.arg(Arg::with_name("devel")
.long("dev")
.takes_value(false)
.req... | build_ui | identifier_name |
location.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::LocationBinding;
use dom::bindings::codegen::Bindings::LocationBinding::Loca... |
}
| {
&self.reflector_
} | identifier_body |
location.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::LocationBinding;
use dom::bindings::codegen::Bindings::LocationBinding::Loca... | (self) -> DOMString {
UrlHelper::Href(&self.page.get_url())
}
fn Search(self) -> DOMString {
UrlHelper::Search(&self.page.get_url())
}
fn Hash(self) -> DOMString {
UrlHelper::Hash(&self.page.get_url())
}
}
impl Reflectable for Location {
fn reflector<'a>(&'a self) -> &... | Href | identifier_name |
location.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::LocationBinding;
use dom::bindings::codegen::Bindings::LocationBinding::Loca... | fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
} | random_line_split | |
exposure.rs | use leelib::math;
use leelib::matrix::Matrix;
pub struct ExposureInfo {
pub floor: usize,
pub ceil: usize,
pub bias: f64
}
/**
* 'Static' class
* Finds the'meaningful' range of values in a matrix, along with a 'bias' value.
* Experiment.
*/
pub struct ExposureUtil;
impl ExposureUtil {
/**
* max_val - ... | }
let mut i_c = 0 as usize;
let thresh = sum as f64 * (0.5 + 0.34);
let mut s = 0;
for i in lower..(upper + 1) {
s += histogram[i] as u64;
if s as f64 > thresh {
// is like 84th percentile
i_c = i;
break;
}
}
// make hand-wavey value using the above to represent 'bias'
let a = ... | i_b = i;
break;
} | random_line_split |
exposure.rs | use leelib::math;
use leelib::matrix::Matrix;
pub struct ExposureInfo {
pub floor: usize,
pub ceil: usize,
pub bias: f64
}
/**
* 'Static' class
* Finds the'meaningful' range of values in a matrix, along with a 'bias' value.
* Experiment.
*/
pub struct ExposureUtil;
impl ExposureUtil {
/**
* max_val - ... | (matrix: &Matrix<u16>, max_val: u16, lower_thresh_ratio: f64, upper_thresh_ratio: f64) -> ExposureInfo {
// count the values in `matrix`
let mut histogram = vec!(0u16; (max_val + 1) as usize);
for val in matrix {
histogram[val as usize] += 1;
}
let range = ExposureUtil::get_range(&histogram, &matrix, low... | calc | identifier_name |
exposure.rs | use leelib::math;
use leelib::matrix::Matrix;
pub struct ExposureInfo {
pub floor: usize,
pub ceil: usize,
pub bias: f64
}
/**
* 'Static' class
* Finds the'meaningful' range of values in a matrix, along with a 'bias' value.
* Experiment.
*/
pub struct ExposureUtil;
impl ExposureUtil {
/**
* max_val - ... | for i in (0..histogram.len()).rev() {
sum += histogram[i];
if sum as f64 > sum_thresh {
upper_index = if i == histogram.len() - 1 {
histogram.len() - 1
} else if i <= 1 {
0
} else {
i - 1
};
break;
}
}
(lower_index, upper_index)
}
/**
* Returns a value... | {
let sum_thresh = (matrix.width() as f64 * matrix.height() as f64) * lower_thresh_ratio;
let mut lower_index = 0;
let mut sum = 0;
for i in 0..histogram.len() {
sum += histogram[i];
if sum as f64 > sum_thresh {
lower_index = if i <= 1 {
0 as usize
} else {
i - 1 // rewind by 1
... | identifier_body |
exposure.rs | use leelib::math;
use leelib::matrix::Matrix;
pub struct ExposureInfo {
pub floor: usize,
pub ceil: usize,
pub bias: f64
}
/**
* 'Static' class
* Finds the'meaningful' range of values in a matrix, along with a 'bias' value.
* Experiment.
*/
pub struct ExposureUtil;
impl ExposureUtil {
/**
* max_val - ... |
}
let sum_thresh = (matrix.width() as f64 * matrix.height() as f64) * upper_thresh_ratio;
let mut upper_index = 0;
let mut sum = 0;
for i in (0..histogram.len()).rev() {
sum += histogram[i];
if sum as f64 > sum_thresh {
upper_index = if i == histogram.len() - 1 {
histogram.len() - 1
... | {
lower_index = if i <= 1 {
0 as usize
} else {
i - 1 // rewind by 1
};
break;
} | conditional_block |
lib.rs | #![feature(test, i128_type)]
extern crate test;
use test::Bencher;
extern crate rand;
extern crate speck;
use rand::Rng;
use rand::OsRng;
use speck::Key;
#[bench]
fn generate_key(mut bencher: &mut Bencher) {
let mut rng = OsRng::new().unwrap();
let key_input = rng.gen();
bencher.iter(|| test::black_b... | {
let mut rng = OsRng::new().unwrap();
(Key::new(rng.gen()), rng.gen())
} | identifier_body | |
lib.rs | #![feature(test, i128_type)]
extern crate test;
use test::Bencher;
extern crate rand;
extern crate speck;
use rand::Rng;
use rand::OsRng;
use speck::Key;
#[bench]
fn generate_key(mut bencher: &mut Bencher) {
let mut rng = OsRng::new().unwrap();
let key_input = rng.gen();
bencher.iter(|| test::black_b... | (mut bencher: &mut Bencher) {
let (key, block) = gen_test();
bencher.iter(|| test::black_box(key.encrypt_block(block)));
}
#[bench]
fn decrypt(mut bencher: &mut Bencher) {
let (key, block) = gen_test();
bencher.iter(|| test::black_box(key.decrypt_block(block)));
}
fn gen_test() -> (Key, u128) {
... | encrypt | identifier_name |
lib.rs | #![feature(test, i128_type)]
extern crate test;
use test::Bencher;
extern crate rand;
extern crate speck;
use rand::Rng;
use rand::OsRng; | #[bench]
fn generate_key(mut bencher: &mut Bencher) {
let mut rng = OsRng::new().unwrap();
let key_input = rng.gen();
bencher.iter(|| test::black_box(Key::new(key_input)));
}
#[bench]
fn encrypt(mut bencher: &mut Bencher) {
let (key, block) = gen_test();
bencher.iter(|| test::black_box(key.encry... |
use speck::Key;
| random_line_split |
base.rs | token_tree: &[ast::TokenTree])
-> ~MacResult {
(self.expander)(ecx, span, token_tree)
}
}
pub struct BasicIdentMacroExpander {
pub expander: IdentMacroExpanderFn,
pub span: Option<Span>
}
pub trait IdentMacroExpander {
fn expand(&self,
cx: &mut ExtCtxt,
... |
/// A syntax extension that is attached to an item and modifies it
/// in-place.
ItemModifier(ItemModifier),
/// A normal, function-like syntax extension.
///
/// `bytes!` is a `NormalTT`.
NormalTT(~MacroExpander:'static, Option<Span>),
/// A function-like syntax extension that has an... | /// A syntax extension that is attached to an item and creates new items
/// based upon it.
///
/// `#[deriving(...)]` is an `ItemDecorator`.
ItemDecorator(ItemDecorator), | random_line_split |
base.rs | token_tree: &[ast::TokenTree])
-> ~MacResult {
(self.expander)(ecx, span, token_tree)
}
}
pub struct BasicIdentMacroExpander {
pub expander: IdentMacroExpanderFn,
pub span: Option<Span>
}
pub trait IdentMacroExpander {
fn expand(&self,
cx: &mut ExtCtxt,
... |
pub fn bt_push(&mut self, ei: codemap::ExpnInfo) {
match ei {
ExpnInfo {call_site: cs, callee: ref callee} => {
self.backtrace =
Some(@ExpnInfo {
call_site: Span {lo: cs.lo, hi: cs.hi,
expn_info... | {
let mut v = Vec::new();
v.push(token::str_to_ident(self.ecfg.crate_id.name));
v.extend(self.mod_path.iter().map(|a| *a));
return v;
} | identifier_body |
base.rs | token_tree: &[ast::TokenTree])
-> ~MacResult {
(self.expander)(ecx, span, token_tree)
}
}
pub struct BasicIdentMacroExpander {
pub expander: IdentMacroExpanderFn,
pub span: Option<Span>
}
pub trait IdentMacroExpander {
fn expand(&self,
cx: &mut ExtCtxt,
... | (&self) { }
pub fn backtrace(&self) -> Option<@ExpnInfo> { self.backtrace }
pub fn mod_push(&mut self, i: ast::Ident) { self.mod_path.push(i); }
pub fn mod_pop(&mut self) { self.mod_path.pop().unwrap(); }
pub fn mod_path(&self) -> Vec<ast::Ident> {
let mut v = Vec::new();
v.push(token::s... | print_backtrace | identifier_name |
opaque_node.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/. */
#![allow(unsafe_code)]
use gfx::display_list::OpaqueNode;
use libc::{c_void, uintptr_t};
use script::layout_inter... | /// of node that script expects to receive in a hit test.
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress;
}
impl OpaqueNodeMethods for OpaqueNode {
fn from_script_node(node: TrustedNodeAddress) -> OpaqueNode {
unsafe {
OpaqueNodeMethods::from_jsmanaged(&LayoutJS::from_trust... | /// Converts this node to an `UntrustedNodeAddress`. An `UntrustedNodeAddress` is just the type | random_line_split |
opaque_node.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/. */
#![allow(unsafe_code)]
use gfx::display_list::OpaqueNode;
use libc::{c_void, uintptr_t};
use script::layout_inter... | (node: TrustedNodeAddress) -> OpaqueNode {
unsafe {
OpaqueNodeMethods::from_jsmanaged(&LayoutJS::from_trusted_node_address(node))
}
}
fn from_jsmanaged(node: &LayoutJS<Node>) -> OpaqueNode {
unsafe {
let ptr: uintptr_t = node.get_jsobject() as uintptr_t;
... | from_script_node | identifier_name |
opaque_node.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/. */
#![allow(unsafe_code)]
use gfx::display_list::OpaqueNode;
use libc::{c_void, uintptr_t};
use script::layout_inter... |
}
| {
UntrustedNodeAddress(self.0 as *const c_void)
} | identifier_body |
geniza-net.rs | // Free Software under GPL-3.0, see LICENSE
// Copyright 2017 Bryan Newbold
extern crate clap;
extern crate env_logger;
#[macro_use]
extern crate error_chain;
extern crate geniza;
extern crate sodiumoxide;
// TODO: more careful import
use geniza::*;
use std::path::Path;
use clap::{App, SubCommand, Arg};
use sodiumoxi... | )
.subcommand(
SubCommand::with_name("discover-dns")
.about("Does a centralized DNS lookup for peers with the given key")
.arg_from_usage("<dat_key> 'dat key (public key) to lookup"),
)
.subcommand(
SubCommand::with_name("naive-clone")
... | {
env_logger::init().unwrap();
let matches = App::new("geniza-net")
.version(env!("CARGO_PKG_VERSION"))
.subcommand(
SubCommand::with_name("connect")
.about("Connects to a peer and exchanges handshake")
.arg_from_usage("<host_port> 'peer host:port to ... | identifier_body |
geniza-net.rs | // Free Software under GPL-3.0, see LICENSE
// Copyright 2017 Bryan Newbold
extern crate clap;
extern crate env_logger;
#[macro_use]
extern crate error_chain;
extern crate geniza;
extern crate sodiumoxide;
// TODO: more careful import
use geniza::*;
use std::path::Path;
use clap::{App, SubCommand, Arg};
use sodiumoxi... | () -> Result<()> {
env_logger::init().unwrap();
let matches = App::new("geniza-net")
.version(env!("CARGO_PKG_VERSION"))
.subcommand(
SubCommand::with_name("connect")
.about("Connects to a peer and exchanges handshake")
.arg_from_usage("<host_port> 'peer ... | run | identifier_name |
geniza-net.rs | // Free Software under GPL-3.0, see LICENSE
// Copyright 2017 Bryan Newbold
extern crate clap;
extern crate env_logger;
#[macro_use]
extern crate error_chain;
extern crate geniza;
extern crate sodiumoxide;
// TODO: more careful import
use geniza::*;
use std::path::Path;
use clap::{App, SubCommand, Arg};
use sodiumoxi... | .arg_from_usage("<dat_key> 'dat key (public key) to lookup"),
)
.subcommand(
SubCommand::with_name("naive-clone")
.about("Pulls a drive from a single (known) peer, using a naive algorithm")
.arg(Arg::with_name("dat-dir")
.short("... | .subcommand(
SubCommand::with_name("discover-dns")
.about("Does a centralized DNS lookup for peers with the given key") | random_line_split |
geniza-net.rs | // Free Software under GPL-3.0, see LICENSE
// Copyright 2017 Bryan Newbold
extern crate clap;
extern crate env_logger;
#[macro_use]
extern crate error_chain;
extern crate geniza;
extern crate sodiumoxide;
// TODO: more careful import
use geniza::*;
use std::path::Path;
use clap::{App, SubCommand, Arg};
use sodiumoxi... |
("discover-dns", Some(subm)) => {
let dat_key = subm.value_of("dat_key").unwrap();
let key_bytes = parse_dat_address(&dat_key)?;
let peers = discover_peers_dns(&key_bytes)?;
if peers.len() == 0 {
println!("No peers found!");
} else {
... | {
let dat_key = subm.value_of("dat_key").unwrap();
let key_bytes = parse_dat_address(&dat_key)?;
let disc_key = make_discovery_key(&key_bytes);
for b in 0..20 {
print!("{:02x}", disc_key[b]);
}
println!(".dat.local");
} | conditional_block |
dispatcher.rs | use color_printer::ColorPrinter;
use command::{Command, WorkResult, WorkType};
use std::{collections::BTreeMap, sync::mpsc::Receiver};
use threadpool::ThreadPool;
const THREAD_SIGNAL: &str = "Could not signal main thread with WorkType::Work";
pub struct Dispatcher<'a> {
queue: BTreeMap<usize, Option<Box<dyn WorkR... | }
}
}
// Sanity check
if!self.queue.is_empty() {
panic!(
"There are {} unprocessed items in the queue. \
Did you forget to send WorkEmpty::WorkEmpty messages?",
self.queue.len()
);
}
... | // If there are adjacent items in the queue, process them.
self.process_queue(); | random_line_split |
dispatcher.rs | use color_printer::ColorPrinter;
use command::{Command, WorkResult, WorkType};
use std::{collections::BTreeMap, sync::mpsc::Receiver};
use threadpool::ThreadPool;
const THREAD_SIGNAL: &str = "Could not signal main thread with WorkType::Work";
pub struct Dispatcher<'a> {
queue: BTreeMap<usize, Option<Box<dyn WorkR... | (&mut self, rx: &Receiver<WorkType>) {
while let Ok(result) = rx.recv() {
match result {
WorkType::Repo { index, repo, tx } => {
let worker = self.command.box_clone();
self.pool.execute(move || {
let result = match worke... | run | identifier_name |
dispatcher.rs | use color_printer::ColorPrinter;
use command::{Command, WorkResult, WorkType};
use std::{collections::BTreeMap, sync::mpsc::Receiver};
use threadpool::ThreadPool;
const THREAD_SIGNAL: &str = "Could not signal main thread with WorkType::Work";
pub struct Dispatcher<'a> {
queue: BTreeMap<usize, Option<Box<dyn WorkR... |
WorkType::WorkEmpty { index } => {
if index == self.next_index {
self.process_queue();
} else {
self.queue.insert(index, None);
}
}
WorkType::Work { index, result ... | {
let worker = self.command.box_clone();
self.pool.execute(move || {
let result = match worker.process(repo) {
Some(r) => WorkType::result(index, r),
None => WorkType::empty(index),
... | conditional_block |
dispatcher.rs | use color_printer::ColorPrinter;
use command::{Command, WorkResult, WorkType};
use std::{collections::BTreeMap, sync::mpsc::Receiver};
use threadpool::ThreadPool;
const THREAD_SIGNAL: &str = "Could not signal main thread with WorkType::Work";
pub struct Dispatcher<'a> {
queue: BTreeMap<usize, Option<Box<dyn WorkR... |
}
| {
self.next_index += 1;
while let Some(result) = self.queue.remove(&self.next_index) {
if let Some(work_result) = result {
work_result.print(&mut self.printer);
}
self.next_index += 1;
}
} | identifier_body |
badge.rs | use krate::Crate;
use schema::badges;
use diesel::pg::Pg;
use diesel::prelude::*;
use serde_json;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case", tag = "badge_type", content = "attributes")]
pub enum Badge {
TravisCi {
repository... | pub struct EncodableBadge {
pub badge_type: String,
pub attributes: HashMap<String, Option<String>>,
}
impl Queryable<badges::SqlType, Pg> for Badge {
type Row = (i32, String, serde_json::Value);
fn build((_, badge_type, attributes): Self::Row) -> Self {
let json = json!({"badge_type": badge_t... | LookingForMaintainer,
Deprecated,
}
#[derive(PartialEq, Debug, Serialize, Deserialize)] | random_line_split |
badge.rs | use krate::Crate;
use schema::badges;
use diesel::pg::Pg;
use diesel::prelude::*;
use serde_json;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case", tag = "badge_type", content = "attributes")]
pub enum Badge {
TravisCi {
repository... | <'a>(
conn: &PgConnection,
krate: &Crate,
badges: Option<&'a HashMap<String, HashMap<String, String>>>,
) -> QueryResult<Vec<&'a str>> {
use diesel::{insert, delete};
#[derive(Insertable, Debug)]
#[table_name = "badges"]
struct NewBadge<'a> {
crat... | update_crate | identifier_name |
badge.rs | use krate::Crate;
use schema::badges;
use diesel::pg::Pg;
use diesel::prelude::*;
use serde_json;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case", tag = "badge_type", content = "attributes")]
pub enum Badge {
TravisCi {
repository... | else {
invalid_badges.push(&**k);
}
}
}
conn.transaction(|| {
delete(badges::table.filter(badges::crate_id.eq(krate.id)))
.execute(conn)?;
insert(&new_badges).into(badges::table).execute(conn)?;
Ok(inval... | {
new_badges.push(NewBadge {
crate_id: krate.id,
badge_type: &**k,
attributes: attributes_json,
});
} | conditional_block |
cssrulelist.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::CSSRuleListBinding;
use dom::bindings::... | (&self, index: u32) -> Option<Root<CSSRule>> {
self.Item(index)
}
}
| IndexedGetter | identifier_name |
cssrulelist.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::CSSRuleListBinding;
use dom::bindings::... |
// In case of a keyframe rule, index must be valid.
pub fn remove_rule(&self, index: u32) -> ErrorResult {
let index = index as usize;
match self.rules {
RulesSource::Rules(ref css_rules) => {
css_rules.write().remove_rule(index)?;
let mut dom_rules... | {
let css_rules = if let RulesSource::Rules(ref rules) = self.rules {
rules
} else {
panic!("Called insert_rule on non-CssRule-backed CSSRuleList");
};
let global = self.global();
let window = global.as_window();
let index = idx as usize;
... | identifier_body |
cssrulelist.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::CSSRuleListBinding;
use dom::bindings::... | let global = self.global();
let window = global.as_window();
let index = idx as usize;
let parent_stylesheet = self.parent_stylesheet.style_stylesheet();
let new_rule = css_rules.write().insert_rule(rule, parent_stylesheet, index, nested)?;
let parent_stylesheet = &*sel... | random_line_split | |
tcp.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 ... | (c::WSAEVENT);
unsafe impl Send for Event {}
unsafe impl Sync for Event {}
impl Event {
pub fn new() -> IoResult<Event> {
let event = unsafe { c::WSACreateEvent() };
if event == c::WSA_INVALID_EVENT {
Err(super::last_error())
} else {
Ok(Event(event))
}
... | Event | identifier_name |
tcp.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 ... |
}
| {
TcpAcceptor {
inner: self.inner.clone(),
deadline: 0,
}
} | identifier_body |
tcp.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 ret = unsafe {
c::WSAEventSelect(socket, events[1], 0)
};
if ret!= 0 { return Err(last_net_error()) }
set_nonblocking(socket, false);
return Ok(stream)
}
}
... | // so we need to deregister our event and switch the socket back
// to blocking mode
socket => {
let stream = TcpStream::new(socket); | random_line_split |
card.rs |
use game_state::GameState;
use minion_card::UID;
use client_option::{OptionGenerator, ClientOption, OptionType};
use tags_list::TARGET;
use controller::Controller;
use hlua;
#[derive(Copy, Clone)]
#[allow(dead_code)]
pub enum ECardType {
Minion,
Spell,
Weapon,
}
#[derive(Clone)]
pub struct Card {
cost... |
pub fn get_content(&self) -> String {
self.content.clone()
}
// fn set_cost(&mut self, cost: u16){
// self.cost = cost;
// }
//
// fn set_uid(&mut self, uid: String){
// self.uid = uid;
// }
//
// fn set_name(&mut self, name: String){
// self.name = name;
/... | {
self.id.clone()
} | identifier_body |
card.rs |
use game_state::GameState;
use minion_card::UID;
use client_option::{OptionGenerator, ClientOption, OptionType};
use tags_list::TARGET;
use controller::Controller;
use hlua;
#[derive(Copy, Clone)]
#[allow(dead_code)]
pub enum ECardType {
Minion,
Spell,
Weapon,
}
#[derive(Clone)]
pub struct Card {
cost... | (&self) -> u32 {
self.uid.clone()
}
pub fn _get_name(&self) -> String {
self.name.clone()
}
pub fn get_card_type(&self) -> ECardType {
self.card_type
}
pub fn _get_id(&self) -> String {
self.id.clone()
}
pub fn get_content(&self) -> String {
se... | get_uid | identifier_name |
card.rs | use game_state::GameState;
use minion_card::UID;
use client_option::{OptionGenerator, ClientOption, OptionType};
use tags_list::TARGET;
use controller::Controller;
use hlua;
#[derive(Copy, Clone)]
#[allow(dead_code)]
pub enum ECardType {
Minion, | Weapon,
}
#[derive(Clone)]
pub struct Card {
cost: u8,
card_type: ECardType,
id: String,
uid: UID,
name: String,
// for play minion cards this is the uid of the minion
// for spells this is the rhai file that executes the spell
content: String,
}
impl Card {
pub fn new(cost: u8... | Spell, | random_line_split |
mem.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... | /// one field of a struct by replacing it with another value. The normal approach
/// doesn't always work:
///
/// ```rust,ignore
/// struct Buffer<T> { buf: Vec<T> }
///
/// impl<T> Buffer<T> {
/// fn get_and_reset(&mut self) -> Vec<T> {
/// // error: cannot move out of dereference of `&mut`-pointer
/// ... | /// in a mutable location. For example, this function allows consumption of | random_line_split |
mem.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... | <T>() -> uint {
unsafe { intrinsics::size_of::<T>() }
}
/// Returns the size of the type that `_val` points to in bytes.
#[inline]
#[stable]
pub fn size_of_val<T>(_val: &T) -> uint {
size_of::<T>()
}
/// Returns the ABI-required minimum alignment of a type
///
/// This is the alignment used for struct fields.... | size_of | identifier_name |
mem.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... |
/// Disposes of a value.
///
/// This function can be used to destroy any value by allowing `drop` to take
/// ownership of its argument.
///
/// # Example
///
/// ```
/// use std::cell::RefCell;
///
/// let x = RefCell::new(1i);
///
/// let mut mutable_borrow = x.borrow_mut();
/// *mutable_borrow = 1;
/// drop(mutab... | {
swap(dest, &mut src);
src
} | identifier_body |
dump.rs | use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io;
use std::mem;
use std::net::{IpAddr, SocketAddr};
extern crate flate2;
use flate2::read::ZlibDecoder;
extern crate netflowv9;
use netflowv9::*;
fn main() {
let stdout = io::stdout();
let mut out = stdout.loc... | .map(|ip| IpAddr::V6(ip.into()))).unwrap();
let destination_ip = rec.destination_ipv4_address()
.map(|ip| IpAddr::V4(ip.into()))
.or(rec.destination_ipv6_address()
.map(|ip| IpAddr::V6(ip.into()))).unwrap();
// let packet_time = header.seconds() as u64 * 1000;
// let sys... | {
let strbuf: String;
let protocol_name = match rec.protocol_identifier() {
Some(1) => "ICMP",
Some(4) => "IPIP",
Some(6) => "TCP",
Some(17) => "UDP",
Some(41) => "IP6IP",
Some(47) => "GRE",
Some(50) => "ESP",
Some(58) => "ICMP",
Some(n... | identifier_body |
dump.rs | use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io;
use std::mem;
use std::net::{IpAddr, SocketAddr};
extern crate flate2;
use flate2::read::ZlibDecoder;
extern crate netflowv9;
use netflowv9::*;
fn | () {
let stdout = io::stdout();
let mut out = stdout.lock();
for arg in env::args().skip(1) {
match File::open(&arg) {
Ok(ref mut file) => dump_file(&mut out, file),
Err(err) => writeln!(out, "Could not open {}: {}", arg, err).unwrap()
}
}
}
fn dump_file<F,W>(mut... | main | identifier_name |
dump.rs | use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io;
use std::mem;
use std::net::{IpAddr, SocketAddr};
extern crate flate2;
use flate2::read::ZlibDecoder;
extern crate netflowv9;
use netflowv9::*;
fn main() {
let stdout = io::stdout();
let mut out = stdout.loc... | //println!("raw template: {:?}", &template_raw[..]);
let template: DataTemplate = DataTemplate {
template_id: template_id,
field_count: (template_length / 4) as u16,
fields: TemplateFieldIter { raw: &template_raw[..]}
};
ext... | writeln!(out, "template_id: {}, template_length: {}", template_id, template_length).unwrap();
let mut template_raw = Vec::with_capacity(template_length);
file.take(template_length as u64).read_to_end(&mut template_raw).unwrap(); | random_line_split |
dump.rs | use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io;
use std::mem;
use std::net::{IpAddr, SocketAddr};
extern crate flate2;
use flate2::read::ZlibDecoder;
extern crate netflowv9;
use netflowv9::*;
fn main() {
let stdout = io::stdout();
let mut out = stdout.loc... | else {
break;
}
}
}
fn print_record<W>(w: &mut W, rec: &Record) where W: Write {
let strbuf: String;
let protocol_name = match rec.protocol_identifier() {
Some(1) => "ICMP",
Some(4) => "IPIP",
Some(6) => "TCP",
Some(17) => "UDP",
Some(41) => ... | {
records.read_exact(&mut len[..]).unwrap();
let template_id = unsafe { mem::transmute::<[u8;2], u16>(tid).to_be()};
let record_length = unsafe { mem::transmute::<[u8;2], u16>(len).to_be() as usize};
records.read_exact(&mut buf[..record_length]).unwrap();
// p... | conditional_block |
more-gates.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 ... |
#[proc_macro_attribute]
pub fn attr2mac2(_: TokenStream, _: TokenStream) -> TokenStream {
"macro foo2(a) { a }".parse().unwrap()
}
#[proc_macro]
pub fn mac2mac1(_: TokenStream) -> TokenStream {
"macro_rules! foo3 { (a) => (a) }".parse().unwrap()
}
#[proc_macro]
pub fn mac2mac2(_: TokenStream) -> TokenStream... | {
"macro_rules! foo1 { (a) => (a) }".parse().unwrap()
} | identifier_body |
more-gates.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 ... | (_: TokenStream) -> TokenStream {
"macro foo4(a) { a }".parse().unwrap()
}
#[proc_macro]
pub fn tricky(_: TokenStream) -> TokenStream {
"fn foo() {
macro_rules! foo { (a) => (a) }
}".parse().unwrap()
}
| mac2mac2 | identifier_name |
more-gates.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 ... | "macro_rules! foo1 { (a) => (a) }".parse().unwrap()
}
#[proc_macro_attribute]
pub fn attr2mac2(_: TokenStream, _: TokenStream) -> TokenStream {
"macro foo2(a) { a }".parse().unwrap()
}
#[proc_macro]
pub fn mac2mac1(_: TokenStream) -> TokenStream {
"macro_rules! foo3 { (a) => (a) }".parse().unwrap()
}
#[p... |
#[proc_macro_attribute]
pub fn attr2mac1(_: TokenStream, _: TokenStream) -> TokenStream { | random_line_split |
framerate.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 actor::{Actor, ActorMessageStatus, ActorRegistry};
use actors::timeline::HighResolutionStamp;
use devtools_tra... |
fn stop_recording(&mut self) {
if!self.is_recording {
return;
}
self.is_recording = false;
self.start_time = None;
}
}
impl Drop for FramerateActor {
fn drop(&mut self) {
self.stop_recording();
}
}
| {
if self.is_recording {
return;
}
self.start_time = Some(precise_time_ns());
self.is_recording = true;
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline,
self.name());
sel... | identifier_body |
framerate.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 actor::{Actor, ActorMessageStatus, ActorRegistry};
use actors::timeline::HighResolutionStamp;
use devtools_tra... | (&self) -> String {
self.name.clone()
}
fn handle_message(&self,
_registry: &ActorRegistry,
_msg_type: &str,
_msg: &json::Object,
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(ActorMessage... | name | identifier_name |
framerate.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 actor::{Actor, ActorMessageStatus, ActorRegistry};
use actors::timeline::HighResolutionStamp;
use devtools_tra... |
self.start_time = Some(precise_time_ns());
self.is_recording = true;
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline,
self.name());
self.script_sender.send(msg).unwrap();
}
fn stop_recordi... | {
return;
} | conditional_block |
framerate.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 actor::{Actor, ActorMessageStatus, ActorRegistry};
use actors::timeline::HighResolutionStamp;
use devtools_tra... | let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline,
self.name());
self.script_sender.send(msg).unwrap();
}
}
pub fn take_pending_ticks(&mut self) -> Vec<HighResolutionStamp> {
mem::r... | random_line_split | |
extra-unused-mut.rs | // extra unused mut lint tests for #51918
// check-pass
#![feature(generators, nll)]
#![deny(unused_mut)]
fn ref_argument(ref _y: i32) {}
// #51801
fn mutable_upvar() {
let mut x = 0;
move || {
x = 1;
};
} | x = 1;
yield;
};
}
// #51830
fn ref_closure_argument() {
let _ = Some(0).as_ref().map(|ref _a| true);
}
struct Expr {
attrs: Vec<u32>,
}
// #51904
fn parse_dot_or_call_expr_with(mut attrs: Vec<u32>) {
let x = Expr { attrs: vec![] };
Some(Some(x)).map(|expr|
expr.map(|mut e... |
// #50897
fn generator_mutable_upvar() {
let mut x = 0;
move || { | random_line_split |
extra-unused-mut.rs | // extra unused mut lint tests for #51918
// check-pass
#![feature(generators, nll)]
#![deny(unused_mut)]
fn ref_argument(ref _y: i32) {}
// #51801
fn mutable_upvar() {
let mut x = 0;
move || {
x = 1;
};
}
// #50897
fn generator_mutable_upvar() {
let mut x = 0;
move || {
x = 1;
... |
// #59620
fn nested_closures() {
let mut i = 0;
[].iter().for_each(|_: &i32| {
[].iter().for_each(move |_: &i32| {
i += 1;
});
});
}
fn main() {}
| {
match x {
Ok(mut r) | Err(mut r) if true => r = 1,
_ => (),
}
} | identifier_body |
extra-unused-mut.rs | // extra unused mut lint tests for #51918
// check-pass
#![feature(generators, nll)]
#![deny(unused_mut)]
fn ref_argument(ref _y: i32) {}
// #51801
fn mutable_upvar() {
let mut x = 0;
move || {
x = 1;
};
}
// #50897
fn generator_mutable_upvar() {
let mut x = 0;
move || {
x = 1;
... | (x: Result<i32, i32>) {
match x {
Ok(mut r) | Err(mut r) if true => r = 1,
_ => (),
}
}
// #59620
fn nested_closures() {
let mut i = 0;
[].iter().for_each(|_: &i32| {
[].iter().for_each(move |_: &i32| {
i += 1;
});
});
}
fn main() {}
| if_guard | identifier_name |
trait-bounds-in-arc.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... | (&self) -> bool {
self.bark_decibels < 70 || self.tricks_known > 20
}
}
impl Pet for Goldfyshe {
fn name(&self, blk: |&str|) { blk(self.name.as_slice()) }
fn num_legs(&self) -> uint { 0 }
fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
}
pub fn main() {
let catte = Catte { num... | of_good_pedigree | identifier_name |
trait-bounds-in-arc.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... | bark_decibels: uint,
tricks_known: uint,
name: String,
}
struct Goldfyshe {
swim_speed: uint,
name: String,
}
impl Pet for Catte {
fn name(&self, blk: |&str|) { blk(self.name.as_slice()) }
fn num_legs(&self) -> uint { 4 }
fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 }
}
... | }
struct Dogge { | random_line_split |
trait-bounds-in-arc.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... |
fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
}
pub fn main() {
let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_string() };
let dogge1 = Dogge {
bark_decibels: 100,
tricks_known: 42,
name: "alan_turing".to_string(),
};
let dogge2 = Dogge {
... | { 0 } | identifier_body |
channel_dao_testing.rs | extern crate proton_cli;
use proton_cli::dao::ChannelDao;
use proton_cli::error::Error;
use proton_cli::project_types::Channel;
/// Implementation of ChannelDao for testing purposes. Uses given functions to return values.
/// Functions are boxed so their sizes are known (pointers).
/// The general naming convention ... | (
&self,
name: &str,
primary_num: Option<u32>,
secondary_num: Option<u32>,
color: &str,
channel_internal: u32,
channel_dmx: u32,
location: (Option<i32>, Option<i32>, Option<i32>),
rotation: (Option<i32>, Option<i32>, Option<i32>)
) -> Result<Ch... | new_channel | identifier_name |
channel_dao_testing.rs | extern crate proton_cli;
use proton_cli::dao::ChannelDao; |
/// Implementation of ChannelDao for testing purposes. Uses given functions to return values.
/// Functions are boxed so their sizes are known (pointers).
/// The general naming convention used is trait_function_name_fn, for all trait functions.
/// &str references are converted to Strings so we don't have to deal wit... | use proton_cli::error::Error;
use proton_cli::project_types::Channel;
| random_line_split |
tag-align-shape.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | t: a_tag
}
pub fn main() {
let x = t_rec {c8: 22u8, t: a_tag(44u64)};
let y = fmt!("%?", x);
info!("y = %s", y);
assert_eq!(y, ~"t_rec{c8: 22u8, t: a_tag(44u64)}");
} |
struct t_rec {
c8: u8, | random_line_split |
tag-align-shape.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let x = t_rec {c8: 22u8, t: a_tag(44u64)};
let y = fmt!("%?", x);
info!("y = %s", y);
assert_eq!(y, ~"t_rec{c8: 22u8, t: a_tag(44u64)}");
}
| main | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A simple application that uses glutin to open a window for Servo to display in.
#![feature(box_syntax, result... |
pub trait NestedEventLoopListener {
fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool;
}
pub fn create_window(parent: WindowID) -> Rc<Window> {
// Read command-line options.
let opts = opts::get();
let foreground = opts.output_file.is_none();
let scale_factor = ScaleFac... | pub type WindowID = glutin::WindowID; | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A simple application that uses glutin to open a window for Servo to display in.
#![feature(box_syntax, result... | (parent: WindowID) -> Rc<Window> {
// Read command-line options.
let opts = opts::get();
let foreground = opts.output_file.is_none();
let scale_factor = ScaleFactor::new(opts.device_pixels_per_px.unwrap_or(1.0));
let size = opts.initial_window_size.as_f32() * scale_factor;
// Open a window.
... | create_window | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A simple application that uses glutin to open a window for Servo to display in.
#![feature(box_syntax, result... | {
// Read command-line options.
let opts = opts::get();
let foreground = opts.output_file.is_none();
let scale_factor = ScaleFactor::new(opts.device_pixels_per_px.unwrap_or(1.0));
let size = opts.initial_window_size.as_f32() * scale_factor;
// Open a window.
Window::new(foreground, size.as_... | identifier_body | |
media_queries.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/. */
//! [Media queries][mq].
//!
//! [mq]: https://drafts.csswg.org/mediaqueries/
use Atom;
use context::QuirksMode;
... | fn parse(name: &str) -> Result<Self, ()> {
// From https://drafts.csswg.org/mediaqueries/#mq-syntax:
//
// The <media-type> production does not include the keywords not, or, and, and only.
//
// Here we also perform the to-ascii-lowercase part of the serialization
/... | /// The `print` media type.
pub fn print() -> Self {
MediaType(CustomIdent(atom!("print")))
}
| random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.