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 |
|---|---|---|---|---|
htmlmodelement.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::HTMLModElementBinding;
use dom::bindings::js::Root;
use dom::bindings::str::... |
#[allow(unrooted_must_root)]
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLModElement> {
Node::reflect_node(box HTMLModElement::new_inherited(localName, prefix, document),
document,
... | {
HTMLModElement {
htmlelement:
HTMLElement::new_inherited(localName, prefix, document)
}
} | identifier_body |
htmlmodelement.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 |
use dom::bindings::codegen::Bindings::HTMLModElementBinding;
use dom::bindings::js::Root;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use string_cache::Atom;
#[dom_struct]
pub struct HTMLModElement {
htmlelement: HTMLElement
}
impl HTMLM... | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | random_line_split |
expr-block-generic-box1.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 ... |
test_generic::<bool>(@true, compare_box);
}
pub fn main() { test_box(); }
| {
info!(*b1);
info!(*b2);
return *b1 == *b2;
} | identifier_body |
expr-block-generic-box1.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// -*- rust -*-
... | // http://rust-lang.org/COPYRIGHT.
// | random_line_split |
expr-block-generic-box1.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 ... | () {
fn compare_box(b1: @bool, b2: @bool) -> bool {
info!(*b1);
info!(*b2);
return *b1 == *b2;
}
test_generic::<bool>(@true, compare_box);
}
pub fn main() { test_box(); }
| test_box | identifier_name |
mod.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | /// let mut items = vec!(Weighted { weight: 2, item: 'a' },
/// Weighted { weight: 4, item: 'b' },
/// Weighted { weight: 1, item: 'c' });
/// let wc = WeightedChoice::new(items.as_mut_slice());
/// let mut rng = rand::task_rng();
/// for _ in range(0u, 16) {
/// // on ave... | random_line_split | |
mod.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 ... | <R: Rng>(&mut self, rng: &mut R) -> T { self.ind_sample(rng) }
}
impl<'a, T: Clone> IndependentSample<T> for WeightedChoice<'a, T> {
fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
// we want to find the first element that has cumulative
// weight > sample_weight, which we do by binary since the
... | sample | identifier_name |
mod.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 ... | // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i])
if test_x < x_tab[i + 1] {
return x;
}
if i == 0 {
return zero_case(rng, u);
}
// algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
if f_tab[i + 1] +... | {
static SCALE: f64 = (1u64 << 53) as f64;
loop {
// reimplement the f64 generation as an optimisation suggested
// by the Doornik paper: we have a lot of precision-space
// (i.e. there are 11 bits of the 64 of a u64 to use after
// creating a f64), so we might as well reuse some... | identifier_body |
fn-single-line.rs | // rustfmt-fn_single_line: true
// rustfmt-emit_mode: checkstyle
// Test single-line functions.
fn foo_expr() {
1
}
fn foo_stmt() {
foo();
}
fn foo_decl_local() {
let z = 5;
}
fn foo_decl_item(x: &mut i32) {
x = 3;
}
fn empty() {
}
fn foo_return() -> String {
"yay"
}
fn foo_whe... |
fn fooblock() {
{
"inner-block"
}
}
fn fooblock2(x: i32) {
let z = match x {
_ => 2,
};
}
fn comment() {
// this is a test comment
1
}
fn comment2() {
// multi-line comment
let z = 2;
1
}
fn only_comment() {
// Keep this here
}
fn aaaaaaaaaaaaaaaaa_looooooo... | {
let x = 2;
} | identifier_body |
fn-single-line.rs | // rustfmt-fn_single_line: true
// rustfmt-emit_mode: checkstyle
// Test single-line functions.
fn foo_expr() {
1
}
fn foo_stmt() {
foo();
}
fn foo_decl_local() {
let z = 5;
}
fn foo_decl_item(x: &mut i32) {
x = 3;
}
fn empty() {
}
fn foo_return() -> String { | }
fn foo_where() -> T where T: Sync {
let x = 2;
}
fn fooblock() {
{
"inner-block"
}
}
fn fooblock2(x: i32) {
let z = match x {
_ => 2,
};
}
fn comment() {
// this is a test comment
1
}
fn comment2() {
// multi-line comment
let z = 2;
1
}
fn only_comment() {... | "yay" | random_line_split |
fn-single-line.rs | // rustfmt-fn_single_line: true
// rustfmt-emit_mode: checkstyle
// Test single-line functions.
fn foo_expr() {
1
}
fn foo_stmt() {
foo();
}
fn foo_decl_local() {
let z = 5;
}
fn foo_decl_item(x: &mut i32) {
x = 3;
}
fn empty() {
}
fn foo_return() -> String {
"yay"
}
fn foo_whe... | () {
1
}
fn mac() -> Vec<i32> { vec![] }
trait CoolTypes {
fn dummy(&self) {
}
}
trait CoolerTypes { fn dummy(&self) {
}
}
fn Foo<T>() where T: Bar {
}
| lots_of_space | identifier_name |
core-uint-to-str.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 args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"10000000"]
} else if args.len() <= 1u {
~[~"", ~"100000"]
} else {
args
};
let n = from_str::<uint>(args[1]).unwrap();
for i in range(0u, n) {
let x = i.to_str();
... | main | identifier_name |
core-uint-to-str.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 | use std::os;
use std::uint;
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"10000000"]
} else if args.len() <= 1u {
~[~"", ~"100000"]
} else {
args
};
let n = from_str::<uint>(args[1]).unwrap();
for i in range(0u, n) {... | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
| random_line_split |
core-uint-to-str.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 args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"10000000"]
} else if args.len() <= 1u {
~[~"", ~"100000"]
} else {
args
};
let n = from_str::<uint>(args[1]).unwrap();
for i in range(0u, n) {
let x = i.to_str();
in... | identifier_body | |
core-uint-to-str.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 ... | else {
args
};
let n = from_str::<uint>(args[1]).unwrap();
for i in range(0u, n) {
let x = i.to_str();
info!(x);
}
}
| {
~[~"", ~"100000"]
} | conditional_block |
nested-patterns.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 ... | () {
match A {a: 10, b: @20} {
x@A {a, b: @20} => { assert!(x.a == 10); assert!(a == 10); }
A {b: _b, _} => { fail!(); }
}
let mut x@B {b, _} = B {a: 10, b: C {c: 20}};
x.b.c = 30;
assert_eq!(b.c, 20);
let mut y@D {d, _} = D {a: 10, d: C {c: 20}};
y.d.c = 30;
assert_eq!(d... | main | identifier_name |
nested-patterns.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 | // option. This file may not be copied, modified, or distributed
// except according to those terms.
struct A { a: int, b: @int }
struct B { a: int, b: C }
struct D { a: int, d: C }
struct C { c: int }
pub fn main() {
match A {a: 10, b: @20} {
x@A {a, b: @20} => { assert!(x.a == 10); assert!(a == 10); }
... | // 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 |
trait-inheritance-call-bound-inherited.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 a = &A { x: 3 };
assert_eq!(gg(a), 10);
} | identifier_body | |
trait-inheritance-call-bound-inherited.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&self) -> isize { 20 } }
// Call a function on Foo, given a T: Bar
fn gg<T:Bar>(a: &T) -> isize {
a.f()
}
pub fn main() {
let a = &A { x: 3 };
assert_eq!(gg(a), 10);
}
| g | identifier_name |
trait-inheritance-call-bound-inherited.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 a = &A { x: 3 };
assert_eq!(gg(a), 10);
} | fn gg<T:Bar>(a: &T) -> isize {
a.f()
}
| random_line_split |
image_private.rs | extern crate image;
extern crate itertools;
extern crate walkdir;
pub(crate) trait CifarImageTrait {
fn new(bytes: &[u8]) -> Result<super::image_pub::CifarImage, ::std::io::Error>;
}
impl CifarImageTrait for super::image_pub::CifarImage {
fn new(bytes: &[u8]) -> Result<Self, ::std::io::Error> {
use st... | let label: u8 = unsafe {
let label: &mut [u8; 1] = &mut mem::uninitialized();
bytes.read_exact(label)?;
*label.get_unchecked(0)
};
let img = unsafe {
let mut img = image::DynamicImage::new_rgb8(32, 32);
let red: &mut [u8; 1024] = &mut m... | use std::mem;
use self::image::GenericImage;
use self::itertools::multizip;
use self::itertools::Itertools;
let bytes: &mut &[u8] = &mut bytes.as_ref(); | random_line_split |
image_private.rs | extern crate image;
extern crate itertools;
extern crate walkdir;
pub(crate) trait CifarImageTrait {
fn new(bytes: &[u8]) -> Result<super::image_pub::CifarImage, ::std::io::Error>;
}
impl CifarImageTrait for super::image_pub::CifarImage {
fn new(bytes: &[u8]) -> Result<Self, ::std::io::Error> | multizip((
(0..32).cartesian_product(0..32),
red.iter(),
green.iter(),
blue.iter(),
)).for_each(|((y, x), r, g, b)| {
let mut pixel: image::Rgba<u8> = mem::uninitialized();
pixel.data = [*r, *g, *b, 2... | {
use std::io::Read;
use std::mem;
use self::image::GenericImage;
use self::itertools::multizip;
use self::itertools::Itertools;
let bytes: &mut &[u8] = &mut bytes.as_ref();
let label: u8 = unsafe {
let label: &mut [u8; 1] = &mut mem::uninitialized();
... | identifier_body |
image_private.rs | extern crate image;
extern crate itertools;
extern crate walkdir;
pub(crate) trait CifarImageTrait {
fn new(bytes: &[u8]) -> Result<super::image_pub::CifarImage, ::std::io::Error>;
}
impl CifarImageTrait for super::image_pub::CifarImage {
fn | (bytes: &[u8]) -> Result<Self, ::std::io::Error> {
use std::io::Read;
use std::mem;
use self::image::GenericImage;
use self::itertools::multizip;
use self::itertools::Itertools;
let bytes: &mut &[u8] = &mut bytes.as_ref();
let label: u8 = unsafe {
let ... | new | identifier_name |
openbsd_base.rs | // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
TargetOptions {
linker: "cc".to_string(),
dynamic_linking: true,
executables: true,
morestack: false,
linker_is_gnu: true,
has_rpath: true,
pre_link_args: vec!(
// GNU-style linkers will use this to omit linking to libraries
// which ... | identifier_body | |
openbsd_base.rs | // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () -> TargetOptions {
TargetOptions {
linker: "cc".to_string(),
dynamic_linking: true,
executables: true,
morestack: false,
linker_is_gnu: true,
has_rpath: true,
pre_link_args: vec!(
// GNU-style linkers will use this to omit linking to libraries
... | opts | identifier_name |
openbsd_base.rs | // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | has_rpath: true,
pre_link_args: vec!(
// GNU-style linkers will use this to omit linking to libraries
// which don't actually fulfill any relocations, but only for
// libraries which follow this flag. Thus, use it before
// specifying libraries to link to... | executables: true,
morestack: false,
linker_is_gnu: true, | random_line_split |
lint-dead-code-2.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 ... | }
// this is not main
fn main() { //~ ERROR: function is never used
dead_fn();
dead_fn2();
} | random_line_split | |
lint-dead-code-2.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 ... | () {}
#[start]
fn start(_: int, _: *const *const u8) -> int {
used_fn();
let foo = Foo;
foo.bar2();
0
}
// this is not main
fn main() { //~ ERROR: function is never used
dead_fn();
dead_fn2();
}
| used_fn | identifier_name |
main.rs | extern crate syscall;
use std::fs::File;
use std::io::{Read, Write};
use std::str;
use syscall::{Packet, Result, Scheme};
struct ExampleScheme;
impl Scheme for ExampleScheme {
fn open(&self, path: &[u8], _flags: usize, uid: u32, gid: u32) -> Result<usize> {
println!("{} from {}:{}", unsafe { str::from_u... |
}
| {
let mut socket = File::create(":example").expect("example: failed to create example scheme");
let scheme = ExampleScheme;
loop {
let mut packet = Packet::default();
socket.read(&mut packet).expect("example: failed to read events from example scheme");
printl... | conditional_block |
main.rs | extern crate syscall;
use std::fs::File;
use std::io::{Read, Write};
use std::str;
use syscall::{Packet, Result, Scheme};
struct ExampleScheme;
impl Scheme for ExampleScheme {
fn open(&self, path: &[u8], _flags: usize, uid: u32, gid: u32) -> Result<usize> {
println!("{} from {}:{}", unsafe { str::from_u... | }
fn close(&self, _file: usize) -> Result<usize> {
Ok(0)
}
}
fn main(){
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
let mut socket = File::create(":example").expect("example: failed to create example scheme");
let scheme = ExampleScheme;
loop {
... | fn dup(&self, file: usize, _buf: &[u8]) -> Result<usize> {
Ok(file) | random_line_split |
main.rs | extern crate syscall;
use std::fs::File;
use std::io::{Read, Write};
use std::str;
use syscall::{Packet, Result, Scheme};
struct ExampleScheme;
impl Scheme for ExampleScheme {
fn open(&self, path: &[u8], _flags: usize, uid: u32, gid: u32) -> Result<usize> |
fn dup(&self, file: usize, _buf: &[u8]) -> Result<usize> {
Ok(file)
}
fn close(&self, _file: usize) -> Result<usize> {
Ok(0)
}
}
fn main(){
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
let mut socket = File::create(":example").expect("example: failed t... | {
println!("{} from {}:{}", unsafe { str::from_utf8_unchecked(path) }, uid, gid);
Ok(0)
} | identifier_body |
main.rs | extern crate syscall;
use std::fs::File;
use std::io::{Read, Write};
use std::str;
use syscall::{Packet, Result, Scheme};
struct ExampleScheme;
impl Scheme for ExampleScheme {
fn open(&self, path: &[u8], _flags: usize, uid: u32, gid: u32) -> Result<usize> {
println!("{} from {}:{}", unsafe { str::from_u... | (){
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
let mut socket = File::create(":example").expect("example: failed to create example scheme");
let scheme = ExampleScheme;
loop {
let mut packet = Packet::default();
socket.read(&mut packet).expect("e... | main | identifier_name |
console_play.rs | use clap::App;
use std::default::Default;
use thud_game;
use thud_ui_common;
use thud_ui_console;
fn main() | .version("0.1.0")
.author("Stu Black <trurl@freeshell.org>")
.about("Play Thud on the console"),
&[
thud_ui_common::FLAG_INITIAL_BOARD,
thud_ui_common::FLAG_INITIAL_PLAYER,
thud_ui_common::FLAG_LOG_LEVEL,
],
);
app = agents.register_args(app);
app.get... | {
let mut agents = thud_ui_common::agent_registry::AgentRegistry::new();
agents
.register(Box::new(
thud_ui_common::agent_registry::StdinAgentBuilder::new(),
))
.register(Box::new(
thud_ui_common::agent_registry::mcts::MctsAgentBuilder::new("mcts1"),
))
.register(Box::new(
thud... | identifier_body |
console_play.rs | use clap::App;
use std::default::Default;
use thud_game;
use thud_ui_common;
use thud_ui_console;
fn main() {
let mut agents = thud_ui_common::agent_registry::AgentRegistry::new();
agents
.register(Box::new(
thud_ui_common::agent_registry::StdinAgentBuilder::new(),
))
.register(Box::new(
thud... | );
app = agents.register_args(app);
app.get_matches()
};
let initial_cells = match matches
.value_of(thud_ui_common::FLAG_INITIAL_BOARD)
.map(|x| x.parse::<thud_ui_common::InitialBoard>())
{
None => thud_game::board::Cells::default(),
Some(Ok(x)) => x.cells(),
Some(Err(e)) => panic!(... | random_line_split | |
console_play.rs | use clap::App;
use std::default::Default;
use thud_game;
use thud_ui_common;
use thud_ui_console;
fn | () {
let mut agents = thud_ui_common::agent_registry::AgentRegistry::new();
agents
.register(Box::new(
thud_ui_common::agent_registry::StdinAgentBuilder::new(),
))
.register(Box::new(
thud_ui_common::agent_registry::mcts::MctsAgentBuilder::new("mcts1"),
))
.register(Box::new(
thud... | main | identifier_name |
tab.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/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d... | {
from: String,
__type__: String,
threadActor: String,
cacheDisabled: bool,
javascriptEnabled: bool,
traits: TabTraits,
}
#[derive(RustcEncodable)]
struct TabDetachedReply {
from: String,
__type__: String,
}
#[derive(RustcEncodable)]
struct ReconfigureReply {
from: String
}
#[der... | TabAttachedReply | identifier_name |
tab.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/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d... |
//FIXME: The current implementation won't work for multiple connections. Need to ensure 105
// that the correct stream is removed.
"detach" => {
let msg = TabDetachedReply {
from: self.name(),
__type__: "detached".to_str... | {
let msg = TabAttachedReply {
from: self.name(),
__type__: "tabAttached".to_string(),
threadActor: self.name(),
cacheDisabled: false,
javascriptEnabled: true,
traits: TabTraits,
... | conditional_block |
tab.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/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d... | inspectorActor: self.inspector.clone(),
timelineActor: self.timeline.clone(),
}
}
} | actor: self.name(),
title: self.title.clone(),
url: self.url.clone(),
outerWindowID: 0, //FIXME: this should probably be the pipeline id
consoleActor: self.console.clone(), | random_line_split |
tab.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/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d... |
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &str,
_msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type {
"reconfigure" => {
stream.write_json... | {
self.name.clone()
} | identifier_body |
lib.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2020 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 F... | } | random_line_split | |
lib.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2020 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 F... | (rt: Runtime) -> Result<()> {
if let Some(command) = rt.cli().subcommand_name() {
debug!("Call: {}", command);
match command.deref() {
"create" => create(&rt),
"delete" => delete(&rt),
"get" => get(&rt),
"retrieve" ... | run | identifier_name |
lib.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2020 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 F... | else {
Err(anyhow!("Subcommand failed"))
}
},
}
} else {
Err(anyhow!("No command"))
}
}
fn build_cli<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
ui::build_ui(app)
}
fn name() -> &'static str {
... | {
Ok(())
} | conditional_block |
lib.rs | // =================================================================
//
// * WARNING *
//
// This file is generated!
//
// Changes made to this file will be overwritten. If changes are
// required to the generated code, the service_crategen project
// must be updated to g... | pub use generated::*; | mod generated;
pub use custom::*; | random_line_split |
is_empty.rs | use malachite_base_test_util::bench::bucketers::rational_sequence_len_bucketer;
use malachite_base_test_util::bench::{run_benchmark, BenchmarkType};
use malachite_base_test_util::generators::common::{GenConfig, GenMode};
use malachite_base_test_util::generators::unsigned_rational_sequence_gen;
use malachite_base_test_u... |
fn benchmark_rational_sequence_is_empty(
gm: GenMode,
config: GenConfig,
limit: usize,
file_name: &str,
) {
run_benchmark(
"RationalSequence.is_empty()",
BenchmarkType::Single,
unsigned_rational_sequence_gen::<u8>().get(gm, &config),
gm.name(),
limit,
... | {
for xs in unsigned_rational_sequence_gen::<u8>()
.get(gm, &config)
.take(limit)
{
if xs.is_empty() {
println!("{} is empty", xs);
} else {
println!("{} is not empty", xs);
}
}
} | identifier_body |
is_empty.rs | use malachite_base_test_util::bench::bucketers::rational_sequence_len_bucketer;
use malachite_base_test_util::bench::{run_benchmark, BenchmarkType};
use malachite_base_test_util::generators::common::{GenConfig, GenMode};
use malachite_base_test_util::generators::unsigned_rational_sequence_gen;
use malachite_base_test_u... | else {
println!("{} is not empty", xs);
}
}
}
fn benchmark_rational_sequence_is_empty(
gm: GenMode,
config: GenConfig,
limit: usize,
file_name: &str,
) {
run_benchmark(
"RationalSequence.is_empty()",
BenchmarkType::Single,
unsigned_rational_sequence_... | {
println!("{} is empty", xs);
} | conditional_block |
is_empty.rs | use malachite_base_test_util::bench::bucketers::rational_sequence_len_bucketer;
use malachite_base_test_util::bench::{run_benchmark, BenchmarkType};
use malachite_base_test_util::generators::common::{GenConfig, GenMode};
use malachite_base_test_util::generators::unsigned_rational_sequence_gen;
use malachite_base_test_u... | (gm: GenMode, config: GenConfig, limit: usize) {
for xs in unsigned_rational_sequence_gen::<u8>()
.get(gm, &config)
.take(limit)
{
if xs.is_empty() {
println!("{} is empty", xs);
} else {
println!("{} is not empty", xs);
}
}
}
fn benchmark_ratio... | demo_rational_sequence_is_empty | identifier_name |
is_empty.rs | use malachite_base_test_util::bench::bucketers::rational_sequence_len_bucketer;
use malachite_base_test_util::bench::{run_benchmark, BenchmarkType};
use malachite_base_test_util::generators::common::{GenConfig, GenMode};
use malachite_base_test_util::generators::unsigned_rational_sequence_gen;
use malachite_base_test_u... | &mut [("Malachite", &mut |xs| no_out!(xs.is_empty()))],
);
} | limit,
file_name,
&rational_sequence_len_bucketer("xs"), | random_line_split |
video.rs | pub const WIDTH: u8 = 64;
pub const HEIGHT: u8 = 32;
pub const BYTES_WIDTH: u8 = WIDTH / 8;
/// CHIP-8 gliphs, see: mattmik.com/chip8.html
pub static GLYPHS: [u8; 16*5] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, ... |
#[test]
fn test_flipped() {
assert!(flipped(0b_0000_0000, 0b_0001_0000) == false);
assert!(flipped(0b_0001_0000, 0b_0000_0000) == true);
assert!(flipped(0b_1010_0101, 0b_1111_1111) == false);
assert!(flipped(0b_1010_0101, 0b_0000_0000) == true);
assert!(flipped(0b_1010_0101, 0b_1010_0100) == true)... | {
v1 & !v2 != 0
} | identifier_body |
video.rs | pub const WIDTH: u8 = 64;
pub const HEIGHT: u8 = 32;
pub const BYTES_WIDTH: u8 = WIDTH / 8;
/// CHIP-8 gliphs, see: mattmik.com/chip8.html
pub static GLYPHS: [u8; 16*5] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, ... | (&mut self) {
self.screen_modified = true;
for px in self.data.iter_mut() {
*px = 0x0;
}
}
pub fn draw(&mut self, x: u8, y: u8, val: u8) -> u8 {
self.screen_modified = true;
let x = x % WIDTH;
let y = y % HEIGHT;
let i = (x / 8 + y * BYTES_W... | clear | identifier_name |
video.rs | pub const WIDTH: u8 = 64;
pub const HEIGHT: u8 = 32;
pub const BYTES_WIDTH: u8 = WIDTH / 8;
/// CHIP-8 gliphs, see: mattmik.com/chip8.html
pub static GLYPHS: [u8; 16*5] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, ... | 0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
0xF0, 0x10, 0x20, 0x40, 0x40, // 7
0xF0, 0x90, 0xF0, 0x90, 0xF0, // 8
0xF0, 0x90, 0xF0, 0x10, 0xF0, // 9
0xF0, 0x90, 0xF0, 0x90, 0x90, // A
0xE0, 0x90, 0xE0, 0x90, 0xE0, // B
0xF0, 0x80, 0x80, 0x80, 0xF0, // C
0xE0... | 0x90, 0x90, 0xF0, 0x10, 0x10, // 4 | random_line_split |
video.rs | pub const WIDTH: u8 = 64;
pub const HEIGHT: u8 = 32;
pub const BYTES_WIDTH: u8 = WIDTH / 8;
/// CHIP-8 gliphs, see: mattmik.com/chip8.html
pub static GLYPHS: [u8; 16*5] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, ... |
}
else {
let old = self.data[i];
self.data[i] ^= val;
// If any bits were flipped as a result of drawing the sprite then return 1
if flipped(old, self.data[i]) { 1 } else { 0 }
}
}
}
/// Returns true if any of the bits have been fliped from ... | { 0 } | conditional_block |
debug.rs | // normalize-stderr-test "pref: Align \{\n *pow2: [1-3],\n *\}" -> "pref: $$PREF_ALIGN"
#![feature(never_type, rustc_attrs, type_alias_impl_trait)]
#![crate_type = "lib"]
#[rustc_layout(debug)]
enum E { Foo, Bar(!, i32, i32) } //~ ERROR: layout_of
#[rustc_layout(debug)]
struct S { f1: i32, f2: (), f3: i32 } //~ ERROR... | () -> T {
0i32
}
| f | identifier_name |
debug.rs | // normalize-stderr-test "pref: Align \{\n *pow2: [1-3],\n *\}" -> "pref: $$PREF_ALIGN" | enum E { Foo, Bar(!, i32, i32) } //~ ERROR: layout_of
#[rustc_layout(debug)]
struct S { f1: i32, f2: (), f3: i32 } //~ ERROR: layout_of
#[rustc_layout(debug)]
union U { f1: (i32, i32), f3: i32 } //~ ERROR: layout_of
#[rustc_layout(debug)]
type Test = Result<i32, i32>; //~ ERROR: layout_of
#[rustc_layout(debug)]
typ... | #![feature(never_type, rustc_attrs, type_alias_impl_trait)]
#![crate_type = "lib"]
#[rustc_layout(debug)] | random_line_split |
config.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... |
fn filter_view_item<'r>(cx: &mut Context, view_item: &'r ast::ViewItem)
-> Option<&'r ast::ViewItem> {
if view_item_in_cfg(cx, view_item) {
Some(view_item)
} else {
None
}
}
fn fold_mod(cx: &mut Context, m: &ast::Mod) -> ast::Mod {
let filtered_items: Vec<&Gc<a... | {
let mut ctxt = Context {
in_cfg: in_cfg,
};
ctxt.fold_crate(krate)
} | identifier_body |
config.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... | (cfg: &[Gc<ast::MetaItem>], attrs: &[ast::Attribute]) -> bool {
attr::test_cfg(cfg, attrs.iter().map(|x| *x))
}
| in_cfg | identifier_name |
config.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 item = match *item {
ast::ItemImpl(ref a, ref b, c, ref methods) => {
let methods = methods.iter().filter(|m| method_in_cfg(cx, &***m))
.map(|x| *x).collect();
ast::ItemImpl((*a).clone(), (*b).clone(), c, methods)
}
ast::ItemTrait(ref a, ref b, ref ... | items: filtered_items
}
}
fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ { | random_line_split |
main.rs | extern crate hyper;
extern crate flate2;
extern crate basmap;
use std::env;
use hyper::Client;
use hyper::header::Connection;
use std::io::stdout;
use std::io::prelude::*;
use flate2::read::GzDecoder;
use basmap::basmap::Basmap;
use basmap::options::OptionBuilder;
fn send_ping(client: &Client, engine: &str, url: S... | ;
println!("Fetched {} URLs from {}\n", parsed, url);
}
basmap.run();
let success_rate = basmap.summarize();
if success_rate >= matches.min_ping() {
if matches.ping("google") {
send_ping(&client, "Google",
format!("http://www.google.com/webmasters/sit... | {
basmap.parse(resp)
} | conditional_block |
main.rs | extern crate hyper;
extern crate flate2;
extern crate basmap;
use std::env;
use hyper::Client;
use hyper::header::Connection;
use std::io::stdout;
use std::io::prelude::*;
use flate2::read::GzDecoder;
use basmap::basmap::Basmap;
use basmap::options::OptionBuilder;
fn send_ping(client: &Client, engine: &str, url: S... | send_ping(&client, "Bing",
format!("http://www.bing.com/webmaster/ping.aspx?siteMap={}", url));
}
}
} | }
if matches.ping("bing") { | random_line_split |
main.rs | extern crate hyper;
extern crate flate2;
extern crate basmap;
use std::env;
use hyper::Client;
use hyper::header::Connection;
use std::io::stdout;
use std::io::prelude::*;
use flate2::read::GzDecoder;
use basmap::basmap::Basmap;
use basmap::options::OptionBuilder;
fn send_ping(client: &Client, engine: &str, url: S... |
fn main() {
let args: Vec<String> = env::args().collect();
let program = args[0].clone();
let options = OptionBuilder::new();
let matches = match options.parse(&args[1..]) {
Ok(m) => { m }
Err(e) => { panic!(e.to_string()) }
};
if matches.wants_help() {
options.print_u... | {
print!("Pinging {}... ", engine);
stdout().flush().ok();
match client.get(&url[..]).send() {
Ok(_) => println!("Success"),
Err(_) => println!("Failed"),
};
} | identifier_body |
main.rs | extern crate hyper;
extern crate flate2;
extern crate basmap;
use std::env;
use hyper::Client;
use hyper::header::Connection;
use std::io::stdout;
use std::io::prelude::*;
use flate2::read::GzDecoder;
use basmap::basmap::Basmap;
use basmap::options::OptionBuilder;
fn | (client: &Client, engine: &str, url: String) {
print!("Pinging {}... ", engine);
stdout().flush().ok();
match client.get(&url[..]).send() {
Ok(_) => println!("Success"),
Err(_) => println!("Failed"),
};
}
fn main() {
let args: Vec<String> = env::args().collect();
let program = ... | send_ping | identifier_name |
mnist_benchmark.rs | #![feature(test)]
extern crate o2lsh;
extern crate test;
use test::Bencher;
#[bench]
fn build_table_from_mnist_and_query(b: &mut Bencher) {
let mnist_data = match o2lsh::util::get_mnist_vector("mnist1k.dts") { | Ok(v) => v,
Err(reason) => panic!("couldnt open because {}", reason)
};
let vec_length = mnist_data[0].len();
let num_hashes = 10;
let mnist_q = match o2lsh::util::get_mnist_vector("mnist1k.q") {
Ok(v) => v,
Err(reason) => panic!("couldnt open because {}", reason)
}... | random_line_split | |
mnist_benchmark.rs | #![feature(test)]
extern crate o2lsh;
extern crate test;
use test::Bencher;
#[bench]
fn build_table_from_mnist_and_query(b: &mut Bencher) {
let mnist_data = match o2lsh::util::get_mnist_vector("mnist1k.dts") {
Ok(v) => v,
Err(reason) => panic!("couldnt open because {}", reason)
};
let vec... | (b: &mut Bencher) {
let mnist_data = match o2lsh::util::get_mnist_vector("mnist1k.dts") {
Ok(v) => v,
Err(reason) => panic!("couldnt open because {}", reason)
};
let vec_length = mnist_data[0].len();
let num_hashes = 10;
let mnist_q = match o2lsh::util::get_mnist_vector("mnist1k.q"... | build_many_tables_from_mnist_and_time_query | identifier_name |
mnist_benchmark.rs | #![feature(test)]
extern crate o2lsh;
extern crate test;
use test::Bencher;
#[bench]
fn build_table_from_mnist_and_query(b: &mut Bencher) | .collect();
let hash_boxes: Vec<_> = (1..num_hashes).map(|_| o2lsh::hashes::get_hash_closure(vec_length, 1.0)).collect();
let hash_table: o2lsh::table::LSHTable<Vec<f32>, Fn(&Vec<f32>) -> f32> = o2lsh::table::LSHTable::new_build(&mnist_data, hash_boxes, &ms);
let run_test = || {
for vec in... | {
let mnist_data = match o2lsh::util::get_mnist_vector("mnist1k.dts") {
Ok(v) => v,
Err(reason) => panic!("couldnt open because {}", reason)
};
let vec_length = mnist_data[0].len();
let num_hashes = 10;
let mnist_q = match o2lsh::util::get_mnist_vector("mnist1k.q") {
Ok(v)... | identifier_body |
error.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/. */
//! Utilities to throw exceptions from Rust bindings.
use dom::bindings::codegen::Bindings::DOMExceptionBinding::... | /// InvalidCharacterError DOMException
InvalidCharacter,
/// NotSupportedError DOMException
NotSupported,
/// InUseAttributeError DOMException
InUseAttribute,
/// InvalidStateError DOMException
InvalidState,
/// SyntaxError DOMException
Syntax,
/// NamespaceError DOMException... | NotFound,
/// HierarchyRequestError DOMException
HierarchyRequest,
/// WrongDocumentError DOMException
WrongDocument, | random_line_split |
error.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/. */
//! Utilities to throw exceptions from Rust bindings.
use dom::bindings::codegen::Bindings::DOMExceptionBinding::... | ,
};
assert!(!JS_IsExceptionPending(cx));
let exception = DOMException::new(global, code);
rooted!(in(cx) let mut thrown = UndefinedValue());
exception.to_jsval(cx, thrown.handle_mut());
JS_SetPendingException(cx, thrown.handle());
}
/// A struct encapsulating information about a runtime scrip... | {
assert!(JS_IsExceptionPending(cx));
return;
} | conditional_block |
error.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/. */
//! Utilities to throw exceptions from Rust bindings.
use dom::bindings::codegen::Bindings::DOMExceptionBinding::... | (
self,
cx: *mut JSContext,
global: &GlobalScope,
rval: MutableHandleValue,
) {
assert!(!JS_IsExceptionPending(cx));
throw_dom_exception(cx, global, self);
assert!(JS_IsExceptionPending(cx));
assert!(JS_GetPendingException(cx, rval));
JS_ClearP... | to_jsval | identifier_name |
iter.rs | // Copyright (c) 2015, Sam Payson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, dist... | Some(Ok(v))
}
Some(Err(e)) => Some(Err(FromError::from_error(e))),
None => match mem::replace(&mut self.err, None) {
Some(err) => Some(Err(err)),
None => None,
}
}
}
... | Some(Ok(v)) => {
self.remaining -= 1; | random_line_split |
iter.rs | // Copyright (c) 2015, Sam Payson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, dist... | (&mut self) -> Option<<I as Iterator>::Item> {
if self.done {
None
} else {
match self.inner.next() {
Some(x) => {
self.done =!(self.pred)(&x);
Some(x)
},
None => None,
}
}... | next | identifier_name |
iter.rs | // Copyright (c) 2015, Sam Payson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, dist... |
}
/// `RexIterExt` provides methods on top of iterators (which feel generally useful).
pub trait RexIterExt: Iterator + Sized {
/// `take_while_incl` returns an iterator which will return the elements of an underlying
/// iterator until `pred` fails (or the iterator runs out). `take_while_incl` differs from... | {
if self.done {
None
} else {
match self.inner.next() {
Some(x) => {
self.done = !(self.pred)(&x);
Some(x)
},
None => None,
}
}
} | identifier_body |
main.rs | /*
> ++ptr;
< --ptr;
+ ++*ptr;
- --*ptr;
. putchar(*ptr);
, *ptr = getchar();
[ while (*ptr) {
] }
*/
use std::os;
extern {
fn getchar() -> i8;
}
fn get_val_of_ptr(val: &Vec<i8>, ptr: uint) -> i8 {
if ptr < val.len() {
val[ptr]
} else {
0
}
}
fn set_val_... |
fn match_loop_states(states: &mut Vec<LoopState>, index: uint) -> uint {
for state in states.iter() {
if state.from == index {
return state.to.unwrap();
} else if state.to.unwrap() == index {
return state.from;
}
}
panic!("no match loop state at pos {}", ind... | {
println!("\n{}", code);
for _ in range(0, index) {
print!(" ");
}
println!("^");
} | identifier_body |
main.rs | /*
> ++ptr;
< --ptr;
+ ++*ptr;
- --*ptr;
. putchar(*ptr);
, *ptr = getchar();
[ while (*ptr) {
] }
*/
use std::os;
extern {
fn getchar() -> i8;
}
fn get_val_of_ptr(val: &Vec<i8>, ptr: uint) -> i8 {
if ptr < val.len() {
val[ptr]
} else { | }
fn set_val_of_ptr(val: &mut Vec<i8>, ptr: uint, v: i8){
if ptr >= val.len() {
for _ in range(0, ptr + 1 - val.len()) {
val.push(0);
}
}
val[ptr] = v;
}
// inc (if x==1) or dec (if x==-1)
fn inc_val_of_ptr(val: &mut Vec<i8>, ptr: uint, x: i8) {
let x = get_val_of_ptr(val, ... | 0
} | random_line_split |
main.rs | /*
> ++ptr;
< --ptr;
+ ++*ptr;
- --*ptr;
. putchar(*ptr);
, *ptr = getchar();
[ while (*ptr) {
] }
*/
use std::os;
extern {
fn getchar() -> i8;
}
fn get_val_of_ptr(val: &Vec<i8>, ptr: uint) -> i8 {
if ptr < val.len() {
val[ptr]
} else {
0
}
}
fn set_val_... |
}
']' => {
ip = match_loop_states(&mut loop_states, ip);
continue;
}
'v' => println!("{}", get_val_of_ptr(&val, ptr)),
_ => {}
}
ip += 1;
}
// println!("{}", val); // for debug, print all ptr values
}
| {
ip = match_loop_states(&mut loop_states, ip) + 1;
continue;
} | conditional_block |
main.rs | /*
> ++ptr;
< --ptr;
+ ++*ptr;
- --*ptr;
. putchar(*ptr);
, *ptr = getchar();
[ while (*ptr) {
] }
*/
use std::os;
extern {
fn getchar() -> i8;
}
fn get_val_of_ptr(val: &Vec<i8>, ptr: uint) -> i8 {
if ptr < val.len() {
val[ptr]
} else {
0
}
}
fn set_val_... | {
from: uint,
to: Option<uint>,
}
impl Copy for LoopState {}
impl LoopState {
fn new(from: uint, to: Option<uint>) -> LoopState {
LoopState { from: from, to: to }
}
}
fn init_loop_states(states: &mut Vec<LoopState>, code: &str) {
let mut stack: Vec<LoopState> = vec![];
for (i,c) in ... | LoopState | identifier_name |
test.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 ... | #[cfg(unix)]
use io::net::pipe::*;
use io::timer::*;
use io::process::*;
use rt::running_on_valgrind;
use str;
use time::Duration;
fn f() $b
$(#[$a])* #[test] fn green() { f() }
$(#[$a])* #[test] fn... | use io::net::tcp::*;
use io::net::ip::*;
use io::net::udp::*; | random_line_split |
test.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 ... | () {
// The strategy here is to fetch the current resource limits, read the kern.maxfilesperproc
// sysctl value, and bump the soft resource limit for maxfiles up to the sysctl value.
use ptr::null_mut;
use mem::size_of_val;
use os::last_os_error;
// Fetch the kern.maxfi... | raise_fd_limit | identifier_name |
test.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 ... |
/*
XXX: Welcome to MegaHack City.
The bots run multiple builds at the same time, and these builds
all want to use ports. This function figures out which workspace
it is running in and assigns a port range based on it.
*/
fn base_port() -> u16 {
let base = 9600u16;
let range = 1000u16;
let bases = [
... | {
SocketAddr { ip: Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 1), port: next_test_port() }
} | identifier_body |
test.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 ... |
}
/// Get a unique IPv4 localhost:port pair starting at 9600
pub fn next_test_ip4() -> SocketAddr {
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: next_test_port() }
}
/// Get a unique IPv6 localhost:port pair starting at 9600
pub fn next_test_ip6() -> SocketAddr {
SocketAddr { ip: Ipv6Addr(0, 0, 0, 0, 0, 0,... | {
Path::new(format!("{}{}", r"\\.\pipe\", string))
} | conditional_block |
server.rs | use std::fmt;
use wrust_io::mio;
use wrust_io::mio::tcp::TcpListener;
use wrust_io::mio::unix::UnixListener;
use wrust_types::net::Protocol;
use wrust_types::net::connection::Descriptor;
use wrust_module::stream::{Behavior, Intention, Flush};
use super::ServerConf;
pub type ServerProtocol = Protocol<TcpListener, (), ... | impl Server {
pub fn new(token: mio::Token, config: ServerConf, socket: ServerProtocol, forward: Box<Behavior>) -> Server {
Server {
token: token,
config: config,
socket: socket,
forward: ForwardProxy::new(forward),
}
}
pub fn token(&self) -> &mio::Token {
&self.token
}
pub fn config(&self) -> ... | }
}
| random_line_split |
server.rs | use std::fmt;
use wrust_io::mio;
use wrust_io::mio::tcp::TcpListener;
use wrust_io::mio::unix::UnixListener;
use wrust_types::net::Protocol;
use wrust_types::net::connection::Descriptor;
use wrust_module::stream::{Behavior, Intention, Flush};
use super::ServerConf;
pub type ServerProtocol = Protocol<TcpListener, (), ... | (self: &Self, desc: &Descriptor, buf: &Vec<u8>) -> Intention {
self.instance
.read(desc, buf)
}
fn write(self: &Self, desc: &Descriptor, buf: &mut Vec<u8>) -> (Intention, Flush) {
self.instance
.write(desc, buf)
}
fn close(self: &Self, desc: &Descriptor) {
self.instance
.close(desc)
}
}
impl Ser... | read | identifier_name |
server.rs | use std::fmt;
use wrust_io::mio;
use wrust_io::mio::tcp::TcpListener;
use wrust_io::mio::unix::UnixListener;
use wrust_types::net::Protocol;
use wrust_types::net::connection::Descriptor;
use wrust_module::stream::{Behavior, Intention, Flush};
use super::ServerConf;
pub type ServerProtocol = Protocol<TcpListener, (), ... |
pub fn forward(&self) -> &ForwardProxy {
&self.forward
}
}
impl fmt::Debug for Server {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.socket {
Protocol::Tcp(_) => write!(f, "TCP Server #{:?}", self.token),
Protocol::Udp(_) => write!(f, "UDP Server #{:?}", self.token),
Protocol::U... | {
&self.socket
} | identifier_body |
list_tools.rs | use super::toolset::*;
use super::functional_tool::*;
use super::super::tool::*;
use super::super::environment::*;
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct | {
pub names: Vec<String>
}
impl ListToolsResult {
///
/// Creates a new list tools result with a particular set of names
///
pub fn with_names(names: Vec<&str>) -> ListToolsResult {
ListToolsResult {
names: names.iter().map(|s| String::from(*s)).collect()
}
}
/... | ListToolsResult | identifier_name |
list_tools.rs | use super::toolset::*;
use super::functional_tool::*;
use super::super::tool::*;
use super::super::environment::*;
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct ListToolsResult {
pub names: Vec<String>
}
impl ListToolsResult {
///
/// Creates a new list tools result with a particular ... | }
} | assert!(list_result == Ok(ListToolsResult::with_names(vec!["add-1", "add-2", "list-tools"]))); | random_line_split |
main.rs | // Copyright (c) 2016 srither developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
/... |
}
| {
let _ = writeln!(&mut io::stderr(), "{}", e);
process::exit(255);
} | conditional_block |
main.rs | // Copyright (c) 2016 srither developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
/... | {
if let Err(e) = run() {
let _ = writeln!(&mut io::stderr(), "{}", e);
process::exit(255);
}
} | identifier_body | |
main.rs | // Copyright (c) 2016 srither developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
/... | if let Err(e) = run() {
let _ = writeln!(&mut io::stderr(), "{}", e);
process::exit(255);
}
} |
fn main() { | random_line_split |
main.rs | // Copyright (c) 2016 srither developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
/... | () {
if let Err(e) = run() {
let _ = writeln!(&mut io::stderr(), "{}", e);
process::exit(255);
}
}
| main | identifier_name |
main.rs | extern crate may;
extern crate mimalloc;
extern crate num_cpus;
#[macro_use]
extern crate serde_derive;
extern crate may_minihttp;
extern crate serde_json;
use may_minihttp::{BodyWriter, HttpServer, HttpService, Request, Response};
use std::io;
use mimalloc::MiMalloc; | static GLOBAL: MiMalloc = MiMalloc;
#[derive(Serialize)]
struct Message<'a> {
message: &'a str,
}
struct Techempower;
impl HttpService for Techempower {
fn call(&self, req: Request) -> io::Result<Response> {
let mut resp = Response::new();
// Bare-bones router
match req.path() {
... |
#[global_allocator] | random_line_split |
main.rs | extern crate may;
extern crate mimalloc;
extern crate num_cpus;
#[macro_use]
extern crate serde_derive;
extern crate may_minihttp;
extern crate serde_json;
use may_minihttp::{BodyWriter, HttpServer, HttpService, Request, Response};
use std::io;
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = Mi... | (&self, req: Request) -> io::Result<Response> {
let mut resp = Response::new();
// Bare-bones router
match req.path() {
"/plaintext" => {
resp.header("Content-Type", "text/plain")
.body("Hello, World!");
}
"/json" => {
... | call | identifier_name |
main.rs | extern crate may;
extern crate mimalloc;
extern crate num_cpus;
#[macro_use]
extern crate serde_derive;
extern crate may_minihttp;
extern crate serde_json;
use may_minihttp::{BodyWriter, HttpServer, HttpService, Request, Response};
use std::io;
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = Mi... | }
_ => {
resp.status_code("404", "Not Found");
}
}
Ok(resp)
}
}
fn main() {
may::config()
.set_io_workers(num_cpus::get())
.set_pool_capacity(20000)
.set_stack_size(0x800);
let mut servers = Vec::new();
for _ in... | {
let mut resp = Response::new();
// Bare-bones router
match req.path() {
"/plaintext" => {
resp.header("Content-Type", "text/plain")
.body("Hello, World!");
}
"/json" => {
resp.header("Content-Type", "appli... | identifier_body |
font.rs | 0 < 550. {
FontWeight(700.)
} else {
FontWeight(self.0.max(900.))
}
}
/// Return the lighter weight.
///
/// See the table in:
/// https://drafts.csswg.org/css-fonts-4/#font-weight-numeric-values
pub fn lighter(self) -> Self {
if self.0 < 550. {
... |
let first_ident = input.expect_ident_cloned()?;
if let Ok(generic) = GenericFontFamily::from_ident(&first_ident) {
return Ok(SingleFontFamily::Generic(generic));
}
let reserved = match_ignore_ascii_case! { &first_ident,
// https://drafts.csswg.org/css-fonts/#pr... | {
return Ok(SingleFontFamily::FamilyName(FamilyName {
name: Atom::from(&*value),
syntax: FontFamilyNameSyntax::Quoted,
}));
} | conditional_block |
font.rs | < 550. {
FontWeight(700.)
} else {
FontWeight(self.0.max(900.))
}
}
/// Return the lighter weight.
///
/// See the table in:
/// https://drafts.csswg.org/css-fonts-4/#font-weight-numeric-values
pub fn lighter(self) -> Self {
if self.0 < 550. {
... | ngleFontFamily]>);
#[cfg(feature = "gecko")]
#[derive(Clone, Debug, ToComputedValue, ToResolvedValue)]
/// A list of SingleFontFamily
pub enum FontFamilyList {
/// A strong reference to a Gecko SharedFontList object.
SharedFontList(
#[compute(no_field_bound)]
#[resolve(no_field_bound)]
... | lyList(Box<[Si | identifier_name |
font.rs | weight-numeric-values
pub fn lighter(self) -> Self {
if self.0 < 550. {
FontWeight(self.0.min(100.))
} else if self.0 < 750. {
FontWeight(400.)
} else {
FontWeight(700.)
}
}
}
impl FontSize {
/// The actual computed font size.
#[inline... | }
}
| random_line_split | |
class-trait-bounded-param.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 ... |
fn eachi(blk: &fn(uint, K) -> bool) { old_iter::eachi(self, blk) }
}
pub fn main() {
let m = int_hash();
m.insert(1, 2);
m.insert(3, 4);
assert!(old_iter::to_vec(keys(m)) == ~[1, 3]);
}
| { Some(self.map.size()) } | identifier_body |
class-trait-bounded-param.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 ... | () -> Option<uint> { Some(self.map.size()) }
fn eachi(blk: &fn(uint, K) -> bool) { old_iter::eachi(self, blk) }
}
pub fn main() {
let m = int_hash();
m.insert(1, 2);
m.insert(3, 4);
assert!(old_iter::to_vec(keys(m)) == ~[1, 3]);
}
| size_hint | identifier_name |
class-trait-bounded-param.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
exte... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
configs-fn_args_layout-visual.rs | // rustfmt-fn_args_layout: Visual
// Function arguments layout
fn lorem() {}
fn | (ipsum: usize) {}
fn lorem(ipsum: usize, dolor: usize, sit: usize, amet: usize, consectetur: usize, adipiscing: usize, elit: usize) {
// body
}
// #1922
extern "C" {
pub fn LAPACKE_csytrs_rook_work(matrix_layout: c_int,
uplo: c_char,
n: lapack_int,
nrhs: lapack_int,
... | lorem | identifier_name |
configs-fn_args_layout-visual.rs | // rustfmt-fn_args_layout: Visual
// Function arguments layout
fn lorem() |
fn lorem(ipsum: usize) {}
fn lorem(ipsum: usize, dolor: usize, sit: usize, amet: usize, consectetur: usize, adipiscing: usize, elit: usize) {
// body
}
// #1922
extern "C" {
pub fn LAPACKE_csytrs_rook_work(matrix_layout: c_int,
uplo: c_char,
n: lapack_int,
nrhs: lapack_in... | {} | identifier_body |
configs-fn_args_layout-visual.rs | // rustfmt-fn_args_layout: Visual
// Function arguments layout
fn lorem() {}
| fn lorem(ipsum: usize) {}
fn lorem(ipsum: usize, dolor: usize, sit: usize, amet: usize, consectetur: usize, adipiscing: usize, elit: usize) {
// body
}
// #1922
extern "C" {
pub fn LAPACKE_csytrs_rook_work(matrix_layout: c_int,
uplo: c_char,
n: lapack_int,
nrhs: lapack_int,... | random_line_split | |
dialog.rs | #![allow(non_snake_case)]
/*
use super::super::win::types::*;
use super::super::win::api::*;
use super::super::Wnd;
// 所有窗口 组件 都必须实现的接口。
// 部分方法 preTranslate wndProc 消息映射需要用到. | wndProc: WndProc
}
impl Wnd for Dialog{
// fn getSelf(&mut self)->&mut Self{self}
fn preTranslate(&self,hWnd: HWND,msg:& mut MSG)->bool
{
if msg.msg == 256 && msg.wparam == 27 {
msg.handle = hWnd;
return false;
}
unsafe{
if msg.IsDialogMessage(hWnd) {
msg.Tr... |
struct Dialog{
hWnd: HWND, | random_line_split |
dom_html_head_element.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::DOMElement;
use crate::DOMEventTarget;
use crate::DOMHTMLElement;
use crate::DOMNode;
use crate::DOMObject;
use glib::object::Cast;
use glib::object::IsA;
use glib::si... |
fn set_profile(&self, value: &str) {
unsafe {
ffi::webkit_dom_html_head_element_set_profile(
self.as_ref().to_glib_none().0,
value.to_glib_none().0,
);
}
}
fn connect_property_profile_notify<F: Fn(&Self) +'static>(&self, f: F) -> Sig... | {
unsafe {
from_glib_full(ffi::webkit_dom_html_head_element_get_profile(
self.as_ref().to_glib_none().0,
))
}
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.