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 |
|---|---|---|---|---|
vec_box_sized.rs | // run-rustfix
#![allow(dead_code)]
struct SizedStruct(i32);
struct UnsizedStruct([i32]);
struct BigStruct([i32; 10000]);
/// The following should trigger the lint
mod should_trigger {
use super::SizedStruct;
const C: Vec<Box<i32>> = Vec::new();
static S: Vec<Box<i32>> = Vec::new();
struct StructWit... | () -> Vec<Box<S>> {
vec![]
}
}
}
fn main() {}
| f | identifier_name |
vec_box_sized.rs | // run-rustfix
#![allow(dead_code)]
struct SizedStruct(i32);
struct UnsizedStruct([i32]);
struct BigStruct([i32; 10000]);
/// The following should trigger the lint
mod should_trigger {
use super::SizedStruct;
const C: Vec<Box<i32>> = Vec::new();
static S: Vec<Box<i32>> = Vec::new();
struct StructWit... | unsized_type: Vec<Box<UnsizedStruct>>,
}
struct TraitVec<T:?Sized> {
// Regression test for #3720. This was causing an ICE.
inner: Vec<Box<T>>,
}
}
mod inner_mod {
mod inner {
pub struct S;
}
mod inner2 {
use super::inner::S;
pub fn f() -> Vec<... | struct StructWithVecBoxButItsUnsized { | random_line_split |
upgrade.rs | use header::{Header, HeaderFormat};
use std::fmt;
use std::str::FromStr;
use header::parsing::{from_comma_delimited, fmt_comma_delimited};
use unicase::UniCase;
use self::Protocol::{WebSocket, ProtocolExt}; | pub struct Upgrade(pub Vec<Protocol>);
deref!(Upgrade => Vec<Protocol>);
/// Protocol values that can appear in the Upgrade header.
#[derive(Clone, PartialEq, Debug)]
pub enum Protocol {
/// The websocket protocol.
WebSocket,
/// Some other less common protocol.
ProtocolExt(String),
}
impl FromStr fo... |
/// The `Upgrade` header.
#[derive(Clone, PartialEq, Debug)] | random_line_split |
upgrade.rs | use header::{Header, HeaderFormat};
use std::fmt;
use std::str::FromStr;
use header::parsing::{from_comma_delimited, fmt_comma_delimited};
use unicase::UniCase;
use self::Protocol::{WebSocket, ProtocolExt};
/// The `Upgrade` header.
#[derive(Clone, PartialEq, Debug)]
pub struct Upgrade(pub Vec<Protocol>);
deref!(Upg... |
fn parse_header(raw: &[Vec<u8>]) -> Option<Upgrade> {
from_comma_delimited(raw).map(|vec| Upgrade(vec))
}
}
impl HeaderFormat for Upgrade {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let Upgrade(ref parts) = *self;
fmt_comma_delimited(fmt, &parts[..])
}
}
... | {
"Upgrade"
} | identifier_body |
upgrade.rs | use header::{Header, HeaderFormat};
use std::fmt;
use std::str::FromStr;
use header::parsing::{from_comma_delimited, fmt_comma_delimited};
use unicase::UniCase;
use self::Protocol::{WebSocket, ProtocolExt};
/// The `Upgrade` header.
#[derive(Clone, PartialEq, Debug)]
pub struct Upgrade(pub Vec<Protocol>);
deref!(Upg... | () -> &'static str {
"Upgrade"
}
fn parse_header(raw: &[Vec<u8>]) -> Option<Upgrade> {
from_comma_delimited(raw).map(|vec| Upgrade(vec))
}
}
impl HeaderFormat for Upgrade {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let Upgrade(ref parts) = *self;
f... | header_name | identifier_name |
upgrade.rs | use header::{Header, HeaderFormat};
use std::fmt;
use std::str::FromStr;
use header::parsing::{from_comma_delimited, fmt_comma_delimited};
use unicase::UniCase;
use self::Protocol::{WebSocket, ProtocolExt};
/// The `Upgrade` header.
#[derive(Clone, PartialEq, Debug)]
pub struct Upgrade(pub Vec<Protocol>);
deref!(Upg... |
}
}
impl fmt::Display for Protocol {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{}", match *self {
WebSocket => "websocket",
ProtocolExt(ref s) => s.as_ref()
})
}
}
impl Header for Upgrade {
fn header_name() -> &'static str {
... | {
Ok(ProtocolExt(s.to_string()))
} | conditional_block |
simd-intrinsic-float-math.rs | // run-pass
// ignore-emscripten
// ignore-android
// FIXME: this test fails on arm-android because the NDK version 14 is too old.
// It needs at least version 18. We disable it on all android build bots because
// there is no way in compile-test to disable it for an (arch,os) pair.
// Test that the simd floating-poi... | assert_approx_eq!(x, r);
let r = simd_fexp(z);
assert_approx_eq!(x, r);
let r = simd_fexp2(z);
assert_approx_eq!(x, r);
let r = simd_fma(x, h, h);
assert_approx_eq!(x, r);
let r = simd_fsqrt(x);
assert_approx_eq!(x, r);
let r = simd_fl... | let r = simd_fcos(z); | random_line_split |
simd-intrinsic-float-math.rs | // run-pass
// ignore-emscripten
// ignore-android
// FIXME: this test fails on arm-android because the NDK version 14 is too old.
// It needs at least version 18. We disable it on all android build bots because
// there is no way in compile-test to disable it for an (arch,os) pair.
// Test that the simd floating-poi... | (pub f32, pub f32, pub f32, pub f32);
extern "platform-intrinsic" {
fn simd_fsqrt<T>(x: T) -> T;
fn simd_fabs<T>(x: T) -> T;
fn simd_fsin<T>(x: T) -> T;
fn simd_fcos<T>(x: T) -> T;
fn simd_fexp<T>(x: T) -> T;
fn simd_fexp2<T>(x: T) -> T;
fn simd_fma<T>(x: T, y: T, z: T) -> T;
fn simd_fl... | f32x4 | identifier_name |
image_cache_task.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 image::base::Image;
use ipc_channel::ipc::{self, IpcSender};
use url::Url;
use std::sync::Arc;
use util::mem::... | {
sender: IpcSender<ImageResponse>,
}
impl ImageResponder {
pub fn new(sender: IpcSender<ImageResponse>) -> ImageResponder {
ImageResponder {
sender: sender,
}
}
pub fn respond(&self, response: ImageResponse) {
self.sender.send(response).unwrap()
}
}
/// The c... | ImageResponder | identifier_name |
image_cache_task.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 image::base::Image;
use ipc_channel::ipc::{self, IpcSender};
use url::Url;
use std::sync::Arc;
use util::mem::... | self.chan.send(ImageCacheCommand::Exit(response_chan)).unwrap();
response_port.recv().unwrap();
}
} | random_line_split | |
cgmath_augment.rs | use cgmath::{Point2, Vector2};
pub trait Cross<T, S> { | pub trait Dot<T, S> {
fn dot(&self, other: &T) -> S;
}
//stupid type rules won't let me add std::ops::Add for f32/f64
pub trait AddScalar<T, S> {
fn add_scalar(self, rhs: S) -> T;
}
impl<S> Cross<Point2<S>, S> for Point2<S> where S: cgmath::BaseFloat {
fn cross(&self, other: &Point2<S>) -> S {
(se... | fn cross(&self, other: &T) -> S;
}
| random_line_split |
cgmath_augment.rs | use cgmath::{Point2, Vector2};
pub trait Cross<T, S> {
fn cross(&self, other: &T) -> S;
}
pub trait Dot<T, S> {
fn dot(&self, other: &T) -> S;
}
//stupid type rules won't let me add std::ops::Add for f32/f64
pub trait AddScalar<T, S> {
fn add_scalar(self, rhs: S) -> T;
}
impl<S> Cross<Point2<S>, S> for ... |
}
impl<S> Dot<Point2<S>, S> for Point2<S> where S: cgmath::BaseFloat {
fn dot(&self, other: &Point2<S>) -> S {
(self.x * other.x) + (self.y * other.y)
}
}
impl<S> Dot<Vector2<S>, S> for Vector2<S> where S: cgmath::BaseFloat {
fn dot(&self, other: &Vector2<S>) -> S {
(self.x * other.x) + (... | {
(self.x * other.y) - (self.y * other.x)
} | identifier_body |
cgmath_augment.rs | use cgmath::{Point2, Vector2};
pub trait Cross<T, S> {
fn cross(&self, other: &T) -> S;
}
pub trait Dot<T, S> {
fn dot(&self, other: &T) -> S;
}
//stupid type rules won't let me add std::ops::Add for f32/f64
pub trait AddScalar<T, S> {
fn add_scalar(self, rhs: S) -> T;
}
impl<S> Cross<Point2<S>, S> for ... | (&self, other: &Point2<S>) -> S {
(self.x * other.y) - (self.y * other.x)
}
}
impl<S> Cross<Vector2<S>, S> for Vector2<S> where S: cgmath::BaseFloat {
fn cross(&self, other: &Vector2<S>) -> S {
(self.x * other.y) - (self.y * other.x)
}
}
impl<S> Dot<Point2<S>, S> for Point2<S> where S: cgm... | cross | identifier_name |
create.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
// | // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; version
// 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; withou... | random_line_split | |
create.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | (inner: TagStoreIdIter, store: &'a Store) -> CreateTimeTrackIter<'a> {
CreateTimeTrackIter {
inner: inner,
store: store,
}
}
pub fn set_end_time(self, datetime: NDT) -> SetEndTimeIter<'a> {
SetEndTimeIter::new(self, datetime)
}
}
impl<'a> Iterator for Create... | new | identifier_name |
day_05.rs | pub fn first() {
let filename = "day05-01.txt";
let mut lines: Vec<String> = super::helpers::read_lines(filename)
.into_iter()
.map(|x| x.unwrap())
.collect();
lines.sort();
let mut max = 0;
for line in lines {
let id = get_id(&line);
if id > max {
... |
gap = max - min + 1;
println!("{} {} {}", max, min, gap);
}
idx = max * 8;
min = 0;
max = 7;
gap = max - min + 1;
for x in lr.chars() {
if x == 'L' {
max = max - gap / 2;
} else if x == 'R' {
min = min + gap / 2;
}
gap = ... | {
min = min + gap / 2;
} | conditional_block |
day_05.rs | pub fn first() {
let filename = "day05-01.txt";
let mut lines: Vec<String> = super::helpers::read_lines(filename)
.into_iter()
.map(|x| x.unwrap())
.collect();
lines.sort();
let mut max = 0;
for line in lines {
let id = get_id(&line);
if id > max {
... | let mut min: i32 = 0;
let mut max: i32 = 127;
let mut gap = max - min + 1;
for y in fb.chars() {
if y == 'F' {
max = max - gap / 2;
} else if y == 'B' {
min = min + gap / 2;
}
gap = max - min + 1;
println!("{} {} {}", max, min, gap);
}... | let lr = &code[7..];
let mut idx;
| random_line_split |
day_05.rs | pub fn first() |
fn get_id(code: &str) -> i32 {
let fb = &code[0..7];
let lr = &code[7..];
let mut idx;
let mut min: i32 = 0;
let mut max: i32 = 127;
let mut gap = max - min + 1;
for y in fb.chars() {
if y == 'F' {
max = max - gap / 2;
} else if y == 'B' {
min = mi... | {
let filename = "day05-01.txt";
let mut lines: Vec<String> = super::helpers::read_lines(filename)
.into_iter()
.map(|x| x.unwrap())
.collect();
lines.sort();
let mut max = 0;
for line in lines {
let id = get_id(&line);
if id > max {
max = id;
... | identifier_body |
day_05.rs | pub fn | () {
let filename = "day05-01.txt";
let mut lines: Vec<String> = super::helpers::read_lines(filename)
.into_iter()
.map(|x| x.unwrap())
.collect();
lines.sort();
let mut max = 0;
for line in lines {
let id = get_id(&line);
if id > max {
max = id;
... | first | identifier_name |
issue-19479.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 | |
issue-19479.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 ... | (&self) { }
}
trait AssocA {
type X: Base;
fn dummy(&self) { }
}
trait AssocB {
type Y: Base;
fn dummy(&self) { }
}
impl<T: AssocA> AssocB for T {
type Y = <T as AssocA>::X;
}
fn main() {}
| dummy | identifier_name |
issue-19479.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 ... |
}
trait AssocB {
type Y: Base;
fn dummy(&self) { }
}
impl<T: AssocA> AssocB for T {
type Y = <T as AssocA>::X;
}
fn main() {}
| { } | identifier_body |
exchange.rs | //! The exchange pattern distributes pushed data between many target pushees.
use {Push, Data};
use dataflow::channels::Content;
use abomonation::Abomonation;
// TODO : Software write combining
/// Distributes records among target pushees according to a distribution function.
pub struct Exchange<T, D, P: Push<(T, Co... | let index = (((self.hash_func)(&datum)) & mask) as usize;
self.buffers[index].push(datum);
if self.buffers[index].len() == self.buffers[index].capacity() {
self.flush(index);
}
... | {
// if only one pusher, no exchange
if self.pushers.len() == 1 {
self.pushers[0].push(message);
}
else {
if let Some((ref time, ref mut data)) = *message {
// if the time isn't right, flush everything.
if self.current.as_ref().map... | identifier_body |
exchange.rs | //! The exchange pattern distributes pushed data between many target pushees.
use {Push, Data};
use dataflow::channels::Content;
use abomonation::Abomonation;
// TODO : Software write combining
/// Distributes records among target pushees according to a distribution function.
pub struct Exchange<T, D, P: Push<(T, Co... | }
} | } | random_line_split |
exchange.rs | //! The exchange pattern distributes pushed data between many target pushees.
use {Push, Data};
use dataflow::channels::Content;
use abomonation::Abomonation;
// TODO : Software write combining
/// Distributes records among target pushees according to a distribution function.
pub struct Exchange<T, D, P: Push<(T, Co... | (&mut self, message: &mut Option<(T, Content<D>)>) {
// if only one pusher, no exchange
if self.pushers.len() == 1 {
self.pushers[0].push(message);
}
else {
if let Some((ref time, ref mut data)) = *message {
// if the time isn't right, flush every... | push | identifier_name |
exchange.rs | //! The exchange pattern distributes pushed data between many target pushees.
use {Push, Data};
use dataflow::channels::Content;
use abomonation::Abomonation;
// TODO : Software write combining
/// Distributes records among target pushees according to a distribution function.
pub struct Exchange<T, D, P: Push<(T, Co... |
// as a last resort, use mod (%)
else {
for datum in data.drain(..) {
let index = (((self.hash_func)(&datum)) % self.pushers.len() as u64) as usize;
self.buffers[index].push(datum);
if self.buffe... | {
let mask = (self.pushers.len() - 1) as u64;
for datum in data.drain(..) {
let index = (((self.hash_func)(&datum)) & mask) as usize;
self.buffers[index].push(datum);
if self.buffers[index].len() == self.buf... | conditional_block |
serialise.rs | /* Notice: Copyright 2016, The Care Connections Initiative c.i.c.
* Author: Charlie Fyvie-Gauld (cfg@zunautica.org)
* License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.txt)
*/
use std::mem::transmute;
use ::enums::Failure;
pub trait NetSerial : Sized {
fn serialise(&self) -> Vec<u8>;
fn deserialise(bytes: &[u8... | }
}
pub fn u32_transmute_be_arr(a: &[u8]) -> u32 {
unsafe { transmute::<[u8;4], u32>([a[3], a[2], a[1], a[0]]) }
}
pub fn u32_transmute_le_arr(a: &[u8]) -> u32 {
unsafe { transmute::<[u8;4], u32>([a[0], a[1], a[2], a[3]]) }
}
pub fn array_transmute_be_u32(d: u32) -> [u8;4] {
unsafe { transmute(d.to_be()) }
}
... | v.push(*b) | random_line_split |
serialise.rs | /* Notice: Copyright 2016, The Care Connections Initiative c.i.c.
* Author: Charlie Fyvie-Gauld (cfg@zunautica.org)
* License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.txt)
*/
use std::mem::transmute;
use ::enums::Failure;
pub trait NetSerial : Sized {
fn serialise(&self) -> Vec<u8>;
fn deserialise(bytes: &[u8... |
pub fn array_transmute_le_u32(d: u32) -> [u8;4] {
unsafe { transmute(d.to_le()) }
}
pub fn byte_slice_4array(a: &[u8]) -> [u8;4] {
[ a[0], a[1], a[2], a[3] ]
}
pub fn deserialise_bool(byte: u8) -> bool {
match byte {
0 => false,
_ => true
}
}
pub fn hex_str_to_byte(src: &[u8]) -> Option<u8> {
let mut v... | {
unsafe { transmute(d.to_be()) }
} | identifier_body |
serialise.rs | /* Notice: Copyright 2016, The Care Connections Initiative c.i.c.
* Author: Charlie Fyvie-Gauld (cfg@zunautica.org)
* License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.txt)
*/
use std::mem::transmute;
use ::enums::Failure;
pub trait NetSerial : Sized {
fn serialise(&self) -> Vec<u8>;
fn deserialise(bytes: &[u8... | (byte: u8) -> bool {
match byte {
0 => false,
_ => true
}
}
pub fn hex_str_to_byte(src: &[u8]) -> Option<u8> {
let mut val = 0;
let mut factor = 16;
for i in 0.. 2 {
val += match src[i] {
v @ 48... 57 => (v - 48) * factor,
v @ 65... 70 => (v - 55) * factor,
v @ 97... 102 => (v - 87) * factor,
... | deserialise_bool | identifier_name |
structsource0.rs | // On créé un type nommé `Borrowed` qui a pour attribut
// une référence d'un entier codé sur 32 bits. La référence
// doit survivre à l'instance de la structure `Borrowed`.
#[derive(Debug)]
struct Borrowed<'a>(&'a i32);
// Même combat, ces deux références doivent survivre à l'instance
// (ou aux instances) de la s... | Ref(&'a i32),
}
fn main() {
let x = 18;
let y = 15;
let single = Borrowed(&x);
let double = NamedBorrowed { x: &x, y: &y };
let reference = Either::Ref(&x);
let number = Either::Num(y);
println!("x is borrowed in {:?}", single);
println!("x and y are borrowed in {:?}", double);
... | 32),
| identifier_name |
structsource0.rs | // On créé un type nommé `Borrowed` qui a pour attribut
// une référence d'un entier codé sur 32 bits. La référence
// doit survivre à l'instance de la structure `Borrowed`.
#[derive(Debug)]
struct Borrowed<'a>(&'a i32);
// Même combat, ces deux références doivent survivre à l'instance
// (ou aux instances) de la s... | Ref(&'a i32),
}
fn main() {
let x = 18;
let y = 15;
let single = Borrowed(&x);
let double = NamedBorrowed { x: &x, y: &y };
let reference = Either::Ref(&x);
let number = Either::Num(y);
println!("x is borrowed in {:?}", single);
println!("x and y are borrowed in {:?}", double);... | Num(i32), | random_line_split |
lib.rs | pub use platform::*;
pub type Handle = *const std::os::raw::c_void;
pub type Error = Box<dyn std::error::Error>;
pub const CURRENT_PROCESS: Handle = 0 as Handle;
#[cfg(unix)]
mod platform {
use super::{Error, Handle, CURRENT_PROCESS};
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int, c_void... | if handle.is_null() {
Err(format!("{:?}", CStr::from_ptr(dlerror())).into())
} else {
Ok(handle)
}
}
pub unsafe fn free_library(handle: Handle) -> Result<(), Error> {
if dlclose(handle) == 0 {
Ok(())
} else {
Err(format!("{... | random_line_split | |
lib.rs | pub use platform::*;
pub type Handle = *const std::os::raw::c_void;
pub type Error = Box<dyn std::error::Error>;
pub const CURRENT_PROCESS: Handle = 0 as Handle;
#[cfg(unix)]
mod platform {
use super::{Error, Handle, CURRENT_PROCESS};
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int, c_void... |
}
pub unsafe fn free_library(handle: Handle) -> Result<(), Error> {
if FreeLibrary(handle)!= 0 {
Ok(())
} else {
Err(format!("Could not free library (err={:08X})", GetLastError()).into())
}
}
pub unsafe fn find_symbol(handle: Handle, name: &str) -> Resu... | {
Ok(handle)
} | conditional_block |
lib.rs | pub use platform::*;
pub type Handle = *const std::os::raw::c_void;
pub type Error = Box<dyn std::error::Error>;
pub const CURRENT_PROCESS: Handle = 0 as Handle;
#[cfg(unix)]
mod platform {
use super::{Error, Handle, CURRENT_PROCESS};
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int, c_void... |
pub unsafe fn find_symbol(handle: Handle, name: &str) -> Result<*const c_void, Error> {
let cname = CString::new(name).unwrap();
let ptr = GetProcAddress(handle, cname.as_ptr() as *const c_char);
if ptr.is_null() {
Err(format!("Could not find {} (err={:08X})", name, GetLastErro... | {
if FreeLibrary(handle) != 0 {
Ok(())
} else {
Err(format!("Could not free library (err={:08X})", GetLastError()).into())
}
} | identifier_body |
lib.rs | pub use platform::*;
pub type Handle = *const std::os::raw::c_void;
pub type Error = Box<dyn std::error::Error>;
pub const CURRENT_PROCESS: Handle = 0 as Handle;
#[cfg(unix)]
mod platform {
use super::{Error, Handle, CURRENT_PROCESS};
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int, c_void... | (handle: Handle) -> Result<(), Error> {
if FreeLibrary(handle)!= 0 {
Ok(())
} else {
Err(format!("Could not free library (err={:08X})", GetLastError()).into())
}
}
pub unsafe fn find_symbol(handle: Handle, name: &str) -> Result<*const c_void, Error> {
let... | free_library | identifier_name |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... | else {Inconsistent}
}
}
}
impl<T> Drop for Queue<T> {
fn drop(&mut self) {
unsafe {
let mut cur = *self.tail.get();
while!cur.is_null() {
let next = (*cur).next.load(Ordering::Relaxed);
let _: Box<Node<T>> = mem::transmute(cur);
... | {Empty} | conditional_block |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... | (&mut self) {
unsafe {
let mut cur = *self.tail.get();
while!cur.is_null() {
let next = (*cur).next.load(Ordering::Relaxed);
let _: Box<Node<T>> = mem::transmute(cur);
cur = next;
}
}
}
}
| drop | identifier_name |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or impli... | random_line_split | |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... |
/// Pushes a new value onto this queue.
pub fn push(&self, t: T) {
unsafe {
let n = Node::new(Some(t));
let prev = self.head.swap(n, Ordering::AcqRel);
(*prev).next.store(n, Ordering::Release);
}
}
/// Pops some data from this queue.
///
///... | {
let stub = unsafe { Node::new(None) };
Queue {
head: AtomicPtr::new(stub),
tail: UnsafeCell::new(stub),
}
} | identifier_body |
pod_account.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... | balance: Diff::Born(x.balance),
nonce: Diff::Born(x.nonce),
code: Diff::Born(x.code.as_ref().expect("account is newly created; newly created accounts must be given code; all caches should remain in place; qed").clone()),
storage: x.storage.iter().map(|(k, v)| (k.clone(), Diff::Born(v.clone()))).collect(),
... | (None, Some(x)) => Some(AccountDiff { | random_line_split |
pod_account.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... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "(bal={}; nonce={}; code={} bytes, #{}; storage={} items)",
self.balance,
self.nonce,
self.code.as_ref().map_or(0, |c| c.len()),
self.code.as_ref().map_or_else(H256::new, |c| c.sha3()),
self.storage.len(),
)
}
}
/// Determine difference bet... | fmt | identifier_name |
pod_account.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... |
/// Returns the RLP for this account.
pub fn rlp(&self) -> Bytes {
let mut stream = RlpStream::new_list(4);
stream.append(&self.nonce);
stream.append(&self.balance);
stream.append(&sec_trie_root(self.storage.iter().map(|(k, v)| (k.to_vec(), rlp::encode(&U256::from(&**v)).to_vec())).collect()));
stream.app... | {
PodAccount {
balance: *acc.balance(),
nonce: *acc.nonce(),
storage: acc.storage_changes().iter().fold(BTreeMap::new(), |mut m, (k, v)| {m.insert(k.clone(), v.clone()); m}),
code: acc.code().map(|x| x.to_vec()),
}
} | identifier_body |
walk.rs | use super::tree::*;
use super::super::Graph;
use super::super::dominators::Dominators;
use super::super::node_vec::NodeVec;
use std::collections::HashSet;
use std::default::Default;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum NodeState {
NotYetStarted,
InProgress(Option<LoopId>),
FinishedHeadWalk,
... | (&mut self, mut loop_id: LoopId, successor: G::Node) {
match self.loop_tree.loop_id(successor) {
Some(successor_loop_id) => {
// If the successor's loop is an outer-loop of ours,
// then this is an exit from our loop and all
// intervening loops.
... | update_loop_exit | identifier_name |
walk.rs | use super::tree::*;
use super::super::Graph;
use super::super::dominators::Dominators;
use super::super::node_vec::NodeVec;
use std::collections::HashSet;
use std::default::Default;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum NodeState {
NotYetStarted,
InProgress(Option<LoopId>),
FinishedHeadWalk,
... |
}
}
self.state[node] = FinishedHeadWalk;
// Assign a loop-id to this node. This will be the innermost
// loop that we could reach.
match self.innermost(&set) {
Some(loop_id) => {
self.loop_tree.set_loop_id(node, Some(loop_id));
... | {
unreachable!()
} | conditional_block |
walk.rs | use super::tree::*;
use super::super::Graph;
use super::super::dominators::Dominators;
use super::super::node_vec::NodeVec;
use std::collections::HashSet;
use std::default::Default;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum NodeState {
NotYetStarted,
InProgress(Option<LoopId>),
FinishedHeadWalk,
... | match self.innermost(&set) {
Some(loop_id) => {
self.loop_tree.set_loop_id(node, Some(loop_id));
// Check if we are the loop head. In that case, we
// should remove ourselves from the returned set,
// since our parent in the spanning t... |
self.state[node] = FinishedHeadWalk;
// Assign a loop-id to this node. This will be the innermost
// loop that we could reach. | random_line_split |
cabi_x86_64.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... | (ty: Type,
cls: &mut [RegClass], ix: usize,
off: usize) {
let t_align = ty_align(ty);
let t_size = ty_size(ty);
let misalign = off % t_align;
if misalign!= 0 {
let mut i = off / 8;
let e = (off + t_size + 7) / 8;
while ... | classify | identifier_name |
cabi_x86_64.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... | Array => {
let len = ty.array_length();
let elt = ty.element_type();
let eltsz = ty_size(elt);
let mut i = 0;
while i < len {
classify(elt, cls, ix, off + i * eltsz);
i += 1;
... | } | random_line_split |
cabi_x86_64.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... |
_ => panic!("llregtype: unhandled class")
}
i += 1;
}
if tys.len() == 1 && tys[0].kind() == Vector {
// if the type contains only a vector, pass it as that vector.
tys[0]
} else {
Type::struct_(ccx, &tys, false)
}
}
pub fn compute_abi_info(ccx: &Crat... | {
tys.push(Type::f64(ccx));
} | conditional_block |
cabi_x86_64.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... | ArgType::direct(ty, None, None, attr)
}
}
let mut arg_tys = Vec::new();
for t in atys {
let ty = x86_64_ty(ccx, *t, |cls| cls.is_pass_byval(), Attribute::ByVal);
arg_tys.push(ty);
}
let ret_ty = if ret_def {
x86_64_ty(ccx, rty, |cls| cls.is_ret_bysret(),... | {
fn x86_64_ty<F>(ccx: &CrateContext,
ty: Type,
is_mem_cls: F,
ind_attr: Attribute)
-> ArgType where
F: FnOnce(&[RegClass]) -> bool,
{
if !ty.is_reg_ty() {
let cls = classify_ty(ty);
if is_mem... | identifier_body |
project.rs |
};
use mentat_core::{
SQLValueType,
SQLValueTypeSet,
};
use mentat_core::util::{
Either,
};
use edn::query::{
Element,
Pull,
Variable,
};
use mentat_query_algebrizer::{
AlgebraicQuery,
ColumnName,
ConjoiningClauses,
QualifiedAlias,
VariableColumn,
};
use mentat_query_s... | &Element::Pull(_) => {
},
};
// Record variables -- `(the?x)` and `?x` are different in this regard, because we don't want
// to group on variables that are corresponding-projected.
match e {
&Element::Variable(ref var) => {
outer_vari... | },
| conditional_block |
project.rs | ,
};
use mentat_core::{
SQLValueType,
SQLValueTypeSet,
};
use mentat_core::util::{
Either,
};
use edn::query::{
Element,
Pull,
Variable,
};
use mentat_query_algebrizer::{
AlgebraicQuery,
ColumnName, |
use mentat_query_sql::{
ColumnOrExpression,
GroupBy,
Name,
Projection,
ProjectedColumn,
};
use query_projector_traits::aggregates::{
SimpleAggregation,
projected_column_for_simple_aggregate,
};
use query_projector_traits::errors::{
ProjectorError,
Result,
};
use projectors::{
... | ConjoiningClauses,
QualifiedAlias,
VariableColumn,
};
| random_line_split |
project.rs | };
use mentat_core::{
SQLValueType,
SQLValueTypeSet,
};
use mentat_core::util::{
Either,
};
use edn::query::{
Element,
Pull,
Variable,
};
use mentat_query_algebrizer::{
AlgebraicQuery,
ColumnName,
ConjoiningClauses,
QualifiedAlias,
VariableColumn,
};
use mentat_query_sq... | c: &ConjoiningClauses, var: &Variable) -> Result<(ColumnOrExpression, Name)> {
cc.extracted_types
.get(var)
.cloned()
.map(|alias| {
let type_name = VariableColumn::VariableTypeTag(var.clone()).column_name();
(ColumnOrExpression::Column(alias), type_name)
})
.ok_or_else... | ndidate_type_column(c | identifier_name |
project.rs |
};
use mentat_core::{
SQLValueType,
SQLValueTypeSet,
};
use mentat_core::util::{
Either,
};
use edn::query::{
Element,
Pull,
Variable,
};
use mentat_query_algebrizer::{
AlgebraicQuery,
ColumnName,
ConjoiningClauses,
QualifiedAlias,
VariableColumn,
};
use mentat_query_s... | pub(crate) fn take_pulls(&mut self) -> Vec<PullTemplate> {
let mut out = vec![];
::std::mem::swap(&mut out, &mut self.pulls);
out
}
}
fn candidate_type_column(cc: &ConjoiningClauses, var: &Variable) -> Result<(ColumnOrExpression, Name)> {
cc.extracted_types
.get(var)
.clon... | let mut out = vec![];
::std::mem::swap(&mut out, &mut self.templates);
out
}
| identifier_body |
hmacsha512256.rs | //! `HMAC-SHA-512-256`, i.e., the first 256 bits of
//! `HMAC-SHA-512`. `HMAC-SHA-512-256` is conjectured to meet the standard notion
//! of unforgeability.
use ffi::{crypto_auth_hmacsha512256,
crypto_auth_hmacsha512256_verify,
crypto_auth_hmacsha512256_KEYBYTES,
crypto_auth_hmacsha512256... | () {
// corresponding to tests/auth.c from NaCl
// "Test Case 2" from RFC 4231
let key = Key([74, 101, 102, 101, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0]);
let c = [0x77, 0x68, 0x... | test_vector_1 | identifier_name |
hmacsha512256.rs | //! `HMAC-SHA-512-256`, i.e., the first 256 bits of
//! `HMAC-SHA-512`. `HMAC-SHA-512-256` is conjectured to meet the standard notion
//! of unforgeability.
use ffi::{crypto_auth_hmacsha512256,
crypto_auth_hmacsha512256_verify,
crypto_auth_hmacsha512256_KEYBYTES,
crypto_auth_hmacsha512256... |
}
| {
// corresponding to tests/auth.c from NaCl
// "Test Case 2" from RFC 4231
let key = Key([74, 101, 102, 101, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0]);
let c = [0x77, 0x68, 0x... | identifier_body |
hmacsha512256.rs | //! `HMAC-SHA-512`. `HMAC-SHA-512-256` is conjectured to meet the standard notion
//! of unforgeability.
use ffi::{crypto_auth_hmacsha512256,
crypto_auth_hmacsha512256_verify,
crypto_auth_hmacsha512256_KEYBYTES,
crypto_auth_hmacsha512256_BYTES};
auth_module!(crypto_auth_hmacsha512256,
... | //! `HMAC-SHA-512-256`, i.e., the first 256 bits of | random_line_split | |
enum-nullable-simplifycfg-misopt.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. | // option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(unknown_features)]
#![feature(box_syntax)]
/*!
* This is a regression test for a bug in LLVM, fixed in upstream r179587,
* where the switch instructions generated for destructuring enums
* represented with... | //
// 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 | random_line_split |
enum-nullable-simplifycfg-misopt.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 ... | <X> { Nil, Cons(X, Box<List<X>>) }
pub fn main() {
match List::Cons(10, box List::Nil) {
List::Cons(10, _) => {}
List::Nil => {}
_ => panic!()
}
}
| List | identifier_name |
enum-nullable-simplifycfg-misopt.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 ... | {
match List::Cons(10, box List::Nil) {
List::Cons(10, _) => {}
List::Nil => {}
_ => panic!()
}
} | identifier_body | |
literals.rs | // https://rustbyexample.com/cast/literals.html
// http://rust-lang-ja.org/rust-by-example/cast/literals.html
fn main() {
// Suffixed literals, their types are known at initialization
let x = 1u8;
let y = 2u32;
let z = 3f32;
// Unsuffixed literal, their types depend on how they are used
let i ... | println!("size of `i` in bytes: {}", std::mem::size_of_val(&i));
println!("size of `f` in bytes: {}", std::mem::size_of_val(&f));
} | random_line_split | |
literals.rs | // https://rustbyexample.com/cast/literals.html
// http://rust-lang-ja.org/rust-by-example/cast/literals.html
fn | () {
// Suffixed literals, their types are known at initialization
let x = 1u8;
let y = 2u32;
let z = 3f32;
// Unsuffixed literal, their types depend on how they are used
let i = 1;
let f = 1.0;
// `size_of_val` returns the size of a variable in bytes
println!("size of `x` in bytes... | main | identifier_name |
literals.rs | // https://rustbyexample.com/cast/literals.html
// http://rust-lang-ja.org/rust-by-example/cast/literals.html
fn main() | {
// Suffixed literals, their types are known at initialization
let x = 1u8;
let y = 2u32;
let z = 3f32;
// Unsuffixed literal, their types depend on how they are used
let i = 1;
let f = 1.0;
// `size_of_val` returns the size of a variable in bytes
println!("size of `x` in bytes: {... | identifier_body | |
macro_import.rs | // Copyright 2012-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-MI... |
}
impl<'a> MacroLoader<'a> {
fn load_macros<'b>(&mut self,
vi: &ast::Item,
import: Option<MacroSelection>,
reexport: MacroSelection) {
if let Some(sel) = import.as_ref() {
if sel.is_empty() && reexport.is_empty() {
... | {
// bummer... can't see macro imports inside macros.
// do nothing.
} | identifier_body |
macro_import.rs | // Copyright 2012-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-MI... |
}
if!self.span_whitelist.contains(&vi.span) {
self.sess.span_err(vi.span, "an `extern crate` loading macros must be at \
the crate root");
return;
}
let macros = self.reader.read_exported_macros(vi);
let mut seen... | {
return;
} | conditional_block |
macro_import.rs | // Copyright 2012-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-MI... | (sess: &'a Session) -> MacroLoader<'a> {
MacroLoader {
sess: sess,
span_whitelist: HashSet::new(),
reader: CrateReader::new(sess),
macros: vec![],
}
}
}
/// Read exported macros.
pub fn read_macro_defs(sess: &Session, krate: &ast::Crate) -> Vec<ast::M... | new | identifier_name |
macro_import.rs | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT | // 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 accordin... | // file at the top-level directory of this distribution and at | random_line_split |
binary_tree.rs | // Copyright (c) 2015 Takeru Ohta <phjgt308@gmail.com>
//
// This software is released under the MIT License,
// see the LICENSE file at the top-level directory.
extern crate dawg;
use dawg::binary_tree::Builder;
#[test]
fn build() |
#[test]
fn search_common_prefix() {
let trie = words()
.iter()
.fold(Builder::new(), |mut b, w| {
b.insert(w.bytes()).ok().unwrap();
b
})
.finish();
assert_eq!(0, trie.search_common_prefix("... | {
let mut b = Builder::new();
for w in words().iter() {
assert!(b.insert(w.bytes()).is_ok());
}
assert_eq!(words().len(), b.finish().len());
} | identifier_body |
binary_tree.rs | // Copyright (c) 2015 Takeru Ohta <phjgt308@gmail.com>
//
// This software is released under the MIT License,
// see the LICENSE file at the top-level directory.
extern crate dawg;
use dawg::binary_tree::Builder; | let mut b = Builder::new();
for w in words().iter() {
assert!(b.insert(w.bytes()).is_ok());
}
assert_eq!(words().len(), b.finish().len());
}
#[test]
fn search_common_prefix() {
let trie = words()
.iter()
.fold(Builder::new(), |mut b, w| {
... |
#[test]
fn build() { | random_line_split |
binary_tree.rs | // Copyright (c) 2015 Takeru Ohta <phjgt308@gmail.com>
//
// This software is released under the MIT License,
// see the LICENSE file at the top-level directory.
extern crate dawg;
use dawg::binary_tree::Builder;
#[test]
fn | () {
let mut b = Builder::new();
for w in words().iter() {
assert!(b.insert(w.bytes()).is_ok());
}
assert_eq!(words().len(), b.finish().len());
}
#[test]
fn search_common_prefix() {
let trie = words()
.iter()
.fold(Builder::new(), |mut b, w| {
... | build | identifier_name |
euclidext.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 https://mozilla.org/MPL/2.0/. */
use euclid::default::{Rect, Size2D};
pub trait Size2DExt {
fn to_u64(&self) -> Size2D<u64>;
}
impl Size2DEx... |
}
impl Size2DExt for Size2D<f64> {
fn to_u64(&self) -> Size2D<u64> {
self.cast()
}
}
impl Size2DExt for Size2D<u32> {
fn to_u64(&self) -> Size2D<u64> {
self.cast()
}
}
pub trait RectExt {
fn to_u64(&self) -> Rect<u64>;
}
impl RectExt for Rect<f64> {
fn to_u64(&self) -> Rect<... | {
self.cast()
} | identifier_body |
euclidext.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 https://mozilla.org/MPL/2.0/. */
|
impl Size2DExt for Size2D<f32> {
fn to_u64(&self) -> Size2D<u64> {
self.cast()
}
}
impl Size2DExt for Size2D<f64> {
fn to_u64(&self) -> Size2D<u64> {
self.cast()
}
}
impl Size2DExt for Size2D<u32> {
fn to_u64(&self) -> Size2D<u64> {
self.cast()
}
}
pub trait RectExt {... | use euclid::default::{Rect, Size2D};
pub trait Size2DExt {
fn to_u64(&self) -> Size2D<u64>;
} | random_line_split |
euclidext.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 https://mozilla.org/MPL/2.0/. */
use euclid::default::{Rect, Size2D};
pub trait Size2DExt {
fn to_u64(&self) -> Size2D<u64>;
}
impl Size2DEx... | (&self) -> Size2D<u64> {
self.cast()
}
}
impl Size2DExt for Size2D<u32> {
fn to_u64(&self) -> Size2D<u64> {
self.cast()
}
}
pub trait RectExt {
fn to_u64(&self) -> Rect<u64>;
}
impl RectExt for Rect<f64> {
fn to_u64(&self) -> Rect<u64> {
self.cast()
}
}
impl RectExt f... | to_u64 | identifier_name |
active_object.rs | // Implements http://rosettacode.org/wiki/Active_object
#![feature(std_misc)]
extern crate time;
extern crate num;
extern crate schedule_recv;
use num::traits::Zero;
use num::Float;
use std::f64::consts::PI;
use std::sync::{Arc, Mutex};
use std::time::duration::Duration;
use std::thread::{self, spawn};
use std::sync:... |
// Rust supports both shared-memory and actor models of concurrency, and the Integrator utilizes
// both. We use a Sender (actor model) to send the Integrator new functions, while we use a Mutex
// (shared-memory concurrency) to hold the result of the integration.
//
// Note that these are not the only options here--... | random_line_split | |
active_object.rs | // Implements http://rosettacode.org/wiki/Active_object
#![feature(std_misc)]
extern crate time;
extern crate num;
extern crate schedule_recv;
use num::traits::Zero;
use num::Float;
use std::f64::consts::PI;
use std::sync::{Arc, Mutex};
use std::time::duration::Duration;
use std::thread::{self, spawn};
use std::sync:... | // Rust, timers can yield Receivers that are periodically notified with an empty
// message (where the period is the frequency). This is useful because it lets us wait
// on either a tick or another type of message (in this case, a request to change the
// function we ar... | {
// We create a pipe allowing functions to be sent from tx (the sending end) to input (the
// receiving end). In order to change the function we are integrating from the task in
// which the Integrator lives, we simply send the function through tx.
let (tx, input) = channel();
... | identifier_body |
active_object.rs | // Implements http://rosettacode.org/wiki/Active_object
#![feature(std_misc)]
extern crate time;
extern crate num;
extern crate schedule_recv;
use num::traits::Zero;
use num::Float;
use std::f64::consts::PI;
use std::sync::{Arc, Mutex};
use std::time::duration::Duration;
use std::thread::{self, spawn};
use std::sync:... | () -> f64 {
let object = Integrator::new(10);
object.input(Box::new(|t: u32| {
let f = 1. / Duration::seconds(2).num_milliseconds() as f64;
(2. * PI * f * t as f64).sin()
})).ok().expect("Failed to set input");
thread::sleep_ms(2000);
object.input(Box::new(|_| 0.)).ok().expect("Faile... | integrate | identifier_name |
tcp.rs | use traits::*;
use rotor::mio::tcp::TcpStream as MioTcpStream;
use rotor::mio::tcp::Shutdown;
use netbuf::Buf;
use std::io;
pub struct TcpStream {
stream: MioTcpStream,
read_buffer: Buf,
}
impl Transport for TcpStream {
type Buffer = MioTcpStream;
/// Returns a buffer object that will write data to t... |
}
| {
debug!("writable tcp stream");
} | identifier_body |
tcp.rs | use traits::*;
use rotor::mio::tcp::TcpStream as MioTcpStream;
use rotor::mio::tcp::Shutdown;
use netbuf::Buf;
use std::io;
pub struct TcpStream {
stream: MioTcpStream,
read_buffer: Buf,
}
impl Transport for TcpStream {
type Buffer = MioTcpStream;
/// Returns a buffer object that will write data to t... | ,
_ => {
return Err(e)
},
}
},
}
}
}
/// Tells transport that "bytes" number of bytes have been read
fn consume(&mut self, bytes: usize) {
self.read_buffer.consume(byt... | {} | conditional_block |
tcp.rs | use traits::*;
use rotor::mio::tcp::TcpStream as MioTcpStream;
use rotor::mio::tcp::Shutdown;
use netbuf::Buf;
use std::io;
pub struct TcpStream {
stream: MioTcpStream,
read_buffer: Buf,
}
impl Transport for TcpStream {
type Buffer = MioTcpStream;
/// Returns a buffer object that will write data to t... | fn read(&mut self) -> io::Result<&[u8]> {
use std::io::ErrorKind::*;
let stream = &mut self.stream;
let buf = &mut self.read_buffer;
loop {
match buf.read_from(stream) {
Ok(_) => {},
Err(e) => {
match e.kind() {
... | random_line_split | |
tcp.rs | use traits::*;
use rotor::mio::tcp::TcpStream as MioTcpStream;
use rotor::mio::tcp::Shutdown;
use netbuf::Buf;
use std::io;
pub struct | {
stream: MioTcpStream,
read_buffer: Buf,
}
impl Transport for TcpStream {
type Buffer = MioTcpStream;
/// Returns a buffer object that will write data to the underlying socket. This is used by the
/// Codecs in order to efficiently write data without copying.
fn buffer(&mut self) -> &mut Sel... | TcpStream | identifier_name |
persistent_list.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 persistent, thread-safe singly-linked list.
use std::sync::Arc;
pub struct PersistentList<T> {
head: P... | }
}
}
pub struct PersistentListIterator<'a, T> where T: 'a + Send + Sync {
entry: Option<&'a PersistentListEntry<T>>,
}
impl<'a, T> Iterator for PersistentListIterator<'a, T> where T: Send + Sync +'static {
type Item = &'a T;
#[inline]
fn next(&mut self) -> Option<&'a T> {
let ent... | // This establishes the persistent nature of this list: we can clone a list by just cloning
// its head.
PersistentList {
head: self.head.clone(),
length: self.length, | random_line_split |
persistent_list.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 persistent, thread-safe singly-linked list.
use std::sync::Arc;
pub struct PersistentList<T> {
head: P... | (&self) -> PersistentListIterator<T> {
// This could clone (and would not need the lifetime if it did), but then it would incur
// atomic operations on every call to `.next()`. Bad.
PersistentListIterator {
entry: self.head.as_ref().map(|head| &**head),
}
}
}
impl<T> Clo... | iter | 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/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... |
/// Data needed to construct a script thread.
///
/// NB: *DO NOT* add any Senders or Receivers here! pcwalton will have to rewrite your code if you
/// do! Use IPC senders and receivers instead.
pub struct InitialScriptState {
/// The ID of the pipeline with which this script thread is associated.
pub id: Pi... | {
Length::new(time::precise_time_ns())
} | 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... | (pub IpcSender<TimerEvent>,
pub TimerSource,
pub TimerEventId,
pub MsDuration);
/// Notifies the script thread to fire due timers.
/// TimerSource must be FromWindow when dispatched to ScriptThread and
/// must be FromWorker when di... | TimerEventRequest | 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/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | IconChange(String, String, String),
/// Sent when the browser `<iframe>` has reached the server.
Connected,
/// Sent when the browser `<iframe>` has finished loading all its assets.
LoadEnd,
/// Sent when the browser `<iframe>` starts to load a new page.
LoadStart,
/// Sent when a browse... | Error,
/// Sent when the favicon of a browser `<iframe>` changes. | random_line_split |
index.rs | use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use rustc_serialize::json;
use core::dependency::{Dependency, DependencyInner, Kind};
use core::{SourceId, Summary, PackageId, Registry};
use sources::registry::{RegistryPackage, RegistryDependency, INDEX_LOCK}; |
pub struct RegistryIndex<'cfg> {
source_id: SourceId,
path: Filesystem,
cache: HashMap<String, Vec<(Summary, bool)>>,
hashes: HashMap<(String, String), String>, // (name, vers) => cksum
config: &'cfg Config,
locked: bool,
}
impl<'cfg> RegistryIndex<'cfg> {
pub fn new(id: &SourceId,
... | use util::{CargoResult, ChainError, internal, Filesystem, Config}; | random_line_split |
index.rs | use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use rustc_serialize::json;
use core::dependency::{Dependency, DependencyInner, Kind};
use core::{SourceId, Summary, PackageId, Registry};
use sources::registry::{RegistryPackage, RegistryDependency, INDEX_LOCK};
use util::... | (&mut self, name: &str) -> CargoResult<&Vec<(Summary, bool)>> {
if self.cache.contains_key(name) {
return Ok(self.cache.get(name).unwrap());
}
let summaries = self.load_summaries(name)?;
let summaries = summaries.into_iter().filter(|summary| {
summary.0.package_id... | summaries | identifier_name |
index.rs | use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use rustc_serialize::json;
use core::dependency::{Dependency, DependencyInner, Kind};
use core::{SourceId, Summary, PackageId, Registry};
use sources::registry::{RegistryPackage, RegistryDependency, INDEX_LOCK};
use util::... | let path = match fs_name.len() {
1 => path.join("1").join(&fs_name),
2 => path.join("2").join(&fs_name),
3 => path.join("3").join(&fs_name[..1]).join(&fs_name),
_ => path.join(&fs_name[0..2])
.join(&fs_name[2..4])
.join(&fs_... | {
let (path, _lock) = if self.locked {
let lock = self.path.open_ro(Path::new(INDEX_LOCK),
self.config,
"the registry index");
match lock {
Ok(lock) => {
(lock.path().par... | identifier_body |
string_list.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 libc::{c_int};
use std::slice;
use string::cef_string_utf16_set;
use types::{cef_string_list_t,cef_string_t};
... |
#[no_mangle]
pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int {
unsafe {
if lt.is_null() { return 0; }
(*lt).len() as c_int
}
}
#[no_mangle]
pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *const cef_string_t) {
unsafe {
if lt... | {
Box::into_raw(box vec!())
} | identifier_body |
string_list.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 libc::{c_int};
use std::slice;
use string::cef_string_utf16_set;
use types::{cef_string_list_t,cef_string_t};
... | (lt: *mut cef_string_list_t) -> *mut cef_string_list_t {
unsafe {
if lt.is_null() { return 0 as *mut cef_string_list_t; }
let copy = (*lt).clone();
Box::into_raw(box copy)
}
}
| cef_string_list_copy | identifier_name |
string_list.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 libc::{c_int};
use std::slice;
use string::cef_string_utf16_set;
use types::{cef_string_list_t,cef_string_t};
... |
let ref string = (*lt)[index as usize];
let utf16_chars: Vec<u16> = Utf16Encoder::new(string.chars()).collect();
cef_string_utf16_set(utf16_chars.as_ptr(), utf16_chars.len() as u64, value, 1)
}
}
#[no_mangle]
pub extern "C" fn cef_string_list_clear(lt: *mut cef_string_list_t) {
unsafe ... | { return 0; } | conditional_block |
string_list.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 libc::{c_int};
use std::slice;
use string::cef_string_utf16_set;
use types::{cef_string_list_t,cef_string_t};
... | pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int {
unsafe {
if lt.is_null() { return 0; }
(*lt).len() as c_int
}
}
#[no_mangle]
pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *const cef_string_t) {
unsafe {
if lt.is_null() { re... | #[no_mangle] | random_line_split |
coord_units.rs | //! `userSpaceOnUse` or `objectBoundingBox` values.
use cssparser::Parser;
use crate::error::*;
use crate::parsers::Parse;
/// Defines the units to be used for things that can consider a
/// coordinate system in terms of the current transformation, or in
/// terms of the current object's bounding box.
#[derive(Debug... |
#[test]
fn converts_to_coord_units() {
assert_eq!(
CoordUnits::from(MyUnits(CoordUnits::ObjectBoundingBox)),
CoordUnits::ObjectBoundingBox
);
}
} | random_line_split | |
coord_units.rs | //! `userSpaceOnUse` or `objectBoundingBox` values.
use cssparser::Parser;
use crate::error::*;
use crate::parsers::Parse;
/// Defines the units to be used for things that can consider a
/// coordinate system in terms of the current transformation, or in
/// terms of the current object's bounding box.
#[derive(Debug... | () {
assert!(MyUnits::parse_str("").is_err());
assert!(MyUnits::parse_str("foo").is_err());
}
#[test]
fn parses_paint_server_units() {
assert_eq!(
MyUnits::parse_str("userSpaceOnUse").unwrap(),
MyUnits(CoordUnits::UserSpaceOnUse)
);
assert_eq!... | parsing_invalid_strings_yields_error | identifier_name |
coord_units.rs | //! `userSpaceOnUse` or `objectBoundingBox` values.
use cssparser::Parser;
use crate::error::*;
use crate::parsers::Parse;
/// Defines the units to be used for things that can consider a
/// coordinate system in terms of the current transformation, or in
/// terms of the current object's bounding box.
#[derive(Debug... |
#[test]
fn has_correct_default() {
assert_eq!(MyUnits::default(), MyUnits(CoordUnits::ObjectBoundingBox));
}
#[test]
fn converts_to_coord_units() {
assert_eq!(
CoordUnits::from(MyUnits(CoordUnits::ObjectBoundingBox)),
CoordUnits::ObjectBoundingBox
)... | {
assert_eq!(
MyUnits::parse_str("userSpaceOnUse").unwrap(),
MyUnits(CoordUnits::UserSpaceOnUse)
);
assert_eq!(
MyUnits::parse_str("objectBoundingBox").unwrap(),
MyUnits(CoordUnits::ObjectBoundingBox)
);
} | identifier_body |
fileapi.rs | // Copyright © 2015, Peter Atashian
// Licensed under the MIT License <LICENSE.md>
//! ApiSet Contract for api-ms-win-core-file-l1
pub const CREATE_NEW: ::DWORD = 1;
pub const CREATE_ALWAYS: ::DWORD = 2;
pub const OPEN_EXISTING: ::DWORD = 3;
pub const OPEN_ALWAYS: ::DWORD = 4;
pub const TRUNCATE_EXISTING: ::DWORD = 5;
... | {
pub dwFileAttributes: ::DWORD,
pub ftCreationTime: ::FILETIME,
pub ftLastAccessTime: ::FILETIME,
pub ftLastWriteTime: ::FILETIME,
pub nFileSizeHigh: ::DWORD,
pub nFileSizeLow: ::DWORD,
}
pub type LPWIN32_FILE_ATTRIBUTE_DATA = *mut WIN32_FILE_ATTRIBUTE_DATA;
#[repr(C)] #[derive(Clone, Copy, Deb... | IN32_FILE_ATTRIBUTE_DATA | identifier_name |
fileapi.rs | // Copyright © 2015, Peter Atashian
// Licensed under the MIT License <LICENSE.md>
//! ApiSet Contract for api-ms-win-core-file-l1
pub const CREATE_NEW: ::DWORD = 1;
pub const CREATE_ALWAYS: ::DWORD = 2;
pub const OPEN_EXISTING: ::DWORD = 3;
pub const OPEN_ALWAYS: ::DWORD = 4;
pub const TRUNCATE_EXISTING: ::DWORD = 5;
... | pub struct CREATEFILE2_EXTENDED_PARAMETERS {
pub dwSize: ::DWORD,
pub dwFileAttributes: ::DWORD,
pub dwFileFlags: ::DWORD,
pub dwSecurityQosFlags: ::DWORD,
pub lpSecurityAttributes: ::LPSECURITY_ATTRIBUTES,
pub hTemplateFile: ::HANDLE,
}
pub type PCREATEFILE2_EXTENDED_PARAMETERS = *mut CREATEFIL... | pub type PBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION;
pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION;
#[repr(C)] #[derive(Clone, Copy, Debug)] | random_line_split |
main.rs | use std::io::BufReader;
use std::io::BufRead;
use std::path::Path;
use std::fs::OpenOptions;
use std::io::BufWriter;
use std::io::Write;
fn | () {
let mut read_options = OpenOptions::new();
read_options.read(true);
let mut write_options = OpenOptions::new();
write_options.write(true).create(true);
/* We may use Path to read/write existing file or create
new files. Hence, no error handling for Path. Erros happen
during 'ope... | main | identifier_name |
main.rs | use std::io::BufReader;
use std::io::BufRead;
use std::path::Path;
use std::fs::OpenOptions;
use std::io::BufWriter;
use std::io::Write;
fn main() {
let mut read_options = OpenOptions::new();
read_options.read(true);
let mut write_options = OpenOptions::new();
write_options.write(true).create(true);
... | let num = line.parse::<i32>().unwrap();
match (num % 5, num % 3){
(0, 0) => writeln!(& mut writer, "Num = {}", "FizzBuzz"),
(0, _) => writeln!(& mut writer, "Num = {}", "Fizz"),
(_, 0) => writeln!(& mut writer, "Num = {}", "Buzz"),
_ => writeln!(& mu... | let line = line.unwrap(); | random_line_split |
main.rs | use std::io::BufReader;
use std::io::BufRead;
use std::path::Path;
use std::fs::OpenOptions;
use std::io::BufWriter;
use std::io::Write;
fn main() | match (num % 5, num % 3){
(0, 0) => writeln!(& mut writer, "Num = {}", "FizzBuzz"),
(0, _) => writeln!(& mut writer, "Num = {}", "Fizz"),
(_, 0) => writeln!(& mut writer, "Num = {}", "Buzz"),
_ => writeln!(& mut writer, "Num = {}", num)
};
}
}
| {
let mut read_options = OpenOptions::new();
read_options.read(true);
let mut write_options = OpenOptions::new();
write_options.write(true).create(true);
/* We may use Path to read/write existing file or create
new files. Hence, no error handling for Path. Erros happen
during 'open' ... | identifier_body |
constant_offsets.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
use core::hash::{Hash, Hasher};
use pyo3::class::basic::CompareOp;
use pyo3::prelude::*;
use pyo3::PyObjectProtocol;
use std::collections::hash_map::DefaultHasher;
/// Contains the offsets of the displacement and immediate.... | (&self) -> u32 {
self.offsets.immediate_offset2() as u32
}
/// int: (``u32``) Size in bytes of the second immediate, or 0 if there's no second immediate
#[getter]
fn immediate_size2(&self) -> u32 {
self.offsets.immediate_size2() as u32
}
/// bool: ``True`` if :class:`ConstantOffsets.displacement_offset` and... | immediate_offset2 | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.