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_ty_param_default_dependent_associated_type.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() {
let foo = Foo::new();
}
| {
Foo { data: PhantomData }
} | identifier_body |
default_ty_param_default_dependent_associated_type.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 ... | () -> Foo<X, Y> {
Foo { data: PhantomData }
}
}
fn main() {
let foo = Foo::new();
}
| new | identifier_name |
lib.rs | #![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")]
#![doc(html_logo_url = "https://www.ruma.io/images/logo.png")]
//! (De)serializable types for the [Matrix Identity Service API][identity-api].
//! These types can be shared by client and identity service code.
//!
//! [identity-api]: https://spec.matrix.org/... | (Box<str>);
impl fmt::Debug for PrivOwnedStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
| PrivOwnedStr | identifier_name |
lib.rs | #![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")]
#![doc(html_logo_url = "https://www.ruma.io/images/logo.png")]
//! (De)serializable types for the [Matrix Identity Service API][identity-api].
//! These types can be shared by client and identity service code.
//!
//! [identity-api]: https://spec.matrix.org/... | pub mod association;
pub mod authentication;
pub mod invitation;
pub mod keys;
pub mod lookup;
pub mod status;
pub mod tos;
// Wrapper around `Box<str>` that cannot be used in a meaningful way outside of
// this crate. Used for string enums because their `_Custom` variant can't be
// truly private (only `#[doc(hidden)... |
#![warn(missing_docs)]
use std::fmt;
| random_line_split |
lib.rs | #![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")]
#![doc(html_logo_url = "https://www.ruma.io/images/logo.png")]
//! (De)serializable types for the [Matrix Identity Service API][identity-api].
//! These types can be shared by client and identity service code.
//!
//! [identity-api]: https://spec.matrix.org/... |
}
| {
self.0.fmt(f)
} | identifier_body |
main.rs |
extern crate clap;
extern crate hex;
use clap::{App, Arg};
use self::hex::{FromHex, ToHex};
use std::collections::HashMap;
use std::io::{self, Read};
use std::f32;
use std::u8;
fn tally(vec: Vec<u8>) -> HashMap<u8, u8> {
let mut hashmap = HashMap::new();
for byte in vec {
let count = hashmap.entry(b... | (vec: Vec<u8>) -> HashMap<u8, f32> {
let tallied = tally(vec);
normalize(tallied)
}
pub fn freqs_ascii() -> HashMap<u8, f32> {
[ (9, 0.000057)
, (23, 0.000000)
, (32, 0.171662)
, (33, 0.000072)
, (34, 0.002442)
, (35, 0.000179)
, (36, 0.000561)
, (37, 0.000160)
, (38, 0.000226)
,... | frequency_distribution | identifier_name |
main.rs | extern crate clap;
extern crate hex;
use clap::{App, Arg};
use self::hex::{FromHex, ToHex};
use std::collections::HashMap;
use std::io::{self, Read};
use std::f32;
use std::u8;
fn tally(vec: Vec<u8>) -> HashMap<u8, u8> {
let mut hashmap = HashMap::new();
for byte in vec {
let count = hashmap.entry(by... | , (123, 0.000026)
, (124, 0.000007)
, (125, 0.000026)
, (126, 0.000003)
, (131, 0.000000)
, (149, 0.006410)
, (183, 0.000010)
, (223, 0.000000)
, (226, 0.000000)
, (229, 0.000000)
, (230, 0.000000)
, (237, 0.000000)
].iter().cloned().collect()
}
fn mse(reference: HashMap<u8, f32... | , (120, 0.001950)
, (121, 0.011330)
, (122, 0.000596) | random_line_split |
main.rs |
extern crate clap;
extern crate hex;
use clap::{App, Arg};
use self::hex::{FromHex, ToHex};
use std::collections::HashMap;
use std::io::{self, Read};
use std::f32;
use std::u8;
fn tally(vec: Vec<u8>) -> HashMap<u8, u8> {
let mut hashmap = HashMap::new();
for byte in vec {
let count = hashmap.entry(b... |
fn score(string: &str) -> f32 {
let decoded = FromHex::from_hex(&string).unwrap();
let freq_dist = frequency_distribution(decoded);
mse(freqs_ascii(), freq_dist)
}
pub fn break_single_byte_xor(string: &str) -> (u8, String) {
let bytes: Vec<u8> = FromHex::from_hex(&string).unwrap();
let mut mi... | {
let mut result = HashMap::new();
for (key, val) in reference.iter() {
if target.contains_key(key) {
// (jtobin) branch is only entered if 'target' contains 'key'
let tval = target.get(key).unwrap();
let sqdiff = (tval - val).powf(2.0);
result.insert(... | identifier_body |
main.rs |
extern crate clap;
extern crate hex;
use clap::{App, Arg};
use self::hex::{FromHex, ToHex};
use std::collections::HashMap;
use std::io::{self, Read};
use std::f32;
use std::u8;
fn tally(vec: Vec<u8>) -> HashMap<u8, u8> {
let mut hashmap = HashMap::new();
for byte in vec {
let count = hashmap.entry(b... |
}
| {
println!("{}", message.1);
} | conditional_block |
main.rs | pub mod cpu;
pub mod musashi;
mod ram;
#[macro_use]
extern crate lazy_static;
extern crate itertools;
use itertools::Itertools;
use std::io::Result;
use std::io::prelude::*;
use std::fs::File;
fn | () {
let mut cpu = cpu::Core::new_mem(0x40, &[0xc3, 0x00]);
cpu.ophandlers = cpu::ops::instruction_set();
cpu.dar[0] = 0x16;
cpu.dar[1] = 0x26;
cpu.execute1();
musashi::experimental_communication();
println!("Hello, CPU at {}", cpu.pc);
match write_state(&cpu) {
Ok(_) => return (... | main | identifier_name |
main.rs | pub mod cpu;
pub mod musashi;
mod ram;
#[macro_use]
extern crate lazy_static;
extern crate itertools;
use itertools::Itertools;
use std::io::Result;
use std::io::prelude::*;
use std::fs::File;
fn main() |
fn write_state(core: &cpu::Core) -> Result<()> {
let mut buffer = try!(File::create("cpustate.txt"));
let dxs = (0..8).map(|i| format!("D{}:{:08x}", i, core.dar[i])).join(" ");
let axs = (0..8).map(|i| format!("A{}:{:08x}", i, core.dar[i+8])).join(" ");
try!(writeln!(buffer, "PC:{:08x} SP:{:08x} SR:{:... | {
let mut cpu = cpu::Core::new_mem(0x40, &[0xc3, 0x00]);
cpu.ophandlers = cpu::ops::instruction_set();
cpu.dar[0] = 0x16;
cpu.dar[1] = 0x26;
cpu.execute1();
musashi::experimental_communication();
println!("Hello, CPU at {}", cpu.pc);
match write_state(&cpu) {
Ok(_) => return (),
... | identifier_body |
main.rs | pub mod cpu;
pub mod musashi;
mod ram;
#[macro_use]
extern crate lazy_static;
extern crate itertools;
use itertools::Itertools; |
use std::io::Result;
use std::io::prelude::*;
use std::fs::File;
fn main() {
let mut cpu = cpu::Core::new_mem(0x40, &[0xc3, 0x00]);
cpu.ophandlers = cpu::ops::instruction_set();
cpu.dar[0] = 0x16;
cpu.dar[1] = 0x26;
cpu.execute1();
musashi::experimental_communication();
println!("Hello, CP... | random_line_split | |
errorevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ErrorEventBinding;
use dom::bindings::c... | ;
let cancelable = if init.parent.cancelable {
EventCancelable::Cancelable
} else {
EventCancelable::NotCancelable
};
// Dictionaries need to be rooted
// https://github.com/servo/servo/issues/6381
let error = RootedValue::new(global.get_cx(), in... | { EventBubbles::DoesNotBubble } | conditional_block |
errorevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ErrorEventBinding;
use dom::bindings::c... | (global: GlobalRef,
type_: Atom,
bubbles: EventBubbles,
cancelable: EventCancelable,
message: DOMString,
filename: DOMString,
lineno: u32,
colno: u32,
error: HandleValue) -> Root<ErrorEvent> {
... | new | identifier_name |
errorevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ErrorEventBinding;
use dom::bindings::c... | pub fn Constructor(global: GlobalRef,
type_: DOMString,
init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Root<ErrorEvent>>{
let msg = match init.message.as_ref() {
Some(message) => message.clone(),
None => DOMString::new(),
}... | }
| random_line_split |
errorevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ErrorEventBinding;
use dom::bindings::c... |
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.event.IsTrusted()
}
}
| {
self.error.get()
} | identifier_body |
config.rs | // Copyright (C) 2020 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// ... |
pub fn get_string(&self, key: &str) -> Result<Option<String>> {
let mut default: Option<String> = None;
// First check if an argument was explicitly provided.
if let Some(args) = &self.args {
if args.occurrences_of(key) > 0 {
return Ok(Some(args.value_of(key).u... | {
let xform = key.replace(".", "_").replace("-", "_");
format!("EVEBOX_{}", xform.to_uppercase())
} | identifier_body |
config.rs | // Copyright (C) 2020 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// ... | (&self, key: &str) -> Result<bool> {
if let Some(args) = &self.args {
if args.occurrences_of(key) > 0 {
return Ok(true);
}
}
// If no argument provided, check environment.
if let Ok(val) = std::env::var(self.env_key(key)) {
return matc... | get_bool | identifier_name |
config.rs | // Copyright (C) 2020 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// ... | bail!("value not convertable to string")
}
}
}
/// Get a value as a bool, returning false if the key does not exist.
pub fn get_bool(&self, key: &str) -> Result<bool> {
if let Some(args) = &self.args {
if args.occurrences_of(key) > 0 {
... | // Return the clap default value.
Ok(default)
}
_ => { | random_line_split |
config.rs | // Copyright (C) 2020 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// ... |
// No argument or environment variable, check the configuration file.
let config_value = match self.find_value(key) {
serde_yaml::Value::String(s) => Some(s.into()),
serde_yaml::Value::Number(n) => Some(n.to_string()),
_ => None,
};
if let Some(value... | {
return Ok(Some(val));
} | conditional_block |
path.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | () -> PathBuf { super::config_path("Ethereum") }
/// Default path for ethereum installation (testnet)
pub fn test() -> PathBuf {
let mut path = default();
path.push("testnet");
path
}
/// Get the specific folder inside default ethereum installation
pub fn with_default(s: &str) -> PathBuf {
let mut path =... | default | identifier_name |
path.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... |
/// Default path for ethereum installation (testnet)
pub fn test() -> PathBuf {
let mut path = default();
path.push("testnet");
path
}
/// Get the specific folder inside default ethereum installation
pub fn with_default(s: &str) -> PathBuf {
let mut path = default();
path.push(s);
path
}
/// Get ... | { super::config_path("Ethereum") } | identifier_body |
path.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | Ok(())
} | pub fn restrict_permissions_owner(_file_path: &Path, _write: bool, _executable: bool) -> Result<(), String> {
//TODO: implement me | random_line_split |
float.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... | // Decrease the deccumulator one fractional digit at a time
deccum = deccum.fract();
dig += 1u;
}
// If digits are limited, and that limit has been reached,
// cut off the one extra digit, and depending on its value
// round the remaining ones.
... | radix);
buf[end] = c.unwrap() as u8;
end += 1;
| random_line_split |
float.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... | (&mut self, bytes: &[u8]) -> fmt::Result {
slice::bytes::copy_memory(self.buf.mut_slice_from(*self.end),
bytes);
*self.end += bytes.len();
Ok(())
}
}
let mut filler = Filler... | write | identifier_name |
float.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... | _ => return f("inf".as_bytes()),
};
}
FPInfinite if num < _0 => {
return match sign {
SignNone => return f("inf".as_bytes()),
_ => return f("-inf".as_bytes()),
};
}
_ => {}
}
let neg... | {
assert!(2 <= radix && radix <= 36);
match exp_format {
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
use of 'e' as decimal exponent", radix),
ExpBin if radix >= DIGIT_P_RADIX ... | identifier_body |
build_schema.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::compiler_state::CompilerState;
use crate::config::ProjectConfig;
use crate::docblocks::extract_schema_from_docblock_so... | (
compiler_state: &CompilerState,
project_config: &ProjectConfig,
) -> DiagnosticsResult<Arc<SDLSchema>> {
let schema = compiler_state.schema_cache.get(&project_config.name);
match schema {
Some(schema) if!compiler_state.project_has_pending_schema_changes(project_config.name) => {
Ok... | build_schema | identifier_name |
build_schema.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::compiler_state::CompilerState;
use crate::config::ProjectConfig;
use crate::docblocks::extract_schema_from_docblock_so... | relay_schema::build_schema_with_extensions(&schema_sources, &extensions)?;
if project_config.feature_flags.enable_relay_resolver_transform {
let mut projects = vec![project_config.name];
projects.extend(project_config.base);
let docblock_sour... | {
let mut extensions = vec![];
if let Some(project_extensions) = compiler_state.extensions.get(&project_config.name) {
extensions.extend(project_extensions.get_sources_with_location());
}
if let Some(base_project_name) = project_config.base {
... | conditional_block |
build_schema.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::compiler_state::CompilerState;
use crate::config::ProjectConfig;
use crate::docblocks::extract_schema_from_docblock_so... | compiler_state.schemas[&project_config.name]
.get_sources()
.into_iter()
.map(String::as_str),
);
let mut schema =
relay_schema::build_schema_with_extensions(&schema_sources, &extensions)?;
if p... | {
let schema = compiler_state.schema_cache.get(&project_config.name);
match schema {
Some(schema) if !compiler_state.project_has_pending_schema_changes(project_config.name) => {
Ok(schema.clone())
}
_ => {
let mut extensions = vec![];
if let Some(proje... | identifier_body |
build_schema.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::compiler_state::CompilerState;
use crate::config::ProjectConfig;
use crate::docblocks::extract_schema_from_docblock_so... | }
}
}
}
Ok(Arc::new(schema))
}
}
} | random_line_split | |
foldable.rs | use lift::Foldable;
use std::hash::Hash;
use std::collections::linked_list::LinkedList;
use std::collections::vec_deque::VecDeque;
use std::collections::{BinaryHeap, BTreeSet, HashSet};
//Implementation of Foldable for Vec
foldable!(Vec);
//Implementation of Foldable for LinkedList
foldable!(LinkedList);
//Implement... | <F>(&self, accum: Self::A, f: F) -> Self::A
where F: FnMut(Self::A, &Self::A) -> Self::A
{
self.iter().fold(accum, f)
}
}
//Implementation of Foldable for BTreeSet
impl<T: Ord> Foldable for BTreeSet<T> {
type A = T;
fn foldr<F>(&self, accum: Self::A, f: F) -> Self::A
where F: Fn... | foldr | identifier_name |
foldable.rs | use lift::Foldable;
use std::hash::Hash;
use std::collections::linked_list::LinkedList;
use std::collections::vec_deque::VecDeque;
use std::collections::{BinaryHeap, BTreeSet, HashSet};
//Implementation of Foldable for Vec
foldable!(Vec);
//Implementation of Foldable for LinkedList
foldable!(LinkedList);
//Implement... |
}
//Implementation of Foldable for HashSet
impl<T: Hash + Eq> Foldable for HashSet<T> {
type A = T;
fn foldr<F>(&self, accum: Self::A, f: F) -> Self::A
where F: FnMut(Self::A, &Self::A) -> Self::A
{
self.iter().fold(accum, f)
}
}
| {
self.iter().fold(accum, f)
} | identifier_body |
foldable.rs | use std::collections::linked_list::LinkedList;
use std::collections::vec_deque::VecDeque;
use std::collections::{BinaryHeap, BTreeSet, HashSet};
//Implementation of Foldable for Vec
foldable!(Vec);
//Implementation of Foldable for LinkedList
foldable!(LinkedList);
//Implementation of Foldable for VeqDeque
foldable!(... | use lift::Foldable;
use std::hash::Hash; | random_line_split | |
assoc-const.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | let x: [i32; <Succ<Succ<Succ<Succ<Zero>>>>>::VALUE] = [1, 2, 3, 4];
} | random_line_split | |
assoc-const.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let x: [i32; <Succ<Succ<Succ<Succ<Zero>>>>>::VALUE] = [1, 2, 3, 4];
}
| main | identifier_name |
assoc-const.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let x: [i32; <Succ<Succ<Succ<Succ<Zero>>>>>::VALUE] = [1, 2, 3, 4];
} | identifier_body | |
response_file.rs | use std::io::Read;
use std::iter::Iterator;
use std::option::Option;
use std::collections::VecDeque;
use std::fs::File;
pub struct ParseResponseFiles<I>
where I: Iterator<Item = String>
{
iter: I,
response_file_stack: VecDeque<String>,
}
impl<I> ParseResponseFiles<I>
where I: Iterator<Item = String>
{... |
fn next_from_stack(&mut self) -> Option<I::Item> {
self.response_file_stack.pop_front()
}
}
impl<I> Iterator for ParseResponseFiles<I>
where I: Iterator<Item = String>
{
type Item = I::Item;
fn next(&mut self) -> Option<I::Item> {
if self.response_file_stack.is_empty() {
... | {
match self.iter.next() {
None => None,
Some(item) => {
if item.starts_with("@") {
let mut f = File::open(&item[1..]).unwrap();
let mut s = String::new();
f.read_to_string(&mut s).unwrap();
s... | identifier_body |
response_file.rs | use std::io::Read;
use std::iter::Iterator;
use std::option::Option;
use std::collections::VecDeque;
use std::fs::File;
pub struct ParseResponseFiles<I>
where I: Iterator<Item = String>
{
iter: I,
response_file_stack: VecDeque<String>,
}
impl<I> ParseResponseFiles<I>
where I: Iterator<Item = String>
{... | "-DBAR".to_string(),
"-DPOST".to_string()];
assert_eq!(s.clone(), args.into_iter()
.extend_with_response_file()
.collect::<Vec<_>>())
}
} | "c++".to_string(),
"-DMID1".to_string(),
"-DMID2".to_string(),
"-DFOO".to_string(), | random_line_split |
response_file.rs | use std::io::Read;
use std::iter::Iterator;
use std::option::Option;
use std::collections::VecDeque;
use std::fs::File;
pub struct ParseResponseFiles<I>
where I: Iterator<Item = String>
{
iter: I,
response_file_stack: VecDeque<String>,
}
impl<I> ParseResponseFiles<I>
where I: Iterator<Item = String>
{... | (content: &String) -> Result<(String, TempDir)> {
let tmp_dir = try!(TempDir::new("cpp-codegen"));
let response_file_path = tmp_dir.path().join("interface.rsp");
let mut response_file = try!(File::create(&response_file_path));
try!(response_file.write(content.as_bytes()));
Ok((re... | write_response_file | identifier_name |
main.rs | extern crate chan_signal;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate env_logger;
extern crate fuse;
extern crate libc;
#[macro_use]
extern crate log;
extern crate syslog;
extern crate time;
use std::env;
use std::ffi::{OsStr, OsString};
use std::os::unix::ffi::OsStrExt;
use std::io;
use std::... |
static mut SYSLOG: bool = false;
static mut SYSLOGGER: Option<Box<syslog::Logger>> = None;
fn main_internal() -> error::Result<()> {
let format = |record: &LogRecord| {
let t = time::now();
let syslog: bool;
unsafe {
syslog = SYSLOG;
}
if!syslog {
f... | {
if let Err(e) = main_internal() {
error!("Cannot mount: {}", e);
std::process::exit(1);
}
} | identifier_body |
main.rs | extern crate chan_signal;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate env_logger;
extern crate fuse;
extern crate libc;
#[macro_use]
extern crate log;
extern crate syslog;
extern crate time;
use std::env;
use std::ffi::{OsStr, OsString};
use std::os::unix::ffi::OsStrExt;
use std::io;
use std::... | () {
if let Err(e) = main_internal() {
error!("Cannot mount: {}", e);
std::process::exit(1);
}
}
static mut SYSLOG: bool = false;
static mut SYSLOGGER: Option<Box<syslog::Logger>> = None;
fn main_internal() -> error::Result<()> {
let format = |record: &LogRecord| {
let t = time::no... | main | identifier_name |
main.rs | extern crate chan_signal;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate env_logger;
extern crate fuse;
extern crate libc;
#[macro_use]
extern crate log;
extern crate syslog;
extern crate time;
use std::env;
use std::ffi::{OsStr, OsString};
use std::os::unix::ffi::OsStrExt;
use std::io;
use std::... | .takes_value(true)
.help("Run as this gid"),
value: &mut flags.gid,
},
flags::Flag {
arg: Arg::with_name("option")
.short("o")
.takes_value(true)
.multiple(true)
... | arg: Arg::with_name("gid")
.long("gid") | random_line_split |
main.rs | extern crate chan_signal;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate env_logger;
extern crate fuse;
extern crate libc;
#[macro_use]
extern crate log;
extern crate syslog;
extern crate time;
use std::env;
use std::ffi::{OsStr, OsString};
use std::os::unix::ffi::OsStrExt;
use std::io;
use std::... |
}
static mut SYSLOG: bool = false;
static mut SYSLOGGER: Option<Box<syslog::Logger>> = None;
fn main_internal() -> error::Result<()> {
let format = |record: &LogRecord| {
let t = time::now();
let syslog: bool;
unsafe {
syslog = SYSLOG;
}
if!syslog {
... | {
error!("Cannot mount: {}", e);
std::process::exit(1);
} | conditional_block |
normalization-debruijn-1.rs | // build-pass
// edition:2018
// Regression test to ensure we handle debruijn indices correctly in projection
// normalization under binders. Found in crater run for #85499
use std::future::Future;
use std::pin::Pin;
pub enum Outcome<S, E> {
Success((S, E)),
}
pub struct Request<'r> {
_marker: std::marker::Ph... | }
fn main() {} | }
});
todo!()
} | random_line_split |
normalization-debruijn-1.rs | // build-pass
// edition:2018
// Regression test to ensure we handle debruijn indices correctly in projection
// normalization under binders. Found in crater run for #85499
use std::future::Future;
use std::pin::Pin;
pub enum Outcome<S, E> {
Success((S, E)),
}
pub struct Request<'r> {
_marker: std::marker::Ph... | <'life0>(
request: &'r Request<'life0>,
) -> Pin<Box<dyn Future<Output = Outcome<Self, Self::Error>>>> {
Box::pin(async move {
let request = request;
match T::from_request(request).await {
_ => todo!(),
}
});
todo!()
}
}
fn mai... | from_request | identifier_name |
normalization-debruijn-1.rs | // build-pass
// edition:2018
// Regression test to ensure we handle debruijn indices correctly in projection
// normalization under binders. Found in crater run for #85499
use std::future::Future;
use std::pin::Pin;
pub enum Outcome<S, E> {
Success((S, E)),
}
pub struct Request<'r> {
_marker: std::marker::Ph... |
}
fn main() {}
| {
Box::pin(async move {
let request = request;
match T::from_request(request).await {
_ => todo!(),
}
});
todo!()
} | 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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::WebSocketBinding;
use dom::bindings::co... |
}
}
}
| {
self.dispatch_close();
} | 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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::WebSocketBinding;
use dom::bindings::co... | let event = Event::new(global.r(), "open".to_owned(),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable);
event.fire(EventTargetCast::from_ref(ws.r()));
}
fn dispatch_close(&self) {
let ws = self.addr.root();
... | // Step 4: Protocols.
// Step 5: Cookies.
// Step 6.
let global = ws.global.root(); | 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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::WebSocketBinding;
use dom::bindings::co... | (global: GlobalRef, url: DOMString) -> Fallible<Root<WebSocket>> {
WebSocket::new(global, url)
}
}
impl<'a> WebSocketMethods for &'a WebSocket {
event_handler!(open, GetOnopen, SetOnopen);
event_handler!(close, GetOnclose, SetOnclose);
event_handler!(error, GetOnerror, SetOnerror);
fn Url(... | Constructor | 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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::WebSocketBinding;
use dom::bindings::co... |
pub fn new(global: GlobalRef, url: DOMString) -> Fallible<Root<WebSocket>> {
// Step 1.
// FIXME extract the right variables once Client::connect
// implementation is fixed to follow the RFC 6455 properly.
let (url, _, _, _, _) = try!(parse_web_socket_url(&url));
/*TODO: T... | {
WebSocket {
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WebSocket),
url: url,
global: GlobalField::from_rooted(&global),
ready_state: Cell::new(WebSocketRequestState::Connecting),
failed: Cell::new(false),
sender: RefCell::... | identifier_body |
parse_file.rs | #[macro_use]
extern crate difference;
use liquid::*;
use std::fs::File;
use std::io::Read;
fn compare_by_file(name: &str, globals: &Object) {
let input_file = format!("tests/fixtures/input/{}.txt", name);
let output_file = format!("tests/fixtures/output/{}.txt", name);
let template = ParserBuilder::with_... | {
let globals = object!({
"num": 5,
"numTwo": 6
});
compare_by_file("example", &globals);
} | identifier_body | |
parse_file.rs | #[macro_use]
extern crate difference;
use liquid::*;
use std::fs::File;
use std::io::Read;
fn compare_by_file(name: &str, globals: &Object) {
let input_file = format!("tests/fixtures/input/{}.txt", name);
let output_file = format!("tests/fixtures/output/{}.txt", name);
let template = ParserBuilder::with_... | File::open(output_file)
.unwrap()
.read_to_string(&mut comp)
.unwrap();
assert_diff!(&comp, &output, " ", 0);
}
#[test]
pub fn error_on_nonexistent_file() {
let template = ParserBuilder::with_stdlib()
.build()
.unwrap()
.parse_file("not-a-file.ext");
assert!(t... |
let output = template.render(globals).unwrap();
let mut comp = String::new(); | random_line_split |
parse_file.rs | #[macro_use]
extern crate difference;
use liquid::*;
use std::fs::File;
use std::io::Read;
fn compare_by_file(name: &str, globals: &Object) {
let input_file = format!("tests/fixtures/input/{}.txt", name);
let output_file = format!("tests/fixtures/output/{}.txt", name);
let template = ParserBuilder::with_... | () {
let template = ParserBuilder::with_stdlib()
.build()
.unwrap()
.parse_file("not-a-file.ext");
assert!(template.is_err());
}
#[test]
pub fn example_by_file() {
let globals = object!({
"num": 5,
"numTwo": 6
});
compare_by_file("example", &globals);
}
| error_on_nonexistent_file | identifier_name |
tool_bar.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! Create bars of buttons and other widgets
use libc::c_int;
use ffi;
use glib::{to_bool, ... | lse {
Some(::FFIWidget::wrap_widget(tmp_pointer))
}
}
}
pub fn get_drop_index(&self, x: i32, y: i32) -> i32 {
unsafe {
ffi::gtk_toolbar_get_drop_index(GTK_TOOLBAR(self.pointer), x as c_int, y as c_int) as i32
}
}
pub fn set_drop_highlight... | None
} e | conditional_block |
tool_bar.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! Create bars of buttons and other widgets
use libc::c_int;
use ffi;
use glib::{to_bool, ... | pub fn get_drop_index(&self, x: i32, y: i32) -> i32 {
unsafe {
ffi::gtk_toolbar_get_drop_index(GTK_TOOLBAR(self.pointer), x as c_int, y as c_int) as i32
}
}
pub fn set_drop_highlight_item<T: ::ToolItemTrait>(&self, item: &T, index: i32) -> () {
unsafe {
ffi::... | unsafe {
let tmp_pointer = ffi::gtk_toolbar_get_nth_item(GTK_TOOLBAR(self.pointer), n as c_int) as *mut ffi::GtkWidget;
if tmp_pointer.is_null() {
None
} else {
Some(::FFIWidget::wrap_widget(tmp_pointer))
}
}
}
| identifier_body |
tool_bar.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! Create bars of buttons and other widgets
use libc::c_int;
use ffi;
use glib::{to_bool, ... | self) -> () {
unsafe {
ffi::gtk_toolbar_unset_icon_size(GTK_TOOLBAR(self.pointer))
}
}
pub fn get_show_arrow(&self) -> bool {
unsafe { to_bool(ffi::gtk_toolbar_get_show_arrow(GTK_TOOLBAR(self.pointer))) }
}
pub fn get_style(&self) -> ToolbarStyle {
unsafe {
... | set_icon_size(& | identifier_name |
tool_bar.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! Create bars of buttons and other widgets
use libc::c_int;
use ffi;
use glib::{to_bool, ... |
pub fn get_style(&self) -> ToolbarStyle {
unsafe {
ffi::gtk_toolbar_get_style(GTK_TOOLBAR(self.pointer))
}
}
pub fn get_icon_size(&self) -> IconSize {
unsafe {
ffi::gtk_toolbar_get_icon_size(GTK_TOOLBAR(self.pointer))
}
}
pub fn get_relief_s... | }
pub fn get_show_arrow(&self) -> bool {
unsafe { to_bool(ffi::gtk_toolbar_get_show_arrow(GTK_TOOLBAR(self.pointer))) }
} | random_line_split |
nested_item.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | static X: usize = 1;
}
}
// issue 8134
pub struct Parser<T>(T);
impl<T: std::iter::Iterator<Item=char>> Parser<T> {
fn in_doctype(&mut self) {
static DOCTYPEPattern: [char; 6] = ['O', 'C', 'T', 'Y', 'P', 'E'];
}
}
struct Bar;
impl Foo {
pub fn bar<T>(&self) {
static X: usize = ... | pub fn foo<T>(&self) { | random_line_split |
nested_item.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 ... |
}
struct Bar;
impl Foo {
pub fn bar<T>(&self) {
static X: usize = 1;
}
}
| {
static DOCTYPEPattern: [char; 6] = ['O', 'C', 'T', 'Y', 'P', 'E'];
} | identifier_body |
nested_item.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 ... | <T>(&self) {
static X: usize = 1;
}
}
| bar | identifier_name |
expr-if-fail.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 test_elseif_fail() {
let x = if false { 0 } else if false { fail2!() } else { 10 };
assert_eq!(x, 10);
}
pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); }
| {
let x = if true { 10 } else { fail2!() };
assert_eq!(x, 10);
} | identifier_body |
expr-if-fail.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | else { 10 }; assert!((x == 10)); }
fn test_else_fail() {
let x = if true { 10 } else { fail2!() };
assert_eq!(x, 10);
}
fn test_elseif_fail() {
let x = if false { 0 } else if false { fail2!() } else { 10 };
assert_eq!(x, 10);
}
pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); }
| { fail2!() } | conditional_block |
expr-if-fail.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () { let x = if false { fail2!() } else { 10 }; assert!((x == 10)); }
fn test_else_fail() {
let x = if true { 10 } else { fail2!() };
assert_eq!(x, 10);
}
fn test_elseif_fail() {
let x = if false { 0 } else if false { fail2!() } else { 10 };
assert_eq!(x, 10);
}
pub fn main() { test_if_fail(); test_e... | test_if_fail | identifier_name |
expr-if-fail.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn test_if_fail() { let x = if false { fail2!() } else { 10 }; assert!((x == 10)); }
fn... | random_line_split | |
main.rs | const n: usize = (16*1024);
struct foo {
chaMem: *mut [u32; n],
}
impl foo {
pub fn new() -> foo {
let mem: *mut [u32; n] = unsafe { ::std::mem::transmute(Box::new([1; n])) };
foo {chaMem: mem}
}
pub fn get_sig_ptr(&mut self, cha_signal: *mut *mut u32) {
unsafe {
... |
pub fn get_sig_ptr4(&mut self) -> &mut [u32; n] {
unsafe {
return &mut *(self.chaMem);
}
}
}
// This code is editable and runnable!
fn main() {
let mut f = foo::new();
let mut cha_signal1: *mut u32 = ::std::ptr::null_mut();
f.get_sig_ptr(&mut cha_signal1);
... | {
return self.chaMem;
} | identifier_body |
main.rs | const n: usize = (16*1024);
struct foo {
chaMem: *mut [u32; n],
}
impl foo {
pub fn new() -> foo {
let mem: *mut [u32; n] = unsafe { ::std::mem::transmute(Box::new([1; n])) };
foo {chaMem: mem}
}
pub fn get_sig_ptr(&mut self, cha_signal: *mut *mut u32) {
unsafe {
... |
let mut cha_signal1: *mut u32 = ::std::ptr::null_mut();
f.get_sig_ptr(&mut cha_signal1);
for i in 1..n {
println!("{}", unsafe { *cha_signal1.offset(i as isize) }); // (*cha_signal)[i]
}
let mut cha_signal2: *mut u32 = f.get_sig_ptr2();
for i in 1..n {
printl... | // This code is editable and runnable!
fn main() {
let mut f = foo::new(); | random_line_split |
main.rs | const n: usize = (16*1024);
struct | {
chaMem: *mut [u32; n],
}
impl foo {
pub fn new() -> foo {
let mem: *mut [u32; n] = unsafe { ::std::mem::transmute(Box::new([1; n])) };
foo {chaMem: mem}
}
pub fn get_sig_ptr(&mut self, cha_signal: *mut *mut u32) {
unsafe {
*cha_signal = self.chaMem as *mut _;... | foo | identifier_name |
grid_level.rs | use std::default::Default;
use tile::Tile;
use util::{Error, Grid};
use Vector;
#[derive(Clone)]
pub struct GridLevel<T> {
pub(crate) tiles: Grid<T>,
}
impl<T> GridLevel<T> {
pub fn get_width(&self) -> usize {
self.tiles.get_width()
}
pub fn get_height(&self) -> usize {
self.tiles.get... | (level: &GridLevel<Tile>, x: usize, y: usize) -> bool {
use util::Direction;
let mut paths = 0;
for dir in Direction::get_orthogonal_dirs() {
let vector = dir.get_vec();
let coord = match (
add_isize_to_usize(vector.x, x),
add_isize_to_usize(vector.y, y),
) {
... | is_deadend | identifier_name |
grid_level.rs | use std::default::Default;
use tile::Tile;
use util::{Error, Grid};
use Vector;
#[derive(Clone)]
pub struct GridLevel<T> {
pub(crate) tiles: Grid<T>,
}
impl<T> GridLevel<T> {
pub fn get_width(&self) -> usize {
self.tiles.get_width()
}
pub fn get_height(&self) -> usize {
self.tiles.get... |
Some(u)
}
| {
return None;
} | conditional_block |
grid_level.rs | use std::default::Default;
use tile::Tile;
use util::{Error, Grid};
use Vector;
#[derive(Clone)]
pub struct GridLevel<T> {
pub(crate) tiles: Grid<T>,
}
impl<T> GridLevel<T> {
pub fn get_width(&self) -> usize {
self.tiles.get_width()
}
pub fn get_height(&self) -> usize {
self.tiles.get... |
pub fn new_filled_with(tile: T, width: usize, height: usize) -> GridLevel<T> {
GridLevel {
tiles: Grid::new_filled_with(tile, width, height),
}
}
}
pub fn fill_dead_end_tiles(level: &mut GridLevel<Tile>) -> bool {
let mut deadends = Vec::new();
for y in 0..level.get_height... | {
GridLevel {
tiles: Grid::new(width, height),
}
} | identifier_body |
grid_level.rs | use std::default::Default;
use tile::Tile;
use util::{Error, Grid};
use Vector;
#[derive(Clone)]
pub struct GridLevel<T> {
pub(crate) tiles: Grid<T>,
}
impl<T> GridLevel<T> {
pub fn get_width(&self) -> usize {
self.tiles.get_width()
}
pub fn get_height(&self) -> usize {
self.tiles.get... |
pub fn add_isize_to_usize(i: isize, mut u: usize) -> Option<usize> {
if i < 0 && u!= 0 {
u -= (-i) as usize;
} else if i >= 0 && u < usize::max_value() {
u += i as usize;
} else {
return None;
}
Some(u)
} | }
paths < 2
} | random_line_split |
mod.rs | lazy_universe = Some(universe);
universe
});
let placeholder = ty::PlaceholderRegion { universe, name: br };
delegate.next_placeholder_region(placeholder)
} else {
delegate.next_existential_... | {
debug!(
"TypeGeneralizer::relate_with_variance(variance={:?}, a={:?}, b={:?})",
variance, a, b
);
let old_ambient_variance = self.ambient_variance;
self.ambient_variance = self.ambient_variance.xform(variance);
debug!(
"TypeGeneralizer::rel... | identifier_body | |
mod.rs | ::Region<'tcx>;
/// Define the normalization strategy to use, eager or lazy.
fn normalization() -> NormalizationStrategy;
/// Enable some optimizations if we do not expect inference variables
/// in the RHS of the relation.
fn forbid_inference_vars() -> bool;
}
#[derive(Clone, Debug)]
struct Scop... | debug!("binders: b_scope = {:?} (universal)", b_scope);
self.b_scopes.push(b_scope);
self.a_scopes.push(a_scope);
// Reset the ambient variance to covariant. This is needed
// to correctly handle cases like
//
// for<'a> fn(&'a u3... | debug!("binders: a_scope = {:?} (existential)", a_scope); | random_line_split |
mod.rs | ) -> RelateResult<'tcx, Ty<'tcx>> {
debug!("relate_ty_var(vid={:?}, value_ty={:?})", vid, value_ty);
match value_ty.sty {
ty::Infer(ty::TyVar(value_vid)) => {
// Two type variables: just equate them.
self.infcx.type_variables.borrow_mut().equate(vid, value_v... | {
debug!(
"TypeGeneralizer::tys: root universe {:?} cannot name\
placeholder in universe {:?}",
self.universe,
placeholder.universe
);
Err(TypeError::Mismatch)
... | conditional_block | |
mod.rs | {
Lazy,
Eager,
}
pub struct TypeRelating<'me, 'gcx: 'tcx, 'tcx:'me, D>
where
D: TypeRelatingDelegate<'tcx>,
{
infcx: &'me InferCtxt<'me, 'gcx, 'tcx>,
/// Callback to use when we deduce an outlives relationship
delegate: D,
/// How are we relating `a` and `b`?
///
/// - covariant ... | NormalizationStrategy | identifier_name | |
net.rs | //! A collection of traits abstracting over Listeners and Streams.
use std::any::{Any, TypeId};
use std::fmt;
use std::io::{self, ErrorKind, Read, Write};
use std::net::{SocketAddr, ToSocketAddrs, TcpStream, TcpListener, Shutdown};
use std::mem;
#[cfg(feature = "openssl")]
pub use self::openssl::Openssl;
use typeable... | <S: Ssl> {
ssl: S
}
impl<S: Ssl> HttpsConnector<S> {
/// Create a new connector using the provided SSL implementation.
pub fn new(s: S) -> HttpsConnector<S> {
HttpsConnector { ssl: s }
}
}
impl<S: Ssl> NetworkConnector for HttpsConnector<S> {
type Stream = HttpsStream<S::Stream>;
fn c... | HttpsConnector | identifier_name |
net.rs | //! A collection of traits abstracting over Listeners and Streams.
use std::any::{Any, TypeId};
use std::fmt;
use std::io::{self, ErrorKind, Read, Write};
use std::net::{SocketAddr, ToSocketAddrs, TcpStream, TcpListener, Shutdown};
use std::mem;
#[cfg(feature = "openssl")]
pub use self::openssl::Openssl;
use typeable... |
fn close(&mut self, how: Shutdown) -> io::Result<()> {
self.get_mut().close(how)
}
}
}
#[cfg(test)]
mod tests {
use mock::MockStream;
use super::{NetworkStream};
#[test]
fn test_downcast_box_stream() {
// FIXME: Use Type ascription
let stream: Box<Netw... | {
self.get_mut().peer_addr()
} | identifier_body |
net.rs | //! A collection of traits abstracting over Listeners and Streams.
use std::any::{Any, TypeId};
use std::fmt;
use std::io::{self, ErrorKind, Read, Write};
use std::net::{SocketAddr, ToSocketAddrs, TcpStream, TcpListener, Shutdown};
use std::mem;
#[cfg(feature = "openssl")]
pub use self::openssl::Openssl;
use typeable... | Ok(try!(match scheme {
"http" => {
debug!("http scheme");
Ok(HttpStream(try!(TcpStream::connect(addr))))
},
_ => {
Err(io::Error::new(io::ErrorKind::InvalidInput,
"Invalid scheme for Http"))
... | type Stream = HttpStream;
fn connect(&self, host: &str, port: u16, scheme: &str) -> ::Result<HttpStream> {
let addr = &(host, port); | random_line_split |
lib.rs | use std::collections::VecDeque;
use std::io::{Cursor, Read, Write};
#[macro_use]
extern crate strider;
use strider::SliceRing;
use strider::SliceRingImpl;
macro_rules! test_string_windowing {
($new:expr) => {{
const WINDOW_SIZE: usize = 8;
const STEP_SIZE: usize = 2;
let mut input = Curso... | () {
test_string_windowing!(VecDeque::<u8>::new());
}
#[test]
fn test_string_windowing_optimized() {
test_string_windowing!(SliceRingImpl::<u8>::new());
}
#[test]
fn test_slice_ring_deque() {
test_slice_ring!(VecDeque::<i32>::new());
}
#[test]
fn test_slice_ring_optimized() {
test_slice_ring!(SliceRing... | test_test_string_windowing_deque | identifier_name |
lib.rs | use std::collections::VecDeque;
use std::io::{Cursor, Read, Write};
#[macro_use]
extern crate strider;
use strider::SliceRing;
use strider::SliceRingImpl;
macro_rules! test_string_windowing {
($new:expr) => {{
const WINDOW_SIZE: usize = 8;
const STEP_SIZE: usize = 2;
let mut input = Curso... |
#[test]
fn test_slice_ring_deque() {
test_slice_ring!(VecDeque::<i32>::new());
}
#[test]
fn test_slice_ring_optimized() {
test_slice_ring!(SliceRingImpl::<i32>::new());
}
| {
test_string_windowing!(SliceRingImpl::<u8>::new());
} | identifier_body |
lib.rs | use std::collections::VecDeque;
use std::io::{Cursor, Read, Write};
#[macro_use]
extern crate strider;
use strider::SliceRing;
use strider::SliceRingImpl;
macro_rules! test_string_windowing {
($new:expr) => {{
const WINDOW_SIZE: usize = 8;
const STEP_SIZE: usize = 2;
let mut input = Curso... |
#[test]
fn test_slice_ring_deque() {
test_slice_ring!(VecDeque::<i32>::new());
}
#[test]
fn test_slice_ring_optimized() {
test_slice_ring!(SliceRingImpl::<i32>::new());
} | } | random_line_split |
parse.rs | use std::str;
/// A fragment of json.
#[derive(Debug)]
pub enum JsonFragment<'a> {
Literal(String),
Repl(&'a str)
}
/// Parse and sanitise the complete sequence as a literal.
pub fn parse_literal(remainder: &[u8], json: &mut String) {
let _ = literal(remainder, json, false);
}
/// Parse and sanitise the ... | <F, S>(i: &[u8], mut s: S, f: F) -> (&[u8], &str)
where F: Fn(S, u8) -> (S, bool)
{
let mut ctr = 0;
for c in i {
let (new_state, more) = f(s, *c);
if more {
s = new_state;
ctr += 1;
}
else {
break;
}
}
(&i[ctr..], unsaf... | take_while | identifier_name |
parse.rs | use std::str;
/// A fragment of json.
#[derive(Debug)]
pub enum JsonFragment<'a> {
Literal(String),
Repl(&'a str)
}
/// Parse and sanitise the complete sequence as a literal.
pub fn parse_literal(remainder: &[u8], json: &mut String) {
let _ = literal(remainder, json, false);
}
/// Parse and sanitise the ... | ((), is_ident(c as char))
});
//Check if the string is a special value; true, false or null
//For special values, push them as straight unquoted values. Otherwise, quote them
match key {
"true"|"false"|"null" =>
sanitis... | let (rest, key) = take_while(remainder, (), |_, c| { | random_line_split |
parse.rs | use std::str;
/// A fragment of json.
#[derive(Debug)]
pub enum JsonFragment<'a> {
Literal(String),
Repl(&'a str)
}
/// Parse and sanitise the complete sequence as a literal.
pub fn parse_literal(remainder: &[u8], json: &mut String) {
let _ = literal(remainder, json, false);
}
/// Parse and sanitise the ... |
fn shift_while<F>(i: &[u8], f: F) -> &[u8]
where F: Fn(u8) -> bool
{
let mut ctr = 0;
for c in i {
if f(*c) {
ctr += 1;
}
else {
break;
}
}
&i[ctr..]
}
fn take_while<F, S>(i: &[u8], mut s: S, f: F) -> (&[u8], &str)
where F: Fn(S, u8)... | {
c.is_alphabetic() || c == '_'
} | identifier_body |
parse.rs | use std::str;
/// A fragment of json.
#[derive(Debug)]
pub enum JsonFragment<'a> {
Literal(String),
Repl(&'a str)
}
/// Parse and sanitise the complete sequence as a literal.
pub fn parse_literal(remainder: &[u8], json: &mut String) {
let _ = literal(remainder, json, false);
}
/// Parse and sanitise the ... |
// If there's anything left, run again
if remainder.len() > 0 {
parse_fragments(remainder, fragments);
}
}
// Parse a replacement ident.
fn repl(remainder: &[u8]) -> (&[u8], &str) {
if remainder.len() == 0 {
return (&[], "");
}
take_while(&remainder, (), |_, c| {
((),... | {
fragments.push(JsonFragment::Repl(r));
} | conditional_block |
for_each_concurrent.rs | use crate::stream::{FuturesUnordered, StreamExt};
use core::fmt;
use core::pin::Pin;
use core::num::NonZeroUsize;
use futures_core::future::{FusedFuture, Future};
use futures_core::stream::Stream;
use futures_core::task::{Context, Poll};
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Future for the [`for_each_co... | <St, Fut, F> {
stream: Option<St>,
f: F,
futures: FuturesUnordered<Fut>,
limit: Option<NonZeroUsize>,
}
impl<St, Fut, F> Unpin for ForEachConcurrent<St, Fut, F>
where St: Unpin,
Fut: Unpin,
{}
impl<St, Fut, F> fmt::Debug for ForEachConcurrent<St, Fut, F>
where
St: fmt::Debug,
Fut: fmt::D... | ForEachConcurrent | identifier_name |
for_each_concurrent.rs | use crate::stream::{FuturesUnordered, StreamExt};
use core::fmt;
use core::pin::Pin;
use core::num::NonZeroUsize;
use futures_core::future::{FusedFuture, Future};
use futures_core::stream::Stream;
use futures_core::task::{Context, Poll};
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Future for the [`for_each_co... | else {
None
};
if stream_completed {
self.as_mut().stream().set(None);
}
if let Some(elem) = elem {
let next_future = (self.as_mut().f())(elem);
self.as_mut().futures().push(n... | {
match stream.poll_next(cx) {
Poll::Ready(Some(elem)) => {
made_progress_this_iter = true;
Some(elem)
},
Poll::Ready(None) => {
stream_complete... | conditional_block |
for_each_concurrent.rs | use crate::stream::{FuturesUnordered, StreamExt};
use core::fmt;
use core::pin::Pin;
use core::num::NonZeroUsize;
use futures_core::future::{FusedFuture, Future};
use futures_core::stream::Stream;
use futures_core::task::{Context, Poll};
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Future for the [`for_each_co... | Fut: Future<Output = ()>,
{
unsafe_pinned!(stream: Option<St>);
unsafe_unpinned!(f: F);
unsafe_unpinned!(futures: FuturesUnordered<Fut>);
unsafe_unpinned!(limit: Option<NonZeroUsize>);
pub(super) fn new(stream: St, limit: Option<usize>, f: F) -> ForEachConcurrent<St, Fut, F> {
ForEach... | random_line_split | |
for_each_concurrent.rs | use crate::stream::{FuturesUnordered, StreamExt};
use core::fmt;
use core::pin::Pin;
use core::num::NonZeroUsize;
use futures_core::future::{FusedFuture, Future};
use futures_core::stream::Stream;
use futures_core::task::{Context, Poll};
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Future for the [`for_each_co... |
}
impl<St, Fut, F> FusedFuture for ForEachConcurrent<St, Fut, F>
where St: Stream,
F: FnMut(St::Item) -> Fut,
Fut: Future<Output = ()>,
{
fn is_terminated(&self) -> bool {
self.stream.is_none() && self.futures.is_empty()
}
}
impl<St, Fut, F> Future for ForEachConcurrent<St, Fu... | {
ForEachConcurrent {
stream: Some(stream),
// Note: `limit` = 0 gets ignored.
limit: limit.and_then(NonZeroUsize::new),
f,
futures: FuturesUnordered::new(),
}
} | identifier_body |
enum_set.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 ... |
impl<E:CLike> Iterator for Iter<E> {
type Item = E;
fn next(&mut self) -> Option<E> {
if self.bits == 0 {
return None;
}
while (self.bits & 1) == 0 {
self.index += 1;
self.bits >>= 1;
}
let elem = CLike::from_usize(self.index);
... | impl<E:CLike> Iter<E> {
fn new(bits: usize) -> Iter<E> {
Iter { index: 0, bits: bits, marker: marker::PhantomData }
}
} | random_line_split |
enum_set.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: IntoIterator<Item=E>>(&mut self, iter: I) {
for element in iter {
self.insert(element);
}
}
}
| extend | identifier_name |
enum_set.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 ... |
try!(write!(fmt, "{:?}", e));
first = false;
}
write!(fmt, "}}")
}
}
/// An interface for casting C-like enum to usize and back.
/// A typically implementation is as below.
///
/// ```{rust,ignore}
/// #[repr(usize)]
/// enum Foo {
/// A, B, C
/// }
///
/// impl CLike f... | {
try!(write!(fmt, ", "));
} | conditional_block |
enum_set.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 ... |
/// Returns `true` if this `EnumSet` is included in the given `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn is_subset(&self, other: &EnumSet<E>) -> bool {
other.is_superset(self)
}
/// ... | {
(self.bits & other.bits) == other.bits
} | identifier_body |
main.rs | extern crate chrono;
extern crate clap;
extern crate openssl;
extern crate helperlib;
use chrono::Utc;
use clap::{Arg, App};
use openssl::x509::X509;
fn | () {
let args = App::new("X.509 Parse")
.about("Experiment in parsing X.509 certificates")
.arg(Arg::with_name("InputFile")
.long("file")
.short("f")
.takes_value(true)
.required(true))
.get_matches();
let input_file_path = args.value_of("InputFi... | main | identifier_name |
main.rs | extern crate chrono;
extern crate clap;
extern crate openssl;
extern crate helperlib;
use chrono::Utc;
use clap::{Arg, App};
use openssl::x509::X509;
fn main() | }
}
println!("------------SUBJECT ALT NAMES------------");
let cert_subject_alt_names = helperlib::get_subject_alt_names(&cert);
match cert_subject_alt_names {
None => println!("{:?}", "No SANs listed in certificate".to_string()),
Some(sans) => {
for san in sans {
... | {
let args = App::new("X.509 Parse")
.about("Experiment in parsing X.509 certificates")
.arg(Arg::with_name("InputFile")
.long("file")
.short("f")
.takes_value(true)
.required(true))
.get_matches();
let input_file_path = args.value_of("Inp... | identifier_body |
main.rs | extern crate chrono;
extern crate clap;
extern crate openssl;
extern crate helperlib;
use chrono::Utc;
use clap::{Arg, App};
use openssl::x509::X509;
fn main() {
let args = App::new("X.509 Parse")
.about("Experiment in parsing X.509 certificates")
.arg(Arg::with_name("InputFile")
.long("f... |
}
}
| {
let now = Utc::now();
if not_before <= now && now <= not_after {
println!("Certificate is between validity dates");
} else if now < not_before {
println!("Certificate not yet valid");
} else {
println!("Certificate expired... | conditional_block |
main.rs | extern crate chrono;
extern crate clap;
extern crate openssl;
extern crate helperlib;
use chrono::Utc;
use clap::{Arg, App};
use openssl::x509::X509;
| fn main() {
let args = App::new("X.509 Parse")
.about("Experiment in parsing X.509 certificates")
.arg(Arg::with_name("InputFile")
.long("file")
.short("f")
.takes_value(true)
.required(true))
.get_matches();
let input_file_path = args.value_of("... | random_line_split | |
world.rs | use rand::Rng;
use crate::{
geometry::Size,
models::{Bullet, Enemy, Particle, Player, Powerup, Star},
};
const MAX_STARS: usize = 100;
| pub bullets: Vec<Bullet>,
pub enemies: Vec<Enemy>,
pub stars: Vec<Star>,
pub size: Size,
}
impl World {
/// Returns a new world of the given size
pub fn new<R: Rng>(rng: &mut R, size: Size) -> World {
World {
player: Player::random(rng, size),
particles: Vec::wit... | /// A model that contains the other models and renders them
pub struct World {
pub player: Player,
pub particles: Vec<Particle>,
pub powerups: Vec<Powerup>, | random_line_split |
world.rs | use rand::Rng;
use crate::{
geometry::Size,
models::{Bullet, Enemy, Particle, Player, Powerup, Star},
};
const MAX_STARS: usize = 100;
/// A model that contains the other models and renders them
pub struct World {
pub player: Player,
pub particles: Vec<Particle>,
pub powerups: Vec<Powerup>,
p... |
}
| {
World {
player: Player::random(rng, size),
particles: Vec::with_capacity(1000),
powerups: vec![],
bullets: vec![],
enemies: vec![],
stars: (0..MAX_STARS).map(|_| Star::new(size, rng)).collect(),
size: size,
}
} | identifier_body |
world.rs | use rand::Rng;
use crate::{
geometry::Size,
models::{Bullet, Enemy, Particle, Player, Powerup, Star},
};
const MAX_STARS: usize = 100;
/// A model that contains the other models and renders them
pub struct | {
pub player: Player,
pub particles: Vec<Particle>,
pub powerups: Vec<Powerup>,
pub bullets: Vec<Bullet>,
pub enemies: Vec<Enemy>,
pub stars: Vec<Star>,
pub size: Size,
}
impl World {
/// Returns a new world of the given size
pub fn new<R: Rng>(rng: &mut R, size: Size) -> World {
... | World | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.