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 |
|---|---|---|---|---|
mod.rs | extern crate rustc_serialize;
|
use rustc_serialize::{ Encodable, Decodable };
use byteorder::{ ByteOrder, BigEndian, WriteBytesExt };
use self::impl_rustc_serialize::{ encode as enc, decode as dec };
pub use super::*;
pub type EncodingResult<T> = impl_rustc_serialize::EncodingResult<T>;
pub type DecodingResult<T> = impl_rustc_serialize::DecodingRe... | mod impl_rustc_serialize; | random_line_split |
htmlquoteelement.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 crate::dom::bindings::codegen::Bindings::HTMLQuoteElementBinding;
use crate::dom::bindings::root::DomRoot;
use... | (
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLQuoteElement {
HTMLQuoteElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
pub fn new(
local_name: Lo... | new_inherited | identifier_name |
htmlquoteelement.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 crate::dom::bindings::codegen::Bindings::HTMLQuoteElementBinding;
use crate::dom::bindings::root::DomRoot;
use... |
#[allow(unrooted_must_root)]
pub fn new(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> DomRoot<HTMLQuoteElement> {
Node::reflect_node(
Box::new(HTMLQuoteElement::new_inherited(
local_name, prefix, document,
)... | random_line_split | |
htmlquoteelement.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 crate::dom::bindings::codegen::Bindings::HTMLQuoteElementBinding;
use crate::dom::bindings::root::DomRoot;
use... |
#[allow(unrooted_must_root)]
pub fn new(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> DomRoot<HTMLQuoteElement> {
Node::reflect_node(
Box::new(HTMLQuoteElement::new_inherited(
local_name, prefix, document,
... | {
HTMLQuoteElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
} | identifier_body |
day_7.rs | pub fn compress(src: &str) -> String {
if src.is_empty() {
src.to_owned()
} else {
let mut compressed = String::new();
let mut chars = src.chars().peekable();
while let Some(c) = chars.peek().cloned() {
let mut counter = 0;
while let Some(n) = chars.peek()... | () {
assert_eq!(compress("aabbcc"), "2a2b2c");
}
}
| compress_doubled_chars_string | identifier_name |
day_7.rs | pub fn compress(src: &str) -> String {
if src.is_empty() {
src.to_owned()
} else {
let mut compressed = String::new();
let mut chars = src.chars().peekable();
while let Some(c) = chars.peek().cloned() {
let mut counter = 0;
while let Some(n) = chars.peek()... |
#[test]
fn compress_doubled_chars_string() {
assert_eq!(compress("aabbcc"), "2a2b2c");
}
}
| {
assert_eq!(compress("abc"), "1a1b1c");
} | identifier_body |
day_7.rs | pub fn compress(src: &str) -> String {
if src.is_empty() {
src.to_owned()
} else {
let mut compressed = String::new();
let mut chars = src.chars().peekable();
while let Some(c) = chars.peek().cloned() {
let mut counter = 0;
while let Some(n) = chars.peek()... | assert_eq!(compress(""), "");
}
#[test]
fn compress_unique_chars_string() {
assert_eq!(compress("abc"), "1a1b1c");
}
#[test]
fn compress_doubled_chars_string() {
assert_eq!(compress("aabbcc"), "2a2b2c");
}
} | mod tests {
use super::*;
#[test]
fn compress_empty_string() { | random_line_split |
day_7.rs | pub fn compress(src: &str) -> String {
if src.is_empty() | else {
let mut compressed = String::new();
let mut chars = src.chars().peekable();
while let Some(c) = chars.peek().cloned() {
let mut counter = 0;
while let Some(n) = chars.peek().cloned() {
if c == n {
counter += 1;
... | {
src.to_owned()
} | conditional_block |
const-bound.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 ... |
struct F { field: int }
pub fn main() {
/*foo(1);
foo(~"hi");
foo(~[1, 2, 3]);
foo(F{field: 42});
foo((1, 2u));
foo(@1);*/
foo(~1);
}
| { x } | identifier_body |
const-bound.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T:Copy + Const>(x: T) -> T { x }
struct F { field: int }
pub fn main() {
/*foo(1);
foo(~"hi");
foo(~[1, 2, 3]);
foo(F{field: 42});
foo((1, 2u));
foo(@1);*/
foo(~1);
}
| foo | identifier_name |
const-bound.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {
/*foo(1);
foo(~"hi");
foo(~[1, 2, 3]);
foo(F{field: 42});
foo((1, 2u));
foo(@1);*/
foo(~1);
} | random_line_split | |
htmlulistelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLUListElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLUList... | fn is_htmlulistelement(&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLUListElement)))
}
}
impl HTMLUListElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, documen... |
impl HTMLUListElementDerived for EventTarget { | random_line_split |
htmlulistelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLUListElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLUList... | (localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLUListElement> {
let element = HTMLUListElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLUListElementBinding::Wrap)
}
}
| new | identifier_name |
generate_exploit_golf_512_sh.rs | /*!
```cargo
[dependencies]
goblin = "0.2"
anyhow = "1.0"
faerie = "0.15"
target-lexicon = "0.10"
```
*/
extern crate faerie;
extern crate goblin;
extern crate target_lexicon;
use goblin::elf::{Elf, dynamic::*};
use goblin::elf64::{
header::{self, Header},
program_header::{self as Phdr, ProgramHeader},
sect... | let e_ident = [0x7f, b'E', b'L', b'F', header::ELFCLASS64, header::ELFDATA2LSB, header::EV_CURRENT, header::ELFOSABI_NONE, 0, 0, 0, 0, 0, 0, 0, 0];
let mut elfbytes = vec![0; 512];
let mut header: &mut Header = unsafe { &mut *(elfbytes.as_mut_ptr() as *mut Header) };
*header = Header {
e_ident,
... | println!("{:#?}", from_c);*/ | random_line_split |
generate_exploit_golf_512_sh.rs | /*!
```cargo
[dependencies]
goblin = "0.2"
anyhow = "1.0"
faerie = "0.15"
target-lexicon = "0.10"
```
*/
extern crate faerie;
extern crate goblin;
extern crate target_lexicon;
use goblin::elf::{Elf, dynamic::*};
use goblin::elf64::{
header::{self, Header},
program_header::{self as Phdr, ProgramHeader},
sect... | () -> Result<(), anyhow::Error> {
/*let bytes_from_c = fs::read("./a.out")?;
let from_c = Elf::parse(&bytes_from_c)?;
println!("{:#?}", from_c);*/
let e_ident = [0x7f, b'E', b'L', b'F', header::ELFCLASS64, header::ELFDATA2LSB, header::EV_CURRENT, header::ELFOSABI_NONE, 0, 0, 0, 0, 0, 0, 0, 0];
let m... | main | identifier_name |
generate_exploit_golf_512_sh.rs | /*!
```cargo
[dependencies]
goblin = "0.2"
anyhow = "1.0"
faerie = "0.15"
target-lexicon = "0.10"
```
*/
extern crate faerie;
extern crate goblin;
extern crate target_lexicon;
use goblin::elf::{Elf, dynamic::*};
use goblin::elf64::{
header::{self, Header},
program_header::{self as Phdr, ProgramHeader},
sect... | e_shnum: 0,
e_shstrndx: 0,
};
println!("header: {:?}", header);
let mut phdr: &mut ProgramHeader = unsafe { &mut *(elfbytes.as_mut_ptr().offset(128) as *mut ProgramHeader) };
*phdr = ProgramHeader {
p_type: Phdr::PT_LOAD,
p_flags: Phdr::PF_R | Phdr::PF_W | Phdr::PF_X,
... | {
/*let bytes_from_c = fs::read("./a.out")?;
let from_c = Elf::parse(&bytes_from_c)?;
println!("{:#?}", from_c);*/
let e_ident = [0x7f, b'E', b'L', b'F', header::ELFCLASS64, header::ELFDATA2LSB, header::EV_CURRENT, header::ELFOSABI_NONE, 0, 0, 0, 0, 0, 0, 0, 0];
let mut elfbytes = vec![0; 512];
... | identifier_body |
spi_dummy.rs | ///! A dummy SPI client to test the SPI implementation
use sam4l;
use hil::gpio;
use hil::spi_master::{self, SpiMaster};
#[allow(unused_variables,dead_code)]
pub struct DummyCB {
val: u8
}
pub static mut FLOP: bool = false;
pub static mut buf1: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];
pub static mut buf2: [u8; 8] = [8,... | // the SPI MOSI and CLK pins (exposed on the Firestorm's 22-pin header). Setup
// the logic analyzer to trigger sampling on assertion of pin 2, then restart
// the board.
pub unsafe fn spi_dummy_test() {
let pin2 : &mut gpio::GPIOPin = &mut sam4l::gpio::PA[16];
pin2.enable_output();
pin2.set();
sam4l:... | // The first SPI transfer outputs [8, 7, 6, 5, 4, 3, 2, 1] then echoes whatever
// input it recieves from the slave on peripheral 1 continuously.
//
// To test with a logic analyzer, connect probes to pin 2 on the Firestorm, and | random_line_split |
spi_dummy.rs | ///! A dummy SPI client to test the SPI implementation
use sam4l;
use hil::gpio;
use hil::spi_master::{self, SpiMaster};
#[allow(unused_variables,dead_code)]
pub struct DummyCB {
val: u8
}
pub static mut FLOP: bool = false;
pub static mut buf1: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];
pub static mut buf2: [u8; 8] = [8,... |
}
pub static mut SPICB: DummyCB = DummyCB{val: 0x55 as u8};
// This test first asserts the Firestorm's pin 2, then initiates a continuous
// SPI transfer of 8 bytes.
//
// The first SPI transfer outputs [8, 7, 6, 5, 4, 3, 2, 1] then echoes whatever
// input it recieves from the slave on peripheral 1 continuously.
//... | {
unsafe {
FLOP = !FLOP;
let len: usize = buf1.len();
if FLOP {
sam4l::spi::SPI.read_write_bytes(Some(&mut buf1), Some(&mut buf2), len);
} else {
sam4l::spi::SPI.read_write_bytes(Some(&mut buf2), Some(&mut buf1), len);
}... | identifier_body |
spi_dummy.rs | ///! A dummy SPI client to test the SPI implementation
use sam4l;
use hil::gpio;
use hil::spi_master::{self, SpiMaster};
#[allow(unused_variables,dead_code)]
pub struct | {
val: u8
}
pub static mut FLOP: bool = false;
pub static mut buf1: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];
pub static mut buf2: [u8; 8] = [8, 7, 6, 5, 4, 3, 2, 1];
impl spi_master::SpiCallback for DummyCB {
#[allow(unused_variables,dead_code)]
fn read_write_done(&'static self) {
unsafe {
FLOP ... | DummyCB | identifier_name |
spi_dummy.rs | ///! A dummy SPI client to test the SPI implementation
use sam4l;
use hil::gpio;
use hil::spi_master::{self, SpiMaster};
#[allow(unused_variables,dead_code)]
pub struct DummyCB {
val: u8
}
pub static mut FLOP: bool = false;
pub static mut buf1: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];
pub static mut buf2: [u8; 8] = [8,... |
}
}
}
pub static mut SPICB: DummyCB = DummyCB{val: 0x55 as u8};
// This test first asserts the Firestorm's pin 2, then initiates a continuous
// SPI transfer of 8 bytes.
//
// The first SPI transfer outputs [8, 7, 6, 5, 4, 3, 2, 1] then echoes whatever
// input it recieves from the slave on peripheral 1 ... | {
sam4l::spi::SPI.read_write_bytes(Some(&mut buf2), Some(&mut buf1), len);
} | conditional_block |
expr_method.rs | // Copyright 2016 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 ... | #![allow(dead_code)]
#![deny(unreachable_code)]
struct Foo;
impl Foo {
fn foo(&self, x:!, y: usize) { }
fn bar(&self, x:!) { }
}
fn a() {
// the `22` is unreachable:
Foo.foo(return, 22); //~ ERROR unreachable
}
fn b() {
// the call is unreachable:
Foo.bar(return); //~ ERROR unreachable
}
fn... | // except according to those terms.
#![feature(never_type)]
#![allow(unused_variables)]
#![allow(unused_assignments)] | random_line_split |
expr_method.rs | // Copyright 2016 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 |
capturing-logging.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let (tx, rx) = channel();
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
let _t = Thread::spawn(move|| {
set_logger(box MyWriter(w) as Box<Logger+Send>);
debug!("debug");
info!("info");
});
let s = r.read_to_string().unwrap();
assert!(s.contains("info"));
... | identifier_body | |
capturing-logging.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// exec-env:RUST_LO... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
capturing-logging.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let (tx, rx) = channel();
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
let _t = Thread::spawn(move|| {
set_logger(box MyWriter(w) as Box<Logger+Send>);
debug!("debug");
info!("info");
});
let s = r.read_to_string().unwrap();
assert!(s.contains("info")... | main | identifier_name |
p042.rs | //! [Problem 42](https://projecteuler.net/problem=42) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
extern crate seq;
use std::fs::File;
use std::io::{self, BufReader};
use std::io::pre... |
problem!("162", "p042_words.txt", solve);
#[cfg(test)]
mod tests {
#[test]
fn word_to_value() {
assert_eq!(55, super::word_to_value("SKY"));
}
}
| {
let mut values = vec![];
for bytes in BufReader::new(file).split(b',') {
let word_str = String::from_utf8(try!(bytes)).unwrap();
let word = word_str
.trim_right_matches(',')
.trim_matches('\"');
values.push(word_to_value(word));
}
let max_value = *valu... | identifier_body |
p042.rs | //! [Problem 42](https://projecteuler.net/problem=42) solver.
#![warn(bad_style,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
extern crate seq;
use std::fs::File;
use std::io::{self, BufReader};
use std::io::pre... | (file: File) -> io::Result<String> {
let mut values = vec![];
for bytes in BufReader::new(file).split(b',') {
let word_str = String::from_utf8(try!(bytes)).unwrap();
let word = word_str
.trim_right_matches(',')
.trim_matches('\"');
values.push(word_to_value(word));... | solve | identifier_name |
p042.rs | //! [Problem 42](https://projecteuler.net/problem=42) solver.
#![warn(bad_style, | unused_qualifications, unused_results)]
#[macro_use(problem)] extern crate common;
extern crate seq;
use std::fs::File;
use std::io::{self, BufReader};
use std::io::prelude::*;
use seq::TriangularNums;
fn word_to_value(word: &str) -> u32 {
let mut value = 0;
for b in word.bytes() {
value += (... | unused, unused_extern_crates, unused_import_braces, | random_line_split |
check-doc-alias-attr.rs | #![crate_type = "lib"]
#[doc(alias = "foo")] // ok!
#[doc(alias("bar", "baz"))] // ok!
pub struct Bar;
#[doc(alias)] //~ ERROR
#[doc(alias = 0)] //~ ERROR
#[doc(alias = "\"")] //~ ERROR
#[doc(alias = "\n")] //~ ERROR
#[doc(alias = "
")] //~^ ERROR
#[doc(alias = "\t")] //~ ERROR
#[doc(alias = " hello")] //~ ERROR
#[do... | ;
| Foo2 | identifier_name |
check-doc-alias-attr.rs | #![crate_type = "lib"]
#[doc(alias = "foo")] // ok!
#[doc(alias("bar", "baz"))] // ok!
pub struct Bar;
#[doc(alias)] //~ ERROR
#[doc(alias = 0)] //~ ERROR
#[doc(alias = "\"")] //~ ERROR
#[doc(alias = "\n")] //~ ERROR
#[doc(alias = "
")] //~^ ERROR | #[doc(alias = " hello")] //~ ERROR
#[doc(alias = "hello ")] //~ ERROR
#[doc(alias = "")] //~ ERROR
pub struct Foo;
#[doc(alias(0))] //~ ERROR
#[doc(alias("\""))] //~ ERROR
#[doc(alias("\n"))] //~ ERROR
#[doc(alias("
"))] //~^ ERROR
#[doc(alias("\t"))] //~ ERROR
#[doc(alias(" hello"))] //~ ERROR
#[doc(alias("hello "))]... | #[doc(alias = "\t")] //~ ERROR | random_line_split |
problem.rs | use std::fs;
use std::fs::File;
use std::process::{Command, Stdio};
use std::io::prelude::*;
use std::io::BufReader;
use std::error::Error;
use std::fmt;
const PROBLEMS_DIR: &'static str = "problems";
const INPUT_DIR: &'static str = "input";
const OUTPUT_DIR: &'static str = "output";
pub struct Problem {
str_id: St... | .arg(format!("{}/{}/{}.rs", PROBLEMS_DIR, self.str_id, self.str_id))
.arg("--out-dir")
.arg(format!("{}/{}", PROBLEMS_DIR, self.str_id))
.output() {
Ok(cmd) => cmd,
Err(e) => return self.make_error("failed to execute rustc", e.to_string(), -1),
};
if!builder.status.success() {
let s = Strin... | }
}
pub fn run(&self) -> Result<(), ProblemError> {
let builder = match Command::new("rustc") | random_line_split |
problem.rs | use std::fs;
use std::fs::File;
use std::process::{Command, Stdio};
use std::io::prelude::*;
use std::io::BufReader;
use std::error::Error;
use std::fmt;
const PROBLEMS_DIR: &'static str = "problems";
const INPUT_DIR: &'static str = "input";
const OUTPUT_DIR: &'static str = "output";
pub struct Problem {
str_id: St... |
fn run_test(&self, test_no: i32) -> Result<(), ProblemError> {
let mut input = match File::open(format!("{}/{}/{}/{}.txt",
PROBLEMS_DIR, self.str_id, INPUT_DIR, test_no)) {
Ok(file) => file,
Err(e) => return self.make_error("failed to load test", e.to_string(), test_no),
};
let mut s = String::new()... | {
let builder = match Command::new("rustc")
.arg(format!("{}/{}/{}.rs", PROBLEMS_DIR, self.str_id, self.str_id))
.arg("--out-dir")
.arg(format!("{}/{}", PROBLEMS_DIR, self.str_id))
.output() {
Ok(cmd) => cmd,
Err(e) => return self.make_error("failed to execute rustc", e.to_string(), -1),
};
... | identifier_body |
problem.rs | use std::fs;
use std::fs::File;
use std::process::{Command, Stdio};
use std::io::prelude::*;
use std::io::BufReader;
use std::error::Error;
use std::fmt;
const PROBLEMS_DIR: &'static str = "problems";
const INPUT_DIR: &'static str = "input";
const OUTPUT_DIR: &'static str = "output";
pub struct Problem {
str_id: St... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.test_no >= 0 {
write!(f, "{} on problem {} at test {}: {}", self.reason, self.problem_strid,
self.test_no, self.sys_part)
}
else {
write!(f, "{} on problem {}: {}", self.reason, self.problem_strid,
self.sys_part)
}
}
}
impl fmt::Debug fo... | fmt | identifier_name |
rc.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> {
priv p: *c_void // ~(uint, T)
}
impl<T> RC<T> {
pub fn new(val: T) -> RC<T> {
unsafe {
let v = ~(1, val);
let p: *c_void = cast::transmute(v);
RC { p: p }
}
}
fn get_mut_state(&mut self) -> *mut (uint, T) {
unsafe {
let p: &... | RC | identifier_name |
rc.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 ... | //! # Safety note
//!
//! XXX There is currently no type-system mechanism for enforcing that
//! reference counted types are both allocated on the exchange heap
//! and also non-sendable
//!
//! This doesn't prevent borrowing multiple aliasable mutable pointers
use ops::Drop;
use clone::Clone;
use libc::c_void;
use ca... | //! | random_line_split |
rc.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 ... |
}
}
}
pub fn refcount(&self) -> uint {
unsafe {
match *self.get_state() {
(count, _) => count
}
}
}
}
#[unsafe_destructor]
impl<T> Drop for RC<T> {
fn drop(&mut self) {
assert!(self.refcount() > 0);
unsafe {
... | {
let p: *mut T = p;
return p;
} | conditional_block |
rc.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 ... | assert!(v3.refcount() == 1);
}
}
}
| {
unsafe {
let mut v1 = RC::new(100);
assert!(*v1.unsafe_borrow_mut() == 100);
assert!(v1.refcount() == 1);
let mut v2 = v1.clone();
assert!(*v2.unsafe_borrow_mut() == 100);
assert!(v2.refcount() == 2);
*v2.unsafe_borrow_mut()... | identifier_body |
error.rs | // Copyright 2015, 2016 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 la... | }
} | random_line_split | |
error.rs | // Copyright 2015, 2016 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 la... |
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
match *self {
Error::Trace(ref err) => write!(f, "{}", err),
Error::Trie(ref err) => write!(f, "{}", err),
Error::Util(ref err) => write!(f, "{}", err),
Error::Database(ref s) => write!(f, "Database error: {}", s),
... | {
Error::from(*err)
} | identifier_body |
error.rs | // Copyright 2015, 2016 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 la... | (err: TrieError) -> Self {
Error::Trie(err)
}
}
impl From<UtilError> for Error {
fn from(err: UtilError) -> Self {
Error::Util(err)
}
}
impl<E> From<Box<E>> for Error where Error: From<E> {
fn from(err: Box<E>) -> Self {
Error::from(*err)
}
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> R... | from | identifier_name |
eval_benches.rs |
use std::time::Duration;
use criterion::{Criterion,black_box};
use pleco::tools::eval::Eval;
use pleco::{Board};
fn | (c: &mut Criterion) {
c.bench_function("bench_100_evaluations", |b| {
let rand_boards: Vec<Board> = RAND_BOARD_NON_CHECKS_100.iter()
.map(|b| Board::from_fen(b).unwrap())
.collect();
b.iter(|| {
black_box({
for board in rand_boards.iter() {
... | bench_100_evaluations | identifier_name |
eval_benches.rs |
use std::time::Duration;
use criterion::{Criterion,black_box};
use pleco::tools::eval::Eval;
use pleco::{Board};
fn bench_100_evaluations(c: &mut Criterion) |
criterion_group!(name = eval_benches;
config = Criterion::default().sample_size(20).warm_up_time(Duration::from_millis(5));
targets = bench_100_evaluations
);
static RAND_BOARD_NON_CHECKS_100: [&str; 100] = [
"3qkb1r/3ppp2/3r1np1/2Q4p/5P2/1P3B2/P1P1PP1P/R2NK2R b k - 0 22",
"r3kb1r/1p1bpp2/1p3n1p/q2p... | {
c.bench_function("bench_100_evaluations", |b| {
let rand_boards: Vec<Board> = RAND_BOARD_NON_CHECKS_100.iter()
.map(|b| Board::from_fen(b).unwrap())
.collect();
b.iter(|| {
black_box({
for board in rand_boards.iter() {
black_... | identifier_body |
eval_benches.rs | use std::time::Duration;
use criterion::{Criterion,black_box};
use pleco::tools::eval::Eval;
use pleco::{Board};
fn bench_100_evaluations(c: &mut Criterion) {
c.bench_function("bench_100_evaluations", |b| {
let rand_boards: Vec<Board> = RAND_BOARD_NON_CHECKS_100.iter()
.map(|b| Board::from_fe... | "r3kr2/p3pp2/1qbp2p1/1p5p/1P3B2/P1P2PP1/1N5P/R2Q1K b q - 0 24",
"2r5/3k1p2/2p2P1p/p2r4/3P4/P1p4P/4R3/3BK w - - 1 39",
"5r2/b4kp1/p1p4p/1p3P2/1P2R3/2N1PK1P/5P2/2N w - - 1 28",
"2n1qk2/p4pb1/6p1/1p2P3/5P2/4P1P1/PPP2K1R/R4Q b - - 0 22",
"r2qkb2/p5pQ/5p1p/4p3/4p3/P3PN2/1P1B2PP/3NKB1R w Kq - 0 27",
"... | "6nr/pQbk4/2N1ppB1/1N5p/3P4/P7/1P1P1PPP/R1B1K2R b KQ - 4 21", | random_line_split |
util.rs | use cpu::Cpu;
use opcode::Opcode;
pub static mut DEBUG_MODE: bool = true;
pub static FONTSET: [u8; 80] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, ... | (cpu: &Cpu, opcode: &Opcode) {
unsafe {
if!DEBUG_MODE {
return;
}
}
println!("cpu:");
for i in 0..16 {
if cpu.v[i] == 0 {
continue;
}
println!(" v{:.x}: {:.x}", i, cpu.v[i]);
}
println!(" pc: {:.x}", cpu.pc);
println!(" ... | debug_cycle | identifier_name |
util.rs | use cpu::Cpu;
use opcode::Opcode;
pub static mut DEBUG_MODE: bool = true;
pub static FONTSET: [u8; 80] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, ... |
println!(" v{:.x}: {:.x}", i, cpu.v[i]);
}
println!(" pc: {:.x}", cpu.pc);
println!(" I: {:.x}", cpu.i);
println!(" sp: {:.x}", cpu.sp);
println!("opcode: {:.x}", opcode.code);
}
| {
continue;
} | conditional_block |
util.rs | use cpu::Cpu;
use opcode::Opcode;
pub static mut DEBUG_MODE: bool = true;
pub static FONTSET: [u8; 80] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, ... | {
unsafe {
if !DEBUG_MODE {
return;
}
}
println!("cpu:");
for i in 0..16 {
if cpu.v[i] == 0 {
continue;
}
println!(" v{:.x}: {:.x}", i, cpu.v[i]);
}
println!(" pc: {:.x}", cpu.pc);
println!(" I: {:.x}", cpu.i);
pr... | identifier_body | |
util.rs | use cpu::Cpu;
use opcode::Opcode;
pub static mut DEBUG_MODE: bool = true; |
pub static FONTSET: [u8; 80] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
0xF0, 0x10, 0x20, 0x40, 0... | random_line_split | |
dxgi.rs | // Copyright © 2015-2017 winapi-rs developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied,... | ppTarget: *mut *mut IDXGIOutput,
) -> HRESULT,
fn GetDesc(
pDesc: *mut DXGI_SWAP_CHAIN_DESC,
) -> HRESULT,
fn ResizeBuffers(
BufferCount: UINT,
Width: UINT,
Height: UINT,
NewFormat: DXGI_FORMAT,
SwapChainFlags: UINT,
) -> HRESULT,
fn Resize... | pTarget: *mut IDXGIOutput,
) -> HRESULT,
fn GetFullscreenState(
pFullscreen: *mut BOOL, | random_line_split |
03.rs | #[macro_use]
extern crate lazy_static;
extern crate itertools;
extern crate regex;
use itertools::Itertools;
use regex::Regex;
#[derive(Clone)]
struct Claim {
id: i32,
offset_left: i32,
offset_top: i32,
width: i32,
height: i32,
}
impl Claim {
fn parse(raw_claim: &str) -> Claim {
lazy_... | } else if prev!= c {
checked = false;
}
prev = c;
}
overlaps
}
fn main() {
let input = include_str!("input.txt").into();
println!("{}", overlapping_inches(input));
}
#[test]
fn test_03() {
let input = vec!["#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2"];
... | overlaps += 1;
checked = true; | random_line_split |
03.rs | #[macro_use]
extern crate lazy_static;
extern crate itertools;
extern crate regex;
use itertools::Itertools;
use regex::Regex;
#[derive(Clone)]
struct Claim {
id: i32,
offset_left: i32,
offset_top: i32,
width: i32,
height: i32,
}
impl Claim {
fn parse(raw_claim: &str) -> Claim {
lazy_... | {
let input = vec!["#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2"];
let result = overlapping_inches(input.join("\n"));
assert_eq!(result, 4);
} | identifier_body | |
03.rs | #[macro_use]
extern crate lazy_static;
extern crate itertools;
extern crate regex;
use itertools::Itertools;
use regex::Regex;
#[derive(Clone)]
struct Claim {
id: i32,
offset_left: i32,
offset_top: i32,
width: i32,
height: i32,
}
impl Claim {
fn parse(raw_claim: &str) -> Claim {
lazy_... | else if prev!= c {
checked = false;
}
prev = c;
}
overlaps
}
fn main() {
let input = include_str!("input.txt").into();
println!("{}", overlapping_inches(input));
}
#[test]
fn test_03() {
let input = vec!["#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2"];
let re... | {
overlaps += 1;
checked = true;
} | conditional_block |
03.rs | #[macro_use]
extern crate lazy_static;
extern crate itertools;
extern crate regex;
use itertools::Itertools;
use regex::Regex;
#[derive(Clone)]
struct | {
id: i32,
offset_left: i32,
offset_top: i32,
width: i32,
height: i32,
}
impl Claim {
fn parse(raw_claim: &str) -> Claim {
lazy_static! {
static ref CLAIM_REGEX: Regex =
Regex::new(r"^#(\d+) @ (\d+),(\d+): (\d+)x(\d+)$").unwrap();
}
let capt... | Claim | identifier_name |
changelog.rs | //! Project changelog
/// ## Breaking changes
///
/// Upgrade to `rand_core = ^0.5.1`. This involves a major change to how errors are handled. See
/// [`ErrorCode`](crate::ErrorCode).
///
/// rustc version 1.42 is now required to build the library (up from 1.32).
pub mod r0_7_0 {}
/// Fix unsound mutable reference al... | /// Updated rand_core dependency from `0.3` to `0.4`.
pub mod r0_5_0 {}
/// ## Breaking changes
///
/// Crate gained an enabled-by-default `std` feature. If you relied on rdrand being `core`-able
/// change your dependency to appear as such:
///
/// ```toml
/// rdrand = { version = "0.4", default-features = false }
//... | /// Replaced likely unsound use of `core::mem::uninitialized()`.
pub mod r0_5_1 {}
/// ## Breaking changes
/// | random_line_split |
scope_wrapper.rs | use std::default::Default;
use communication::Communicator;
use progress::frontier::{MutableAntichain, Antichain};
use progress::{Timestamp, Scope};
use progress::nested::Target;
use progress::nested::subgraph::Target::{GraphOutput, ScopeInput};
use progress::count_map::CountMap;
pub struct ScopeWrapper<T: Timestam... |
pub fn name(&self) -> String { self.name.clone() }
} | random_line_split | |
scope_wrapper.rs | use std::default::Default;
use communication::Communicator;
use progress::frontier::{MutableAntichain, Antichain};
use progress::{Timestamp, Scope};
use progress::nested::Target;
use progress::nested::subgraph::Target::{GraphOutput, ScopeInput};
use progress::count_map::CountMap;
pub struct ScopeWrapper<T: Timestam... | (mut scope: Box<Scope<T>>, index: u64, _path: String) -> ScopeWrapper<T> {
let inputs = scope.inputs();
let outputs = scope.outputs();
let notify = scope.notify_me();
let (summary, work) = scope.get_internal_summary();
assert!(summary.len() as u64 == inputs);
assert!(!s... | new | identifier_name |
scope_wrapper.rs | use std::default::Default;
use communication::Communicator;
use progress::frontier::{MutableAntichain, Antichain};
use progress::{Timestamp, Scope};
use progress::nested::Target;
use progress::nested::subgraph::Target::{GraphOutput, ScopeInput};
use progress::count_map::CountMap;
pub struct ScopeWrapper<T: Timestam... | }
pub fn pull_pointstamps<A: FnMut(u64,T,i64)->()>(&mut self,
pointstamp_messages: &mut CountMap<(u64, u64, T)>,
pointstamp_internal: &mut CountMap<(u64, u64, T)>,
... | {
assert!(self.scope.is_some() || external_progress.iter().all(|x| x.len() == 0));
if self.notify && external_progress.iter().any(|x| x.len() > 0) {
for input_port in (0..self.inputs as usize) {
self.guarantees[input_port]
.update_into_cm(&external_progr... | identifier_body |
scope_wrapper.rs | use std::default::Default;
use communication::Communicator;
use progress::frontier::{MutableAntichain, Antichain};
use progress::{Timestamp, Scope};
use progress::nested::Target;
use progress::nested::subgraph::Target::{GraphOutput, ScopeInput};
use progress::count_map::CountMap;
pub struct ScopeWrapper<T: Timestam... |
else { false }
};
// shutting down if nothing left to do
if self.scope.is_some() &&
!active &&
self.notify && // we don't track guarantees and capabilities for non-notify scopes. bug?
self.guarantees.iter().all(|guarantee| guarantee.empty()) &&
... | {
scope.pull_internal_progress(&mut self.internal_progress,
&mut self.consumed_messages,
&mut self.produced_messages)
} | conditional_block |
quickcheck_impls.rs | extern crate quickcheck;
use self::quickcheck::{Arbitrary, Gen};
use super::{PgDate, PgTime, PgTimestamp, PgInterval};
impl Arbitrary for PgDate {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
PgDate(i32::arbitrary(g))
}
}
impl Arbitrary for PgTime {
fn arbitrary<G: Gen>(g: &mut G) -> Self |
}
impl Arbitrary for PgTimestamp {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
PgTimestamp(i64::arbitrary(g))
}
}
impl Arbitrary for PgInterval {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
PgInterval {
microseconds: i64::arbitrary(g),
days: i32::arbitrary(g),
... | {
let mut time = -1;
while time < 0 {
time = i64::arbitrary(g);
}
PgTime(time)
} | identifier_body |
quickcheck_impls.rs | extern crate quickcheck;
use self::quickcheck::{Arbitrary, Gen};
use super::{PgDate, PgTime, PgTimestamp, PgInterval}; | fn arbitrary<G: Gen>(g: &mut G) -> Self {
PgDate(i32::arbitrary(g))
}
}
impl Arbitrary for PgTime {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let mut time = -1;
while time < 0 {
time = i64::arbitrary(g);
}
PgTime(time)
}
}
impl Arbitrary for PgTimest... |
impl Arbitrary for PgDate { | random_line_split |
quickcheck_impls.rs | extern crate quickcheck;
use self::quickcheck::{Arbitrary, Gen};
use super::{PgDate, PgTime, PgTimestamp, PgInterval};
impl Arbitrary for PgDate {
fn | <G: Gen>(g: &mut G) -> Self {
PgDate(i32::arbitrary(g))
}
}
impl Arbitrary for PgTime {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let mut time = -1;
while time < 0 {
time = i64::arbitrary(g);
}
PgTime(time)
}
}
impl Arbitrary for PgTimestamp {
fn arb... | arbitrary | identifier_name |
encode.rs | use std::collections::{HashMap, BTreeMap};
use regex::Regex;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use core::{Package, PackageId, SourceId, Workspace};
use util::{CargoResult, Graph, Config};
use super::Resolve;
#[derive(RustcEncodable, RustcDecodable, Debug)]
pub struct EncodableResolve {
... | Some(id.source_id().with_precise(None))
};
EncodablePackageId {
name: id.name().to_string(),
version: id.version().to_string(),
source: source,
}
} | fn encodable_package_id(id: &PackageId) -> EncodablePackageId {
let source = if id.source_id().is_path() {
None
} else { | random_line_split |
encode.rs | use std::collections::{HashMap, BTreeMap};
use regex::Regex;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use core::{Package, PackageId, SourceId, Workspace};
use util::{CargoResult, Graph, Config};
use super::Resolve;
#[derive(RustcEncodable, RustcDecodable, Debug)]
pub struct EncodableResolve {
... |
EncodableDependency {
name: id.name().to_string(),
version: id.version().to_string(),
source: source,
dependencies: deps,
replace: replace,
}
}
fn encodable_package_id(id: &PackageId) -> EncodablePackageId {
let source = if id.source_id().is_path() {
None
... | {
let (replace, deps) = match resolve.replacement(id) {
Some(id) => {
(Some(encodable_package_id(id)), None)
}
None => {
let mut deps = resolve.graph.edges(id)
.into_iter().flat_map(|a| a)
.map(encoda... | identifier_body |
encode.rs | use std::collections::{HashMap, BTreeMap};
use regex::Regex;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use core::{Package, PackageId, SourceId, Workspace};
use util::{CargoResult, Graph, Config};
use super::Resolve;
#[derive(RustcEncodable, RustcDecodable, Debug)]
pub struct EncodableResolve {
... | else {
Some(id.source_id().clone())
};
EncodableDependency {
name: id.name().to_string(),
version: id.version().to_string(),
source: source,
dependencies: deps,
replace: replace,
}
}
fn encodable_package_id(id: &PackageId) -> EncodablePackageId {
let so... | {
None
} | conditional_block |
encode.rs | use std::collections::{HashMap, BTreeMap};
use regex::Regex;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use core::{Package, PackageId, SourceId, Workspace};
use util::{CargoResult, Graph, Config};
use super::Resolve;
#[derive(RustcEncodable, RustcDecodable, Debug)]
pub struct EncodableResolve {
... | (id: &PackageId) -> EncodablePackageId {
let source = if id.source_id().is_path() {
None
} else {
Some(id.source_id().with_precise(None))
};
EncodablePackageId {
name: id.name().to_string(),
version: id.version().to_string(),
source: source,
}
}
| encodable_package_id | identifier_name |
associated-types-nested-projections.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 into_iter(self) -> slice::Iter<'a, T> {
self.iter()
}
}
fn foo<X>(x: X) where
X: IntoIterator,
<<X as IntoIterator>::Iter as Iterator>::Item: Bound,
{
}
fn bar<T, I, X>(x: X) where
T: Bound,
I: Iterator<Item=T>,
X: IntoIterator<Iter=I>,
{
}
fn main() {
foo(&[0, 1, 2]);
... |
impl<'a, T> IntoIterator for &'a [T; 3] {
type Iter = slice::Iter<'a, T>;
| random_line_split |
associated-types-nested-projections.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 ... | <T, I, X>(x: X) where
T: Bound,
I: Iterator<Item=T>,
X: IntoIterator<Iter=I>,
{
}
fn main() {
foo(&[0, 1, 2]);
bar(&[0, 1, 2]);
}
| bar | identifier_name |
associated-types-nested-projections.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() {
foo(&[0, 1, 2]);
bar(&[0, 1, 2]);
}
| {
} | identifier_body |
bench.rs | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
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 a... | () {
let opts: Opts = Opts::parse();
init_logging(&opts);
let commit = Commit::new();
let logdir = DynLogdir::new(opts.logdir).expect("DynLogdir::new");
let mut loader = LogdirLoader::new(
&commit,
logdir,
opts.reload_threads.unwrap_or(0),
Arc::new(PluginSamplingHint... | main | identifier_name |
bench.rs | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
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 a... | .init();
} | random_line_split | |
bench.rs | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
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 a... | {
use env_logger::{Builder, Env};
Builder::from_env(Env::default().default_filter_or(&opts.log_level))
.format_timestamp_micros()
.init();
} | identifier_body | |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate docopt;
use docopt::Docopt;
use std::fs;
use std::path::PathBuf;
mod directory_files;
use directory_files::*;
mod file_comparable;
mod directory_comparable;
use directory_comparable::*;
/// The Docopt usage string
const USAGE: &'static str = "
Usage: subset [-q ... | {
arg_dir1: String,
arg_dir2: String,
flag_quiet: bool,
flag_verbose: bool,
flag_trivial: bool,
flag_name: bool,
flag_bidirectional: bool,
}
/// This should be the UI layer as much as possible-- it parses the command line arguments,
/// hands it off to our business logic, and then collects... | Args | identifier_name |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate docopt;
use docopt::Docopt;
use std::fs;
use std::path::PathBuf;
mod directory_files;
use directory_files::*;
mod file_comparable;
mod directory_comparable;
use directory_comparable::*;
/// The Docopt usage string
const USAGE: &'static str = "
Usage: subset [-q ... | else {
let md5_comparator = file_comparable::Md5Comparable::new();
Box::new(DirectoryComparableWithFileComparable::new(md5_comparator))
};
let superset_dirpath = PathBuf::from(&args.arg_dir2);
// eww... why do we have to coerce these Box types again?
// (again, only two of these Box ty... | {
let filename_comparator = file_comparable::FileNameComparable::new();
Box::new(DirectoryComparableWithFileComparable::new(
filename_comparator,
))
} | conditional_block |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate docopt;
use docopt::Docopt;
use std::fs;
use std::path::PathBuf;
mod directory_files;
use directory_files::*;
mod file_comparable;
mod directory_comparable;
use directory_comparable::*;
/// The Docopt usage string
const USAGE: &'static str = "
Usage: subset [-q ... | } else {
let md5_comparator = file_comparable::Md5Comparable::new();
Box::new(DirectoryComparableWithFileComparable::new(md5_comparator))
};
let superset_dirpath = PathBuf::from(&args.arg_dir2);
// eww... why do we have to coerce these Box types again?
// (again, only two of these B... | {
let args: Args = Docopt::new(USAGE)
.and_then(|d| d.deserialize())
.unwrap_or_else(|e| e.exit());
println!("Comparing {} with {}", args.arg_dir1, args.arg_dir2);
// Make sure both of our inputs are valid directories
fs::read_dir(&args.arg_dir1).expect("Directory cannot be read!");
... | identifier_body |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate docopt;
use docopt::Docopt;
use std::fs;
use std::path::PathBuf;
mod directory_files;
use directory_files::*;
mod file_comparable; | use directory_comparable::*;
/// The Docopt usage string
const USAGE: &'static str = "
Usage: subset [-q | -v] [-t | -n] [-b] <dir1> <dir2>
subset --help
subset lets you compare two directory structures.
We are going to check whether the files in dir1 are a subset of the files in dir2, regardless of directory... |
mod directory_comparable; | random_line_split |
helpers.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | (&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec<u8>) -> Result<(), NetworkError> {
self.queue.push_back(TestPacket {
data: data,
packet_id: packet_id,
recipient: peer_id,
});
Ok(())
}
fn send_protocol(&mut self, _protocol: ProtocolId, peer_id: PeerId, packet_id: PacketId, data: Vec<u8>) ->... | send | identifier_name |
helpers.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | pub queue: &'p mut VecDeque<TestPacket>,
pub sender: Option<PeerId>,
pub to_disconnect: HashSet<PeerId>,
overlay: RwLock<HashMap<BlockNumber, Bytes>>,
}
impl<'p> TestIo<'p> {
pub fn new(chain: &'p mut TestBlockChainClient, ss: &'p TestSnapshotService, queue: &'p mut VecDeque<TestPacket>, sender: Option<PeerId>) -... | random_line_split | |
helpers.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | else { self.eth_protocol_version(peer_id) }
}
fn chain_overlay(&self) -> &RwLock<HashMap<BlockNumber, Bytes>> {
&self.overlay
}
}
pub struct TestPacket {
pub data: Bytes,
pub packet_id: PacketId,
pub recipient: PeerId,
}
pub struct TestPeer {
pub chain: TestBlockChainClient,
pub snapshot_service: Arc<Test... | { 1 } | conditional_block |
challenge15.rs | use aes::{unpad_inplace, Aes128};
| use crate::errors::*;
pub fn run() -> Result<()> {
{
let mut message = b"ICE ICE BABY\x04\x04\x04\x04".to_vec();
unpad_inplace(&mut message, 16)?;
compare_eq(b"ICE ICE BABY".as_ref(), &message)?;
}
compare_eq(false, b"ICE ICE BABY\x05\x05\x05\x05".padding_valid())?;
compare_eq(... | random_line_split | |
challenge15.rs | use aes::{unpad_inplace, Aes128};
use crate::errors::*;
pub fn | () -> Result<()> {
{
let mut message = b"ICE ICE BABY\x04\x04\x04\x04".to_vec();
unpad_inplace(&mut message, 16)?;
compare_eq(b"ICE ICE BABY".as_ref(), &message)?;
}
compare_eq(false, b"ICE ICE BABY\x05\x05\x05\x05".padding_valid())?;
compare_eq(false, b"ICE ICE BABY\x01\x02\x03... | run | identifier_name |
challenge15.rs | use aes::{unpad_inplace, Aes128};
use crate::errors::*;
pub fn run() -> Result<()> | {
{
let mut message = b"ICE ICE BABY\x04\x04\x04\x04".to_vec();
unpad_inplace(&mut message, 16)?;
compare_eq(b"ICE ICE BABY".as_ref(), &message)?;
}
compare_eq(false, b"ICE ICE BABY\x05\x05\x05\x05".padding_valid())?;
compare_eq(false, b"ICE ICE BABY\x01\x02\x03\x04".padding_val... | identifier_body | |
helpers.rs | // Copyrighttape Technologies 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 to in... | tx.set_valid_until_block(100);
tx.set_quota(1844674);
let stx = tx.sign(*privkey);
let new_tx = SignedTransaction::create(&stx).unwrap();
txs.push(new_tx);
}
body.set_transactions(txs);
block.set_body(body);
block
}
pub fn generate_contract() -> Vec<u8> {
l... | {
let mut block = OpenBlock::default();
block.set_parent_hash(executor.get_current_hash());
block.set_timestamp(AsMillis::as_millis(&UNIX_EPOCH.elapsed().unwrap()));
block.set_number(executor.get_current_height() + 1);
// header.proof= ?;
let mut body = BlockBody::default();
let mut txs = ... | identifier_body |
helpers.rs | // Copyrighttape Technologies 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 to in... | .read_to_string(&mut content)
.expect("failed to read binary");
let deploy_code = content.as_str().from_hex().unwrap();
// read runtime code
let mut content = String::new();
File::open(runtime_code_file)
.expect("failed to open deploy code file!")
.read_to_string(&mut conten... |
// read deploy code
File::open(deploy_code_file)
.expect("failed to open deploy code file!") | random_line_split |
helpers.rs | // Copyrighttape Technologies 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 to in... |
tx.set_nonce(U256::from(i).lower_hex());
tx.set_data(data.clone());
tx.set_valid_until_block(100);
tx.set_quota(1844674);
let stx = tx.sign(*privkey);
let new_tx = SignedTransaction::create(&stx).unwrap();
txs.push(new_tx);
}
body.set_transactions(txs);
... | {
tx.set_to(to.lower_hex());
} | conditional_block |
helpers.rs | // Copyrighttape Technologies 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 to in... | (
fsm_req_receiver: Receiver<OpenBlock>,
fsm_resp_sender: Sender<ClosedBlock>,
command_req_receiver: Receiver<command::Command>,
command_resp_sender: Sender<command::CommandResp>,
) -> Executor {
// FIXME temp dir should be removed automatically, but at present it is not
let tempdir = TempDir::n... | init_executor2 | identifier_name |
lib.rs | // =================================================================
//
// * WARNING *
//
// This file is generated!
//
// Changes made to this file will be overwritten. If changes are
// required to the generated code, the service_crategen project
// must be updated to g... | mod generated;
pub use custom::*;
pub use generated::*; | mod custom; | random_line_split |
issue-11552.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 ... |
{
Atom(int),
Cell(Box<Noun>, Box<Noun>)
}
fn fas(n: &Noun) -> Noun
{
match n {
&Noun::Cell(box Noun::Atom(2), box Noun::Cell(ref a, _)) => (**a).clone(),
_ => panic!("Invalid fas pattern")
}
}
pub fn main() {
fas(&Noun::Cell(box Noun::Atom(2), box Noun::Cell(box Noun::Atom(2), box... | Noun | identifier_name |
issue-11552.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 ... | Cell(Box<Noun>, Box<Noun>)
}
fn fas(n: &Noun) -> Noun
{
match n {
&Noun::Cell(box Noun::Atom(2), box Noun::Cell(ref a, _)) => (**a).clone(),
_ => panic!("Invalid fas pattern")
}
}
pub fn main() {
fas(&Noun::Cell(box Noun::Atom(2), box Noun::Cell(box Noun::Atom(2), box Noun::Atom(3))));... |
#[derive(Clone)]
enum Noun
{
Atom(int), | random_line_split |
target-feature-multiple.rs | // assembly-output: emit-asm
// needs-llvm-components: x86
// revisions: TWOFLAGS SINGLEFLAG
// compile-flags: --target=x86_64-unknown-linux-gnu
// [TWOFLAGS] compile-flags: -C target-feature=+rdrnd -C target-feature=+rdseed
// [SINGLEFLAG] compile-flags: -C target-feature=+rdrnd,+rdseed
// Target features set via fla... | #![no_core]
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
// Use of these requires target features to be enabled
extern "unadjusted" {
#[link_name = "llvm.x86.rdrand.32"]
fn x86_rdrand32_step() -> (u32, i32);
#[link_name = "llvm.x86.rdseed.32"]
fn x86_rdseed32_step() -> (u32, i32);
}... | // See also src/test/codegen/target-feature-overrides.rs
#![feature(no_core, lang_items, link_llvm_intrinsics, abi_unadjusted)]
#![crate_type = "lib"] | random_line_split |
target-feature-multiple.rs | // assembly-output: emit-asm
// needs-llvm-components: x86
// revisions: TWOFLAGS SINGLEFLAG
// compile-flags: --target=x86_64-unknown-linux-gnu
// [TWOFLAGS] compile-flags: -C target-feature=+rdrnd -C target-feature=+rdseed
// [SINGLEFLAG] compile-flags: -C target-feature=+rdrnd,+rdseed
// Target features set via fla... | {
// CHECK-LABEL: foo:
// CHECK: rdrand
// CHECK: rdseed
(x86_rdrand32_step().0, x86_rdseed32_step().0)
} | identifier_body | |
target-feature-multiple.rs | // assembly-output: emit-asm
// needs-llvm-components: x86
// revisions: TWOFLAGS SINGLEFLAG
// compile-flags: --target=x86_64-unknown-linux-gnu
// [TWOFLAGS] compile-flags: -C target-feature=+rdrnd -C target-feature=+rdseed
// [SINGLEFLAG] compile-flags: -C target-feature=+rdrnd,+rdseed
// Target features set via fla... | () -> (u32, u32) {
// CHECK-LABEL: foo:
// CHECK: rdrand
// CHECK: rdseed
(x86_rdrand32_step().0, x86_rdseed32_step().0)
}
| foo | identifier_name |
utils.rs | use iso8601::{Date, DateTime, Time};
use xml::escape::escape_str_pcdata;
use std::borrow::Cow;
use std::fmt::Write;
/// Escape a string for use as XML characters.
///
/// The resulting string is *not* suitable for use in XML attributes, but XML-RPC doesn't use those.
pub fn | (s: &str) -> Cow<'_, str> {
escape_str_pcdata(s)
}
/// Formats a `DateTime` for use in XML-RPC.
///
/// Note that XML-RPC is extremely underspecified when it comes to datetime values. Apparently,
/// some clients [don't even support timezone information][wp-bug] (we do). For maximum
/// interoperability, this will... | escape_xml | identifier_name |
utils.rs | use iso8601::{Date, DateTime, Time};
use xml::escape::escape_str_pcdata;
use std::borrow::Cow;
use std::fmt::Write;
/// Escape a string for use as XML characters.
///
/// The resulting string is *not* suitable for use in XML attributes, but XML-RPC doesn't use those.
pub fn escape_xml(s: &str) -> Cow<'_, str> {
e... | } | random_line_split | |
utils.rs | use iso8601::{Date, DateTime, Time};
use xml::escape::escape_str_pcdata;
use std::borrow::Cow;
use std::fmt::Write;
/// Escape a string for use as XML characters.
///
/// The resulting string is *not* suitable for use in XML attributes, but XML-RPC doesn't use those.
pub fn escape_xml(s: &str) -> Cow<'_, str> |
/// Formats a `DateTime` for use in XML-RPC.
///
/// Note that XML-RPC is extremely underspecified when it comes to datetime values. Apparently,
/// some clients [don't even support timezone information][wp-bug] (we do). For maximum
/// interoperability, this will omit fractional time and time zone if not specified.
... | {
escape_str_pcdata(s)
} | identifier_body |
day24.rs | use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Read;
use std::mem::swap;
use crate::common::Lines;
use crate::Solution;
type Pos = (i32, i32);
const DIRECTIONS: [Pos; 6] = [(-2, 0), (2, 0), (-1, -1), (-1, 1), (1, -1), (1, 1)];
fn convert_pos(s: &str) -> Pos {
let mut s = s.chars();
... | (input: &mut dyn Read) -> HashSet<Pos> {
let mut black = HashSet::new();
for line in Lines::new(input) {
let pos = convert_pos(&line);
if!black.insert(pos) {
black.remove(&pos);
}
}
black
}
#[derive(Default)]
pub struct Day24;
impl Solution for Day24 {
fn par... | get_black_tiles | identifier_name |
day24.rs | use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Read;
use std::mem::swap;
use crate::common::Lines;
use crate::Solution;
type Pos = (i32, i32);
const DIRECTIONS: [Pos; 6] = [(-2, 0), (2, 0), (-1, -1), (-1, 1), (1, -1), (1, 1)];
fn convert_pos(s: &str) -> Pos {
let mut s = s.chars();
... |
#[test]
fn sample_part2() {
test_implementation(Day24, 2, SAMPLE, 2208);
}
}
| {
test_implementation(Day24, 1, SAMPLE, 10);
} | identifier_body |
day24.rs | use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Read;
use std::mem::swap;
use crate::common::Lines;
use crate::Solution;
type Pos = (i32, i32);
const DIRECTIONS: [Pos; 6] = [(-2, 0), (2, 0), (-1, -1), (-1, 1), (1, -1), (1, 1)];
fn convert_pos(s: &str) -> Pos {
let mut s = s.chars();
... | y -= 1;
}
match s.next() {
Some('e') => x += 1,
Some('w') => x -= 1,
_ => panic!(),
}
}
_ => panic!(),
}
}
(x, y)
}
fn step(current: &HashSet<Pos>, t... | if c == 'n' {
y += 1;
} else { | random_line_split |
updater.rs | use update_client::*;
use errors::*;
use database::*;
use db_actor::*;
use atoms::*;
use std;
use std::time::Duration;
use std::collections::HashMap;
use std::env;
use std::str;
use std::thread;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::{Arc, Mutex};
use chan;
use chan::{Sender, Receiver};
use... | {
update_client: UpdateClient,
db_actor: Sender<Atoms>,
period: u64,
}
impl GSBUpdater {
pub fn begin_processing<H>(api_key: String, db_actor: Sender<Atoms>, executor: H)
where H: Spawn + Clone
{
let (sender, receiver) = chan::async();
executor.spawn(futures::lazy(move ||... | GSBUpdater | identifier_name |
updater.rs | use update_client::*;
use errors::*;
use database::*;
use db_actor::*;
use atoms::*;
use std;
use std::time::Duration;
use std::collections::HashMap;
use std::env;
use std::str;
use std::thread;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::{Arc, Mutex};
use chan;
use chan::{Sender, Receiver};
use... | fn parse_backoff(backoff: &str) -> Result<Option<Duration>> {
if backoff.is_empty() {
Ok(None)
} else {
let point_ix = backoff.find('.').unwrap_or(backoff.len() - 1);
// We know this can't panic because the minimum value of point_ix is 0.
// When the s... | random_line_split | |
updater.rs | use update_client::*;
use errors::*;
use database::*;
use db_actor::*;
use atoms::*;
use std;
use std::time::Duration;
use std::collections::HashMap;
use std::env;
use std::str;
use std::thread;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::{Arc, Mutex};
use chan;
use chan::{Sender, Receiver};
use... |
}
}
| {
let point_ix = backoff.find('.').unwrap_or(backoff.len() - 1);
// We know this can't panic because the minimum value of point_ix is 0.
// When the second value to a non inclusive slice is 0, an empty slice is returned.
let backoff = &backoff[..point_ix];
let... | conditional_block |
updater.rs | use update_client::*;
use errors::*;
use database::*;
use db_actor::*;
use atoms::*;
use std;
use std::time::Duration;
use std::collections::HashMap;
use std::env;
use std::str;
use std::thread;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::{Arc, Mutex};
use chan;
use chan::{Sender, Receiver};
use... | updater.db_actor
.send(Atoms::Update {
fetch_response: fetch_response,
receipt: sender.clone(),
});
info!("Awaiting db update status");
receiver.recv()
... | {
let (sender, receiver) = chan::async();
executor.spawn(futures::lazy(move || {
let mut updater = GSBUpdater {
update_client: UpdateClient::new(api_key),
db_actor: db_actor,
period: 30 * 60,
};
loop {
... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.