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 |
|---|---|---|---|---|
borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let mut _a = 3;
let b = &mut _a;
{
let c = &*b;
_a = 4; //[ast]~ ERROR cannot assign to `_a`
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed
drop(c);
}
drop(b);
} | identifier_body | |
borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let mut _a = 3;
let b = &mut _a;
{
let c = &*b;
_a = 4; //[ast]~ ERROR cannot assign to `_a`
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed
drop(c);
}
drop(b);
}
| main | identifier_name |
borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | _a = 4; //[ast]~ ERROR cannot assign to `_a`
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed
drop(c);
}
drop(b);
} | let c = &*b; | random_line_split |
uhci.rs | use alloc::boxed::Box;
use collections::vec::Vec;
use core::intrinsics::volatile_load;
use core::mem;
use scheduler::context::context_switch;
use common::debug;
use common::memory::Memory;
use drivers::pci::config::PciConfig;
use drivers::pio::*;
use schemes::KScheme;
use super::{Hci, Packet, Pipe, Setup};
pub ... | {
pub base: usize,
pub irq: u8,
pub frame_list: Memory<u32>,
}
impl KScheme for Uhci {
fn on_irq(&mut self, irq: u8) {
if irq == self.irq {
// d("UHCI IRQ\n");
}
}
fn on_poll(&mut self) {
}
}
#[repr(packed)]
#[derive(Copy, Clone, Debug, Default)]
struct Td {
... | Uhci | identifier_name |
uhci.rs | use alloc::boxed::Box;
use collections::vec::Vec;
use core::intrinsics::volatile_load;
use core::mem;
use scheduler::context::context_switch;
use common::debug;
use common::memory::Memory;
use drivers::pci::config::PciConfig;
use drivers::pio::*;
use schemes::KScheme;
use super::{Hci, Packet, Pipe, Setup};
pub ... |
debug::d(" FRNUM ");
debug::dh(inw(frnum) as usize);
outw(frnum, 0);
debug::d(" to ");
debug::dh(inw(frnum) as usize);
debug::d(" FLBASEADD ");
debug::dh(ind(flbaseadd) as usize);
for i in 0..1024 {
self.frame_list.write(i, 1);
}
... | debug::d(" INTR ");
debug::dh(inw(usbintr) as usize); | random_line_split |
uhci.rs | use alloc::boxed::Box;
use collections::vec::Vec;
use core::intrinsics::volatile_load;
use core::mem;
use scheduler::context::context_switch;
use common::debug;
use common::memory::Memory;
use drivers::pci::config::PciConfig;
use drivers::pio::*;
use schemes::KScheme;
use super::{Hci, Packet, Pipe, Setup};
pub ... |
}
#[repr(packed)]
#[derive(Copy, Clone, Debug, Default)]
struct Td {
link_ptr: u32,
ctrl_sts: u32,
token: u32,
buffer: u32,
}
#[repr(packed)]
#[derive(Copy, Clone, Debug, Default)]
struct Qh {
head_ptr: u32,
element_ptr: u32,
}
impl Uhci {
pub unsafe fn new(mut pci: PciConfig) -> Box<Sel... | {
} | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... |
impl DomParallelInfo {
pub fn new() -> DomParallelInfo {
DomParallelInfo {
children_to_process: AtomicIsize::new(0),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum LayoutNodeType {
Element(LayoutElementType),
Text,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq... | random_line_split | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
Element(LayoutElementType),
Text,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum LayoutElementType {
Element,
HTMLCanvasElement,
HTMLIFrameElement,
HTMLImageElement,
HTMLInputElement,
HTMLObjectElement,
HTMLTableCellElement,
HTMLTableColElement,
HTMLTableElement,... | LayoutNodeType | identifier_name |
htmlhrelement.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::HTMLHRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHRElemen... | (localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLHRElement {
HTMLHRElement {
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLHRElement, localName, prefix, document)
}
}
#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
... | new_inherited | identifier_name |
htmlhrelement.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::HTMLHRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHRElemen... |
#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLHRElement> {
let element = HTMLHRElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLHRElementB... | {
HTMLHRElement {
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLHRElement, localName, prefix, document)
}
} | identifier_body |
htmlhrelement.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::HTMLHRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHRElemen... | document: &Document) -> Root<HTMLHRElement> {
let element = HTMLHRElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLHRElementBinding::Wrap)
}
} | random_line_split | |
any.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-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Traits for dynamic typing of any `'static` type (through runtime reflection)
//!
//!... | random_line_split | |
any.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... | <T:'static>(self) -> bool {
// Get TypeId of the type this function is instantiated with
let t = TypeId::of::<T>();
// Get TypeId of the type in the trait object
let boxed = self.get_type_id();
// Compare both TypeIds on equality
t == boxed
}
#[inline]
fn a... | is | identifier_name |
any.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... |
}
/// Extension methods for a mutable referenced `Any` trait object
pub trait AnyMutRefExt<'a> {
/// Returns some mutable reference to the boxed value if it is of type `T`, or
/// `None` if it isn't.
fn as_mut<T:'static>(self) -> Option<&'a mut T>;
}
impl<'a> AnyMutRefExt<'a> for &'a mut Any {
#[inli... | {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let to: TraitObject = transmute_copy(&self);
// Extract the data pointer
Some(transmute(to.data))
}
} else {
None
... | identifier_body |
any.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... |
}
}
/// Extension methods for a mutable referenced `Any` trait object
pub trait AnyMutRefExt<'a> {
/// Returns some mutable reference to the boxed value if it is of type `T`, or
/// `None` if it isn't.
fn as_mut<T:'static>(self) -> Option<&'a mut T>;
}
impl<'a> AnyMutRefExt<'a> for &'a mut Any {
... | {
None
} | conditional_block |
reorder.rs | //! Reorder items.
//!
//! `mod`, `extern crate` and `use` declarations are reordered in alphabetical
//! order. Trait items are reordered in pre-determined order (associated types
//! and constants comes before methods).
// FIXME(#2455): Reorder trait items.
use std::cmp::{Ord, Ordering};
use rustc_ast::ast;
use ru... | let result = a_orig_name.cmp(&b_orig_name);
if result!= Ordering::Equal {
return result;
}
// `extern crate foo as bar;`
// ^^^ Comparing this.
match (a_name, b_name) {
(Some(..), None) => Order... | // `extern crate foo as bar;`
// ^^^ Comparing this.
let a_orig_name = a_name.map_or_else(|| a.ident.as_str(), rustc_span::Symbol::as_str);
let b_orig_name = b_name.map_or_else(|| b.ident.as_str(), rustc_span::Symbol::as_str); | random_line_split |
reorder.rs | //! Reorder items.
//!
//! `mod`, `extern crate` and `use` declarations are reordered in alphabetical
//! order. Trait items are reordered in pre-determined order (associated types
//! and constants comes before methods).
// FIXME(#2455): Reorder trait items.
use std::cmp::{Ord, Ordering};
use rustc_ast::ast;
use ru... | (&mut self, mut items: &[&ast::Item]) {
while!items.is_empty() {
// If the next item is a `use`, `extern crate` or `mod`, then extract it and any
// subsequent items that have the same item kind to be reordered within
// `walk_reorderable_items`. Otherwise, just format the ne... | visit_items_with_reordering | identifier_name |
reorder.rs | //! Reorder items.
//!
//! `mod`, `extern crate` and `use` declarations are reordered in alphabetical
//! order. Trait items are reordered in pre-determined order (associated types
//! and constants comes before methods).
// FIXME(#2455): Reorder trait items.
use std::cmp::{Ord, Ordering};
use rustc_ast::ast;
use ru... |
/// Divides imports into three groups, corresponding to standard, external
/// and local imports. Sorts each subgroup.
fn group_imports(uts: Vec<UseTree>) -> Vec<Vec<UseTree>> {
let mut std_imports = Vec::new();
let mut external_imports = Vec::new();
let mut local_imports = Vec::new();
for ut in uts.... | {
crate::attr::contains_name(&item.attrs, sym::macro_use)
} | identifier_body |
control-flow.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T>(mut amt: usize, mut t: T) -> T::Return
where T: Generator<Yield = ()>
{
loop {
match unsafe { t.resume() } {
GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(),
GeneratorState::Complete(ret) => {
assert_eq!(amt, 0);
return ret
... | finish | identifier_name |
control-flow.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | } | yield;
panic!()
}
yield
}); | random_line_split |
control-flow.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
yield
});
}
| {
yield;
panic!()
} | conditional_block |
control-flow.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {
finish(1, || yield);
finish(8, || {
for _ in 0..8 {
yield;
}
});
finish(1, || {
if true {
yield;
} else {
}
});
finish(1, || {
if false {
} else {
yield;
}
});
finish(2, || {... | {
loop {
match unsafe { t.resume() } {
GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(),
GeneratorState::Complete(ret) => {
assert_eq!(amt, 0);
return ret
}
}
}
} | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... |
try!(list[0].to_css(dest));
for item in list.iter().skip(1) {
try!(write!(dest, ", "));
try!(item.to_css(dest));
}
Ok(())
}
| {
return Ok(());
} | conditional_block |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... | {
if list.is_empty() {
return Ok(());
}
try!(list[0].to_css(dest));
for item in list.iter().skip(1) {
try!(write!(dest, ", "));
try!(item.to_css(dest));
}
Ok(())
} | identifier_body | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... | <W, T>(dest: &mut W,
list: &[T])
-> fmt::Result
where W: fmt::Write,
T: ToCss,
{
if list.is_empty() {
return Ok(());
}
try!(list[0].to_css(dest));
for item in list.iter().skip(1) {
try... | serialize_comma_separated_list | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... | pub mod custom_properties;
pub mod data;
pub mod dom;
pub mod element_state;
#[cfg(feature = "servo")] mod encoding_support;
pub mod error_reporting;
pub mod font_face;
pub mod font_metrics;
#[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko;
#[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko_bind... | pub mod context; | random_line_split |
deque.rs |
use giftr::refs::*;
//use giftr::refs::functional::Ref as Ref;
use giftr::refs::imperative::Ref as Ref;
use std::iter::Iterator;
use std::mem::swap;
use list::List;
#[derive(Clone, Debug)]
pub struct Deque<T: Clone> {
front : Ref<List<T>>,
back : Ref<List<T>>,
}
impl <T: Clone> Deque<T> {
pub fn new() ... | () {
let mut d = Deque::new();
d.push_front(2);
d.push_front(1);
d.push_back(3);
assert_eq!(Some(1), d.pop_front());
assert_eq!(Some(2), d.pop_front());
assert_eq!(Some(3), d.pop_front());
assert_eq!(None, d.pop_front());
}
#[test]
fn deque_pop_back() {
let mut d = Deque::new();
... | deque_pop_front | identifier_name |
deque.rs | use giftr::refs::*;
//use giftr::refs::functional::Ref as Ref;
use giftr::refs::imperative::Ref as Ref;
use std::iter::Iterator;
use std::mem::swap;
use list::List;
#[derive(Clone, Debug)]
pub struct Deque<T: Clone> {
front : Ref<List<T>>,
back : Ref<List<T>>,
}
impl <T: Clone> Deque<T> {
pub fn new() -... | }
pub fn rev_iter(&self) -> Iter<T> {
let mut cln = self.clone();
cln.reverse();
cln.to_iter()
}
}
pub struct Iter<T: Clone> {
deque : Ref<Deque<T>>,
}
impl <T: Clone> Iterator for Iter<T> {
type Item = T;
fn next(&mut self) -> Option<T> {
self.deque.pop_front(... |
pub fn iter(&self) -> Iter<T> {
self.clone().to_iter() | random_line_split |
deque.rs |
use giftr::refs::*;
//use giftr::refs::functional::Ref as Ref;
use giftr::refs::imperative::Ref as Ref;
use std::iter::Iterator;
use std::mem::swap;
use list::List;
#[derive(Clone, Debug)]
pub struct Deque<T: Clone> {
front : Ref<List<T>>,
back : Ref<List<T>>,
}
impl <T: Clone> Deque<T> {
pub fn new() ... |
}
pub fn pop_back(&mut self) -> Option<T> {
let back = self.back.pop_front();
if back.is_some() {
back
} else {
// FIXME we should reshuffle here, right?
self.front.pop_back()
}
}
pub fn reverse(&mut self) {
swap(&mut self.fr... | {
// FIXME we should reshuffle here, right?
self.back.pop_back()
} | conditional_block |
mod.rs | /*
Copyright (c) 2016 Saurav Sachidanand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribu... | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
//! Some useful constants
pub mod vmcs;
pub mod vmx_cap;
pub mod vmx_exit;
pub... | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | random_line_split |
issue-39559.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn main() {} | //~^ ERROR no function or associated item named `dim` found for type `D` in the current scope
_dummy: D,
}
| random_line_split |
issue-39559.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T, D: Dim> {
entries: [T; D::dim()],
//~^ ERROR no function or associated item named `dim` found for type `D` in the current scope
_dummy: D,
}
fn main() {}
| Vector | identifier_name |
ifd.rs | //! Function for reading TIFF tags
use std::io::{self, Read, Seek};
use std::collections::{HashMap};
use super::stream::{ByteOrder, SmartReader, EndianReader};
use self::Value::{Unsigned, List};
macro_rules! tags {
{$(
$tag:ident
$val:expr;
)*} => {
/// TIFF tag
#[derive(Clo... | <R: Read + Seek>(&self, decoder: &mut super::TIFFDecoder<R>)
-> ::image::ImageResult<Value> {
let bo = decoder.byte_order();
match (self.type_, self.count) {
// TODO check if this could give wrong results
// at a different endianess of file/computer.
(Type::BYTE, ... | val | identifier_name |
ifd.rs | //! Function for reading TIFF tags
use std::io::{self, Read, Seek};
use std::collections::{HashMap};
use super::stream::{ByteOrder, SmartReader, EndianReader};
use self::Value::{Unsigned, List};
macro_rules! tags {
{$(
$tag:ident
$val:expr;
)*} => {
/// TIFF tag
#[derive(Clo... |
pub fn val<R: Read + Seek>(&self, decoder: &mut super::TIFFDecoder<R>)
-> ::image::ImageResult<Value> {
let bo = decoder.byte_order();
match (self.type_, self.count) {
// TODO check if this could give wrong results
// at a different endianess of file/computer.
... | {
SmartReader::wrap(
io::Cursor::new(self.offset.to_vec()),
byte_order
)
} | identifier_body |
ifd.rs | //! Function for reading TIFF tags
use std::io::{self, Read, Seek};
use std::collections::{HashMap};
use super::stream::{ByteOrder, SmartReader, EndianReader};
use self::Value::{Unsigned, List};
macro_rules! tags {
{$(
$tag:ident
$val:expr;
)*} => {
/// TIFF tag
#[derive(Clo... | }
impl Tag {
pub fn from_u16(n: u16) -> Tag {
$(if n == $val { Tag::$tag } else)* {
Tag::Unknown(n)
}
}
}
}
}
// Note: These tags appear in the order they are mentioned in the TIFF reference
tags!{
// Baseline t... | pub enum Tag {
$($tag,)*
Unknown(u16) | random_line_split |
blake2s.rs | pub const BLOCK_BYTES : usize = 64;
pub const OUT_BYTES : usize = 32;
pub const KEY_BYTES : usize = 32;
static IV : [u32; 8] = [
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
];
static SIGMA : [[u8; 16]; 10] = [
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9... | ;
}
fn compress(&mut self) {
let mut m = [0u32; 16];
let mut v = [0u32; 16];
let block = self.buf.as_ref();
assert!(block.len() >= BLOCK_BYTES);
for i in 0..m.len() {
m[i] = load32(&block[i*4..]);
}
for i in 0..8 {
v[i] = self.h... | {0} | conditional_block |
blake2s.rs | pub const BLOCK_BYTES : usize = 64;
pub const OUT_BYTES : usize = 32;
pub const KEY_BYTES : usize = 32;
static IV : [u32; 8] = [
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
];
static SIGMA : [[u8; 16]; 10] = [
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9... |
#[bench]
fn bench_blake2s_64k(b: &mut Bencher) {
bench_chunk_size(b, 1 << 16);
}
}
| {
bench_chunk_size(b, 1 << 10);
} | identifier_body |
blake2s.rs | pub const BLOCK_BYTES : usize = 64;
pub const OUT_BYTES : usize = 32;
pub const KEY_BYTES : usize = 32;
static IV : [u32; 8] = [
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
];
static SIGMA : [[u8; 16]; 10] = [
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9... | (&mut self, inc: u32) {
self.t[0] += inc;
self.t[1] += if self.t[0] < inc {1} else {0};
}
fn compress(&mut self) {
let mut m = [0u32; 16];
let mut v = [0u32; 16];
let block = self.buf.as_ref();
assert!(block.len() >= BLOCK_BYTES);
for i in 0..m.len() {
... | increment_counter | identifier_name |
blake2s.rs | pub const BLOCK_BYTES : usize = 64;
pub const OUT_BYTES : usize = 32;
pub const KEY_BYTES : usize = 32;
static IV : [u32; 8] = [
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
];
static SIGMA : [[u8; 16]; 10] = [
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9... | $a = $a.wrapping_add($b).wrapping_add(m[SIGMA[$r][2*$i+0] as usize]);
$d = ($d ^ $a).rotate_right(16);
$c = $c.wrapping_add($d);
$b = ($b ^ $c).rotate_right(12);
$a = $a.wrapping_add($b).wrapping_add(m[SIGMA[$r][2*$i+1] as usize]);
... | v[14] = self.f[0] ^ IV[6];
v[15] = self.f[1] ^ IV[7];
macro_rules! g(
($r: expr, $i: expr, $a: expr, $b: expr, $c: expr, $d: expr) => ({ | random_line_split |
lib.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#![crate_name = "lrs_hashmap"]
#![crate_type = "lib"]
#![feature(custom_derive)]
#![no_std]
extern crate lrs_base as... |
pub use table::{Entry, VacantEntry, OccupiedEntry};
mod std { pub use fmt::std::*; }
mod bucket;
mod table;
pub type CompactMap<Key, Value, Hasher = XxHash32, Seed = (), Allocator = Heap>
where Allocator: alloc::MemPool,
Hasher: hash::Hasher,
Seed: Into<Hasher::Seed>+To,
Key: Eq + ... | use bucket::loose::{LooseBucket};
use table::{GenericMap}; | random_line_split |
performanceentry.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::PerformanceEntryBinding;
use dom::bindings::codegen::Bindings::PerformanceEn... | &self.name
}
pub fn start_time(&self) -> f64 {
self.start_time
}
}
impl PerformanceEntryMethods for PerformanceEntry {
// https://w3c.github.io/performance-timeline/#dom-performanceentry-name
fn Name(&self) -> DOMString {
DOMString::from(self.name.clone())
}
// htt... |
pub fn name(&self) -> &DOMString { | random_line_split |
performanceentry.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::PerformanceEntryBinding;
use dom::bindings::codegen::Bindings::PerformanceEn... | (&self) -> &DOMString {
&self.name
}
pub fn start_time(&self) -> f64 {
self.start_time
}
}
impl PerformanceEntryMethods for PerformanceEntry {
// https://w3c.github.io/performance-timeline/#dom-performanceentry-name
fn Name(&self) -> DOMString {
DOMString::from(self.name.cl... | name | identifier_name |
iter.rs | //! Utilities for iteration with duration objects.
use duration::FloatDuration;
use std::iter;
/// An iterator over an evenly spaced lattice of `FloatDuration`s.
///
/// This type is returned by `subdivide` and friends, and it not meant to be
/// instantiated directly.
#[derive(Debug, Clone)]
pub struct Subdivide {
... | impl Subdivide {
fn new(start: FloatDuration, end: FloatDuration, steps: usize) -> Subdivide {
assert!(steps >= 2, "subdivide requires at least two steps");
let step_size = (end - start) / (steps - 1) as f64;
Subdivide {
start: start,
step_size: step_size,
... | step_size: FloatDuration,
len: usize,
index: usize,
}
| random_line_split |
iter.rs | //! Utilities for iteration with duration objects.
use duration::FloatDuration;
use std::iter;
/// An iterator over an evenly spaced lattice of `FloatDuration`s.
///
/// This type is returned by `subdivide` and friends, and it not meant to be
/// instantiated directly.
#[derive(Debug, Clone)]
pub struct Subdivide {
... |
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_subdivide() {
let s = subdivide(FloatDuration::zero(), FloatDuration::minutes(1.0), 3);
let s_rev = s.clone().rev();
assert_eq!(s.collect::<Vec<_>>(),
vec![FloatDuration::zero(),
Floa... | {
let sub = subdivide(begin, end, steps);
let step_size = sub.step_size();
sub.zip(iter::repeat(step_size))
} | identifier_body |
iter.rs | //! Utilities for iteration with duration objects.
use duration::FloatDuration;
use std::iter;
/// An iterator over an evenly spaced lattice of `FloatDuration`s.
///
/// This type is returned by `subdivide` and friends, and it not meant to be
/// instantiated directly.
#[derive(Debug, Clone)]
pub struct Subdivide {
... | else {
self.len -= 1;
let index = self.len;
Some(self.start + self.step_size * (index as f64))
}
}
}
impl ExactSizeIterator for Subdivide {}
/// Subdivide the distance between two duration into `steps` evenly spaced points.
///
/// `subdivide` returns an iterator that ... | {
None
} | conditional_block |
iter.rs | //! Utilities for iteration with duration objects.
use duration::FloatDuration;
use std::iter;
/// An iterator over an evenly spaced lattice of `FloatDuration`s.
///
/// This type is returned by `subdivide` and friends, and it not meant to be
/// instantiated directly.
#[derive(Debug, Clone)]
pub struct | {
start: FloatDuration,
step_size: FloatDuration,
len: usize,
index: usize,
}
impl Subdivide {
fn new(start: FloatDuration, end: FloatDuration, steps: usize) -> Subdivide {
assert!(steps >= 2, "subdivide requires at least two steps");
let step_size = (end - start) / (steps - 1) as ... | Subdivide | identifier_name |
resource-cycle2.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
a: int,
b: int,
c: *int
}
struct r {
v: U,
}
impl Drop for r {
fn drop(&mut self) {
unsafe {
let _v2: ~int = cast::transmute(self.v.c);
}
}
}
fn r(v: U) -> r {
r {
v: v
}
}
struct t(Node);
struct Node {
next: Option<@mut t>,
r: r
}
pub f... | U | identifier_name |
resource-cycle2.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 ... | r: r
}
pub fn main() {
unsafe {
let i1 = ~0xA;
let i1p = cast::transmute_copy(&i1);
cast::forget(i1);
let i2 = ~0xA;
let i2p = cast::transmute_copy(&i2);
cast::forget(i2);
let u1 = U {a: 0xB, b: 0xC, c: i1p};
let u2 = U {a: 0xB, b: 0xC, c: i2p};
... | random_line_split | |
resource-cycle2.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 ... | x1.next = Some(x2);
x2.next = Some(x1);
}
}
| {
unsafe {
let i1 = ~0xA;
let i1p = cast::transmute_copy(&i1);
cast::forget(i1);
let i2 = ~0xA;
let i2p = cast::transmute_copy(&i2);
cast::forget(i2);
let u1 = U {a: 0xB, b: 0xC, c: i1p};
let u2 = U {a: 0xB, b: 0xC, c: i2p};
let x1 = @mut t(N... | identifier_body |
event.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::EventBinding;
use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods};
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JSRef, Temporary};
use dom::bindings::utils::{Reflector, reflect_dom_ob... | use dom::bindings::cell::DOMRefCell; | random_line_split |
event.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codege... |
#[inline]
pub fn stop_propagation(&self) -> bool {
self.stop_propagation.get()
}
#[inline]
pub fn stop_immediate(&self) -> bool {
self.stop_immediate.get()
}
#[inline]
pub fn bubbles(&self) -> bool {
self.bubbles.get()
}
#[inline]
pub fn dispatchi... | {
self.phase.set(val)
} | identifier_body |
event.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codege... | (self,
type_: DOMString,
bubbles: bool,
cancelable: bool) {
if self.dispatching.get() {
return;
}
self.initialized.set(true);
self.stop_propagation.set(false);
self.stop_immediate.set(false);
self.canceled.se... | InitEvent | identifier_name |
event.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codege... | ;
let cancelable = if init.cancelable { EventCancelable::Cancelable } else { EventCancelable::NotCancelable };
Ok(Event::new(global, type_, bubbles, cancelable))
}
#[inline]
pub fn type_id<'a>(&'a self) -> &'a EventTypeId {
&self.type_id
}
#[inline]
pub fn clear_current... | { EventBubbles::DoesNotBubble } | conditional_block |
blockchain.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... |
out.write_fmt(format_args!("\n\"0x{}\": {{\"balance\": \"{:x}\", \"nonce\": \"{:x}\"", account.hex(), balance, client.nonce(&account, at).unwrap_or_else(U256::zero))).expect("Write error");
let code = client.code(&account, at).unwrap_or(None).unwrap_or_else(Vec::new);
if!code.is_empty() {
out.write_fmt(fo... | {
out.write(b",").expect("Write error");
} | conditional_block |
blockchain.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... | // select pruning algorithm
let algorithm = pruning.to_algorithm(&user_defaults);
// check if tracing is on
let tracing = tracing_switch_to_bool(tracing, &user_defaults)?;
// check if fatdb is on
let fat_db = fatdb_switch_to_bool(fat_db, &user_defaults, algorithm)?;
if!fat_db && require_fat_db {
return Err("... | fdlimit::raise_fd_limit();
| random_line_split |
blockchain.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... | {
Hex,
Binary,
}
impl Default for DataFormat {
fn default() -> Self {
DataFormat::Binary
}
}
impl FromStr for DataFormat {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"binary" | "bin" => Ok(DataFormat::Binary),
"hex" => Ok(DataFormat::Hex),
x => Err(format!("Inv... | DataFormat | identifier_name |
vinsertf128.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn vinsertf128_1() {
run_test(&Instruction { mnemonic: Mnemonic::VINSERTF128, operand1: Some(Direct(YMM0)), operand2: Some... | () {
run_test(&Instruction { mnemonic: Mnemonic::VINSERTF128, operand1: Some(Direct(YMM3)), operand2: Some(Direct(YMM7)), operand3: Some(IndirectDisplaced(RAX, 1337666297, Some(OperandSize::Xmmword), None)), operand4: Some(Literal8(119)), lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, b... | vinsertf128_4 | identifier_name |
vinsertf128.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn vinsertf128_1() {
run_test(&Instruction { mnemonic: Mnemonic::VINSERTF128, operand1: Some(Direct(YMM0)), operand2: Some... | } | run_test(&Instruction { mnemonic: Mnemonic::VINSERTF128, operand1: Some(Direct(YMM3)), operand2: Some(Direct(YMM7)), operand3: Some(IndirectDisplaced(RAX, 1337666297, Some(OperandSize::Xmmword), None)), operand4: Some(Literal8(119)), lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadc... | random_line_split |
vinsertf128.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn vinsertf128_1() {
run_test(&Instruction { mnemonic: Mnemonic::VINSERTF128, operand1: Some(Direct(YMM0)), operand2: Some... |
fn vinsertf128_4() {
run_test(&Instruction { mnemonic: Mnemonic::VINSERTF128, operand1: Some(Direct(YMM3)), operand2: Some(Direct(YMM7)), operand3: Some(IndirectDisplaced(RAX, 1337666297, Some(OperandSize::Xmmword), None)), operand4: Some(Literal8(119)), lock: false, rounding_mode: None, merge_mode: None, sae: fa... | {
run_test(&Instruction { mnemonic: Mnemonic::VINSERTF128, operand1: Some(Direct(YMM0)), operand2: Some(Direct(YMM3)), operand3: Some(Direct(XMM2)), operand4: Some(Literal8(36)), lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 227, 101, 24, 194, 36], OperandSize... | identifier_body |
cnvs.rs | CNV, given as Kass Raftery scores: \
N: none, B: barely, P: positive, S: strong, V: very strong \">"
.as_bytes(),
);
header.push_record(
"##FORMAT=<ID=LOCI_DP,Number=.,Type=Integer,Description=\"Depths of contained loci.\">"
.as_bytes(),
);... |
let mut p = LogProb::ln_one();
for (state, obs) in states.into_iter().zip(observations) {
p += hmm.observation_prob(state, obs);
}
p
}
| identifier_body | |
cnvs.rs | .map(|(region, calls)| {
let hmm = HMM::new(depth_norm_factor, min_bayes_factor, purity);
let (states, _prob) = hmm::viterbi(&hmm, calls);
(
region,
states
.iter()
.zip(calls.iter())
... |
// gain = -2: all lost in tumor cells, hence 100% normal cells at this locus.
// Therefore VAF=0.5.
Some(AlleleFreq(0.5))
} | conditional_block | |
cnvs.rs | "##INFO=<ID=LOCI,Number=1,Type=Integer,Description=\"Number of contained loci.\">"
.as_bytes(),
);
header.push_record(
"##INFO=<ID=OBS,Number=1,Type=String,Description=\"Bayes factors for per-locus \
support for no CNV, given as Kass Raftery scores: \
... | ikelihood< | identifier_name | |
cnvs.rs | header.push_record(
"##INFO=<ID=SVLEN,Number=1,Type=Integer,Description=\"CNV length.\">".as_bytes(),
);
header.push_record(
"##INFO=<ID=SVTYPE,Number=1,Type=Integer,Description=\"SV type.\">".as_bytes(),
);
header.push_record(
"##INFO=<ID=LOCI... | pub(crate) fn null_state(&self) -> hmm::State {
self.state_by_gain.get(&0).unwrap()[0]
}
pub(crate) fn bayes_factors(&self, state: hmm::State, observations: &[&Call]) -> Vec<BayesFactor> {
let null_state = self.null_state();
observations
.into_iter()
.map(|obs|... | }
| random_line_split |
main.rs | extern crate graphics;
extern crate freetype as ft;
extern crate sdl2_window;
extern crate opengl_graphics;
extern crate piston;
use std::path::Path;
use sdl2_window::Sdl2Window;
use opengl_graphics::{ GlGraphics, Texture, OpenGL };
use graphics::math::Matrix2d;
use piston::window::WindowSettings;
use piston::event::*... | () {
let opengl = OpenGL::_3_2;
let window = Sdl2Window::new(
opengl,
WindowSettings::new("piston-example-freetype", [300, 300])
.exit_on_esc(true)
);
let freetype = ft::Library::init().unwrap();
let font = Path::new("./bin/assets/FiraSans-Regular.ttf");
let mut face = fr... | main | identifier_name |
main.rs | extern crate graphics;
extern crate freetype as ft;
extern crate sdl2_window;
extern crate opengl_graphics;
extern crate piston;
use std::path::Path;
use sdl2_window::Sdl2Window;
use opengl_graphics::{ GlGraphics, Texture, OpenGL };
use graphics::math::Matrix2d;
use piston::window::WindowSettings;
use piston::event::*... | let font = Path::new("./bin/assets/FiraSans-Regular.ttf");
let mut face = freetype.new_face(&font, 0).unwrap();
face.set_pixel_sizes(0, 48).unwrap();
let ref mut gl = GlGraphics::new(opengl);
for e in window.events() {
if let Some(args) = e.render_args() {
use graphics::*;
... | random_line_split | |
main.rs | extern crate graphics;
extern crate freetype as ft;
extern crate sdl2_window;
extern crate opengl_graphics;
extern crate piston;
use std::path::Path;
use sdl2_window::Sdl2Window;
use opengl_graphics::{ GlGraphics, Texture, OpenGL };
use graphics::math::Matrix2d;
use piston::window::WindowSettings;
use piston::event::*... | x += (g.advance().x >> 6) as i32;
y += (g.advance().y >> 6) as i32;
}
}
fn main() {
let opengl = OpenGL::_3_2;
let window = Sdl2Window::new(
opengl,
WindowSettings::new("piston-example-freetype", [300, 300])
.exit_on_esc(true)
);
let freetype = ft::Library::... | {
use graphics::*;
let mut x = 10;
let mut y = 0;
for ch in text.chars() {
face.load_char(ch as usize, ft::face::RENDER).unwrap();
let g = face.glyph();
let bitmap = g.bitmap();
let texture = Texture::from_memory_alpha(bitmap.buffer(),
... | identifier_body |
main.rs | extern crate graphics;
extern crate freetype as ft;
extern crate sdl2_window;
extern crate opengl_graphics;
extern crate piston;
use std::path::Path;
use sdl2_window::Sdl2Window;
use opengl_graphics::{ GlGraphics, Texture, OpenGL };
use graphics::math::Matrix2d;
use piston::window::WindowSettings;
use piston::event::*... |
}
}
| {
use graphics::*;
gl.draw(args.viewport(), |c, gl| {
let transform = c.transform.trans(0.0, 100.0);
clear(color::WHITE, gl);
render_text(&mut face, gl, transform, "Hello Piston!");
});
} | conditional_block |
options.rs | #![ allow( unused_imports ) ]
#![ allow( unused_mut ) ]
#![ allow( dead_code ) ]
#![ allow( unused_variables ) ]
#![ warn( missing_docs ) ]
#![ warn( missing_debug_implementations ) ]
use meta_tools::*;
use quote::{ quote, ToTokens, TokenStreamExt };
use syn::parse::*;
use syn::spanned::Spanned;
use proc_macro_tools::... | ( name : &str, field : &syn::Field ) -> Result< GetterDescriptor >
{
let name_ident = syn::Ident::new( &name, field.span() );
let ty = &field.ty;
// tree_print!( ty );
let ty_is_ref = matches!( ty, syn::Type::Reference( _ ) );
let ty2 = if ty_is_ref
{
ty.to_token_stream()
}
else
{
quote!{ ... | getter_gen | identifier_name |
options.rs | #![ allow( unused_imports ) ]
#![ allow( unused_mut ) ]
#![ allow( dead_code ) ]
#![ allow( unused_variables ) ]
#![ warn( missing_docs ) ]
#![ warn( missing_debug_implementations ) ]
use meta_tools::*;
use quote::{ quote, ToTokens, TokenStreamExt };
use syn::parse::*;
use syn::spanned::Spanned;
use proc_macro_tools::... | let fn_desc = FnQuick
{
attrs,
vis,
sig,
block : None,
};
return Ok( Element::Fn( fn_desc ) );
}
}
else
{
input.call( syn::Field::parse_named ).map( | mut e |
{
e.vis = vis;
e.attrs = attrs;
El... | {
let sig : syn::Signature = input.parse()?;
let lookahead2 = input.lookahead1();
if lookahead2.peek( syn::token::Brace )
{
let input2;
let brace_token : syn::token::Brace = syn::braced!( input2 in input );
let block : proc_macro2::TokenStream = input2.parse()?;
... | conditional_block |
options.rs | #![ allow( unused_imports ) ]
#![ allow( unused_mut ) ]
#![ allow( dead_code ) ]
#![ allow( unused_variables ) ]
#![ warn( missing_docs ) ]
#![ warn( missing_debug_implementations ) ]
use meta_tools::*;
use quote::{ quote, ToTokens, TokenStreamExt };
use syn::parse::*;
use syn::spanned::Spanned;
use proc_macro_tools::... |
for attr in self.attrs.iter()
{
attr.to_tokens( tokens );
}
self.sig.to_tokens( tokens );
match &self.block
{
Some( block ) => tokens.append( proc_macro2::Group::new( proc_macro2::Delimiter::Brace, block.to_token_stream() ) ),
None => tokens.append( proc_macro2::Punct::new( ... | random_line_split | |
reftest.rs | // Copyright 2013 The Servo 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>, at ... | <'a> {
conditions: &'a str,
kind: &'a str,
file_left: &'a str,
file_right: &'a str,
}
fn parse_lists(file: &Path, servo_args: &[String], render_mode: RenderMode, id_offset: uint) -> Vec<TestDescAndFn> {
let mut tests = Vec::new();
let contents = File::open_mode(file, io::Open, io::Read)
... | TestLine | identifier_name |
reftest.rs | // Copyright 2013 The Servo 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>, at ... | }
if reftest.render_mode.contains(GPU_RENDERING) {
command.arg("-g");
}
if reftest.experimental {
command.arg("--experimental");
}
let retval = match command.status() {
Ok(status) => status,
Err(e) => panic!("failed to execute process: {}", e),
};
assert_e... | random_line_split | |
bind_instead_of_map_multipart.rs | #![deny(clippy::bind_instead_of_map)]
#![allow(clippy::blocks_in_if_conditions)]
pub fn main() {
let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
let _ = Some("42").and_then(|s| if s.len() < 42 { None } else { Some(s.len()) });
let _ = Ok::<_, ()>("42").and_then(|s| if ... | if s == "43" {
return Some(43);
}
s == "42"
} {
return Some(45);
}
match s.len() {
10 => Some(2),
20 => {
if foo() {
return {
if foo() {
... | }
fn hard_example() {
Some("42").and_then(|s| {
if { | random_line_split |
bind_instead_of_map_multipart.rs | #![deny(clippy::bind_instead_of_map)]
#![allow(clippy::blocks_in_if_conditions)]
pub fn main() {
let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
let _ = Some("42").and_then(|s| if s.len() < 42 { None } else { Some(s.len()) });
let _ = Ok::<_, ()>("42").and_then(|s| if ... | {
let _ = Some("").and_then(|s| if s.len() == 20 { m!() } else { Some(20) });
let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
} | identifier_body | |
bind_instead_of_map_multipart.rs | #![deny(clippy::bind_instead_of_map)]
#![allow(clippy::blocks_in_if_conditions)]
pub fn main() {
let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
let _ = Some("42").and_then(|s| if s.len() < 42 { None } else { Some(s.len()) });
let _ = Ok::<_, ()>("42").and_then(|s| if ... | () {
let _ = Some("").and_then(|s| if s.len() == 20 { m!() } else { Some(20) });
let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
}
| macro_example | identifier_name |
lib.rs | #![feature(braced_empty_structs)]
extern crate html5ever;
extern crate hyper;
extern crate libc;
extern crate string_cache;
extern crate tendril;
extern crate url;
use libc::c_char;
use std::collections::{HashMap, HashSet, VecDeque};
use std::default::Default;
use std::ffi::CStr;
use std::io::Read;
use std::result::R... |
dom_steps
}
}
impl AtomicProcess for PageDownloader {
fn process_this(&self) -> Vec<ProcessOutputs> {
let client = Client::new();
// Read the Response.
let mut body = String::new();
let res = client.get(&self.thread_url[..])
.header(Connection::close())
... | {
dom_steps.push(ProcessOutputs::Output(self.count));
} | conditional_block |
lib.rs | #![feature(braced_empty_structs)]
extern crate html5ever;
extern crate hyper;
extern crate libc;
extern crate string_cache;
extern crate tendril;
extern crate url;
use libc::c_char;
use std::collections::{HashMap, HashSet, VecDeque};
use std::default::Default;
use std::ffi::CStr;
use std::io::Read;
use std::result::R... | if name.local == Atom::from("article") {
self.count += 1
}
}
Document => (),
Doctype(_, _, _) => (),
Text(_) => (),
Comment(_) => (),
};
let dom_steps: Vec<ProcessOutputs> = node.children... | fn process_this(&self) -> Vec<ProcessOutputs> {
let node = self.handle.borrow();
match node.node {
Element(ref name, _, _) => { | random_line_split |
lib.rs | #![feature(braced_empty_structs)]
extern crate html5ever;
extern crate hyper;
extern crate libc;
extern crate string_cache;
extern crate tendril;
extern crate url;
use libc::c_char;
use std::collections::{HashMap, HashSet, VecDeque};
use std::default::Default;
use std::ffi::CStr;
use std::io::Read;
use std::result::R... | (&self) -> Vec<ProcessOutputs> {
park();
vec![ProcessOutputs::Output(0i64)]
}
}
impl TaskQueue {
pub fn nextTask(&self) -> Box<AtomicProcess> {
match self.queue.clone().lock().unwrap().pop_back() {
Some(res) => res,
None => Box::new(PauseThread),
}
}
... | process_this | identifier_name |
command.rs | use super::{CommandType};
#[derive(Clone, Debug, PartialEq)]
pub enum Sender {
User(String, Option<String>, Option<String>),
Server(String)
}
impl Sender {
fn to_cmd(&self) -> String {
match *self {
Sender::User(ref n, None, None) => format!(":{} ", n),
Sender::User(ref n, ... |
}
#[derive(Clone, Debug, PartialEq)]
pub struct Command {
pub tags: Option<Tags>,
pub prefix: Option<Sender>,
pub command: CommandType,
pub params: Params,
}
impl Command {
pub fn to_string(&self) -> String {
let cmd: &str = self.command.into();
format!("{}{}{}{}\r\n", self.tags.a... | {
let mut buf = String::new();
buf.push(' ');
let n = self.data.len();
if n > 0 {
for i in 0..n-1 {
buf.push_str(&*format!("{} ", self.data[i]));
}
buf.push_str(&*format!(":{}", self.data[n-1]));
}
buf
} | identifier_body |
command.rs | use super::{CommandType};
#[derive(Clone, Debug, PartialEq)]
pub enum Sender {
User(String, Option<String>, Option<String>),
Server(String)
}
impl Sender {
fn to_cmd(&self) -> String {
match *self {
Sender::User(ref n, None, None) => format!(":{} ", n),
Sender::User(ref n, ... | (&self) -> String {
let cmd: &str = self.command.into();
format!("{}{}{}{}\r\n", self.tags.as_ref().map(|x|x.to_cmd()).unwrap_or("".to_string()),
self.prefix.as_ref().map(|x|x.to_cmd()).unwrap_or("".to_string()),
cmd,
se... | to_string | identifier_name |
command.rs | use super::{CommandType};
#[derive(Clone, Debug, PartialEq)]
pub enum Sender {
User(String, Option<String>, Option<String>),
Server(String)
}
impl Sender {
fn to_cmd(&self) -> String {
match *self {
Sender::User(ref n, None, None) => format!(":{} ", n),
Sender::User(ref n, ... | }
#[derive(Clone, Debug, PartialEq)]
pub struct Command {
pub tags: Option<Tags>,
pub prefix: Option<Sender>,
pub command: CommandType,
pub params: Params,
}
impl Command {
pub fn to_string(&self) -> String {
let cmd: &str = self.command.into();
format!("{}{}{}{}\r\n", self.tags.as... | } | random_line_split |
errors.rs | // Copyright 2018 Mozilla
//
// 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 writing, software... | /// We're just not done yet. Message that the feature is recognized but not yet
/// implemented.
#[fail(display = "not yet implemented: {}", _0)]
NotYetImplemented(String),
#[fail(display = "no possible types for value provided to {:?}", _0)]
CannotProjectImpossibleBinding(SimpleAggregationOp)... |
#[derive(Debug, Fail)]
pub enum ProjectorError { | random_line_split |
errors.rs | // Copyright 2018 Mozilla
//
// 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 writing, software... |
}
impl From<mentat_db::DbError> for ProjectorError {
fn from(error: mentat_db::DbError) -> ProjectorError {
ProjectorError::DbError(error)
}
}
impl From<mentat_query_pull::PullError> for ProjectorError {
fn from(error: mentat_query_pull::PullError) -> ProjectorError {
ProjectorError::Pull... | {
ProjectorError::RusqliteError(error.to_string())
} | identifier_body |
errors.rs | // Copyright 2018 Mozilla
//
// 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 writing, software... | (error: rusqlite::Error) -> ProjectorError {
ProjectorError::RusqliteError(error.to_string())
}
}
impl From<mentat_db::DbError> for ProjectorError {
fn from(error: mentat_db::DbError) -> ProjectorError {
ProjectorError::DbError(error)
}
}
impl From<mentat_query_pull::PullError> for Project... | from | identifier_name |
effect.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | }
}
fn check_str_index(&mut self, e: &ast::Expr) {
let base_type = match e.node {
ast::ExprIndex(ref base, _) => ty::node_id_to_type(self.tcx, base.id),
_ => return
};
debug!("effect: checking index with base type {}",
ppaux::ty_to_string(... | debug!("effect: recording unsafe block as used: {}", block_id);
self.tcx.used_unsafe.borrow_mut().insert(block_id);
}
UnsafeFn => {} | random_line_split |
effect.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&mut self, expr: &ast::Expr) {
match expr.node {
ast::ExprMethodCall(_, _, _) => {
let method_call = MethodCall::expr(expr.id);
let base_type = self.tcx.method_map.borrow().get(&method_call).ty;
debug!("effect: method call case, base type is {}",
... | visit_expr | identifier_name |
effect.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn check_str_index(&mut self, e: &ast::Expr) {
let base_type = match e.node {
ast::ExprIndex(ref base, _) => ty::node_id_to_type(self.tcx, base.id),
_ => return
};
debug!("effect: checking index with base type {}",
ppaux::ty_to_string(self.tcx, base_... | {
match self.unsafe_context {
SafeContext => {
// Report an error.
span_err!(self.tcx.sess, span, E0133,
"{} requires unsafe function or block",
description);
}
UnsafeBlock(block_id) => {
... | identifier_body |
lib.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... | () -> Option<Box<Terminal<WriterWrapper> + Send>> {
TerminfoTerminal::new(WriterWrapper {
wrapped: box std::io::stdout() as Box<Write + Send>,
})
}
#[cfg(windows)]
/// Return a Terminal wrapping stdout, or None if a terminal couldn't be
/// opened.
pub fn stdout() -> Option<Box<Terminal<WriterWrapper> ... | stdout | identifier_name |
lib.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... |
#[inline]
fn flush(&mut self) -> io::Result<()> {
self.wrapped.flush()
}
}
#[cfg(not(windows))]
/// Return a Terminal wrapping stdout, or None if a terminal couldn't be
/// opened.
pub fn stdout() -> Option<Box<Terminal<WriterWrapper> + Send>> {
TerminfoTerminal::new(WriterWrapper {
w... | {
self.wrapped.write(buf)
} | identifier_body |
lib.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... | /// Terminal color definitions
pub mod color {
/// Number for a terminal color
pub type Color = u16;
pub const BLACK: Color = 0;
pub const RED: Color = 1;
pub const GREEN: Color = 2;
pub const YELLOW: Color = 3;
pub const BLUE: Color = 4;
pub const MAGENTA: Color = 5;
pu... | random_line_split | |
state.rs | use ::libc;
#[cfg(feature = "task")]
use super::task::BufProc;
use super::{In, Out, Sig};
use super::control::Control;
#[derive(Copy, Clone, Debug)]
pub enum DeviceState {
/// The current task.
#[cfg(feature = "task")] Proc(BufProc),
/// Update.
Idle, | /// The current character.
InText(Control),
}
impl DeviceState {
#[cfg(feature = "task")]
/// The constructor method `from_task` returns a Process' event.
pub fn from_task(name: BufProc) -> Self {
DeviceState::Proc(name)
}
/// The constructor method `from_idle` returns a Update's ... | /// As catched a signal.
Sig(Sig),
/// The output of new lines.
OutText(Out, libc::size_t), | random_line_split |
state.rs | use ::libc;
#[cfg(feature = "task")]
use super::task::BufProc;
use super::{In, Out, Sig};
use super::control::Control;
#[derive(Copy, Clone, Debug)]
pub enum DeviceState {
/// The current task.
#[cfg(feature = "task")] Proc(BufProc),
/// Update.
Idle,
/// As catched a signal.
Sig(Sig),
///... |
/// The accessor method `is_signal` returns a Option for Signal's event.
pub fn is_signal(&self) -> Option<libc::c_int> {
match *self {
DeviceState::Sig(sig) => Some(sig),
_ => None,
}
}
}
| {
match *self {
DeviceState::InText(event) => Some(event),
_ => None,
}
} | identifier_body |
state.rs | use ::libc;
#[cfg(feature = "task")]
use super::task::BufProc;
use super::{In, Out, Sig};
use super::control::Control;
#[derive(Copy, Clone, Debug)]
pub enum DeviceState {
/// The current task.
#[cfg(feature = "task")] Proc(BufProc),
/// Update.
Idle,
/// As catched a signal.
Sig(Sig),
///... | (&self) -> Option<Control> {
match *self {
DeviceState::InText(event) => Some(event),
_ => None,
}
}
/// The accessor method `is_signal` returns a Option for Signal's event.
pub fn is_signal(&self) -> Option<libc::c_int> {
match *self {
DeviceStat... | is_input | identifier_name |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate cargo;
extern crate rustc_serialize;
extern crate itertools;
extern crate tera;
extern crate toml;
#[cfg(test)]
#[macro_use]
extern crate hamcrest;
mod context;
mod planning;
mod rendering;
mod settings;
mod util;
mod bazel;
use bazel::BazelRen... | <T: AsRef<Path>>(cargo_toml_path: T) -> Result<RazeSettings, CargoError> {
let path = cargo_toml_path.as_ref();
let mut toml = try!(File::open(path)
.map_err(|e| {
println!("{:?}", e);
CargoError::from(format!("Could not load {:?}", path))
... | load_settings | identifier_name |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate cargo;
extern crate rustc_serialize;
extern crate itertools;
extern crate tera;
extern crate toml;
#[cfg(test)]
#[macro_use]
extern crate hamcrest;
mod context;
mod planning;
mod rendering;
mod settings;
mod util;
mod bazel;
use bazel::BazelRen... |
if settings.workspace_path.ends_with("/") {
settings.workspace_path.pop();
}
return Ok(())
}
fn write_to_file_loudly(path: &str, contents: &str) -> CargoResult<()> {
try!(File::create(&path)
.and_then(|mut f| f.write_all(contents.as_bytes()))
.map_err(|_| CargoError::from(format!("failed to crea... | {
return Err(CargoError::from("raze.workspace_path must not be '//' (it is currently unsupported). Its probably not what you want anyway, as this would vendor the crates directly into //vendor."));
} | conditional_block |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate cargo;
extern crate rustc_serialize;
extern crate itertools;
extern crate tera;
extern crate toml;
#[cfg(test)]
#[macro_use]
extern crate hamcrest;
mod context;
mod planning;
mod rendering;
mod settings;
mod util;
mod bazel;
use bazel::BazelRen... |
fn write_to_file_loudly(path: &str, contents: &str) -> CargoResult<()> {
try!(File::create(&path)
.and_then(|mut f| f.write_all(contents.as_bytes()))
.map_err(|_| CargoError::from(format!("failed to create {}", path))));
println!("Generated {} successfully", path);
Ok(())
}
fn load_settings<T: AsRef<P... | {
if !settings.workspace_path.starts_with("//") {
return Err(CargoError::from("raze.workspace_path must start with \"//\". Paths into local repositories (such as @local//path) are currently unsupported."))
}
if settings.workspace_path == "//" {
return Err(CargoError::from("raze.workspace_path must not be... | identifier_body |
main.rs | #[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate cargo;
extern crate rustc_serialize;
extern crate itertools;
extern crate tera;
extern crate toml;
#[cfg(test)]
#[macro_use]
extern crate hamcrest;
mod context;
mod planning;
mod rendering;
mod settings;
mod util;
mod bazel;
use bazel::BazelRen... |
let planned_build = try!(planner.plan_build());
let mut bazel_renderer = BazelRenderer::new();
let render_details = RenderDetails {
path_prefix: "./".to_owned(),
};
let bazel_file_outputs = match settings.genmode {
GenMode::Vendored => try!(bazel_renderer.render_planned_build(&render_details, &plann... | random_line_split | |
fibonacci_word.rs | // Implements http://rosettacode.org/wiki/Fibonacci_word
use entropy::shannon_entropy;
mod entropy;
// Returns "amount" fibonacci words as a vector of tuples
// The first value of the tuple is the length of the word
// and the second one its entropy
fn fib_words(amount: usize) -> Vec<(usize, f64)> {
let mut data =... | let mut next = String::from("0");
// The first two words (we need to add them manually because
// they are the base of the sequence)
data.push((previous.len(), shannon_entropy(&previous[..])));
data.push((next.len(), shannon_entropy(&next[..])));
// The rest of the words
for _ in (3..amoun... | random_line_split | |
fibonacci_word.rs | // Implements http://rosettacode.org/wiki/Fibonacci_word
use entropy::shannon_entropy;
mod entropy;
// Returns "amount" fibonacci words as a vector of tuples
// The first value of the tuple is the length of the word
// and the second one its entropy
fn fib_words(amount: usize) -> Vec<(usize, f64)> |
#[cfg(not(test))]
fn main() {
println!("Calculating... This may take a couple of minutes...\n");
let words = fib_words(18);
let mut i = 1;
println!("{:>2}:{:>10} {}", "N", "length", "entropy");
for &(length, entropy) in &words {
println!("{:>2}:{:>10} {:.15}", i, length, entropy);
... | {
let mut data = Vec::with_capacity(amount);
let mut previous = String::from("1");
let mut next = String::from("0");
// The first two words (we need to add them manually because
// they are the base of the sequence)
data.push((previous.len(), shannon_entropy(&previous[..])));
data.push((nex... | identifier_body |
fibonacci_word.rs | // Implements http://rosettacode.org/wiki/Fibonacci_word
use entropy::shannon_entropy;
mod entropy;
// Returns "amount" fibonacci words as a vector of tuples
// The first value of the tuple is the length of the word
// and the second one its entropy
fn fib_words(amount: usize) -> Vec<(usize, f64)> {
let mut data =... | () {
let expected = vec![
(1, 0.000000000000000f64),
(1, 0.000000000000000),
(2, 1.000000000000000),
(3, 0.918295834054490),
(5, 0.970950594454669),
(8, 0.954434002924965),
(13, 0.961236604722876),
(21, 0.958711882977132),
(34, 0.9596868937742... | test_fibonacii_words | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.