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 |
|---|---|---|---|---|
util.rs | use std::collections::HashSet;
use std::fmt;
use std::net::IpAddr;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use futures::{Async, Future, Poll};
use ifaces;
use url::Url;
use pb::HostPortPb;
use timestamp::DateTime;
use DataType;
use Error;
use Row;
pub fn time_to_us(time: SystemTime) -> i64 {
// TODO: ... | addrs
};
}
/// Returns `true` if socket addr is for a local interface.
#[allow(dead_code)]
pub fn is_local_addr(addr: &IpAddr) -> bool {
LOCAL_ADDRS.contains(addr) || addr.is_loopback()
}
pub(crate) fn urls_from_pb(
hostports: &[HostPortPb],
https_enabled: bool,
) -> Result<Vec<Url>, Error> {
... | random_line_split | |
util.rs | use std::collections::HashSet;
use std::fmt;
use std::net::IpAddr;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use futures::{Async, Future, Poll};
use ifaces;
use url::Url;
use pb::HostPortPb;
use timestamp::DateTime;
use DataType;
use Error;
use Row;
pub fn time_to_us(time: SystemTime) -> i64 {
// TODO: ... | (&mut self) -> Poll<(F::Item, C), (F::Error, C)> {
match self.future.poll() {
Ok(Async::Ready(item)) => Ok(Async::Ready((
item,
self.context.take().expect("future already complete"),
))),
Ok(Async::NotReady) => Ok(Async::NotReady),
... | poll | identifier_name |
error.rs | use std::convert::TryFrom;
use std::error::Error;
use super::*;
use crate::attributes::{ComInterface, ComInterfaceVariant};
use crate::type_system::{AutomationTypeSystem, ExternOutput, RawTypeSystem, TypeSystem};
/// Error structure containing the available information on a COM error.
#[derive(Debug)]
pub struct ComE... |
}
impl From<ComError> for raw::HRESULT
{
fn from(error: ComError) -> raw::HRESULT
{
error.hresult
}
}
impl<'a> From<&'a str> for crate::ComError
{
fn from(s: &'a str) -> Self
{
s.to_string().into()
}
}
impl From<String> for crate::ComError
{
fn from(s: String) -> Self
... | {
ComError::new_hr(hresult)
} | identifier_body |
error.rs | use std::convert::TryFrom;
use std::error::Error;
use super::*;
use crate::attributes::{ComInterface, ComInterfaceVariant};
use crate::type_system::{AutomationTypeSystem, ExternOutput, RawTypeSystem, TypeSystem};
/// Error structure containing the available information on a COM error.
#[derive(Debug)]
pub struct ComE... | {
ComError::new_hr(hresult)
}
}
impl From<ComError> for raw::HRESULT
{
fn from(error: ComError) -> raw::HRESULT
{
error.hresult
}
}
impl<'a> From<&'a str> for crate::ComError
{
fn from(s: &'a str) -> Self
{
s.to_string().into()
}
}
impl From<String> for crate::... | {
fn from(hresult: raw::HRESULT) -> ComError | random_line_split |
error.rs | use std::convert::TryFrom;
use std::error::Error;
use super::*;
use crate::attributes::{ComInterface, ComInterfaceVariant};
use crate::type_system::{AutomationTypeSystem, ExternOutput, RawTypeSystem, TypeSystem};
/// Error structure containing the available information on a COM error.
#[derive(Debug)]
pub struct ComE... | (source: Self::ForeignType) -> ComResult<Self>
{
let com_error: ComError = <ComError as ExternOutput<TS>>::from_foreign_output(source)?;
Ok(Self::from(com_error))
}
}
impl ComError
{
/// Constructs a new `ComError` from a `HRESULT` code.
pub fn new_hr(hresult: raw::HRESULT) -> ComError
... | from_foreign_output | identifier_name |
borrowed-enum.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
fn zzz() {()}
| {
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
// 0b01111100011111000111110001111100 = 2088533116
// 0b0111110001111100 = 31868
// 0b01111100 = 124
let the_a = TheA { x: 0, y: 8970181431921507452 };
let the_a_ref: &ABC = &the_a;
// 0b000100010001000100010... | identifier_body |
borrowed-enum.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 ... | // debugger:run
// debugger:finish
// debugger:print *the_a_ref
// check:$1 = {{TheA, x = 0, y = 8970181431921507452}, {TheA, 0, 2088533116, 2088533116}}
// debugger:print *the_b_ref
// check:$2 = {{TheB, x = 0, y = 1229782938247303441}, {TheB, 0, 286331153, 286331153}}
// debugger:print *univariant_ref
// check:$3 ... | // compile-flags:-Z extra-debug-info
// debugger:rbreak zzz | random_line_split |
borrowed-enum.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 ... | () {
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
// 0b01111100011111000111110001111100 = 2088533116
// 0b0111110001111100 = 31868
// 0b01111100 = 124
let the_a = TheA { x: 0, y: 8970181431921507452 };
let the_a_ref: &ABC = &the_a;
// 0b000100010001000100... | main | identifier_name |
kinds.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 ... | /// covariant with respect to the type itself. This is (typically)
/// used to indicate that an instance of the type `T` is being stored
/// into memory and read from, even though that may not be apparent.
///
/// For more information about variance, refer to this Wikipedia
/// article <http://e... | /// some of the marker types below into your type.
pub mod marker {
/// A marker type whose type parameter `T` is considered to be | random_line_split |
kinds.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 ... | ;
/// A type which is considered managed by the GC. This is typically
/// embedded in other types.
#[lang="managed_bound"]
#[deriving(Eq,Clone)]
pub struct Managed;
}
| NoShare | identifier_name |
wc.rs | use std::process::Command;
use util::*;
static PROGNAME: &'static str = "./wc";
#[path = "common/util.rs"]
#[macro_use] | fn test_stdin_default() {
let mut cmd = Command::new(PROGNAME);
let result = run_piped_stdin(&mut cmd, get_file_contents("lorem_ipsum.txt"));
assert_eq!(result.stdout, " 13 109 772\n");
}
#[test]
fn test_stdin_only_bytes() {
let mut cmd = Command::new(PROGNAME);
let result = run_piped_stdin(&mut c... | mod util;
#[test] | random_line_split |
wc.rs | use std::process::Command;
use util::*;
static PROGNAME: &'static str = "./wc";
#[path = "common/util.rs"]
#[macro_use]
mod util;
#[test]
fn test_stdin_default() {
let mut cmd = Command::new(PROGNAME);
let result = run_piped_stdin(&mut cmd, get_file_contents("lorem_ipsum.txt"));
assert_eq!(result.stdout,... |
#[test]
fn test_multiple_default() {
let mut cmd = Command::new(PROGNAME);
let result = run(&mut cmd.args(&["lorem_ipsum.txt", "moby_dick.txt", "alice_in_wonderland.txt"]));
assert_eq!(result.stdout, " 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 alice_in_wonderland.txt\n... | {
let mut cmd = Command::new(PROGNAME);
let result = run(&mut cmd.args(&["-c", "-l", "-L", "-m", "-w", "alice_in_wonderland.txt"]));
assert_eq!(result.stdout, " 5 57 302 302 66 alice_in_wonderland.txt\n");
} | identifier_body |
wc.rs | use std::process::Command;
use util::*;
static PROGNAME: &'static str = "./wc";
#[path = "common/util.rs"]
#[macro_use]
mod util;
#[test]
fn test_stdin_default() {
let mut cmd = Command::new(PROGNAME);
let result = run_piped_stdin(&mut cmd, get_file_contents("lorem_ipsum.txt"));
assert_eq!(result.stdout,... | () {
let mut cmd = Command::new(PROGNAME);
let result = run(&mut cmd.args(&["lorem_ipsum.txt", "moby_dick.txt", "alice_in_wonderland.txt"]));
assert_eq!(result.stdout, " 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 alice_in_wonderland.txt\n 36 370 2189 total\n");
}
| test_multiple_default | identifier_name |
subst.rs | > for (T, T, T) {
fn len(&self) -> uint {
3
}
fn as_slice<'a>(&'a self) -> &'a [T] {
unsafe {
let ptr: *const T = mem::transmute(self);
let slice = raw::Slice { data: ptr, len: 3 };
mem::transmute(slice)
}
}
fn as_mut_slice<'a>(&'a mut se... | <'a>(&'a self, space: ParamSpace) -> &'a [T] {
let (start, limit) = self.limits(space);
self.content.slice(start, limit)
}
pub fn get_mut_slice<'a>(&'a mut self, space: ParamSpace) -> &'a mut [T] {
let (start, limit) = self.limits(space);
self.content.slice_mut(start, limit)
... | get_slice | identifier_name |
subst.rs | <T> for (T, T, T) {
fn len(&self) -> uint {
3
}
fn as_slice<'a>(&'a self) -> &'a [T] {
unsafe {
let ptr: *const T = mem::transmute(self);
let slice = raw::Slice { data: ptr, len: 3 };
mem::transmute(slice)
}
}
fn as_mut_slice<'a>(&'a mut ... | match space {
TypeSpace => (0, self.type_limit),
SelfSpace => (self.type_limit, self.self_limit),
FnSpace => (self.self_limit, self.content.len()),
}
}
pub fn empty() -> VecPerParamSpace<T> {
VecPerParamSpace {
type_limit: 0,
s... | fn limits(&self, space: ParamSpace) -> (uint, uint) { | random_line_split |
subst.rs | > for (T, T, T) {
fn len(&self) -> uint {
3
}
fn as_slice<'a>(&'a self) -> &'a [T] {
unsafe {
let ptr: *const T = mem::transmute(self);
let slice = raw::Slice { data: ptr, len: 3 };
mem::transmute(slice)
}
}
fn as_mut_slice<'a>(&'a mut se... |
pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) {
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
self.truncate(space, 0);
for t in elems.into_iter() {
self.push(space, t);
}
}
pub fn get_self<'a>(&'a self) -> Option<&'a T> {
... | {
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
while self.len(space) > len {
self.pop(space);
}
} | identifier_body |
associated-types-normalize-in-bounds.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 | // Test that we normalize associated types that appear in bounds; if
// we didn't, the call to `self.split2()` fails to type check.
// pretty-expanded FIXME #23616
use std::marker::PhantomData;
struct Splits<'a, T, P>(PhantomData<(&'a(),T,P)>);
struct SplitsN<I>(PhantomData<I>);
trait SliceExt2 {
type Item;
... | // 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 |
associated-types-normalize-in-bounds.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 ... | () { }
| main | identifier_name |
lib.rs | #![forbid(missing_docs, warnings)]
#![deny(deprecated, improper_ctypes, non_shorthand_field_patterns, overflowing_literals,
plugin_as_library, private_no_mangle_fns, private_no_mangle_statics, stable_features,
unconditional_recursion, unknown_lints, unsafe_code, unused, unused_allocation,
unused_attributes,... | ;
let encrypted = ntru::encrypt(&plain[0..plain_len as usize], public, params, &rand_ctx)
.unwrap();
let kp_decrypt2 = KeyPair::new(kp_multi2.get_private().clone(), public.clone());
let decrypted = ntru::decrypt(&encrypted, &kp_decrypt2, params).unwrap();
... | {
&pub_multi2[i - 1]
} | conditional_block |
lib.rs | #![forbid(missing_docs, warnings)]
#![deny(deprecated, improper_ctypes, non_shorthand_field_patterns, overflowing_literals,
plugin_as_library, private_no_mangle_fns, private_no_mangle_statics, stable_features,
unconditional_recursion, unknown_lints, unsafe_code, unused, unused_allocation,
unused_attributes,... | let seed2 = b"seed value";
let rng = RNG_CTR_DRBG;
let rand_ctx = ntru::rand::init_det(&rng, seed).unwrap();
let rng2 = RNG_CTR_DRBG;
let rand_ctx2 = ntru::rand::init_det(&rng2, seed2).unwrap();
for plain_len in 0..max_len as usize {
let encrypted = ntru::encrypt(&plain[0..plain_len], ... | let plain = ntru::rand::generate(u16::from(max_len), &rand_ctx_plaintext).unwrap();
let plain2 = plain.clone();
let seed = b"seed value"; | random_line_split |
lib.rs | #![forbid(missing_docs, warnings)]
#![deny(deprecated, improper_ctypes, non_shorthand_field_patterns, overflowing_literals,
plugin_as_library, private_no_mangle_fns, private_no_mangle_statics, stable_features,
unconditional_recursion, unknown_lints, unsafe_code, unused, unused_allocation,
unused_attributes,... |
fn gen_key_pair(seed: &str, params: &EncParams) -> KeyPair {
let seed_u8 = seed.as_bytes();
let rng = RNG_CTR_DRBG;
let rand_ctx = ntru::rand::init_det(&rng, seed_u8).unwrap();
ntru::generate_key_pair(params, &rand_ctx).unwrap()
}
fn sha1(input: &[u8]) -> [u8; 20] {
let mut hasher = sha1::Sha1::... | {
let (mut d, _) = if private.get_t().is_product() {
e.mult_prod(private.get_t().get_poly_prod(), modulus - 1)
} else {
e.mult_tern(private.get_t().get_poly_tern(), modulus - 1)
};
d.mod_mask(modulus - 1);
d.mult_fac(3);
d = d + e;
d.mod_center(modulus);
d.mod3();
for... | identifier_body |
lib.rs | #![forbid(missing_docs, warnings)]
#![deny(deprecated, improper_ctypes, non_shorthand_field_patterns, overflowing_literals,
plugin_as_library, private_no_mangle_fns, private_no_mangle_statics, stable_features,
unconditional_recursion, unknown_lints, unsafe_code, unused, unused_allocation,
unused_attributes,... | (input: &[u8]) -> [u8; 20] {
let mut hasher = sha1::Sha1::new();
hasher.update(input);
hasher.digest().bytes()
}
#[test]
fn it_keygen() {
let param_arr = &ALL_PARAM_SETS;
for params in param_arr {
let rand_ctx = ntru::rand::init(&RNG_DEFAULT).unwrap();
let mut kp = ntru::generate_... | sha1 | identifier_name |
borrowed-unique-basic.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... | let i64_ref: &i64 = i64_box;
let uint_box: Box<uint> = box 1;
let uint_ref: &uint = uint_box;
let u8_box: Box<u8> = box 100;
let u8_ref: &u8 = u8_box;
let u16_box: Box<u16> = box 16;
let u16_ref: &u16 = u16_box;
let u32_box: Box<u32> = box 32;
let u32_ref: &u32 = u32_box;
le... | {
let bool_box: Box<bool> = box true;
let bool_ref: &bool = bool_box;
let int_box: Box<int> = box -1;
let int_ref: &int = int_box;
let char_box: Box<char> = box 'a';
let char_ref: &char = char_box;
let i8_box: Box<i8> = box 68;
let i8_ref: &i8 = i8_box;
let i16_box: Box<i16> = bo... | identifier_body |
borrowed-unique-basic.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... | let bool_box: Box<bool> = box true;
let bool_ref: &bool = bool_box;
let int_box: Box<int> = box -1;
let int_ref: &int = int_box;
let char_box: Box<char> = box 'a';
let char_ref: &char = char_box;
let i8_box: Box<i8> = box 68;
let i8_ref: &i8 = i8_box;
let i16_box: Box<i16> = box ... |
fn main() { | random_line_split |
borrowed-unique-basic.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... | () {()}
| zzz | identifier_name |
io.rs | use std::error;
use std::fmt::{self, Display};
use std::io::{self, BufRead};
use {Grid, P};
/// The type for errors occurring in reading puzrs data.
#[derive(Debug)]
pub enum ReadError {
Io(io::Error),
InvalidFormat,
InvalidValue,
}
impl fmt::Display for ReadError {
fn fmt(&self, f: &mut fmt::Formatt... | <R, F, T>(reader: &mut R, converter: F, default: T) -> Result<Grid<T>, ReadError>
where
R: BufRead,
F: Fn(&str) -> Result<T, ReadError>,
T: Clone,
{
let mut buffer = String::new();
let height;
let width;
{
next_valid_line(reader, &mut buffer)?;
let mut header = buffer.split... | read_grid | identifier_name |
io.rs | use std::error;
use std::fmt::{self, Display};
use std::io::{self, BufRead};
use {Grid, P};
/// The type for errors occurring in reading puzrs data.
#[derive(Debug)]
pub enum ReadError {
Io(io::Error),
InvalidFormat,
InvalidValue,
}
impl fmt::Display for ReadError {
fn fmt(&self, f: &mut fmt::Formatt... | }
pub fn read_grid<R, F, T>(reader: &mut R, converter: F, default: T) -> Result<Grid<T>, ReadError>
where
R: BufRead,
F: Fn(&str) -> Result<T, ReadError>,
T: Clone,
{
let mut buffer = String::new();
let height;
let width;
{
next_valid_line(reader, &mut buffer)?;
let mut he... | } | random_line_split |
associated-types-binding-in-where-clause.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 ... | <I: Foo<A=Bar>>(x: I) -> Bar {
x.boo()
}
fn foo_uint<I: Foo<A=uint>>(x: I) -> uint {
x.boo()
}
pub fn main() {
let a = 42;
foo_uint(a);
let a = 'a';
foo_bar(a);
}
| foo_bar | identifier_name |
associated-types-binding-in-where-clause.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 ... |
}
impl Foo for char {
type A = Bar;
fn boo(&self) -> Bar { Bar }
}
fn foo_bar<I: Foo<A=Bar>>(x: I) -> Bar {
x.boo()
}
fn foo_uint<I: Foo<A=uint>>(x: I) -> uint {
x.boo()
}
pub fn main() {
let a = 42;
foo_uint(a);
let a = 'a';
foo_bar(a);
}
| { 42 } | identifier_body |
associated-types-binding-in-where-clause.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 ... | pub fn main() {
let a = 42;
foo_uint(a);
let a = 'a';
foo_bar(a);
} | }
| random_line_split |
build.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/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "bindgen")]
extern crate libbindgen;
#[cfg(feature = "bindg... | {
println!("cargo:rerun-if-changed=build.rs");
generate_properties();
build_gecko::generate();
} | identifier_body | |
build.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/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "bindgen")]
extern crate libbindgen;
#[cfg(feature = "bindg... | else { "regular" })
.status()
.unwrap();
if!status.success() {
exit(1)
}
let path = Path::new(&env::var("OUT_DIR").unwrap()).join("static_ids.rs");
let static_ids = Path::new(&env::var("OUT_DIR").unwrap()).join("static_ids.txt");
let mut file = BufWriter::new(File::create(&pa... | { "testing" } | conditional_block |
build.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/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "bindgen")]
extern crate libbindgen;
#[cfg(feature = "bindg... | map.build(&mut file).unwrap();
write!(&mut file, ";\n").unwrap();
}
fn main() {
println!("cargo:rerun-if-changed=build.rs");
generate_properties();
build_gecko::generate();
} | map.entry(key, value);
} | random_line_split |
build.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/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "bindgen")]
extern crate libbindgen;
#[cfg(feature = "bindg... | () -> String {
if Command::new("python2.7.exe").arg("--version").output().is_ok() {
return "python2.7.exe".to_owned();
}
if Command::new("python27.exe").arg("--version").output().is_ok() {
return "python27.exe".to_owned();
}
if Command::new("python.exe").arg("--version").output().i... | find_python | identifier_name |
data.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/. */
//! Per-node data used in style calculation.
#![deny(missing_docs)]
use context::SharedStyleContext;
use dom::TE... |
/// Returns true if the hint has animation-only restyle.
pub fn has_animation_hint(&self) -> bool {
self.0.intersects(RestyleHint::for_animations())
}
}
impl Default for StoredRestyleHint {
fn default() -> Self {
StoredRestyleHint::empty()
}
}
impl From<RestyleHint> for StoredRes... | {
self.0 |= other.0
} | identifier_body |
data.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/. */
//! Per-node data used in style calculation.
#![deny(missing_docs)]
use context::SharedStyleContext;
use dom::TE... |
result
}
/// Returns a list of the pseudo-elements.
pub fn keys(&self) -> Vec<PseudoElement> {
let mut v = Vec::new();
if let Some(ref arr) = self.0 {
for i in 0..EAGER_PSEUDO_COUNT {
if arr[i].is_some() {
v.push(PseudoElement::from_e... | {
self.0 = None;
} | conditional_block |
data.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/. */
//! Per-node data used in style calculation.
#![deny(missing_docs)]
use context::SharedStyleContext;
use dom::TE... |
/// Whether this element `display` value is `none`.
pub fn is_display_none(&self) -> bool {
self.primary.values().get_box().clone_display() == display::T::none
}
}
/// Restyle hint for storing on ElementData.
///
/// We wrap it in a newtype to force the encapsulation of the complexity of
/// handl... | cached_pseudos: PseudoElementCache::default(),
}
} | random_line_split |
data.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/. */
//! Per-node data used in style calculation.
#![deny(missing_docs)]
use context::SharedStyleContext;
use dom::TE... | (&self) -> bool {
self.0.intersects(RestyleHint::for_self())
}
/// Returns true if the hint indicates that our sibling's style may be
/// invalidated.
pub fn has_sibling_invalidations(&self) -> bool {
self.0.intersects(RESTYLE_LATER_SIBLINGS)
}
/// Whether the restyle hint is e... | has_self_invalidations | identifier_name |
main.rs | #![feature(plugin, no_std, core, start, core_intrinsics)]
#![crate_type="staticlib"]
#![no_std]
#![plugin(macro_platformtree)]
extern crate zinc;
#[macro_use] #[no_link] extern crate macro_platformtree;
use zinc::drivers::chario::CharIO;
platformtree!(
tiva_c@mcu {
clock {
source = "MOSC";
xtal ... | {
use zinc::hal::timer::Timer;
use zinc::hal::pin::Gpio;
args.uart.puts("Hello, world\r\n");
let mut i = 0;
loop {
args.txled.set_high();
args.uart.puts("Waiting for ");
args.uart.puti(i);
args.uart.puts(" seconds...\r\n");
i += 1;
args.txled.set_low();
args.timer.wait(1);
}
... | identifier_body | |
main.rs | #![feature(plugin, no_std, core, start, core_intrinsics)]
#![crate_type="staticlib"]
#![no_std]
#![plugin(macro_platformtree)]
extern crate zinc;
#[macro_use] #[no_link] extern crate macro_platformtree;
use zinc::drivers::chario::CharIO;
platformtree!(
tiva_c@mcu {
clock {
source = "MOSC";
xtal ... | single_task {
loop = "run";
args {
timer = &timer;
uart = &uart;
txled = &txled;
uart_tx = &uart_tx;
}
}
}
);
fn run(args: &pt::run_args) {
use zinc::hal::timer::Timer;
use zinc::hal::pin::Gpio;
args.uart.puts("Hello, world\r\n");
let mut i = 0;
l... | }
}
os { | random_line_split |
main.rs | #![feature(plugin, no_std, core, start, core_intrinsics)]
#![crate_type="staticlib"]
#![no_std]
#![plugin(macro_platformtree)]
extern crate zinc;
#[macro_use] #[no_link] extern crate macro_platformtree;
use zinc::drivers::chario::CharIO;
platformtree!(
tiva_c@mcu {
clock {
source = "MOSC";
xtal ... | (args: &pt::run_args) {
use zinc::hal::timer::Timer;
use zinc::hal::pin::Gpio;
args.uart.puts("Hello, world\r\n");
let mut i = 0;
loop {
args.txled.set_high();
args.uart.puts("Waiting for ");
args.uart.puti(i);
args.uart.puts(" seconds...\r\n");
i += 1;
args.txled.set_low();
ar... | run | identifier_name |
program_parsers.rs | use crate::asm::directive_parsers::*;
use crate::asm::instruction_parsers::*;
use nom::types::CompleteStr;
#[derive(Debug, PartialEq)]
pub struct Program {
pub instructions: Vec<Instruction>,
}
named!(pub program<CompleteStr, Program>,
do_parse!(
instructions: many1!(alt!(instruction | directive)) >>... | () {
let result = program(CompleteStr("load $i1 #42\nload $r2 #10.4\n"));
assert!(result.is_ok());
let (left, program) = result.unwrap();
assert_eq!(left, CompleteStr(""));
assert_eq!(2, program.instructions.len());
assert_eq!(
program.instructions,
... | test_parse_program | identifier_name |
program_parsers.rs | use crate::asm::directive_parsers::*;
use crate::asm::instruction_parsers::*;
use nom::types::CompleteStr;
#[derive(Debug, PartialEq)]
pub struct Program {
pub instructions: Vec<Instruction>,
}
named!(pub program<CompleteStr, Program>,
do_parse!(
instructions: many1!(alt!(instruction | directive)) >>... | );
#[cfg(test)]
mod tests {
use super::*;
use crate::asm::opcode::Opcode;
use crate::asm::Token;
#[test]
fn test_parse_program() {
let result = program(CompleteStr("load $i1 #42\nload $r2 #10.4\n"));
assert!(result.is_ok());
let (left, program) = result.unwrap();
a... | random_line_split | |
shootout-binarytrees.rs | // The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2012-2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted... | let arena = TypedArena::new();
let a = bottom_up_tree(&arena, i, depth);
let b = bottom_up_tree(&arena, -i, depth);
chk += item_check(&a) + item_check(&b);
}
format!("{}\t trees of depth {}\t check: {}",
iterations * 2, depth, chk)
}
fn main() {
let mut args = st... | for i in 1 .. iterations + 1 { | random_line_split |
shootout-binarytrees.rs | // The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2012-2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted... | <'a> {
l: Option<&'a Tree<'a>>,
r: Option<&'a Tree<'a>>,
i: i32
}
fn item_check(t: &Option<&Tree>) -> i32 {
match *t {
None => 0,
Some(&Tree { ref l, ref r, i }) => i + item_check(l) - item_check(r)
}
}
fn bottom_up_tree<'r>(arena: &'r TypedArena<Tree<'r>>, item: i32, depth: i32)
... | Tree | identifier_name |
shootout-binarytrees.rs | // The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2012-2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted... |
}
fn inner(depth: i32, iterations: i32) -> String {
let mut chk = 0;
for i in 1.. iterations + 1 {
let arena = TypedArena::new();
let a = bottom_up_tree(&arena, i, depth);
let b = bottom_up_tree(&arena, -i, depth);
chk += item_check(&a) + item_check(&b);
}
format!("{}\t... | {
None
} | conditional_block |
shootout-binarytrees.rs | // The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2012-2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted... |
fn main() {
let mut args = std::env::args();
let n = if std::env::var_os("RUST_BENCH").is_some() {
17
} else if args.len() <= 1 {
8
} else {
args.nth(1).unwrap().parse().unwrap()
};
let min_depth = 4;
let max_depth = if min_depth + 2 > n {min_depth + 2} else {n};
... | {
let mut chk = 0;
for i in 1 .. iterations + 1 {
let arena = TypedArena::new();
let a = bottom_up_tree(&arena, i, depth);
let b = bottom_up_tree(&arena, -i, depth);
chk += item_check(&a) + item_check(&b);
}
format!("{}\t trees of depth {}\t check: {}",
iterat... | identifier_body |
classpath.rs | // rustyVM - Java VM written in pure Rust
// Copyright (c) 2013 Alexander Gessler
//
// 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 r... | (&self, name : &str) -> Option<~[u8]>
{
let cname = name.to_owned();
let pname = cname.replace(&".", "/") + ".class";
for path in self.elems.get().iter() {
match result(|| {
let p = *path + "/" + pname;
debug!("locate class {}, trying path {}", cname, p);
File::open(&PosixPath::new(p)).read_... | locate_and_read | identifier_name |
classpath.rs | // rustyVM - Java VM written in pure Rust
// Copyright (c) 2013 Alexander Gessler
//
// 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 r... |
}
impl Clone for ClassPath {
fn clone(&self) -> ClassPath {
ClassPath {
elems : self.elems.clone()
}
}
}
#[cfg(test)]
mod tests {
use classpath::*;
#[test]
fn test_class_path_decomposition() {
let cp = ClassPath::new_from_string("~/some/other/bar; /bar/baz;dir ;");
assert_eq!(*cp.get_paths(),~[~".... | {
let cname = name.to_owned();
let pname = cname.replace(&".", "/") + ".class";
for path in self.elems.get().iter() {
match result(|| {
let p = *path + "/" + pname;
debug!("locate class {}, trying path {}", cname, p);
File::open(&PosixPath::new(p)).read_to_end()
}) {
Err(e) => continue... | identifier_body |
classpath.rs | // rustyVM - Java VM written in pure Rust
// Copyright (c) 2013 Alexander Gessler
//
// 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 r... | impl ClassPath {
// ----------------------------------------------
/** Convert from semicolon-separated list of paths to a ClassPath instance */
pub fn new_from_string(invar : &str) -> ClassPath
{
// current folder is always included
let mut v = ~[~"."];
// TODO: how to construct a vector directly from an... | random_line_split | |
extension.rs | use std::borrow::Cow;
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum Extension<'s> {
FlatUsage(Cow<'s, str>),
Hierarchy,
NoBody,
Other(Cow<'s, str>, Cow<'s, str>),
}
impl Extension<'_> {
pub fn key(&self) -> &'_ str {
match self {
Extension::Other(k, _) => k,
... |
}
impl ToString for Extension<'_> {
fn to_string(&self) -> String {
self.to_cow().into()
}
}
#[cfg(test)]
mod tests {
use super::*;
// Hardcoded known extensions could contain typos and not properly encoded characters, so test them.
// Perhaps at some point this could be statically guara... | {
use crate::encoding::encode;
[encode(self.key()), "=".into(), encode(self.value().as_ref())].concat()
} | identifier_body |
extension.rs | use std::borrow::Cow;
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum | <'s> {
FlatUsage(Cow<'s, str>),
Hierarchy,
NoBody,
Other(Cow<'s, str>, Cow<'s, str>),
}
impl Extension<'_> {
pub fn key(&self) -> &'_ str {
match self {
Extension::Other(k, _) => k,
Extension::FlatUsage(..) => "flat_usage",
Extension::Hierarchy => "hierar... | Extension | identifier_name |
extension.rs | use std::borrow::Cow;
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum Extension<'s> {
FlatUsage(Cow<'s, str>),
Hierarchy,
NoBody,
Other(Cow<'s, str>, Cow<'s, str>),
}
impl Extension<'_> {
pub fn key(&self) -> &'_ str {
match self {
Extension::Other(k, _) => k,
... | impl ToString for Extension<'_> {
fn to_string(&self) -> String {
self.to_cow().into()
}
}
#[cfg(test)]
mod tests {
use super::*;
// Hardcoded known extensions could contain typos and not properly encoded characters, so test them.
// Perhaps at some point this could be statically guarantee... | random_line_split | |
issue-83760.rs | struct Struct;
fn test1() {
let mut val = Some(Struct);
while let Some(foo) = val { //~ ERROR use of moved value
if true {
val = None;
} else {
}
}
}
fn test2() {
let mut foo = Some(Struct);
let _x = foo.unwrap();
if true {
foo = Some(Struct);
}... |
fn main() {}
| {
let mut foo = Some(Struct);
let _x = foo.unwrap();
if true {
foo = Some(Struct);
} else if true {
foo = Some(Struct);
} else if true {
foo = Some(Struct);
} else if true {
foo = Some(Struct);
} else {
}
let _y = foo; //~ ERROR use of moved value: `fo... | identifier_body |
issue-83760.rs | struct Struct;
fn | () {
let mut val = Some(Struct);
while let Some(foo) = val { //~ ERROR use of moved value
if true {
val = None;
} else {
}
}
}
fn test2() {
let mut foo = Some(Struct);
let _x = foo.unwrap();
if true {
foo = Some(Struct);
} else {
}
let _y... | test1 | identifier_name |
issue-83760.rs | struct Struct;
fn test1() { | let mut val = Some(Struct);
while let Some(foo) = val { //~ ERROR use of moved value
if true {
val = None;
} else {
}
}
}
fn test2() {
let mut foo = Some(Struct);
let _x = foo.unwrap();
if true {
foo = Some(Struct);
} else {
}
let _y = fo... | random_line_split | |
nullable.rs | use backend::Backend;
use expression::{Expression, SelectableExpression, NonAggregate};
use query_builder::*;
use types::IntoNullable;
pub struct Nullable<T>(T);
impl<T> Nullable<T> {
pub fn new(expr: T) -> Self {
Nullable(expr)
}
}
impl<T> Expression for Nullable<T> where
T: Expression,
<T a... | (&self, out: &mut DB::QueryBuilder) -> BuildQueryResult {
self.0.to_sql(out)
}
}
impl<T, QS> SelectableExpression<QS> for Nullable<T> where
T: SelectableExpression<QS>,
Nullable<T>: Expression,
{
}
impl<T> NonAggregate for Nullable<T> where
T: NonAggregate,
Nullable<T>: Expression,
{
}
| to_sql | identifier_name |
nullable.rs | use backend::Backend;
use expression::{Expression, SelectableExpression, NonAggregate};
use query_builder::*;
use types::IntoNullable;
pub struct Nullable<T>(T);
impl<T> Nullable<T> {
pub fn new(expr: T) -> Self |
}
impl<T> Expression for Nullable<T> where
T: Expression,
<T as Expression>::SqlType: IntoNullable,
{
type SqlType = <<T as Expression>::SqlType as IntoNullable>::Nullable;
}
impl<T, DB> QueryFragment<DB> for Nullable<T> where
DB: Backend,
T: QueryFragment<DB>,
{
fn to_sql(&self, out: &mut DB... | {
Nullable(expr)
} | identifier_body |
nullable.rs | use backend::Backend;
use expression::{Expression, SelectableExpression, NonAggregate};
use query_builder::*;
use types::IntoNullable; | pub struct Nullable<T>(T);
impl<T> Nullable<T> {
pub fn new(expr: T) -> Self {
Nullable(expr)
}
}
impl<T> Expression for Nullable<T> where
T: Expression,
<T as Expression>::SqlType: IntoNullable,
{
type SqlType = <<T as Expression>::SqlType as IntoNullable>::Nullable;
}
impl<T, DB> QueryF... | random_line_split | |
ci_statuses.rs | use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::vec::IntoIter;
use git2::{ Oid, Repository, Note };
use super::{ CIStatus };
use refs;
pub struct CIStatuses {
iter: IntoIter<CIStatus>,
}
fn | (git: &Repository, id: Oid) -> Vec<CIStatus> {
git.find_note(refs::CI_STATUSES, id).map(|note| from_note(id, note)).unwrap_or(Vec::new())
}
fn from_note<'r>(id: Oid, note: Note<'r>) -> Vec<CIStatus> {
note.message()
.map(|msg| from_msg(id, msg))
.unwrap_or(Vec::new())
}
fn from_msg<'r>(id: Oid, msg: &'r str... | find_all_for_commit | identifier_name |
ci_statuses.rs | use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::vec::IntoIter;
use git2::{ Oid, Repository, Note };
use super::{ CIStatus };
use refs;
pub struct CIStatuses {
iter: IntoIter<CIStatus>,
}
fn find_all_for_commit(git: &Repository, id: Oid) -> Vec<CIStatus> {
git.find_note(refs::CI_STAT... | .filter_map(|line| CIStatus::from_str(id, line).map_err(|e| println!("{}", e)).ok())
.collect()
}
fn filter_to_latest(vec: Vec<CIStatus>) -> Vec<CIStatus> {
let mut unkeyed: Vec<CIStatus> = Vec::new();
let mut latest: HashMap<String, CIStatus> = HashMap::new();
for status in vec {
match status.key().ma... | }
fn from_msg<'r>(id: Oid, msg: &'r str) -> Vec<CIStatus> {
msg.lines()
.filter(|line| !line.is_empty()) | random_line_split |
ci_statuses.rs | use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::vec::IntoIter;
use git2::{ Oid, Repository, Note };
use super::{ CIStatus };
use refs;
pub struct CIStatuses {
iter: IntoIter<CIStatus>,
}
fn find_all_for_commit(git: &Repository, id: Oid) -> Vec<CIStatus> |
fn from_note<'r>(id: Oid, note: Note<'r>) -> Vec<CIStatus> {
note.message()
.map(|msg| from_msg(id, msg))
.unwrap_or(Vec::new())
}
fn from_msg<'r>(id: Oid, msg: &'r str) -> Vec<CIStatus> {
msg.lines()
.filter(|line|!line.is_empty())
.filter_map(|line| CIStatus::from_str(id, line).map_err(|e| println!... | {
git.find_note(refs::CI_STATUSES, id).map(|note| from_note(id, note)).unwrap_or(Vec::new())
} | identifier_body |
main.rs | extern crate clap;
use std::io::prelude::*;
use std::io::{Error, ErrorKind};
use std::fs::File;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Direction {
Up,
Down,
Left,
Right,
}
struct Key(char);
impl Key {
fn new() -> Key {
Key('5')
}
fn shift_1(&self, dir: Direction) -> Ke... |
fn parse_args() -> std::io::Result<Box<Read>> {
let source = clap::App::new("Day 02")
.author("Devon Hollowood")
.arg(clap::Arg::with_name("instructions")
.index(1)
.short("f")
.long("instructions")
.help("file to read instructions from. Reads from std... | {
Error::new(ErrorKind::InvalidData, msg)
} | identifier_body |
main.rs | extern crate clap;
use std::io::prelude::*;
use std::io::{Error, ErrorKind};
use std::fs::File;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum | {
Up,
Down,
Left,
Right,
}
struct Key(char);
impl Key {
fn new() -> Key {
Key('5')
}
fn shift_1(&self, dir: Direction) -> Key {
use Direction::*;
let &Key(n) = self;
match dir {
Up =>
match n as u8 - '0' as u8 {
... | Direction | identifier_name |
main.rs | extern crate clap;
| use std::io::prelude::*;
use std::io::{Error, ErrorKind};
use std::fs::File;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Direction {
Up,
Down,
Left,
Right,
}
struct Key(char);
impl Key {
fn new() -> Key {
Key('5')
}
fn shift_1(&self, dir: Direction) -> Key {
use Dire... | random_line_split | |
poll.rs | use crate::future::FutureExt;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
/// A macro which returns the result of polling a future once within the
/// current `async` context.
///
/// This macro is only usable inside of `async` functions, closures, and blocks.
/// It ... | <F: Future + Unpin> {
future: F,
}
impl<F: Future + Unpin> Future for PollOnce<F> {
type Output = Poll<F::Output>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(self.future.poll_unpin(cx))
}
}
| PollOnce | identifier_name |
poll.rs | use crate::future::FutureExt;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
/// A macro which returns the result of polling a future once within the
/// current `async` context.
///
/// This macro is only usable inside of `async` functions, closures, and blocks.
/// It ... |
}
| {
Poll::Ready(self.future.poll_unpin(cx))
} | identifier_body |
poll.rs | use crate::future::FutureExt;
use core::pin::Pin; |
/// A macro which returns the result of polling a future once within the
/// current `async` context.
///
/// This macro is only usable inside of `async` functions, closures, and blocks.
/// It is also gated behind the `async-await` feature of this library, which is
/// activated by default.
///
/// If you need the re... | use futures_core::future::Future;
use futures_core::task::{Context, Poll}; | random_line_split |
issue-7911.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... | (i32);
struct Foo { bar: Bar }
impl FooBar for Bar {}
trait Test {
fn get_immut(&self) -> &FooBar;
fn get_mut(&mut self) -> &mut FooBar;
}
macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => (
impl Test for $type_ {
fn get_immut(&$slf) -> &FooBar {
&$field as &FooBa... | Bar | identifier_name |
issue-7911.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... |
}
struct Bar(i32);
struct Foo { bar: Bar }
impl FooBar for Bar {}
trait Test {
fn get_immut(&self) -> &FooBar;
fn get_mut(&mut self) -> &mut FooBar;
}
macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => (
impl Test for $type_ {
fn get_immut(&$slf) -> &FooBar {
&$fi... | { } | identifier_body |
issue-7911.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... | // with different mutability in macro in two methods
#![allow(unused_variables)] // unused foobar_immut + foobar_mut
trait FooBar {
fn dummy(&self) { }
}
struct Bar(i32);
struct Foo { bar: Bar }
impl FooBar for Bar {}
trait Test {
fn get_immut(&self) -> &FooBar;
fn get_mut(&mut self) -> &mut FooBar;
}
m... | // (Closes #7911) Test that we can use the same self expression | random_line_split |
coherence-impls-copy.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
}
| main | identifier_name |
coherence-impls-copy.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 ... |
fn main() {
} |
impl Copy for &'static [NotSync] {}
//~^ ERROR E0206 | random_line_split |
input.rs | // Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// This file is part of cancer.
//
// cancer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (a... | self.mouse = value;
}
if let Some(value) = table.get("locale").and_then(|v| v.as_str()) {
self.locale = Some(value.into());
}
}
pub fn prefix(&self) -> &Key {
&self.prefix
}
pub fn mouse(&self) -> bool {
self.mouse
}
pub fn locale(&self) -> Option<&str> {
self.locale.as_ref().map(AsRef::as_r... |
if let Some(value) = table.get("mouse").and_then(|v| v.as_bool()) { | random_line_split |
input.rs | // Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// This file is part of cancer.
//
// cancer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (a... | : AsRef<str>>(value: T) -> Key {
let value = value.as_ref();
let mut modifiers = value.split('-').collect::<Vec<&str>>();
let button = modifiers.pop().unwrap().to_lowercase();
let modifiers = modifiers.iter().fold(Default::default(), |acc, modifier|
match *modifier {
"C" => acc | key::CTRL,
... | _key<T | identifier_name |
viewer.rs | use std::f32::consts::PI;
use std::os::raw::c_void;
use std::path::Path;
use std::process;
use std::time::Instant;
use cgmath::{ Deg, Point3 };
use collision::Aabb;
use gl;
use gltf;
use glutin;
use glutin::{
Api,
MouseScrollDelta,
MouseButton,
GlContext,
GlRequest,
GlProfile,
VirtualKeyCod... | {
let pressed = match input.state {
Pressed => true,
Released => false
};
if let Some(code) = input.virtual_keycode {
match code {
VirtualKeyCode::Escape if pressed => return false,
VirtualKeyCode::W | VirtualKeyCode::Up => controls.process_keyboard(FORWARD... | identifier_body | |
viewer.rs | use std::f32::consts::PI;
use std::os::raw::c_void;
use std::path::Path;
use std::process;
use std::time::Instant;
use cgmath::{ Deg, Point3 };
use collision::Aabb;
use gl;
use gltf;
use glutin;
use glutin::{
Api,
MouseScrollDelta,
MouseButton,
GlContext,
GlRequest,
GlProfile,
VirtualKeyCod... | size: PhysicalSize,
dpi_factor: f64,
orbit_controls: OrbitControls,
events_loop: Option<glutin::EventsLoop>,
gl_window: Option<glutin::GlWindow>,
// TODO!: get rid of scene?
root: Root,
scene: Scene,
delta_time: f64, // seconds
last_frame: Instant,
render_timer: FrameTime... | random_line_split | |
viewer.rs | use std::f32::consts::PI;
use std::os::raw::c_void;
use std::path::Path;
use std::process;
use std::time::Instant;
use cgmath::{ Deg, Point3 };
use collision::Aabb;
use gl;
use gltf;
use glutin;
use glutin::{
Api,
MouseScrollDelta,
MouseButton,
GlContext,
GlRequest,
GlProfile,
VirtualKeyCod... | (&mut self, filename: &str, count: u32) {
let min_angle : f32 = 0.0 ;
let max_angle : f32 = 2.0 * PI ;
let increment_angle : f32 = ((max_angle - min_angle)/(count as f32)) as f32;
let suffix_length = count.to_string().len();
for i in 1..=count {
self.orbit_controls.r... | multiscreenshot | identifier_name |
viewer.rs | use std::f32::consts::PI;
use std::os::raw::c_void;
use std::path::Path;
use std::process;
use std::time::Instant;
use cgmath::{ Deg, Point3 };
use collision::Aabb;
use gl;
use gltf;
use glutin;
use glutin::{
Api,
MouseScrollDelta,
MouseButton,
GlContext,
GlRequest,
GlProfile,
VirtualKeyCod... | ,
_ => ()
}
}
WindowEvent::CursorMoved { position,.. } => {
let ph = position.to_physical(*dpi_factor);
orbit_controls.handle_mouse_move(ph)
},
WindowEvent::MouseWheel { de... | {
orbit_controls.state = NavState::None;
orbit_controls.handle_mouse_up();
} | conditional_block |
xray.rs | #![cfg(feature = "xray")]
extern crate rusoto_core;
extern crate rusoto_xray;
extern crate time;
use rusoto_core::Region;
use rusoto_xray::{GetServiceGraphRequest, XRay, XRayClient};
use time::OffsetDateTime;
// duplicates the AWS X-Ray CLI example, which gets an (empty) service graph
// for the last 600 seconds
#[t... | () {
let client = XRayClient::new(Region::UsEast1);
let time = (OffsetDateTime::now_utc().unix_timestamp() - 30) as f64; // 30 seconds in the past
println!("{:?}", time);
let request = GetServiceGraphRequest {
start_time: time - 600.0,
end_time: time,
..Default::default()
};... | should_get_service_graph | identifier_name |
xray.rs | #![cfg(feature = "xray")]
extern crate rusoto_core;
extern crate rusoto_xray;
extern crate time;
use rusoto_core::Region;
use rusoto_xray::{GetServiceGraphRequest, XRay, XRayClient};
use time::OffsetDateTime;
// duplicates the AWS X-Ray CLI example, which gets an (empty) service graph
// for the last 600 seconds
#[t... | {
let client = XRayClient::new(Region::UsEast1);
let time = (OffsetDateTime::now_utc().unix_timestamp() - 30) as f64; // 30 seconds in the past
println!("{:?}", time);
let request = GetServiceGraphRequest {
start_time: time - 600.0,
end_time: time,
..Default::default()
};
... | identifier_body | |
xray.rs | extern crate rusoto_core;
extern crate rusoto_xray;
extern crate time;
use rusoto_core::Region;
use rusoto_xray::{GetServiceGraphRequest, XRay, XRayClient};
use time::OffsetDateTime;
// duplicates the AWS X-Ray CLI example, which gets an (empty) service graph
// for the last 600 seconds
#[tokio::test]
async fn should... | #![cfg(feature = "xray")]
| random_line_split | |
test_ls.rs | /*
* Test Eio module.
*
* List and process all the rust source files '.rs' in the current dir.
*
*/
extern crate libc;
extern crate efl;
use libc::{c_char};
use std::c_str::CString;
use efl::ecore;
use efl::eio;
fn _filter_cb(count: &mut int, handler: &eio::EioFile, file: *c_char) -> bool |
fn _main_cb(count: &mut int, handler: &eio::EioFile, file: *c_char) {
let cstring = unsafe { CString::new(file, false) };
let v = match cstring.as_str() { None => "", Some(s) => s };
// Count processed files
*count += 1;
println!("Processing file: {} ({})", v, *count);
}
fn _done_cb(count: &mut i... | {
// Get a &str from the raw *c_char type
let cstring = unsafe { CString::new(file, false) };
let f = match cstring.as_str() { None => "", Some(s) => s };
// Let's process only rust source files!
if !f.ends_with(".rs") {
println!("Filtering file: {}", f);
return false
}
retur... | identifier_body |
test_ls.rs | /*
* Test Eio module.
*
* List and process all the rust source files '.rs' in the current dir.
*
*/
extern crate libc;
extern crate efl;
use libc::{c_char};
use std::c_str::CString;
use efl::ecore;
use efl::eio;
fn _filter_cb(count: &mut int, handler: &eio::EioFile, file: *c_char) -> bool {
// Get a &str... | (count: &mut int, handler: &eio::EioFile, error: int) {
println!("Error!");
ecore::main_loop_quit();
}
fn main() {
ecore::init();
eio::init();
let count: int = 0;
eio::file_ls(".", _filter_cb, _main_cb, _done_cb, _error_cb, &count);
ecore::main_loop_begin();
eio::shutdown();
eco... | _error_cb | identifier_name |
test_ls.rs | /*
* Test Eio module.
*
* List and process all the rust source files '.rs' in the current dir.
*
*/
extern crate libc;
extern crate efl;
use libc::{c_char};
use std::c_str::CString;
use efl::ecore;
use efl::eio;
fn _filter_cb(count: &mut int, handler: &eio::EioFile, file: *c_char) -> bool { | let f = match cstring.as_str() { None => "", Some(s) => s };
// Let's process only rust source files!
if!f.ends_with(".rs") {
println!("Filtering file: {}", f);
return false
}
return true;
}
fn _main_cb(count: &mut int, handler: &eio::EioFile, file: *c_char) {
let cstring = unsa... | // Get a &str from the raw *c_char type
let cstring = unsafe { CString::new(file, false) }; | random_line_split |
issue-61936.rs | // run-pass
trait SliceExt<T: Clone> {
fn array_windows_example<'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N>;
}
impl <T: Clone> SliceExt<T> for [T] {
fn array_windows_example<'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N> {
ArrayWindowsExample{ idx: 0, slice: &self }
... | };
ptr = ptr.wrapping_add(1);
self.idx += 1;
}
Some(res)
}
}
const FOUR: usize = 4;
fn main() {
let v: Vec<usize> = vec![0; 100];
for array in v.as_slice().array_windows_example::<FOUR>() {
assert_eq!(array, [0, 0, 0, 0])
}
} | random_line_split | |
issue-61936.rs | // run-pass
trait SliceExt<T: Clone> {
fn array_windows_example<'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N>;
}
impl <T: Clone> SliceExt<T> for [T] {
fn array_windows_example<'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N> |
}
struct ArrayWindowsExample<'a, T, const N: usize> {
slice: &'a [T],
idx: usize,
}
impl <'a, T: Clone, const N: usize> Iterator for ArrayWindowsExample<'a, T, N> {
type Item = [T; N];
fn next(&mut self) -> Option<Self::Item> {
// Note: this is unsound for some `T` and not meant as an example... | {
ArrayWindowsExample{ idx: 0, slice: &self }
} | identifier_body |
issue-61936.rs | // run-pass
trait SliceExt<T: Clone> {
fn array_windows_example<'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N>;
}
impl <T: Clone> SliceExt<T> for [T] {
fn | <'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N> {
ArrayWindowsExample{ idx: 0, slice: &self }
}
}
struct ArrayWindowsExample<'a, T, const N: usize> {
slice: &'a [T],
idx: usize,
}
impl <'a, T: Clone, const N: usize> Iterator for ArrayWindowsExample<'a, T, N> {
type Item = [T; N];... | array_windows_example | identifier_name |
endpoint.rs | /*
* Copyright 2021 Google LLC
*
* 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 t... |
}
/// Represents the set of all known upstream endpoints.
#[derive(Clone, Debug, PartialEq)]
pub struct Endpoints(Arc<Vec<Endpoint>>);
impl Endpoints {
/// Returns an [`Endpoints`] backed by the provided list of endpoints.
pub fn new(endpoints: Vec<Endpoint>) -> Option<Self> {
match endpoints.is_empt... | {
Ok(Self {
address: s.parse()?,
..Self::default()
})
} | identifier_body |
endpoint.rs | /*
* Copyright 2021 Google LLC
*
* 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 t... | <'de, D>(de: D) -> Result<Set, D::Error>
where
D: serde::Deserializer<'de>,
{
let items = <Vec<String> as serde::Deserialize>::deserialize(de)?;
let set = items.iter().cloned().collect::<Set<String>>();
if set.len()!= items.len() {
Err(D::Error::custom(
... | deserialize | identifier_name |
endpoint.rs | /*
* Copyright 2021 Google LLC
*
* 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 t... | let not_a_base64_string = "
quilkin.dev:
tokens:
- OGdqM3YyaQ== #8gj3v2i
- iix
";
for yaml in &[not_a_list, not_a_string_value, not_a_base64_string] {
serde_yaml::from_str::<EndpointMetadata>(yaml).unwrap_err();
}
}
} | "; | random_line_split |
endpoint.rs | /*
* Copyright 2021 Google LLC
*
* 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 t... |
let retained_items = new_subset.len();
self.subset = Some(new_subset);
if retained_items == total_items {
RetainedItems::All
} else {
RetainedItems::Some(retained_items)
}
}
/// Iterate over the endpoints in the current subset.
pub fn iter(... | {
return RetainedItems::None;
} | conditional_block |
lib.rs | extern crate num;
extern crate image;
use std::str::FromStr;
use num::Complex;
use image::ColorType;
use image::png::PNGEncoder;
use std::fs::File;
use std::io::Result;
fn escapes(c: Complex<f64>, limit: u32) -> Option<u32> {
let mut z = Complex {re: 0.0, im: 0.0};
for i in 0..limit {
z = z*z + c;
... | }
pub fn parse_pair<T: FromStr>(s: &str, separator: char) -> Option<(T, T)> {
match s.find(separator) {
None => None,
Some(index) => {
match (T::from_str(&s[..index]), T::from_str(&s[index+1..])) {
(Ok(l), Ok(r)) => Some((l, r)),
_ => None
}
... |
Ok(()) | random_line_split |
lib.rs | extern crate num;
extern crate image;
use std::str::FromStr;
use num::Complex;
use image::ColorType;
use image::png::PNGEncoder;
use std::fs::File;
use std::io::Result;
fn escapes(c: Complex<f64>, limit: u32) -> Option<u32> {
let mut z = Complex {re: 0.0, im: 0.0};
for i in 0..limit {
z = z*z + c;
... |
pub fn parse_pair<T: FromStr>(s: &str, separator: char) -> Option<(T, T)> {
match s.find(separator) {
None => None,
Some(index) => {
match (T::from_str(&s[..index]), T::from_str(&s[index+1..])) {
(Ok(l), Ok(r)) => Some((l, r)),
_ => None
}
... | {
let output = try!(File::create(filename));
let encoder = PNGEncoder::new(output);
try!(encoder.encode(&pixels[..],
bounds.0 as u32, bounds.1 as u32,
ColorType::Gray(8)));
Ok(())
} | identifier_body |
lib.rs | extern crate num;
extern crate image;
use std::str::FromStr;
use num::Complex;
use image::ColorType;
use image::png::PNGEncoder;
use std::fs::File;
use std::io::Result;
fn escapes(c: Complex<f64>, limit: u32) -> Option<u32> {
let mut z = Complex {re: 0.0, im: 0.0};
for i in 0..limit {
z = z*z + c;
... | (pixels: &mut [u8],
bounds: (usize, usize),
upper_left: (f64, f64),
lower_right: (f64, f64)) {
assert!(pixels.len() == bounds.0 * bounds.1);
for row in 0.. bounds.1 {
for column in 0.. bounds.0 {
let point = pixel_to_point(bounds, (column,row),
... | render | identifier_name |
main.rs | #[macro_use] extern crate log;
extern crate common;
extern crate env_logger;
extern crate game;
extern crate getopts;
extern crate gfx;
extern crate sdl2;
extern crate time;
extern crate wad;
use common::GeneralError;
use getopts::Options;
use std::path::PathBuf;
use std::error::Error;
use gfx::ShaderLoader;
use wad... | opts.optflag("h", "help", "print this help message and exit");
let matches = try!(opts.parse(&args[1..]).map_err(|e| GeneralError(e.to_string())));
if matches.opt_present("h") {
return Ok(RunMode::DisplayHelp(
opts.usage("rs_doom 0.0.7: A Rust Doom I/II Renderer.... | opts.optflag("", "check", "load metadata and all levels in WAD, then exit");
opts.optflag("", "list-levels",
"list the names and indices of all the levels in the WAD, then exit"); | random_line_split |
main.rs | #[macro_use] extern crate log;
extern crate common;
extern crate env_logger;
extern crate game;
extern crate getopts;
extern crate gfx;
extern crate sdl2;
extern crate time;
extern crate wad;
use common::GeneralError;
use getopts::Options;
use std::path::PathBuf;
use std::error::Error;
use gfx::ShaderLoader;
use wad... | {
DisplayHelp(String),
Check {
wad_file: PathBuf,
metadata_file: PathBuf,
},
ListLevelNames {
wad_file: PathBuf,
metadata_file: PathBuf,
},
Play(GameConfig),
}
impl RunMode {
pub fn from_args(args: &[String]) -> Result<RunMode, Box<Error>> {
let mut ... | RunMode | identifier_name |
flatten_sink.rs | use super::FlattenStreamSink;
use core::pin::Pin;
use futures_core::future::TryFuture;
use futures_core::stream::{FusedStream, Stream, TryStream};
use futures_core::task::{Context, Poll};
use futures_sink::Sink;
use pin_utils::unsafe_pinned;
/// Sink for the [`flatten_sink`](super::TryFutureExt::flatten_sink) method.
... |
impl<Fut, S> Stream for FlattenSink<Fut, S>
where
Fut: TryFuture<Ok = S>,
S: TryStream<Error = Fut::Error>,
{
type Item = Result<S::Ok, Fut::Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.inner().poll_next(cx)
}
}
impl<Fut, Si, Item> Si... | fn is_terminated(&self) -> bool {
self.inner.is_terminated()
}
} | random_line_split |
flatten_sink.rs | use super::FlattenStreamSink;
use core::pin::Pin;
use futures_core::future::TryFuture;
use futures_core::stream::{FusedStream, Stream, TryStream};
use futures_core::task::{Context, Poll};
use futures_sink::Sink;
use pin_utils::unsafe_pinned;
/// Sink for the [`flatten_sink`](super::TryFutureExt::flatten_sink) method.
... |
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
self.inner().start_send(item)
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner().poll_flush(cx)
}
fn poll_close(self: Pin<&mut Self>, cx: &mut Con... | {
self.inner().poll_ready(cx)
} | identifier_body |
flatten_sink.rs | use super::FlattenStreamSink;
use core::pin::Pin;
use futures_core::future::TryFuture;
use futures_core::stream::{FusedStream, Stream, TryStream};
use futures_core::task::{Context, Poll};
use futures_sink::Sink;
use pin_utils::unsafe_pinned;
/// Sink for the [`flatten_sink`](super::TryFutureExt::flatten_sink) method.
... | (self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
self.inner().start_send(item)
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner().poll_flush(cx)
}
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<R... | start_send | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.