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 |
|---|---|---|---|---|
default.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
StaticEnum(..) => {
cx.span_err(trait_span, "`Default` cannot be derived for enums, only structs");
// let compilation continue
cx.expr_usize(trait_span, 0)
}
_ => cx.span_bug(trait_span, "Non-static method in `derive(Default)`")
};
}
| {
match *summary {
Unnamed(ref fields) => {
if fields.is_empty() {
cx.expr_ident(trait_span, substr.type_ident)
} else {
let exprs = fields.iter().map(|sp| default_call(*sp)).collect();
... | conditional_block |
default.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;
use ptr::P;
pub fn expand_deriving_default<F>(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Item,
... | random_line_split | |
default.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | <F>(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Item,
push: F) where
F: FnOnce(P<Item>),
{
let inline = cx.meta_word(span, InternedString::new("inline"));
let at... | expand_deriving_default | identifier_name |
cmd.rs | graph::Graph;
use crate::progress::Progress;
use crate::sim::{Io, GlobalState, RoutingAlgorithm};
use crate::algorithms::vivaldi_routing::VivaldiRouting;
use crate::algorithms::random_routing::RandomRouting;
use crate::algorithms::spring_routing::SpringRouting;
use crate::algorithms::genetic_routing::GeneticRouting;
us... | (out: &mut std::fmt::Write) -> Result<(), MyError> {
for item in COMMANDS {
if item.1!= Cid::Error {
writeln!(out, "{}", item.0)?;
}
}
Ok(())
}
fn cmd_handler(out: &mut std::fmt::Write, sim: &mut GlobalState, input: &str, call: AllowRecursiveCall) -> Result<(), MyError> {
let mut mark_links : Option<Graph> ... | print_help | identifier_name |
cmd.rs | ::graph::Graph;
use crate::progress::Progress;
use crate::sim::{Io, GlobalState, RoutingAlgorithm};
use crate::algorithms::vivaldi_routing::VivaldiRouting;
use crate::algorithms::random_routing::RandomRouting;
use crate::algorithms::spring_routing::SpringRouting;
use crate::algorithms::genetic_routing::GeneticRouting;
... |
sim.test.show_progress(sim.show_progress);
run_test(out, &mut sim.test, &sim.graph, &sim.algorithm, samples)?;
},
Command::Debug(from, to) => {
let node_count = sim.graph.node_count() as u32;
if (from < node_count) && (from < node_count) {
sim.debug_path.init(from, to);
writeln!(out, "Init path... | {
test.clear();
test.run_samples(graph, |p| algo.route(&p), samples as usize);
writeln!(out, "samples: {}, arrived: {:.1}, stretch: {}, duration: {}",
samples,
test.arrived(), test.stretch(),
fmt_duration(test.duration())
)
} | identifier_body |
cmd.rs | ::graph::Graph;
use crate::progress::Progress;
use crate::sim::{Io, GlobalState, RoutingAlgorithm};
use crate::algorithms::vivaldi_routing::VivaldiRouting;
use crate::algorithms::random_routing::RandomRouting;
use crate::algorithms::spring_routing::SpringRouting;
use crate::algorithms::genetic_routing::GeneticRouting;
... | ("tree <node_count> [<inter_count>] Add a tree structure of nodes with interconnections", Cid::AddTree),
("lattice4 <x_xount> <y_count> Create a lattice structure of squares.", Cid::AddLattice4),
("lattice8 <x_xount> <y_count> Create a lattice structure of squares and diagonal connections.", Cid::AddLat... | ("line <node_count> [<create_loop>] Add a line of nodes. Connect ends to create a loop.", Cid::AddLine),
("star <edge_count> Add star structure of nodes.", Cid::AddStar), | random_line_split |
config_handler.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... | } else {
None
};
// If there is no config file, assume we are a client
QuicP2pConfig {
our_type: quic_p2p::OurType::Client,
bootstrap_cache_dir: custom_dir,... | {
// First we read the default configuration file, and use a slightly modified default config
// if there is none.
let mut config: QuicP2pConfig = {
match read_config_file(dirs()?, CONFIG_FILE) {
Err(CoreError::IoError(ref err)) if err.kind() == io::ErrorKind::NotFoun... | identifier_body |
config_handler.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... |
Err(error) => {
trace!("Not available: {}", path.display());
return Err(error.into());
}
};
let reader = BufReader::new(file);
serde_json::from_reader(reader).map_err(|err| {
info!("Could not parse: {} ({:?})", err, err);
err.into()
})
}
/// Writ... | {
trace!("Reading: {}", path.display());
file
} | conditional_block |
config_handler.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... | {
/// QuicP2p options.
pub quic_p2p: QuicP2pConfig,
/// Developer options.
pub dev: Option<DevConfig>,
}
#[cfg(any(target_os = "android", target_os = "androideabi", target_os = "ios"))]
fn check_config_path_set() -> Result<(), CoreError> {
if unwrap!(CONFIG_DIR_PATH.lock()).is_none() {
Err... | Config | identifier_name |
TestFastLength.rs | /*
* Copyright (C) 2016 The Android Open Source Project
*
* 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 app... | float __attribute__((kernel)) testFastLengthFloat2Float(float2 inV) {
return fast_length(inV);
}
float __attribute__((kernel)) testFastLengthFloat3Float(float3 inV) {
return fast_length(inV);
}
float __attribute__((kernel)) testFastLengthFloat4Float(float4 inV) {
return fast_length(inV);
} | random_line_split | |
binary.rs | /*
* Copyright (C) 2017 Genymobile
*
* 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 ... | (data: &[u8]) -> String {
let mut s = String::new();
for (i, &byte) in data.iter().enumerate() {
if i % 16 == 0 {
write!(&mut s, "\n").unwrap();
} else if i % 8 == 0 {
write!(&mut s, " ").unwrap();
}
write!(&mut s, "{:02X} ", byte).unwrap();
}
s
}
... | to_string | identifier_name |
binary.rs | /*
* Copyright (C) 2017 Genymobile
*
* 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 ... | else if i % 8 == 0 {
write!(&mut s, " ").unwrap();
}
write!(&mut s, "{:02X} ", byte).unwrap();
}
s
}
// only compare the data part for fat pointers (ignore the vtable part)
// for some (buggy) reason, the vtable part may be different even if the data reference the same
// object
//... | {
write!(&mut s, "\n").unwrap();
} | conditional_block |
binary.rs | /*
* Copyright (C) 2017 Genymobile
*
* 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 ... | write!(&mut s, "{:02X} ", byte).unwrap();
}
s
}
// only compare the data part for fat pointers (ignore the vtable part)
// for some (buggy) reason, the vtable part may be different even if the data reference the same
// object
// See <https://github.com/Genymobile/gnirehtet/issues/61#issuecomment-37093... | random_line_split | |
binary.rs | /*
* Copyright (C) 2017 Genymobile
*
* 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 ... |
pub fn to_string(data: &[u8]) -> String {
let mut s = String::new();
for (i, &byte) in data.iter().enumerate() {
if i % 16 == 0 {
write!(&mut s, "\n").unwrap();
} else if i % 8 == 0 {
write!(&mut s, " ").unwrap();
}
write!(&mut s, "{:02X} ", byte).unwrap... | {
let mut raw = [0u8; 4];
BigEndian::write_u32(&mut raw, value);
raw
} | identifier_body |
borrowck-overloaded-index-autoderef.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
}
fn test1(mut f: Box<Foo>, s: String) {
let p = &mut f[&s];
let q = &f[&s]; //~ ERROR cannot borrow
p.use_mut();
}
fn test2(mut f: Box<Foo>, s: String) {
let p = &mut f[&s];
let q = &mut f[&s]; //~ ERROR cannot borrow
p.use_mut();
}
struct Bar {
foo: Foo
}
fn test3(mut f: Box<Bar... | {
&mut self.y
} | conditional_block |
borrowck-overloaded-index-autoderef.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (mut f: Box<Bar>, s: String) {
let p = &mut f.foo[&s];
let q = &mut f.foo[&s]; //~ ERROR cannot borrow
p.use_mut();
}
fn test4(mut f: Box<Bar>, s: String) {
let p = &f.foo[&s];
let q = &f.foo[&s];
p.use_ref();
}
fn test5(mut f: Box<Bar>, s: String) {
let p = &f.foo[&s];
let q = &mut f.... | test3 | identifier_name |
borrowck-overloaded-index-autoderef.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 ... | } else {
&mut self.y
}
}
}
fn test1(mut f: Box<Foo>, s: String) {
let p = &mut f[&s];
let q = &f[&s]; //~ ERROR cannot borrow
p.use_mut();
}
fn test2(mut f: Box<Foo>, s: String) {
let p = &mut f[&s];
let q = &mut f[&s]; //~ ERROR cannot borrow
p.use_mut();
}
st... | fn index_mut(&mut self, z: &String) -> &mut isize {
if *z == "x" {
&mut self.x | random_line_split |
generator.rs | // a lot of the source of this file is the same as main.rs
// but instead of tweeting, it just prints to stdout
extern crate rand;
use rand::{thread_rng, ThreadRng};
// these files are paths to plain-text lists of the various word types
// these paths assume you're running with *cargo run* from the root of the crate... | () {
// TemplateManager::new returns a Result because it will fail if there's a problem loading any of the files
match TemplateManager::new(
TEMPLATE_FILENAME,
NOUNS_FILENAME,
ADJECTIVES_FILENAME,
ADVERBS_FILENAME,
ABSTRACTS_FILENAME
) {
Ok(manager) => {
... | main | identifier_name |
generator.rs | // a lot of the source of this file is the same as main.rs
// but instead of tweeting, it just prints to stdout
extern crate rand;
use rand::{thread_rng, ThreadRng};
// these files are paths to plain-text lists of the various word types
// these paths assume you're running with *cargo run* from the root of the crate... | ,
}
},
Err(err) => {
println!("Failed to create a TemplateManager with err: {}", err);
},
}
}
| {
println!("Couldn't generate a tweet");
} | conditional_block |
generator.rs | // a lot of the source of this file is the same as main.rs
// but instead of tweeting, it just prints to stdout
extern crate rand;
use rand::{thread_rng, ThreadRng};
// these files are paths to plain-text lists of the various word types
// these paths assume you're running with *cargo run* from the root of the crate... | },
None => {
println!("Couldn't generate a tweet");
},
}
},
Err(err) => {
println!("Failed to create a TemplateManager with err: {}", err);
},
}
}
| {
// TemplateManager::new returns a Result because it will fail if there's a problem loading any of the files
match TemplateManager::new(
TEMPLATE_FILENAME,
NOUNS_FILENAME,
ADJECTIVES_FILENAME,
ADVERBS_FILENAME,
ABSTRACTS_FILENAME
) {
Ok(manager) => {
... | identifier_body |
generator.rs | // a lot of the source of this file is the same as main.rs
// but instead of tweeting, it just prints to stdout
extern crate rand;
use rand::{thread_rng, ThreadRng};
// these files are paths to plain-text lists of the various word types
// these paths assume you're running with *cargo run* from the root of the crate... | println!("Failed to create a TemplateManager with err: {}", err);
},
}
} | random_line_split | |
derive_input_object.rs | use fnv::FnvHashMap;
use juniper::{
marker, DefaultScalarValue, FromInputValue, GraphQLInputObject, GraphQLType, GraphQLValue,
InputValue, Registry, ToInputValue,
};
#[derive(GraphQLInputObject, Debug, PartialEq)]
#[graphql(
name = "MyInput",
description = "input descr",
scalar = DefaultScalarValue... | () {
let mut registry: Registry = Registry::new(FnvHashMap::default());
let meta = DocComment::meta(&(), &mut registry);
assert_eq!(meta.description(), Some(&"Object comment.".to_string()));
}
#[test]
fn test_multi_doc_comment() {
let mut registry: Registry = Registry::new(FnvHashMap::default());
l... | test_doc_comment | identifier_name |
derive_input_object.rs | use fnv::FnvHashMap;
use juniper::{
marker, DefaultScalarValue, FromInputValue, GraphQLInputObject, GraphQLType, GraphQLValue,
InputValue, Registry, ToInputValue,
};
#[derive(GraphQLInputObject, Debug, PartialEq)]
#[graphql(
name = "MyInput",
description = "input descr",
scalar = DefaultScalarValue... | } | random_line_split | |
builtin-superkinds-self-type.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 ... |
}
impl <T: Sync> Foo for T { }
//~^ ERROR the parameter type `T` may not live long enough
fn main() {
let (tx, rx) = channel();
1193182is.foo(tx);
assert!(rx.recv() == 1193182is);
}
| { } | identifier_body |
builtin-superkinds-self-type.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 | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests (negatively) the ability for the Self type in default methods
// to use capabilities granted by builtin kinds as supertraits.
use std::sync::mpsc::{channel, Sender};
trait Foo : Sync+'static {
fn foo(sel... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
builtin-superkinds-self-type.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 ... | (self, mut chan: Sender<Self>) { }
}
impl <T: Sync> Foo for T { }
//~^ ERROR the parameter type `T` may not live long enough
fn main() {
let (tx, rx) = channel();
1193182is.foo(tx);
assert!(rx.recv() == 1193182is);
}
| foo | identifier_name |
euler50.rs | pub fn main() {
let primes = || (2..).filter(|&n| (2..(n as f32).sqrt() as u32 + 1).all(|i| n % i!= 0));
let isprime = |n: &u32| (2..(*n as f32).sqrt() as u32 + 1).all(|i| n % i!= 0);
let mut sum = 0;
let mut primesums = Vec::new();
for p in primes() {
sum += p;
if sum > 1_000_000 {... |
}
}
println!("{}", max);
}
| {
max = candidate;
} | conditional_block |
euler50.rs | let isprime = |n: &u32| (2..(*n as f32).sqrt() as u32 + 1).all(|i| n % i!= 0);
let mut sum = 0;
let mut primesums = Vec::new();
for p in primes() {
sum += p;
if sum > 1_000_000 {
break;
};
primesums.push(sum);
}
let mut max = 0;
for &n in &primesu... | pub fn main() {
let primes = || (2..).filter(|&n| (2..(n as f32).sqrt() as u32 + 1).all(|i| n % i != 0)); | random_line_split | |
euler50.rs | pub fn | () {
let primes = || (2..).filter(|&n| (2..(n as f32).sqrt() as u32 + 1).all(|i| n % i!= 0));
let isprime = |n: &u32| (2..(*n as f32).sqrt() as u32 + 1).all(|i| n % i!= 0);
let mut sum = 0;
let mut primesums = Vec::new();
for p in primes() {
sum += p;
if sum > 1_000_000 {
... | main | identifier_name |
euler50.rs | pub fn main() | }
}
println!("{}", max);
}
| {
let primes = || (2..).filter(|&n| (2..(n as f32).sqrt() as u32 + 1).all(|i| n % i != 0));
let isprime = |n: &u32| (2..(*n as f32).sqrt() as u32 + 1).all(|i| n % i != 0);
let mut sum = 0;
let mut primesums = Vec::new();
for p in primes() {
sum += p;
if sum > 1_000_000 {
... | identifier_body |
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/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... |
ValueParseErrorKind::InvalidFilter(token) => {
StyleParseErrorKind::InvalidFilter(name, token)
}
}
}
_ => StyleParseErrorKind::OtherInvalidValue(name),
};
cssparser::ParseError {
kind: cs... | {
StyleParseErrorKind::InvalidColor(name, token)
} | conditional_block |
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/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... |
/// Get the pinch zoom factor as an untyped float.
pub fn get(&self) -> f32 {
self.0
}
}
/// One CSS "px" in the coordinate system of the "initial viewport":
/// <http://www.w3.org/TR/css-device-adapt/#initial-viewport>
///
/// `CSSPixel` is equal to `DeviceIndependentPixel` times a "page zoom" f... | {
PinchZoomFactor(scale)
} | identifier_body |
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/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | (this: ValueParseErrorKind<'i>) -> Self {
StyleParseErrorKind::ValueError(this)
}
}
impl<'i> From<SelectorParseErrorKind<'i>> for StyleParseErrorKind<'i> {
fn from(this: SelectorParseErrorKind<'i>) -> Self {
StyleParseErrorKind::SelectorError(this)
}
}
/// Specific errors that can be encou... | from | 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/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | UnbalancedCloseCurlyBracketInDeclarationValueBlock,
/// A property declaration value had input remaining after successfully parsing.
PropertyDeclarationValueNotExhausted,
/// An unexpected dimension token was encountered.
UnexpectedDimension(CowRcStr<'i>),
/// Expected identifier not found.
... | random_line_split | |
rustc.rs | //! Shim which is passed to Cargo as "rustc" when running the bootstrap.
//!
//! This shim will take care of some various tasks that our build process
//! requires that Cargo can't quite do through normal configuration:
//!
//! 1. When compiling build scripts and build dependencies, we need a guaranteed
//! full sta... |
// If we're compiling specifically the `panic_abort` crate then we pass
// the `-C panic=abort` option. Note that we do not do this for any
// other crate intentionally as this is the only crate for now that we
// ship with panic=abort.
//
// This... is a bit of a hack ... | {
cmd.arg("--sysroot").arg(&sysroot);
} | conditional_block |
rustc.rs | //! Shim which is passed to Cargo as "rustc" when running the bootstrap.
//!
//! This shim will take care of some various tasks that our build process
//! requires that Cargo can't quite do through normal configuration:
//!
//! 1. When compiling build scripts and build dependencies, we need a guaranteed
//! full sta... | USER_SEC = rusage.ru_utime.tv_sec,
USER_USEC = rusage.ru_utime.tv_usec,
SYS_SEC = rusage.ru_stime.tv_sec,
SYS_USEC = rusage.ru_stime.tv_usec,
MAXRSS = maxrss
);
// The remaining rusage stats vary in platform support. So we treat
// uniformly zero values in each categ... | {
let rusage: libc::rusage = unsafe {
let mut recv = std::mem::zeroed();
// -1 is RUSAGE_CHILDREN, which means to get the rusage for all children
// (and grandchildren, etc) processes that have respectively terminated
// and been waited for.
let retval = libc::getrusage(-1, &... | identifier_body |
rustc.rs | //! Shim which is passed to Cargo as "rustc" when running the bootstrap.
//!
//! This shim will take care of some various tasks that our build process
//! requires that Cargo can't quite do through normal configuration:
//!
//! 1. When compiling build scripts and build dependencies, we need a guaranteed
//! full sta... | (child: Child) -> Option<String> {
use std::os::windows::io::AsRawHandle;
use winapi::um::{processthreadsapi, psapi, timezoneapi};
let handle = child.as_raw_handle();
macro_rules! try_bool {
($e:expr) => {
if $e!= 1 {
return None;
}
};
}
l... | format_rusage_data | identifier_name |
rustc.rs | //! Shim which is passed to Cargo as "rustc" when running the bootstrap.
//!
//! This shim will take care of some various tasks that our build process
//! requires that Cargo can't quite do through normal configuration:
//!
//! 1. When compiling build scripts and build dependencies, we need a guaranteed
//! full sta... | let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
let mut dylib_path = bootstrap::util::dylib_path();
dylib_path.insert(0, PathBuf::from(&libdir));
let mut cmd = Command::new(r... | let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new);
| random_line_split |
scroll_viewer_mode.rs | /// The `ScrollMode` defines the mode of a scroll direction.
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum ScrollMode {
/// Scrolling will process by `ScrollViewer` logic
Auto,
/// Scrolling could be handled from outside. It will not be
/// process by `ScrollViewer` logic.
Custom,
/// Scro... | (s: &str) -> ScrollMode {
match s {
"Custom" | "custom" => ScrollMode::Custom,
"Disabled" | "disabled" => ScrollMode::Disabled,
_ => ScrollMode::Auto,
}
}
}
/// `ScrollViewerMode` describes the vertical and horizontal scroll
/// behavior of the `ScrollViewer`.
#[... | from | identifier_name |
scroll_viewer_mode.rs | /// The `ScrollMode` defines the mode of a scroll direction.
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum ScrollMode {
/// Scrolling will process by `ScrollViewer` logic
Auto,
/// Scrolling could be handled from outside. It will not be
/// process by `ScrollViewer` logic.
Custom,
/// Scro... | }
}
}
impl Default for ScrollViewerMode {
fn default() -> ScrollViewerMode {
ScrollViewerMode {
vertical: ScrollMode::Auto,
horizontal: ScrollMode::Auto,
}
}
} | vertical: ScrollMode::from(s.1), | random_line_split |
macro_crate_test.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... |
MacExpr::new(quote_expr!(cx, 1i))
}
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>)
-> Gc<Item> {
box(GC) Item {
attrs: it.attrs.clone(),
..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone()
}
}
pub fn foo() {}
| {
cx.span_fatal(sp, "make_a_1 takes no arguments");
} | conditional_block |
macro_crate_test.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 expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
-> Box<MacResult> {
if!tts.is_empty() {
cx.span_fatal(sp, "make_a_1 takes no arguments");
}
MacExpr::new(quote_expr!(cx, 1i))
}
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>)
... | {
reg.register_macro("make_a_1", expand_make_a_1);
reg.register_syntax_extension(
token::intern("into_foo"),
ItemModifier(expand_into_foo));
} | identifier_body |
macro_crate_test.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... | (cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
-> Box<MacResult> {
if!tts.is_empty() {
cx.span_fatal(sp, "make_a_1 takes no arguments");
}
MacExpr::new(quote_expr!(cx, 1i))
}
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>)
-> G... | expand_make_a_1 | identifier_name |
macro_crate_test.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... | -> Gc<Item> {
box(GC) Item {
attrs: it.attrs.clone(),
..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone()
}
}
pub fn foo() {} |
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>) | random_line_split |
string.rs | use std::fmt;
use std::ops;
#[derive(Clone, Eq)]
pub enum StringOrStatic {
String(String),
Static(&'static str),
}
impl From<&str> for StringOrStatic {
fn from(s: &str) -> Self {
StringOrStatic::String(s.to_owned())
}
}
impl From<String> for StringOrStatic {
fn from(s: String) -> Self {
... | (&self) -> &str {
match self {
StringOrStatic::String(s) => &s,
StringOrStatic::Static(s) => s,
}
}
pub fn to_string(&self) -> String {
format!("{}", self)
}
}
impl ops::Deref for StringOrStatic {
type Target = str;
fn deref(&self) -> &str {
... | as_str | identifier_name |
string.rs | use std::fmt;
use std::ops;
#[derive(Clone, Eq)]
pub enum StringOrStatic {
String(String),
Static(&'static str),
}
impl From<&str> for StringOrStatic {
fn from(s: &str) -> Self {
StringOrStatic::String(s.to_owned())
} | }
impl From<String> for StringOrStatic {
fn from(s: String) -> Self {
StringOrStatic::String(s)
}
}
impl StringOrStatic {
pub fn as_str(&self) -> &str {
match self {
StringOrStatic::String(s) => &s,
StringOrStatic::Static(s) => s,
}
}
pub fn to_stri... | random_line_split | |
socket.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may n... |
}
impl TIoChannel for TTcpChannel {
fn split(self) -> ::Result<(ReadHalf<Self>, WriteHalf<Self>)>
where
Self: Sized,
{
let mut s = self;
s.stream
.as_mut()
.and_then(|s| s.try_clone().ok())
.map(
|cloned| {
(Read... | {
if let Some(ref mut s) = self.stream {
stream_operation(s)
} else {
Err(io::Error::new(ErrorKind::NotConnected, "tcp endpoint not connected"),)
}
} | identifier_body |
socket.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may n... | else {
Err(io::Error::new(ErrorKind::NotConnected, "tcp endpoint not connected"),)
}
}
}
impl TIoChannel for TTcpChannel {
fn split(self) -> ::Result<(ReadHalf<Self>, WriteHalf<Self>)>
where
Self: Sized,
{
let mut s = self;
s.stream
.as_mut()
... | {
stream_operation(s)
} | conditional_block |
socket.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may n... | )
} else {
match TcpStream::connect(&remote_address) {
Ok(s) => {
self.stream = Some(s);
Ok(())
}
Err(e) => Err(From::from(e)),
}
}
}
/// Shut down this channel.
///
... | TransportErrorKind::AlreadyOpen,
"tcp connection previously opened",
), | random_line_split |
socket.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may n... | <F, T>(&mut self, mut stream_operation: F) -> io::Result<T>
where
F: FnMut(&mut TcpStream) -> io::Result<T>,
{
if let Some(ref mut s) = self.stream {
stream_operation(s)
} else {
Err(io::Error::new(ErrorKind::NotConnected, "tcp endpoint not connected"),)
... | if_set | identifier_name |
thread_local.rs | use std::cell::RefCell;
use std::mem;
use thread::Thread;
pub struct Data {
pub current_thread: Thread,
pub parkable: bool, // i.e. for frame stack lock
}
pub unsafe fn init(data: Data) {
set_data_ptr(Box::new(RefCell::new(data)));
}
pub fn data() -> &'static RefCell<Data> {
unsafe{&*get_data_ptr(... | let mut data: *const RefCell<Data>;
asm!("movq %fs:0, $0" : "=r"(data) ::: "volatile");
data
}
#[cfg(target_arch = "x86_64")]
unsafe fn set_data_ptr(data: Box<RefCell<Data>>) {
let data_ptr: *const RefCell<Data> = mem::transmute(data);
asm!("movq $0, %fs:0" :: "r"(data_ptr) :: "volatile");
} |
#[cfg(target_arch = "x86_64")]
unsafe fn get_data_ptr() -> *const RefCell<Data> { | random_line_split |
thread_local.rs | use std::cell::RefCell;
use std::mem;
use thread::Thread;
pub struct Data {
pub current_thread: Thread,
pub parkable: bool, // i.e. for frame stack lock
}
pub unsafe fn init(data: Data) {
set_data_ptr(Box::new(RefCell::new(data)));
}
pub fn data() -> &'static RefCell<Data> {
unsafe{&*get_data_ptr(... | {
let data_ptr: *const RefCell<Data> = mem::transmute(data);
asm!("movq $0, %fs:0" :: "r"(data_ptr) :: "volatile");
} | identifier_body | |
thread_local.rs | use std::cell::RefCell;
use std::mem;
use thread::Thread;
pub struct Data {
pub current_thread: Thread,
pub parkable: bool, // i.e. for frame stack lock
}
pub unsafe fn init(data: Data) {
set_data_ptr(Box::new(RefCell::new(data)));
}
pub fn data() -> &'static RefCell<Data> {
unsafe{&*get_data_ptr(... | () -> *const RefCell<Data> {
let mut data: *const RefCell<Data>;
asm!("movq %fs:0, $0" : "=r"(data) ::: "volatile");
data
}
#[cfg(target_arch = "x86_64")]
unsafe fn set_data_ptr(data: Box<RefCell<Data>>) {
let data_ptr: *const RefCell<Data> = mem::transmute(data);
asm!("movq $0, %fs:0" :: "r"(data_p... | get_data_ptr | identifier_name |
label.rs | use Scalar;
use color::{Color, Colorable};
use elmesque::Element;
use graphics::character::CharacterCache;
use label::FontSize;
use theme::Theme;
use ui::GlyphCache;
use widget::{self, Widget, WidgetId};
/// Displays some given text centred within a rectangle.
#[derive(Clone, Debug)]
pub struct Label<'a> {
common... | let widget::UpdateArgs { prev_state,.. } = args;
let widget::State { state: State(ref string),.. } = *prev_state;
if &string[..]!= self.text { Some(State(self.text.to_string())) } else { None }
}
/// Construct an Element for the Label.
fn draw<'b, C>(args: widget::DrawArgs<'b, Self,... | where C: CharacterCache,
{ | random_line_split |
label.rs |
use Scalar;
use color::{Color, Colorable};
use elmesque::Element;
use graphics::character::CharacterCache;
use label::FontSize;
use theme::Theme;
use ui::GlyphCache;
use widget::{self, Widget, WidgetId};
/// Displays some given text centred within a rectangle.
#[derive(Clone, Debug)]
pub struct Label<'a> {
commo... | (&mut self) -> &mut widget::CommonBuilder { &mut self.common }
fn unique_kind(&self) -> &'static str { "Label" }
fn init_state(&self) -> State { State(String::new()) }
fn style(&self) -> Style { self.style.clone() }
fn default_width<C: CharacterCache>(&self, theme: &Theme, glyph_cache: &GlyphCache<C>) ... | common_mut | identifier_name |
label.rs |
use Scalar;
use color::{Color, Colorable};
use elmesque::Element;
use graphics::character::CharacterCache;
use label::FontSize;
use theme::Theme;
use ui::GlyphCache;
use widget::{self, Widget, WidgetId};
/// Displays some given text centred within a rectangle.
#[derive(Clone, Debug)]
pub struct Label<'a> {
commo... | else { None }
}
/// Construct an Element for the Label.
fn draw<'b, C>(args: widget::DrawArgs<'b, Self, C>) -> Element
where C: CharacterCache,
{
use elmesque::form::{text, collage};
use elmesque::text::Text;
let widget::DrawArgs { state, style, theme,.. } = args;
... | { Some(State(self.text.to_string())) } | conditional_block |
main.rs | extern crate piston;
extern crate graphics;
extern crate piston_window;
extern crate time;
extern crate rand;
extern crate ai_behavior;
extern crate cgmath;
extern crate opengl_graphics;
mod app;
mod entitymanager;
mod entity;
mod system;
mod player;
mod config;
mod person;
mod personspawner;
mod graphics_context;
us... | .unwrap_or_else(|e| { panic!("Failed to build PistonWindow: {}", e) });
window.set_ups(60);
let mut background_textures :Vec<String> = Vec::new();
background_textures.push(String::from("assets/img/ground/placeholder_01.jpg"));
background_textures.push(String::from("assets/img/ground/placeholder_... | .exit_on_esc(true)
.opengl(opengl)
.build() | random_line_split |
main.rs | extern crate piston;
extern crate graphics;
extern crate piston_window;
extern crate time;
extern crate rand;
extern crate ai_behavior;
extern crate cgmath;
extern crate opengl_graphics;
mod app;
mod entitymanager;
mod entity;
mod system;
mod player;
mod config;
mod person;
mod personspawner;
mod graphics_context;
us... | () {
let mut rng = rand::thread_rng();
let seed: [u32;4] = [rng.gen::<u32>(), rng.gen::<u32>(), rng.gen::<u32>(), rng.gen::<u32>()];
let opengl = OpenGL::V3_2;
let mut window: PistonWindow = WindowSettings::new("GGJ2016", [800, 600])
.exit_on_esc(true)
.opengl(opengl)
.build()
... | main | identifier_name |
main.rs | extern crate piston;
extern crate graphics;
extern crate piston_window;
extern crate time;
extern crate rand;
extern crate ai_behavior;
extern crate cgmath;
extern crate opengl_graphics;
mod app;
mod entitymanager;
mod entity;
mod system;
mod player;
mod config;
mod person;
mod personspawner;
mod graphics_context;
us... | let person_tex = String::from("assets/img/emoji/77.png");
ctx.load_texture(&player_tex);
ctx.load_texture(&person_tex);
ctx.load_texture(&String::from("assets/img/emoji/33.png"));
let mut app = app::App::new(player_tex);
app.add_system(Box::new(personspawner::PersonSpawner::new()));
app.ad... | {
let mut rng = rand::thread_rng();
let seed: [u32;4] = [rng.gen::<u32>(), rng.gen::<u32>(), rng.gen::<u32>(), rng.gen::<u32>()];
let opengl = OpenGL::V3_2;
let mut window: PistonWindow = WindowSettings::new("GGJ2016", [800, 600])
.exit_on_esc(true)
.opengl(opengl)
.build()
... | identifier_body |
main.rs | extern crate piston;
extern crate graphics;
extern crate piston_window;
extern crate time;
extern crate rand;
extern crate ai_behavior;
extern crate cgmath;
extern crate opengl_graphics;
mod app;
mod entitymanager;
mod entity;
mod system;
mod player;
mod config;
mod person;
mod personspawner;
mod graphics_context;
us... |
if let Some(args) = e.release_args() {
app.key_release(args);
}
if let Some(args) = e.update_args() {
app.update(args);
}
ctx.update_translation(app.get_player().get_position().x as u32, app.get_player().get_position().y as u32);
if let Some(a... | {
app.key_press(args);
} | conditional_block |
ziptuple.rs | use super::size_hint;
/// See [`multizip`](../fn.multizip.html) for more information.
#[derive(Clone)]
pub struct Zip<T> {
t: T, | #[deprecated(note = "Renamed to multizip")]
pub fn new<U>(t: U) -> Zip<T>
where Zip<T>: From<U>,
Zip<T>: Iterator,
{
multizip(t)
}
}
/// An iterator that generalizes *.zip()* and allows running multiple iterators in lockstep.
///
/// The iterator `Zip<(I, J,..., M)>` is fo... | }
impl<T> Zip<T> {
/// Deprecated: renamed to multizip | random_line_split |
ziptuple.rs | use super::size_hint;
/// See [`multizip`](../fn.multizip.html) for more information.
#[derive(Clone)]
pub struct Zip<T> {
t: T,
}
impl<T> Zip<T> {
/// Deprecated: renamed to multizip
#[deprecated(note = "Renamed to multizip")]
pub fn new<U>(t: U) -> Zip<T>
where Zip<T>: From<U>,
... |
}
/// An iterator that generalizes *.zip()* and allows running multiple iterators in lockstep.
///
/// The iterator `Zip<(I, J,..., M)>` is formed from a tuple of iterators (or values that
/// implement `IntoIterator`) and yields elements
/// until any of the subiterators yields `None`.
///
/// The iterator element t... | {
multizip(t)
} | identifier_body |
ziptuple.rs | use super::size_hint;
/// See [`multizip`](../fn.multizip.html) for more information.
#[derive(Clone)]
pub struct Zip<T> {
t: T,
}
impl<T> Zip<T> {
/// Deprecated: renamed to multizip
#[deprecated(note = "Renamed to multizip")]
pub fn | <U>(t: U) -> Zip<T>
where Zip<T>: From<U>,
Zip<T>: Iterator,
{
multizip(t)
}
}
/// An iterator that generalizes *.zip()* and allows running multiple iterators in lockstep.
///
/// The iterator `Zip<(I, J,..., M)>` is formed from a tuple of iterators (or values that
/// implement `... | new | identifier_name |
totaleq.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 trait_def = TraitDef {
cx: cx, span: span,
path: Path::new(~["std", "cmp", "TotalEq"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
methods: ~[
MethodDef {
name: "equals",
generics: LifetimeBounds::empty(),
... | {
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
cx, span, substr)
} | identifier_body |
totaleq.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 ... | (cx: &ExtCtxt,
span: Span,
mitem: @MetaItem,
in_items: ~[@Item]) -> ~[@Item] {
fn cs_equals(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
... | expand_deriving_totaleq | identifier_name |
totaleq.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 ... | }
]
};
trait_def.expand(mitem, in_items)
} | random_line_split | |
sprites.rs |
use sdl2::rect::Rect;
use sdl2::video::Window;
use sdl2::render::{Texture, Canvas};
pub struct Sprite<'a> {
rect: Rect,
pub size: Rect,
texture: &'a Texture,
}
impl<'a> Sprite<'a> {
pub fn | (&self, x: i32, y: i32, canvas: &mut Canvas<Window>) {
let pos_rect = Rect::new(x, y, self.size.width(), self.size.height());
match canvas.copy(&self.texture, Some(self.rect), Some(pos_rect)) {
Err(e) => println!("canvas copy error: {}", e),
_ => {}
}
}
}
pub struct ... | draw | identifier_name |
sprites.rs |
use sdl2::rect::Rect;
use sdl2::video::Window;
use sdl2::render::{Texture, Canvas};
pub struct Sprite<'a> {
rect: Rect,
pub size: Rect,
texture: &'a Texture,
}
impl<'a> Sprite<'a> {
pub fn draw(&self, x: i32, y: i32, canvas: &mut Canvas<Window>) {
let pos_rect = Rect::new(x, y, self.size.widt... |
}
}
}
pub struct SpriteSheet {
pub sprite_width: u32,
pub sprite_height: u32,
padding: u32,
pub texture: Texture,
}
impl SpriteSheet {
pub fn new(texture: Texture, sprite_width: u32, sprite_height: u32, padding: u32) -> Self {
SpriteSheet {
sprite_width,
... | {} | conditional_block |
sprites.rs | use sdl2::rect::Rect;
use sdl2::video::Window;
use sdl2::render::{Texture, Canvas};
pub struct Sprite<'a> {
rect: Rect,
pub size: Rect,
texture: &'a Texture,
}
impl<'a> Sprite<'a> {
pub fn draw(&self, x: i32, y: i32, canvas: &mut Canvas<Window>) {
let pos_rect = Rect::new(x, y, self.size.width... | }
// Creates a sprite object
pub fn get_sprite(&self, index: usize) -> Sprite {
let texture_query = self.texture.query();
let sheet_width = texture_query.width;
let columns = sheet_width / (self.sprite_width + self.padding);
let sheet_x = index as u32 % columns;
le... | sprite_height,
padding,
texture: texture,
} | random_line_split |
sprites.rs |
use sdl2::rect::Rect;
use sdl2::video::Window;
use sdl2::render::{Texture, Canvas};
pub struct Sprite<'a> {
rect: Rect,
pub size: Rect,
texture: &'a Texture,
}
impl<'a> Sprite<'a> {
pub fn draw(&self, x: i32, y: i32, canvas: &mut Canvas<Window>) |
}
pub struct SpriteSheet {
pub sprite_width: u32,
pub sprite_height: u32,
padding: u32,
pub texture: Texture,
}
impl SpriteSheet {
pub fn new(texture: Texture, sprite_width: u32, sprite_height: u32, padding: u32) -> Self {
SpriteSheet {
sprite_width,
sprite_height,... | {
let pos_rect = Rect::new(x, y, self.size.width(), self.size.height());
match canvas.copy(&self.texture, Some(self.rect), Some(pos_rect)) {
Err(e) => println!("canvas copy error: {}", e),
_ => {}
}
} | identifier_body |
motion.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Generic types for CSS Motion Path.
use crate::values::specified::SVGPathData;
/// The <size> in ray() funct... | {
ClosestSide,
ClosestCorner,
FarthestSide,
FarthestCorner,
Sides,
}
/// The `ray()` function, `ray( [ <angle> && <size> && contain? ] )`
///
/// https://drafts.fxtf.org/motion-1/#valdef-offsetpath-ray
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Debug,
MallocSizeOf,
P... | RaySize | identifier_name |
motion.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Generic types for CSS Motion Path.
use crate::values::specified::SVGPathData;
/// The <size> in ray() funct... | ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C)]
pub struct RayFunction<Angle> {
/// The bearing angle with `0deg` pointing up and positive angles
/// representing clockwise rotation.
pub angle: Angle,
/// Decide the path length used when `offset-distan... | MallocSizeOf,
PartialEq,
SpecifiedValueInfo, | random_line_split |
read_exact.rs | use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_exact`](super::AsyncReadExt::read_exact) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or... | return Poll::Ready(Err(io::ErrorKind::UnexpectedEof.into()));
}
}
Poll::Ready(Ok(()))
}
} | {
let (_, rest) = mem::replace(&mut this.buf, &mut []).split_at_mut(n);
this.buf = rest;
}
if n == 0 { | random_line_split |
read_exact.rs | use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_exact`](super::AsyncReadExt::read_exact) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or... |
}
Poll::Ready(Ok(()))
}
}
| {
return Poll::Ready(Err(io::ErrorKind::UnexpectedEof.into()));
} | conditional_block |
read_exact.rs | use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_exact`](super::AsyncReadExt::read_exact) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or... | (mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = &mut *self;
while!this.buf.is_empty() {
let n = ready!(Pin::new(&mut this.reader).poll_read(cx, this.buf))?;
{
let (_, rest) = mem::replace(&mut this.buf, &mut []).split_at_mut(n);... | poll | identifier_name |
read_exact.rs | use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_exact`](super::AsyncReadExt::read_exact) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or... |
}
| {
let this = &mut *self;
while !this.buf.is_empty() {
let n = ready!(Pin::new(&mut this.reader).poll_read(cx, this.buf))?;
{
let (_, rest) = mem::replace(&mut this.buf, &mut []).split_at_mut(n);
this.buf = rest;
}
if n == 0 ... | identifier_body |
fs.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&self) -> c_long { self.0.raw().st_mtime_nsec as c_long }
pub fn ctime(&self) -> raw::time_t { self.0.raw().st_ctime }
pub fn ctime_nsec(&self) -> c_long { self.0.raw().st_ctime_nsec as c_long }
pub fn blksize(&self) -> raw::blksize_t {
self.0.raw().st_blksize as raw::blksize_t
}
pub fn bl... | mtime_nsec | identifier_name |
fs.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
#[unstable(feature = "dir_builder", reason = "recently added API")]
/// An extension trait for `fs::DirBuilder` for unix-specific options.
pub trait DirBuilderExt {
/// Sets the mode to create new directories with. This option defaults to
/// 0o777.
fn mode(&mut self, mode: raw::mode_t) -> &mut Self;
}
i... | {
sys::fs::symlink(src.as_ref(), dst.as_ref())
} | identifier_body |
fs.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | impl Metadata {
pub fn dev(&self) -> raw::dev_t { self.0.raw().st_dev as raw::dev_t }
pub fn ino(&self) -> raw::ino_t { self.0.raw().st_ino as raw::ino_t }
pub fn mode(&self) -> raw::mode_t { self.0.raw().st_mode as raw::mode_t }
pub fn nlink(&self) -> raw::nlink_t { self.0.raw().st_nlink as raw::nlink_... | random_line_split | |
greatfet.rs | #![allow(missing_docs)] | use hal::lpc17xx::pin;
use hal::pin::Gpio;
use hal::pin::GpioDirection;
pub struct Led {
pin: pin::Pin,
}
impl Led {
pub fn new(idx: u8) -> Led {
Led {
pin: match idx {
0 => get_led(pin::Port::Port3, 14),
1 => get_led(pin::Port::Port2, 1),
... |
use core::intrinsics::abort; | random_line_split |
greatfet.rs | #![allow(missing_docs)]
use core::intrinsics::abort;
use hal::lpc17xx::pin;
use hal::pin::Gpio;
use hal::pin::GpioDirection;
pub struct Led {
pin: pin::Pin,
}
impl Led {
pub fn | (idx: u8) -> Led {
Led {
pin: match idx {
0 => get_led(pin::Port::Port3, 14),
1 => get_led(pin::Port::Port2, 1),
2 => get_led(pin::Port::Port3, 13),
3 => get_led(pin::Port::Port3, 12),
_ => unsaf... | new | identifier_name |
greatfet.rs | #![allow(missing_docs)]
use core::intrinsics::abort;
use hal::lpc17xx::pin;
use hal::pin::Gpio;
use hal::pin::GpioDirection;
pub struct Led {
pin: pin::Pin,
}
impl Led {
pub fn new(idx: u8) -> Led {
Led {
pin: match idx {
0 => get_led(pin::Port::Port3, 14),
... |
}
fn get_led(port: pin::Port, pin: u8) -> pin::Pin {
pin::Pin::new(
port, pin,
pin::Function::Gpio,
Some(GpioDirection::Out))
}
| {
self.pin.set_high();
} | identifier_body |
gain.rs | use super::super::api;
pub fn information_gain<T: api::RecordMeta>(data: &api::DataSet<T>, view: &api::DataSetView, criterion: &api::Criterion<T>) -> f64 {
let e = target_entropy(data, view);
let fe = entropy(data, view, criterion);
e - fe
}
fn entropy_helper<T: api::RecordMeta>(data: &api::DataSet<T>, vie... | {
let total = data.records.len();
let mut classes = vec![0; data.target_count];
for index in view.iter() {
let record = &data.records[*index];
classes[record.1 as usize] += 1;
}
for class in classes.iter() {
if *class == 0 {
return 0f64
}
}
let mut result = 0f64;
for class in classes.i... | identifier_body | |
gain.rs | use super::super::api;
pub fn | <T: api::RecordMeta>(data: &api::DataSet<T>, view: &api::DataSetView, criterion: &api::Criterion<T>) -> f64 {
let e = target_entropy(data, view);
let fe = entropy(data, view, criterion);
e - fe
}
fn entropy_helper<T: api::RecordMeta>(data: &api::DataSet<T>, view: &api::DataSetView, value: bool, criterion: &ap... | information_gain | identifier_name |
gain.rs | use super::super::api;
pub fn information_gain<T: api::RecordMeta>(data: &api::DataSet<T>, view: &api::DataSetView, criterion: &api::Criterion<T>) -> f64 {
let e = target_entropy(data, view);
let fe = entropy(data, view, criterion);
e - fe
|
fn entropy_helper<T: api::RecordMeta>(data: &api::DataSet<T>, view: &api::DataSetView, value: bool, criterion: &api::Criterion<T>) -> f64 {
let mut total = 0;
let mut classes = vec![0; data.target_count];
for index in view.iter() {
let record = &data.records[*index];
if criterion(&record.0) == value {
... | }
| random_line_split |
cci_impl_lib.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 ... | i += 1;
}
}
} | while i < v {
f(i); | random_line_split |
cci_impl_lib.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 ... | <F>(&self, v: uint, mut f: F) where F: FnMut(uint) {
let mut i = *self;
while i < v {
f(i);
i += 1;
}
}
}
| to | identifier_name |
cci_impl_lib.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 mut i = *self;
while i < v {
f(i);
i += 1;
}
} | identifier_body |
commit.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Helper library for rendering commit info
use std::collections::{BTreeMap, HashSet};
use std::io::Write;
use anyhow::Error;
use chrono... |
impl TryFrom<&thrift::CommitInfo> for CommitInfo {
type Error = Error;
fn try_from(commit: &thrift::CommitInfo) -> Result<CommitInfo, Error> {
let ids = map_commit_ids(commit.ids.values());
let parents = commit
.parents
.iter()
.map(|ids| map_commit_ids(ids.val... | random_line_split | |
commit.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Helper library for rendering commit info
use std::collections::{BTreeMap, HashSet};
use std::io::Write;
use anyhow::Error;
use chrono... | (commit: &thrift::CommitInfo) -> Result<CommitInfo, Error> {
let ids = map_commit_ids(commit.ids.values());
let parents = commit
.parents
.iter()
.map(|ids| map_commit_ids(ids.values()))
.collect();
let message = commit.message.clone();
let aut... | try_from | identifier_name |
broad_phase_filter2.rs | extern crate nalgebra as na;
use na::{Isometry2, Point2, RealField, Vector2};
use ncollide2d::broad_phase::BroadPhasePairFilter;
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::DefaultJointConstraintSet;
use nphysics2d::joint::{FreeJ... | {
let mut testbed = Testbed::<f32>::new_empty();
init_world(&mut testbed);
testbed.run();
} | identifier_body | |
broad_phase_filter2.rs | extern crate nalgebra as na;
use na::{Isometry2, Point2, RealField, Vector2};
use ncollide2d::broad_phase::BroadPhasePairFilter;
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::DefaultJointConstraintSet;
use nphysics2d::joint::{FreeJ... | ;
impl<N, Bodies, Colliders>
BroadPhasePairFilter<N, BroadPhasePairFilterSets<'_, N, Bodies, Colliders>>
for NoMultibodySelfContactFilter
where
N: RealField,
Bodies: BodySet<N>,
Colliders: ColliderSet<N, Bodies::Handle>,
{
fn is_pair_valid(
&self,
h1: Colliders::Handle,
... | NoMultibodySelfContactFilter | identifier_name |
broad_phase_filter2.rs | extern crate nalgebra as na;
use na::{Isometry2, Point2, RealField, Vector2};
use ncollide2d::broad_phase::BroadPhasePairFilter;
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::DefaultJointConstraintSet;
use nphysics2d::joint::{FreeJ... | * This simplifies experimentation with various scalar types (f32, fixed-point numbers, etc.)
*/
pub fn init_world<N: RealField>(testbed: &mut Testbed<N>) {
/*
* World
*/
let mechanical_world = DefaultMechanicalWorld::new(Vector2::new(r!(0.0), r!(-9.81)));
let geometrical_world = DefaultGeometric... |
/*
* NOTE: The `r` macro is only here to convert from f64 to the `N` scalar type. | random_line_split |
websocket.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::InheritTypes::EventTargetCast;
use dom::bindings::codegen::Bindings::EventHandlerBindi... | (global: &GlobalRef, url: DOMString) -> Temporary<WebSocket> {
let resource_task = global.resource_task();
let ws_url = Url::parse(url.as_slice()).unwrap();
let(start_chan, start_port) = channel();
resource_task.send(Load(LoadData::new(ws_url), start_chan));
let resp = start_port... | new | identifier_name |
websocket.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::InheritTypes::EventTargetCast;
use dom::bindings::codegen::Bindings::EventHandlerBindi... |
pub fn Constructor(global: &GlobalRef, url: DOMString) -> Fallible<Temporary<WebSocket>> {
Ok(WebSocket::new(global, url))
}
}
impl Reflectable for WebSocket {
fn reflector<'a>(&'a self) -> &'a Reflector {
self.eventtarget.reflector()
}
}
impl<'a> WebSocketMethods for JSRef<'a, WebSo... | {
let resource_task = global.resource_task();
let ws_url = Url::parse(url.as_slice()).unwrap();
let(start_chan, start_port) = channel();
resource_task.send(Load(LoadData::new(ws_url), start_chan));
let resp = start_port.recv();
reflect_dom_object(box WebSocket::new_inheri... | identifier_body |
websocket.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::InheritTypes::EventTargetCast;
use dom::bindings::codegen::Bindings::EventHandlerBindi... |
}
fn Close(self) {
}
fn Url(self) -> DOMString {
self.url.clone()
}
}
| {
return;
} | conditional_block |
websocket.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::InheritTypes::EventTargetCast;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::WebSocketBinding;
use dom::bindings::codegen::Bindings::WebSocketBinding::WebSo... | random_line_split | |
exterior.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: Point = Point {x: 10, y: 11, z: 12};
let b: Gc<Cell<Point>> = box(GC) Cell::new(a);
assert_eq!(b.get().z, 12);
f(b);
assert_eq!(a.z, 12);
assert_eq!(b.get().z, 13);
}
| {
assert!((p.get().z == 12));
p.set(Point {x: 10, y: 11, z: 13});
assert!((p.get().z == 13));
} | identifier_body |
exterior.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 f(p: Gc<Cell<Point>>) {
assert!((p.get().z == 12));
p.set(Point {x: 10, y: 11, z: 13});
assert!((p.get().z == 13));
}
pub fn main() {
let a: Point = Point {x: 10, y: 11, z: 12};
let b: Gc<Cell<Point>> = box(GC) Cell::new(a);
assert_eq!(b.get().z, 12);
f(b);
assert_eq!(a.z, 12);
... |
struct Point {x: int, y: int, z: int} | random_line_split |
exterior.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: Point = Point {x: 10, y: 11, z: 12};
let b: Gc<Cell<Point>> = box(GC) Cell::new(a);
assert_eq!(b.get().z, 12);
f(b);
assert_eq!(a.z, 12);
assert_eq!(b.get().z, 13);
}
| main | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.