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 |
|---|---|---|---|---|
nvic.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Ben Harris <mail@bharr.is>
//
// 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
/... | 0..8 => stir,
}
});
} | 0x400 => reg32 ipr[8] { //! Interrupt priority register
0..31 => ipr[4],
}
0xF00 => reg32 stir[8] { //! Software triggered interrupt register | random_line_split |
issue-662-part-2.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[derive(Clone, Copy, Debug)]
pub struct RefPtr<T>(T);
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nsMainThreadPtrHolder<T> {
pub a: T,
pub _phantom_0: ::... | <U> {
pub mPtr: RefPtr<nsMainThreadPtrHolder<U>>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>,
}
impl<U> Default for nsMainThreadPtrHandle<U> {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
| nsMainThreadPtrHandle | identifier_name |
issue-662-part-2.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[derive(Clone, Copy, Debug)]
pub struct RefPtr<T>(T);
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nsMainThreadPtrHolder<T> {
pub a: T,
pub _phantom_0: ::... |
}
#[repr(C)]
pub struct nsMainThreadPtrHandle<U> {
pub mPtr: RefPtr<nsMainThreadPtrHolder<U>>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>,
}
impl<U> Default for nsMainThreadPtrHandle<U> {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
| {
unsafe { ::std::mem::zeroed() }
} | identifier_body |
issue-662-part-2.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals |
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nsMainThreadPtrHolder<T> {
pub a: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl<T> Default for nsMainThreadPtrHolder<T> {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
pub struct nsMa... | )]
#[derive(Clone, Copy, Debug)]
pub struct RefPtr<T>(T); | random_line_split |
main.rs | // Mandelbrot set in rust
//
// This code shows how to calculate the set in serial and parallel.
// More parallel versions will be added in the future.
//
// Written by Willi Kappler, grandor@gmx.de
//
// License: MIT
//
//#![feature(plugin)]
//
//#![plugin(clippy)]
// External crates
extern crate time;
extern crate r... | () {
// For example run with:
// cargo run --release -- --re1=-2.0 --re2=1.0 --img1=-1.5 --img2=1.5
// --max_iter=2048 --img_size=1024 --num_threads=2
//
// Or just using the default values:
// cargo run --release -- --num_threads=2
//
// Note that the image size must be a powe... | main | identifier_name |
main.rs | // Mandelbrot set in rust
//
// This code shows how to calculate the set in serial and parallel.
// More parallel versions will be added in the future.
//
// Written by Willi Kappler, grandor@gmx.de
//
// License: MIT
//
//#![feature(plugin)]
//
//#![plugin(clippy)]
// External crates
extern crate time;
extern crate r... | ,
Err(e) => println!("Rayon error: set number of threads failed: {}", e)
}
do_run("rust_scoped_pool", &rust_scoped_pool, &mandel_config, &mut image, &time_now);
do_run("job_steal", &job_steal, &mandel_config, &mut image, &time_now);
do_run("job_steal_join", &job_steal_join, &mandel_config, &m... | {
do_run("rayon_join", &rayon_join, &mandel_config, &mut image, &time_now);
do_run("rayon_par_iter", &rayon_par_iter, &mandel_config, &mut image, &time_now);
} | conditional_block |
main.rs | // Mandelbrot set in rust
//
// This code shows how to calculate the set in serial and parallel.
// More parallel versions will be added in the future.
//
// Written by Willi Kappler, grandor@gmx.de
//
// License: MIT
//
//#![feature(plugin)]
//
//#![plugin(clippy)]
// External crates
extern crate time;
extern crate r... |
do_run("scoped_thread_pool", &scoped_thread_pool_, &mandel_config, &mut image, &time_now);
// Make sure this is only called once
match rayon::initialize(rayon::Configuration::new().set_num_threads(mandel_config.num_threads as usize)) {
Ok(_) => {
do_run("rayon_join", &rayon_join, &mand... | random_line_split | |
main.rs | // Mandelbrot set in rust
//
// This code shows how to calculate the set in serial and parallel.
// More parallel versions will be added in the future.
//
// Written by Willi Kappler, grandor@gmx.de
//
// License: MIT
//
//#![feature(plugin)]
//
//#![plugin(clippy)]
// External crates
extern crate time;
extern crate r... | let tm = tm.strftime("%Y_%m_%d__%H_%M_%S").unwrap();
let time_now = format!("{}", &tm);
// vec! macro expects usize
let mut image: Vec<u32> = vec![0; (mandel_config.img_size * mandel_config.img_size) as usize];
do_run("serial", &serial, &mandel_config, &mut image, &time_now);
do_run("scoped_t... | {
// For example run with:
// cargo run --release -- --re1=-2.0 --re2=1.0 --img1=-1.5 --img2=1.5
// --max_iter=2048 --img_size=1024 --num_threads=2
//
// Or just using the default values:
// cargo run --release -- --num_threads=2
//
// Note that the image size must be a power o... | identifier_body |
lib.rs | // Copyright 2014 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// 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>,... | extern crate native;
extern crate phf;
extern crate time;
pub use tokenizer::Attribute;
pub use driver::{one_input, ParseOpts, parse_to, parse};
#[cfg(not(for_c))]
pub use serialize::serialize;
mod macros;
mod util {
#![macro_escape]
pub mod str;
pub mod smallcharset;
}
pub mod tokenizer;
pub mod tre... | #[cfg(test)] | random_line_split |
issue-13698.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | impl Bar for Foo {} | #[doc(hidden)]
fn bar(&self) {}
}
// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn bar' | random_line_split |
issue-13698.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 ... | ;
// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn foo'
impl issue_13698::Foo for Foo {}
pub trait Bar {
#[doc(hidden)]
fn bar(&self) {}
}
// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn bar'
impl Bar for Foo {}
| Foo | identifier_name |
lib.rs | //! Data types that represent playing cards.
#![warn(bad_style, missing_docs,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#![feature(str_char)]
use std::fmt;
use std::str::FromStr;
use Suit::{Spade, Heart, Dia, Club};
/// Playing card's suite.
#[allow... | match *self {
Card::BlackJoker => write!(f, "BJ"),
Card::WhiteJoker => write!(f, "WJ"),
Card::Suit(sc) => write!(f, "{}", sc),
}
}
}
impl FromStr for Card {
type Err = ();
fn from_str(s: &str) -> Result<Card, ()> {
match s {
"BJ" => O... | impl fmt::Display for Card {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | random_line_split |
lib.rs | //! Data types that represent playing cards.
#![warn(bad_style, missing_docs,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#![feature(str_char)]
use std::fmt;
use std::str::FromStr;
use Suit::{Spade, Heart, Dia, Club};
/// Playing card's suite.
#[allow... |
check_pair("S".to_string(), Spade);
check_pair("H".to_string(), Heart);
check_pair("D".to_string(), Dia);
check_pair("C".to_string(), Club);
}
#[test]
fn show_card() {
fn check_pair(s: String, card: Card) {
assert_eq!(s, format!("{}", card));
... | {
assert_eq!(s, format!("{}", suite));
assert_eq!(Ok(suite), s.parse());
} | identifier_body |
lib.rs | //! Data types that represent playing cards.
#![warn(bad_style, missing_docs,
unused, unused_extern_crates, unused_import_braces,
unused_qualifications, unused_results)]
#![feature(str_char)]
use std::fmt;
use std::str::FromStr;
use Suit::{Spade, Heart, Dia, Club};
/// Playing card's suite.
#[allow... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match self {
&Spade => "S",
&Heart => "H",
&Dia => "D",
&Club => "C"
};
write!(f, "{}", s)
}
}
impl FromStr for Suit {
type Err = ();
fn from_str(s: &str) -> Result<Suit, ()... | fmt | identifier_name |
active.rs | //! Active (fully-registered) client connection handling
use irc;
use irc::driver::Client;
use irc::send::Sender;
use world::World;
/// An active client
pub struct Active {
world: World,
_out: Sender,
nick: String,
}
impl Active {
/// Creates a new `Active`
pub fn new(world: World, out: Sender, ... | ,
_ => {
irc::Op::ok(self)
}
}
}
}
| {
let chan = "#foo".to_string();
let message = "hello".to_string();
let op = self.world.message(chan, self.nick.clone(), message);
irc::Op::observe(op, self)
} | conditional_block |
active.rs | //! Active (fully-registered) client connection handling
use irc;
use irc::driver::Client;
use irc::send::Sender;
use world::World;
/// An active client
pub struct Active {
world: World,
_out: Sender,
nick: String,
}
impl Active {
/// Creates a new `Active`
pub fn new(world: World, out: Sender, ... | (self, m: irc::Message) -> irc::Op<Client> {
self.handle_easy(m).map(Client::Active)
}
fn handle_easy(mut self, m: irc::Message) -> irc::Op<Active> {
debug!(" -> {:?}", m);
match &m.verb[..] {
b"JOIN" => {
let chan = "#foo".to_string();
let o... | handle | identifier_name |
active.rs | //! Active (fully-registered) client connection handling
| use irc::send::Sender;
use world::World;
/// An active client
pub struct Active {
world: World,
_out: Sender,
nick: String,
}
impl Active {
/// Creates a new `Active`
pub fn new(world: World, out: Sender, nick: String) -> Active {
Active { world: world, _out: out, nick: nick }
}
... | use irc;
use irc::driver::Client; | random_line_split |
cursor.rs | #[cfg(target_os = "android")]
#[macro_use]
extern crate android_glue;
extern crate glutin;
use glutin::{Event, ElementState, MouseCursor};
mod support;
#[cfg(target_os = "android")]
android_start!(main);
#[cfg(not(feature = "window"))]
fn main() { println!("This example requires glutin to be compiled with the `win... | () {
let window = glutin::WindowBuilder::new().with_gl_profile(glutin::GlProfile::Compatibility).build().unwrap();
window.set_title("A fantastic window!");
unsafe { window.make_current() };
let context = support::load(&window);
let cursors = [MouseCursor::Default, MouseCursor::Crosshair, Mo... | main | identifier_name |
cursor.rs | #[cfg(target_os = "android")]
#[macro_use]
extern crate android_glue;
extern crate glutin;
use glutin::{Event, ElementState, MouseCursor};
mod support;
#[cfg(target_os = "android")]
android_start!(main);
#[cfg(not(feature = "window"))]
fn main() { println!("This example requires glutin to be compiled with the `win... | match event {
Event::KeyboardInput(ElementState::Pressed, _, _) => {
println!("Setting cursor to \"{:?}\"", cursors[cursor_idx]);
window.set_cursor(cursors[cursor_idx]);
if cursor_idx < cursors.len() - 1 {
cursor_idx += 1;
... | let mut cursor_idx = 0;
for event in window.wait_events() { | random_line_split |
cursor.rs | #[cfg(target_os = "android")]
#[macro_use]
extern crate android_glue;
extern crate glutin;
use glutin::{Event, ElementState, MouseCursor};
mod support;
#[cfg(target_os = "android")]
android_start!(main);
#[cfg(not(feature = "window"))]
fn main() { println!("This example requires glutin to be compiled with the `win... | },
Event::Closed => break,
_ => (),
}
context.draw_frame((0.0, 1.0, 0.0, 1.0));
window.swap_buffers();
}
}
| {
let window = glutin::WindowBuilder::new().with_gl_profile(glutin::GlProfile::Compatibility).build().unwrap();
window.set_title("A fantastic window!");
unsafe { window.make_current() };
let context = support::load(&window);
let cursors = [MouseCursor::Default, MouseCursor::Crosshair, Mouse... | identifier_body |
webgluniformlocation.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/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use dom::bindings::codegen::Bindings::WebGLUn... |
impl WebGLUniformLocation {
fn new_inherited(id: i32) -> WebGLUniformLocation {
WebGLUniformLocation {
reflector_: Reflector::new(),
id: id,
}
}
pub fn new(global: GlobalRef, id: i32) -> Root<WebGLUniformLocation> {
reflect_dom_object(box WebGLUniformLocatio... | pub struct WebGLUniformLocation {
reflector_: Reflector,
id: i32,
} | random_line_split |
webgluniformlocation.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/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use dom::bindings::codegen::Bindings::WebGLUn... | (id: i32) -> WebGLUniformLocation {
WebGLUniformLocation {
reflector_: Reflector::new(),
id: id,
}
}
pub fn new(global: GlobalRef, id: i32) -> Root<WebGLUniformLocation> {
reflect_dom_object(box WebGLUniformLocation::new_inherited(id), global, WebGLUniformLocatio... | new_inherited | identifier_name |
cssmediarule.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 cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSMediaRuleBinding;
use dom::bindings::codegen::Bind... | (&self) -> Root<MediaList> {
self.medialist()
}
}
| Media | identifier_name |
cssmediarule.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 cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSMediaRuleBinding;
use dom::bindings::codegen::Bind... | fn Media(&self) -> Root<MediaList> {
self.medialist()
}
} | }
}
impl CSSMediaRuleMethods for CSSMediaRule {
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-media | random_line_split |
cssmediarule.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 cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSMediaRuleBinding;
use dom::bindings::codegen::Bind... |
fn get_css(&self) -> DOMString {
self.mediarule.read().to_css_string().into()
}
}
impl CSSMediaRuleMethods for CSSMediaRule {
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-media
fn Media(&self) -> Root<MediaList> {
self.medialist()
}
}
| {
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants;
CSSRuleConstants::MEDIA_RULE
} | identifier_body |
local_ptr.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 ... |
/// Take ownership of a pointer from thread-local storage.
///
/// # Safety note
///
/// Does not validate the pointer type.
#[inline]
pub unsafe fn take<T>() -> ~T {
let ptr = RT_TLS_PTR;
rtassert!(!ptr.is_null());
let ptr: ~T = cast::transmute(ptr);
// can... | {
RT_TLS_PTR = cast::transmute(sched)
} | identifier_body |
local_ptr.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 ... | <'a>(&'a mut self) -> &'a mut T {
unsafe {
let val_ptr: &mut ~T = cast::transmute(&mut self.val);
let val_ptr: &'a mut T = *val_ptr;
val_ptr
}
}
}
/// Borrow the thread-local value from thread-local storage.
/// While the value is borrowed it is not available in ... | get | identifier_name |
local_ptr.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 ... | } else {
Some(RT_TLS_PTR as *mut T)
}
}
}
/// Native implementation of having the runtime thread-local pointer. This
/// implementation uses the `thread_local_storage` module to provide a
/// thread-local value.
pub mod native {
use cast;
use libc::c_void;
use option::{Optio... | random_line_split | |
click_object.rs | extern crate gtk;
use gtk::{ScrolledWindow,ContainerExt,Box,Orientation,Entry,EntryExt,Frame};
use std::vec::Vec;
pub trait Attachable{
fn attach<F:ContainerExt>(&self,parent: &F);
}
pub struct Control {}
impl Control {
pub fn play(&self){
println!("Play")
}
pub fn rew(&self){
printl... |
}
impl Clone for Control{
fn clone(&self)->Self{
return Control{}
}
}
impl Copy for Control {}
pub struct LabelFrame {
label_box:Box,
labels:Vec<Label>
}
impl LabelFrame{
pub fn new(labels:Vec<Label>)->LabelFrame{
let label_box=Box::new(Orientation::Vertical,0);
//Add labe... | {
println!("Fast Forward")
} | identifier_body |
click_object.rs | extern crate gtk;
use gtk::{ScrolledWindow,ContainerExt,Box,Orientation,Entry,EntryExt,Frame};
use std::vec::Vec;
pub trait Attachable{
fn attach<F:ContainerExt>(&self,parent: &F);
}
pub struct Control {}
impl Control {
pub fn play(&self){
println!("Play")
}
pub fn rew(&self){
printl... | } | random_line_split | |
click_object.rs | extern crate gtk;
use gtk::{ScrolledWindow,ContainerExt,Box,Orientation,Entry,EntryExt,Frame};
use std::vec::Vec;
pub trait Attachable{
fn attach<F:ContainerExt>(&self,parent: &F);
}
pub struct Control {}
impl Control {
pub fn play(&self){
println!("Play")
}
pub fn rew(&self){
printl... | (labels:Vec<Label>)->LabelFrame{
let label_box=Box::new(Orientation::Vertical,0);
//Add labels here
for label in &labels{
label.attach(&label_box)
}
LabelFrame{label_box: label_box,labels:labels}
}
}
impl Attachable for LabelFrame{
fn attach<F:ContainerExt>(&s... | new | identifier_name |
rewrite.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 ... | <'a> {
pub parse_session: &'a ParseSess,
pub codemap: &'a CodeMap,
pub config: &'a Config,
}
impl<'a> RewriteContext<'a> {
pub fn snippet(&self, span: Span) -> String {
self.codemap.span_to_snippet(span).unwrap()
}
}
| RewriteContext | identifier_name |
rewrite.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// A generic trait ... | // http://rust-lang.org/COPYRIGHT.
// | random_line_split |
windows.rs | use std::ffi::OsStr;
const INVALID_UTF8: &str = "unexpected invalid UTF-8 code point";
pub trait OsStrExt3 {
fn from_bytes(b: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8];
}
pub trait OsStrExt2 {
fn starts_with(&self, s: &[u8]) -> bool;
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
fn split... |
}
Some(&OsStr::from_bytes(&self.val[..start]))
}
}
| {
return Some(&OsStr::from_bytes(&self.val[self.pos + 1..start]));
} | conditional_block |
windows.rs | use std::ffi::OsStr;
const INVALID_UTF8: &str = "unexpected invalid UTF-8 code point";
pub trait OsStrExt3 {
fn from_bytes(b: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8];
}
pub trait OsStrExt2 {
fn starts_with(&self, s: &[u8]) -> bool;
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
fn split... | (b: &[u8]) -> &Self {
use std::mem;
unsafe { mem::transmute(b) }
}
fn as_bytes(&self) -> &[u8] { self.to_str().map(str::as_bytes).expect(INVALID_UTF8) }
}
impl OsStrExt2 for OsStr {
fn starts_with(&self, s: &[u8]) -> bool { self.as_bytes().starts_with(s) }
fn is_empty_(&self) -> bool ... | from_bytes | identifier_name |
windows.rs | use std::ffi::OsStr;
const INVALID_UTF8: &str = "unexpected invalid UTF-8 code point";
pub trait OsStrExt3 {
fn from_bytes(b: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8];
}
pub trait OsStrExt2 {
fn starts_with(&self, s: &[u8]) -> bool;
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
fn split... | fn split(&self, b: u8) -> OsSplit;
}
impl OsStrExt3 for OsStr {
// TODO JB: fix this allow
#[allow(clippy::transmute_ptr_to_ptr)]
fn from_bytes(b: &[u8]) -> &Self {
use std::mem;
unsafe { mem::transmute(b) }
}
fn as_bytes(&self) -> &[u8] { self.to_str().map(str::as_bytes).expec... | fn trim_left_matches(&self, b: u8) -> &OsStr;
fn len_(&self) -> usize;
fn contains_byte(&self, b: u8) -> bool;
fn is_empty_(&self) -> bool; | random_line_split |
windows.rs | use std::ffi::OsStr;
const INVALID_UTF8: &str = "unexpected invalid UTF-8 code point";
pub trait OsStrExt3 {
fn from_bytes(b: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8];
}
pub trait OsStrExt2 {
fn starts_with(&self, s: &[u8]) -> bool;
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
fn split... |
fn len_(&self) -> usize { self.as_bytes().len() }
fn split(&self, b: u8) -> OsSplit {
OsSplit { sep: b,
val: self.as_bytes(),
pos: 0, }
}
}
#[doc(hidden)]
#[derive(Clone, Debug)]
pub struct OsSplit<'a> {
sep: u8,
val: &'a [u8],
pos: usize,
}
impl<... | {
(&OsStr::from_bytes(&self.as_bytes()[..i]), &OsStr::from_bytes(&self.as_bytes()[i..]))
} | identifier_body |
strconv.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | let mut rbuf : [u8; 32] = unsafe { uninitialized() };
let mut myval : u32 = val;
let mut idx: isize = 0;
if myval == 0 {
buf[0] = '0' as u8;
return;
}
while myval > 0 {
let digit : u8 = (myval % base) as u8;
myval = myval / base;
rbuf[idx as usize] = digit;
idx += 1;
}
idx -... |
/// Convert an integer to a string.
pub fn itoa(val: u32, buf : &mut [u8], base: u32) { | random_line_split |
strconv.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... |
let mut ridx = 0;
while idx >= 0 {
let charcode : u8 = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][rbuf[idx as usize] as usize] as u8;
buf[ridx] = charcode;
idx -= 1;
ridx += 1;
}
}
| {
let mut rbuf : [u8; 32] = unsafe { uninitialized() };
let mut myval : u32 = val;
let mut idx: isize = 0;
if myval == 0 {
buf[0] = '0' as u8;
return;
}
while myval > 0 {
let digit : u8 = (myval % base) as u8;
myval = myval / base;
rbuf[idx as usize] = digit;
idx += 1;
}
idx... | identifier_body |
strconv.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... |
while myval > 0 {
let digit : u8 = (myval % base) as u8;
myval = myval / base;
rbuf[idx as usize] = digit;
idx += 1;
}
idx -= 1;
let mut ridx = 0;
while idx >= 0 {
let charcode : u8 = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][rbuf[idx as usize] as usize] as u... | {
buf[0] = '0' as u8;
return;
} | conditional_block |
strconv.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | (val: u32, buf : &mut [u8], base: u32) {
let mut rbuf : [u8; 32] = unsafe { uninitialized() };
let mut myval : u32 = val;
let mut idx: isize = 0;
if myval == 0 {
buf[0] = '0' as u8;
return;
}
while myval > 0 {
let digit : u8 = (myval % base) as u8;
myval = myval / base;
rbuf[idx as us... | itoa | identifier_name |
generic-struct-style-enum.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... | // 0b0101100101011001 = 22873
// 0b01011001 = 89
let case3: Regular<u16, i32, u64> = Case3 { a: 0, b: 6438275382588823897 };
let univariant = TheOnlyCase { a: -1 };
zzz();
}
fn zzz() {()}
| {
// In order to avoid endianess trouble all of the following test values consist of a single
// repeated byte. This way each interpretation of the union should look the same, no matter if
// this is a big or little endian machine.
// 0b0111110001111100011111000111110001111100011111000111110001111100 ... | identifier_body |
generic-struct-style-enum.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... |
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when
// datatype layout should be predictable as in this case.
enum Regular<T16, T32, T64> {
Case1 { a: T64, b: T16, c: T16, d... | #[feature(struct_variant)];
// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
// substituted with something of size `xx` bits and the same alignment as an integer type of the
// same size. | random_line_split |
generic-struct-style-enum.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {()}
| zzz | identifier_name |
variance-use-invariant-struct-1.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 ... | { } | identifier_body | |
variance-use-invariant-struct-1.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 ... | <'min,'max>(v: SomeStruct<&'min ()>)
-> SomeStruct<&'max ()>
where'max :'min
{
v //~ ERROR mismatched types
}
fn main() { }
| bar | identifier_name |
variance-use-invariant-struct-1.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() { } | random_line_split | |
navigator.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::utils::{WrapperCache, BindingObject, CacheableWrapper};
use dom::bindings::utils::{DOMString, E... |
pub fn GetAppVersion(&self, _rv: &mut ErrorResult) -> DOMString {
null_string
}
pub fn GetPlatform(&self, _rv: &mut ErrorResult) -> DOMString {
null_string
}
pub fn GetUserAgent(&self, _rv: &mut ErrorResult) -> DOMString {
null_string
}
pub fn GetLanguage(&self) ... | {
str(~"Mozilla") // Like Gecko/Webkit
} | identifier_body |
navigator.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::utils::{WrapperCache, BindingObject, CacheableWrapper};
use dom::bindings::utils::{DOMString, E... | impl Navigator {
pub fn new() -> @mut Navigator {
@mut Navigator {
wrapper: WrapperCache::new()
}
}
pub fn DoNotTrack(&self) -> DOMString {
str(~"unspecified")
}
pub fn Vendor(&self) -> DOMString {
str(~"") // Like Gecko
}
pub fn VendorSub(&self... | }
| random_line_split |
navigator.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::utils::{WrapperCache, BindingObject, CacheableWrapper};
use dom::bindings::utils::{DOMString, E... | () -> @mut Navigator {
@mut Navigator {
wrapper: WrapperCache::new()
}
}
pub fn DoNotTrack(&self) -> DOMString {
str(~"unspecified")
}
pub fn Vendor(&self) -> DOMString {
str(~"") // Like Gecko
}
pub fn VendorSub(&self) -> DOMString {
str(~"... | new | identifier_name |
packet_handler.rs | extern crate netfilter_queue as nfq;
use std::ptr::null;
use nfq::handle::{Handle, ProtocolFamily};
use nfq::queue::{CopyMode, Verdict, PacketHandler, QueueHandle};
use nfq::message::Message;
use nfq::error::Error;
fn main() {
let mut handle = Handle::new().ok().unwrap();
handle.bind(ProtocolFamily::INET).ok(... |
}
| {
match message {
Ok(m) => {
let _ = Verdict::set_verdict(hq, m.header.id(), Verdict::Accept, 0, null());
},
Err(_) => ()
}
0
} | identifier_body |
packet_handler.rs | extern crate netfilter_queue as nfq;
use std::ptr::null;
use nfq::handle::{Handle, ProtocolFamily};
use nfq::queue::{CopyMode, Verdict, PacketHandler, QueueHandle};
use nfq::message::Message;
use nfq::error::Error;
fn | () {
let mut handle = Handle::new().ok().unwrap();
handle.bind(ProtocolFamily::INET).ok().unwrap();
let mut queue = handle.queue(0, Decider).ok().unwrap();
let _ = queue.set_mode(CopyMode::Metadata).unwrap();
println!("Listening for packets...");
handle.start(4096);
println!("...finished.... | main | identifier_name |
packet_handler.rs | extern crate netfilter_queue as nfq;
use std::ptr::null;
use nfq::handle::{Handle, ProtocolFamily};
use nfq::queue::{CopyMode, Verdict, PacketHandler, QueueHandle};
use nfq::message::Message;
use nfq::error::Error;
fn main() {
let mut handle = Handle::new().ok().unwrap();
handle.bind(ProtocolFamily::INET).ok(... | handle.start(4096);
println!("...finished.");
}
struct Decider;
impl PacketHandler for Decider {
#[allow(non_snake_case)]
fn handle(&mut self, hq: QueueHandle, message: Result<&Message, &Error>) -> i32 {
match message {
Ok(m) => {
let _ = Verdict::set_verdict(hq, m... | random_line_split | |
posix.rs | use {TryRead, TryWrite};
use io::{self, PipeReader, PipeWriter};
use std::mem;
use std::os::unix::io::{Fd, AsRawFd};
/*
*
* ===== Awakener =====
*
*/
pub struct Awakener {
reader: PipeReader,
writer: PipeWriter,
}
impl Awakener {
pub fn new() -> io::Result<Awakener> {
let (rd, wr) = try!(io::... | // Consume data until all bytes are purged
match rd.read_slice(&mut buf) {
Ok(Some(i)) if i > 0 => {},
_ => return,
}
}
}
}
} | let rd: &mut PipeReader = mem::transmute(&self.reader);
| random_line_split |
posix.rs | use {TryRead, TryWrite};
use io::{self, PipeReader, PipeWriter};
use std::mem;
use std::os::unix::io::{Fd, AsRawFd};
/*
*
* ===== Awakener =====
*
*/
pub struct | {
reader: PipeReader,
writer: PipeWriter,
}
impl Awakener {
pub fn new() -> io::Result<Awakener> {
let (rd, wr) = try!(io::pipe());
Ok(Awakener {
reader: rd,
writer: wr
})
}
pub fn as_raw_fd(&self) -> Fd {
self.reader.as_raw_fd()
}
... | Awakener | identifier_name |
posix.rs | use {TryRead, TryWrite};
use io::{self, PipeReader, PipeWriter};
use std::mem;
use std::os::unix::io::{Fd, AsRawFd};
/*
*
* ===== Awakener =====
*
*/
pub struct Awakener {
reader: PipeReader,
writer: PipeWriter,
}
impl Awakener {
pub fn new() -> io::Result<Awakener> {
let (rd, wr) = try!(io::... |
}
| {
let mut buf = [0; 128];
loop {
// Also a bit hackish. It would be possible to split up the read /
// write sides of the awakener, but that would be a more
// significant refactor. A transmute here is safe.
unsafe {
let rd: &mut PipeReade... | identifier_body |
ws.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... | extractors::WsStats::new(stats),
).unwrap());
(res, port, authcodes)
}
/// Test a single request to running server
pub fn request(server: Server<ws::Server>, request: &str) -> http_client::Response {
http_client::request(server.server.addr(), request)
}
#[cfg(test)]
mod testing {
use std::time;
use hash::kecc... | random_line_split | |
ws.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... | () {
// given
let (server, port, authcodes) = serve();
let code = "initial";
let timestamp = time::UNIX_EPOCH.elapsed().unwrap().as_secs();
assert!(authcodes.is_empty());
// when
let response1 = http_client::request(server.addr(),
&format!("\
GET / HTTP/1.1\r\n\
Host: 127.0.0.1:{}\r\n\
Con... | should_allow_initial_connection_but_only_once | identifier_name |
ws.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... |
#[test]
fn should_block_if_authorization_is_incorrect() {
// given
let (server, port, _) = serve();
// when
let response = request(server,
&format!("\
GET / HTTP/1.1\r\n\
Host: 127.0.0.1:{}\r\n\
Connection: Upgrade\r\n\
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==\r\n\
Sec-WebSocket-P... | {
// given
let (server, port, _) = serve();
// when
let response = request(server,
&format!("\
GET / HTTP/1.1\r\n\
Host: 127.0.0.1:{}\r\n\
Connection: close\r\n\
\r\n\
{{}}
", port)
);
// then
assert_eq!(response.status, "HTTP/1.1 200 Ok".to_owned());
} | identifier_body |
unresolved_type_param.rs | // Provoke an unresolved type error (T).
// Error message should pinpoint the type parameter T as needing to be bound
// (rather than give a general error message)
// edition:2018
async fn bar<T>() -> () {}
async fn foo() {
bar().await;
//~^ ERROR type inside `async fn` body must be known in this context
... | () {}
| main | identifier_name |
unresolved_type_param.rs | // Provoke an unresolved type error (T).
// Error message should pinpoint the type parameter T as needing to be bound
// (rather than give a general error message)
// edition:2018 | //~^ ERROR type inside `async fn` body must be known in this context
//~| ERROR type inside `async fn` body must be known in this context
//~| ERROR type inside `async fn` body must be known in this context
//~| NOTE cannot infer type for type parameter `T`
//~| NOTE cannot infer type for type param... |
async fn bar<T>() -> () {}
async fn foo() {
bar().await; | random_line_split |
unresolved_type_param.rs | // Provoke an unresolved type error (T).
// Error message should pinpoint the type parameter T as needing to be bound
// (rather than give a general error message)
// edition:2018
async fn bar<T>() -> () {}
async fn foo() |
fn main() {}
| {
bar().await;
//~^ ERROR type inside `async fn` body must be known in this context
//~| ERROR type inside `async fn` body must be known in this context
//~| ERROR type inside `async fn` body must be known in this context
//~| NOTE cannot infer type for type parameter `T`
//~| NOTE cannot infer ... | identifier_body |
to_str.rs | use ::ffi;
use ::libc::c_char;
use std::ffi::CStr;
// To-string converters
// See http://www.libnfc.org/api/group__string-converter.html | pub fn modulation_type(pnd: ffi::nfc_modulation_type) -> &'static str {
unsafe {
let modulation_type = CStr::from_ptr(ffi::str_nfc_modulation_type(pnd)).to_str().unwrap();
modulation_type
}
}
/// Converts nfc_baud_rate value to string
pub fn baud_rate(baud_rate: ffi::nfc_baud_rate) -> &'static... |
/// Converts nfc_modulation_type value to string | random_line_split |
to_str.rs | use ::ffi;
use ::libc::c_char;
use std::ffi::CStr;
// To-string converters
// See http://www.libnfc.org/api/group__string-converter.html
/// Converts nfc_modulation_type value to string
pub fn modulation_type(pnd: ffi::nfc_modulation_type) -> &'static str {
unsafe {
let modulation_type = CStr::from_ptr(f... |
/// Returns the number of characters printed
pub fn target(buf: *mut *mut c_char, pnt: *mut ffi::nfc_target, verbose: u8) -> i32 {
unsafe { ffi::str_nfc_target(buf, pnt, verbose) }
} | {
unsafe {
let baud_rate = CStr::from_ptr(ffi::str_nfc_baud_rate(baud_rate)).to_str().unwrap();
baud_rate
}
} | identifier_body |
to_str.rs | use ::ffi;
use ::libc::c_char;
use std::ffi::CStr;
// To-string converters
// See http://www.libnfc.org/api/group__string-converter.html
/// Converts nfc_modulation_type value to string
pub fn modulation_type(pnd: ffi::nfc_modulation_type) -> &'static str {
unsafe {
let modulation_type = CStr::from_ptr(f... | (baud_rate: ffi::nfc_baud_rate) -> &'static str {
unsafe {
let baud_rate = CStr::from_ptr(ffi::str_nfc_baud_rate(baud_rate)).to_str().unwrap();
baud_rate
}
}
/// Returns the number of characters printed
pub fn target(buf: *mut *mut c_char, pnt: *mut ffi::nfc_target, verbose: u8) -> i32 {
u... | baud_rate | identifier_name |
name.rs | use std;
/// Represents a name.
#[derive(Clone,Debug)]
pub enum Name
{
/// The value is unnamed.
Unnamed,
/// The value has a name.
Named(String),
}
impl Name
{
/// Create an unspecified name.
pub fn unnamed() -> Name {
Name::Unnamed
} |
Name::Named(name.into())
}
pub fn is_named(&self) -> bool {
match *self {
Name::Unnamed => false,
Name::Named(..) => true,
}
}
}
impl Into<String> for Name
{
fn into(self) -> String {
match self {
Name::Unnamed => unimplemented!(),
... |
pub fn named<S>(name: S) -> Name
where S: Into<String> { | random_line_split |
name.rs | use std;
/// Represents a name.
#[derive(Clone,Debug)]
pub enum Name
{
/// The value is unnamed.
Unnamed,
/// The value has a name.
Named(String),
}
impl Name
{
/// Create an unspecified name.
pub fn unnamed() -> Name {
Name::Unnamed
}
pub fn named<S>(name: S) -> Name
... | (&self, other: &Name) -> bool {
match (self,other) {
(&Name::Named(ref n1),
&Name::Named(ref n2)) => n1 == n2,
_ => false, // unnamed values are always unique
}
}
}
impl std::cmp::Eq for Name { }
| eq | identifier_name |
name.rs | use std;
/// Represents a name.
#[derive(Clone,Debug)]
pub enum Name
{
/// The value is unnamed.
Unnamed,
/// The value has a name.
Named(String),
}
impl Name
{
/// Create an unspecified name.
pub fn unnamed() -> Name {
Name::Unnamed
}
pub fn named<S>(name: S) -> Name
... |
}
impl std::cmp::Eq for Name { }
| {
match (self,other) {
(&Name::Named(ref n1),
&Name::Named(ref n2)) => n1 == n2,
_ => false, // unnamed values are always unique
}
} | identifier_body |
traits.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... | (&mut self) -> Result<u32, UtilError> {
let mut batch = self.backing().transaction();
let res = self.inject(&mut batch)?;
self.backing().write(batch).map(|_| res).map_err(Into::into)
}
}
| inject_batch | identifier_name |
traits.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... |
/// Get the latest era in the DB. None if there isn't yet any data in there.
fn latest_era(&self) -> Option<u64>;
/// Journal recent database operations as being associated with a given era and id.
// TODO: give the overlay to this function so journaldbs don't manage the overlays themeselves.
fn ... | {
None
} | identifier_body |
traits.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... |
let result = self.backing().write(batch).map(|_| ops).map_err(Into::into);
self.flush();
result
}
/// Inject all changes in a single batch.
#[cfg(test)]
fn inject_batch(&mut self) -> Result<u32, UtilError> {
let mut batch = self.backing().transaction();
let res... | {
ops += self.mark_canonical(&mut batch, end_era, &canon_id)?;
} | conditional_block |
traits.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... | let res = self.inject(&mut batch)?;
self.backing().write(batch).map(|_| res).map_err(Into::into)
}
} | #[cfg(test)]
fn inject_batch(&mut self) -> Result<u32, UtilError> {
let mut batch = self.backing().transaction(); | random_line_split |
workqueue.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/. */
//! A work queue for scheduling units of work across threads in a fork-join fashion.
//!
//! Data associated with ... |
/// Synchronously runs all the enqueued tasks and waits for them to complete.
pub fn run(&mut self) {
// Tell the workers to start.
let mut work_count = AtomicUsize::new(self.work_count);
for worker in self.workers.iter_mut() {
worker.chan.send(WorkerMsg::Start(worker.deque... | {
let deque = &mut self.workers[0].deque;
match *deque {
None => {
panic!("tried to push a block but we don't have the deque?!")
}
Some(ref mut deque) => deque.push(work_unit),
}
self.work_count += 1
} | identifier_body |
workqueue.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/. */
//! A work queue for scheduling units of work across threads in a fork-join fashion.
//!
//! Data associated with ... |
Some(ref mut deque) => deque.push(work_unit),
}
self.work_count += 1
}
/// Synchronously runs all the enqueued tasks and waits for them to complete.
pub fn run(&mut self) {
// Tell the workers to start.
let mut work_count = AtomicUsize::new(self.work_count);
... | {
panic!("tried to push a block but we don't have the deque?!")
} | conditional_block |
workqueue.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/. */
//! A work queue for scheduling units of work across threads in a fork-join fashion.
//!
//! Data associated with ... | <QueueData:'static, WorkData:'static> {
/// Tells the worker to start work.
Start(Worker<WorkUnit<QueueData, WorkData>>, *mut AtomicUsize, *const QueueData),
/// Tells the worker to stop. It can be restarted again with a `WorkerMsg::Start`.
Stop,
/// Tells the worker thread to terminate.
Exit,
}... | WorkerMsg | identifier_name |
workqueue.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/. */
//! A work queue for scheduling units of work across threads in a fork-join fashion.
//!
//! Data associated with ... |
/// Information that the supervisor thread keeps about the worker threads.
struct WorkerInfo<QueueData:'static, WorkData:'static> {
/// The communication channel to the workers.
chan: Sender<WorkerMsg<QueueData, WorkData>>,
/// The worker end of the deque, if we have it.
deque: Option<Worker<WorkUnit<Q... | ReturnDeque(usize, Worker<WorkUnit<QueueData, WorkData>>),
}
unsafe impl<QueueData: 'static, WorkData: 'static> Send for SupervisorMsg<QueueData, WorkData> {} | random_line_split |
ioport.rs | // Copyright Dan Schatzberg, 2015. This file is part of Genesis.
// Genesis is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
... | } | random_line_split | |
ioport.rs | // Copyright Dan Schatzberg, 2015. This file is part of Genesis.
// Genesis is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
... | <T>(port: u16, val: T) {
asm!("out $0, $1"
: // no output
: "{al}" (val), "{dx}" (port)
: // no clobber
: "volatile");
}
pub unsafe fn inb(port: u16) -> u8 {
let val: u8;
asm!("in $1, $0"
: "={al}" (val)
: "{dx}" (port)
... | out | identifier_name |
ioport.rs | // Copyright Dan Schatzberg, 2015. This file is part of Genesis.
// Genesis is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
... | {
let val: u8;
asm!("in $1, $0"
: "={al}" (val)
: "{dx}" (port)
: // no clobber
: "volatile");
val
} | identifier_body | |
vocabs.rs | extern crate rand;
use bahasa::bimap::Bimap;
pub struct Vocabs<'a> {
vocabs: Bimap<&'a str, &'a str>,
vocab_vector: Vec<&'a str>,
}
impl<'b> Vocabs<'b> {
pub fn new<'c> () -> Vocabs<'c> {
Vocabs { vocabs: Bimap::new(), vocab_vector: vec![] }
}
pub fn insert(&mut self, first: &'static st... | let index = (r * self.vocab_vector.len() as f64) as usize;
self.vocab_vector[index]
}
} | random_line_split | |
vocabs.rs | extern crate rand;
use bahasa::bimap::Bimap;
pub struct Vocabs<'a> {
vocabs: Bimap<&'a str, &'a str>,
vocab_vector: Vec<&'a str>,
}
impl<'b> Vocabs<'b> {
pub fn new<'c> () -> Vocabs<'c> |
pub fn insert(&mut self, first: &'static str, second: &'static str) {
self.vocabs.insert(first, second);
self.vocab_vector.push(first);
}
pub fn get<'a>(&'a self, string: &'a str) -> Option<&&str> {
self.vocabs.get(&string)
}
pub fn get_random(&self) -> &str {
let... | {
Vocabs { vocabs: Bimap::new(), vocab_vector: vec![] }
} | identifier_body |
vocabs.rs | extern crate rand;
use bahasa::bimap::Bimap;
pub struct Vocabs<'a> {
vocabs: Bimap<&'a str, &'a str>,
vocab_vector: Vec<&'a str>,
}
impl<'b> Vocabs<'b> {
pub fn new<'c> () -> Vocabs<'c> {
Vocabs { vocabs: Bimap::new(), vocab_vector: vec![] }
}
pub fn insert(&mut self, first: &'static st... | <'a>(&'a self, string: &'a str) -> Option<&&str> {
self.vocabs.get(&string)
}
pub fn get_random(&self) -> &str {
let r = rand::random::<f64>();
let index = (r * self.vocab_vector.len() as f64) as usize;
self.vocab_vector[index]
}
}
| get | identifier_name |
monitor.rs | //! Asynchronous server and topology discovery and monitoring using isMaster results.
use {Client, Result};
use Error::{self, ArgumentError, OperationError};
use bson::{self, Bson, oid};
use chrono::{DateTime, UTC};
use coll::options::FindOptions;
use command_type::CommandType;
use connstring::{self, Host};
use curso... | let ismaster_result = IsMasterResult::new(doc);
let mut server_description = self.server_description.write().unwrap();
match ismaster_result {
Ok(ismaster) => server_description.update(ismaster, round_trip_time),
Err(err) => {
server_description.set_err(er... | random_line_split | |
monitor.rs | //! Asynchronous server and topology discovery and monitoring using isMaster results.
use {Client, Result};
use Error::{self, ArgumentError, OperationError};
use bson::{self, Bson, oid};
use chrono::{DateTime, UTC};
use coll::options::FindOptions;
use command_type::CommandType;
use connstring::{self, Host};
use curso... |
// Updates the server description associated with this monitor using an isMaster server response.
fn update_server_description(&self, doc: bson::Document,
round_trip_time: i64) -> Result<ServerDescription> {
let ismaster_result = IsMasterResult::new(doc);
let ... | {
self.condvar.notify_one();
} | identifier_body |
monitor.rs | //! Asynchronous server and topology discovery and monitoring using isMaster results.
use {Client, Result};
use Error::{self, ArgumentError, OperationError};
use bson::{self, Bson, oid};
use chrono::{DateTime, UTC};
use coll::options::FindOptions;
use command_type::CommandType;
use connstring::{self, Host};
use curso... | (&self) {
match self.is_master() {
Ok((mut cursor, rtt)) => self.update_with_is_master_cursor(&mut cursor, rtt),
Err(err) => {
// Refresh all connections
self.server_pool.clear();
self.personal_pool.clear();
let stype = sel... | execute_update | identifier_name |
test.rs | i),
ignore: is_ignored(&*i),
should_panic: should_panic(&*i)
};
self.cx.testfns.push(test);
self.tests.push(i.ident);
// debug!("have {} test/bench functions",
// cx... | is_test_crate | identifier_name | |
test.rs | Generator<'a> {
cx: TestCtxt<'a>,
tests: Vec<ast::Ident>,
// submodule name, gensym'd identifier for re-exports
tested_submods: Vec<(ast::Ident, ast::Ident)>,
}
impl<'a> fold::Folder for TestHarnessGenerator<'a> {
fn fold_crate(&mut self, c: ast::Crate) -> ast::Crate {
let mut folded = fol... | ignore: is_ignored(&*i),
should_panic: should_panic(&*i)
};
self.cx.testfns.push(test);
self.tests.push(i.ident);
// debug!("have {} test/bench functions",
// cx.tes... | {
let ident = i.ident;
if ident.name != token::special_idents::invalid.name {
self.cx.path.push(ident);
}
debug!("current path: {}",
ast_util::path_name_i(&self.cx.path));
let i = if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) {
... | identifier_body |
test.rs | testfns: Vec<Test>,
reexport_test_harness_main: Option<InternedString>,
is_test_crate: bool,
config: ast::CrateConfig,
// top-level re-export submodule, filled out after folding is finished
toplevel_reexport: Option<ast::Ident>,
}
// Traverse the crate, collecting all the test functions, elidi... | sess: &'a ParseSess,
span_diagnostic: &'a diagnostic::SpanHandler,
path: Vec<ast::Ident>,
ext_cx: ExtCtxt<'a>, | random_line_split | |
issue-54462-mutable-noalias-correctness.rs | row * 1 + col * 3
}
fn main() {
let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0];
for i in 0..2 {
for j in i+1..3 {
if mat[linidx(j, 3)] > mat[linidx(i, 3)] {
for k in 0..4 {
let (x, rest) = mat.split_at_mu... | // run-pass
//
// compile-flags: -Ccodegen-units=1 -O
fn linidx(row: usize, col: usize) -> usize { | random_line_split | |
issue-54462-mutable-noalias-correctness.rs | // run-pass
//
// compile-flags: -Ccodegen-units=1 -O
fn linidx(row: usize, col: usize) -> usize {
row * 1 + col * 3
}
fn main() | {
let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0];
for i in 0..2 {
for j in i+1..3 {
if mat[linidx(j, 3)] > mat[linidx(i, 3)] {
for k in 0..4 {
let (x, rest) = mat.split_at_mut(linidx(i, k) + 1);
... | identifier_body | |
issue-54462-mutable-noalias-correctness.rs | // run-pass
//
// compile-flags: -Ccodegen-units=1 -O
fn | (row: usize, col: usize) -> usize {
row * 1 + col * 3
}
fn main() {
let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0];
for i in 0..2 {
for j in i+1..3 {
if mat[linidx(j, 3)] > mat[linidx(i, 3)] {
for k in 0..4 {
... | linidx | identifier_name |
issue-54462-mutable-noalias-correctness.rs | // run-pass
//
// compile-flags: -Ccodegen-units=1 -O
fn linidx(row: usize, col: usize) -> usize {
row * 1 + col * 3
}
fn main() {
let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0];
for i in 0..2 {
for j in i+1..3 {
if mat[linidx(j, 3)] > mat[linidx(i, 3... |
}
}
assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat);
}
| {
for k in 0..4 {
let (x, rest) = mat.split_at_mut(linidx(i, k) + 1);
let a = x.last_mut().unwrap();
let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap();
::std::mem::swap(a, b);... | conditional_block |
udpsink.rs | // Copyright (C) 2019 Mathieu Duponchelle <mathieu@centricular.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any late... |
thread::sleep(time::Duration::from_millis(50));
let socket = net::UdpSocket::bind("127.0.0.1:5005").unwrap();
let mut buf = [0; 5];
let (amt, _) = socket.recv_from(&mut buf).unwrap();
assert!(amt == 4);
assert!(buf == [42, 43, 44, 45, 0]);
});
let buf = gst::B... | use std::time; | random_line_split |
udpsink.rs | // Copyright (C) 2019 Mathieu Duponchelle <mathieu@centricular.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any late... | () {
init();
let h = gst_check::Harness::new("ts-udpsink");
let udpsink = h.get_element().unwrap();
let clients = udpsink
.get_property("clients")
.unwrap()
.get::<String>()
.unwrap()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004");
udpsink.emit("add", &[&... | test_client_management | identifier_name |
udpsink.rs | // Copyright (C) 2019 Mathieu Duponchelle <mathieu@centricular.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any late... | .unwrap()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004,192.168.1.1:57");
/* Adding a client twice is not supported */
udpsink.emit("add", &[&"192.168.1.1", &57i32]).unwrap();
let clients = udpsink
.get_property("clients")
.unwrap()
.get::<String>()
.unwrap()
... | {
init();
let h = gst_check::Harness::new("ts-udpsink");
let udpsink = h.get_element().unwrap();
let clients = udpsink
.get_property("clients")
.unwrap()
.get::<String>()
.unwrap()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004");
udpsink.emit("add", &... | identifier_body |
mod.rs | //! An asynchronous stub resolver.
//!
//! A resolver is the component in the DNS that answers queries. A stub
//! resolver does so by simply relaying queries to a different resolver
//! chosen from a predefined set. This is how pretty much all user
//! applications use DNS.
//!
//! This module implements a modern, asy... | //!
//! Furthermore, we now can use a relative host name. It will be turned into
//! an absolute name according to the rules set down by the configuration we
//! used when creating the resolver.
//!
//! As an aside, the lookup functions are named after the thing they look
//! up not their result following the example o... | random_line_split | |
outfile.rs | use std::fs::File;
use std::path::Path;
use std::io::Write;
pub struct | {
filename: String,
file: Option<File>,
}
impl FileIo {
pub fn new(name: String) -> FileIo {
FileIo {
filename: name.clone(),
file: match File::create(&Path::new(&*name)) {
Ok(f) => Some(f),
Err(e) => if name == "" {
None
... | FileIo | identifier_name |
outfile.rs | use std::fs::File;
use std::path::Path;
use std::io::Write;
pub struct FileIo {
filename: String,
file: Option<File>,
}
impl FileIo {
pub fn new(name: String) -> FileIo {
FileIo {
filename: name.clone(),
file: match File::create(&Path::new(&*name)) {
Ok(f) =... |
},
}
}
pub fn write(&mut self, message: &str) -> bool {
if self.filename == "" {
println!("{}", message);
true
} else {
match self.file.as_mut().unwrap().write(message.as_bytes()) {
Ok(_) => true,
Err(e) =>... | {
panic!("Could not open file: {}", e);
} | conditional_block |
outfile.rs | use std::fs::File;
use std::path::Path;
use std::io::Write;
pub struct FileIo {
filename: String, |
impl FileIo {
pub fn new(name: String) -> FileIo {
FileIo {
filename: name.clone(),
file: match File::create(&Path::new(&*name)) {
Ok(f) => Some(f),
Err(e) => if name == "" {
None
} else {
panic!... | file: Option<File>,
} | random_line_split |
outfile.rs | use std::fs::File;
use std::path::Path;
use std::io::Write;
pub struct FileIo {
filename: String,
file: Option<File>,
}
impl FileIo {
pub fn new(name: String) -> FileIo |
pub fn write(&mut self, message: &str) -> bool {
if self.filename == "" {
println!("{}", message);
true
} else {
match self.file.as_mut().unwrap().write(message.as_bytes()) {
Ok(_) => true,
Err(e) => {
println!... | {
FileIo {
filename: name.clone(),
file: match File::create(&Path::new(&*name)) {
Ok(f) => Some(f),
Err(e) => if name == "" {
None
} else {
panic!("Could not open file: {}", e);
}
... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.