file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
mod.rs | mod case;
mod functions;
mod parse; |
pub(crate) use self::{
parse::parse,
splitter::{StatementError, StatementSplitter},
};
use shell::flow_control::Statement;
/// Parses a given statement string and return's the corresponding mapped
/// `Statement`
pub(crate) fn parse_and_validate<'a>(statement: Result<String, StatementError>) -> Statement {
... | mod splitter; | random_line_split |
to_function.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
}
impl Typed<Vec<ArgValue<'static>>, RetValue> for fn(Vec<ArgValue<'static>>) -> Result<RetValue> {
fn args(args: Vec<ArgValue<'static>>) -> Result<Vec<ArgValue<'static>>> {
Ok(args)
}
fn ret(o: RetValue) -> Result<RetValue> {
Ok(o)
}
}
impl ToFunction<Vec<ArgValue<'static>>, RetValu... | {
let handle = std::mem::transmute(fhandle);
Self::drop(handle)
} | identifier_body |
to_function.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
let arg_value = ArgValue::from_tvm_value(value, tcode as u32);
local_args.push(arg_value);
}
// Ref-count be 2.
let rv = match Self::call(resource_handle, local_args) {
Ok(v) => v,
Err(msg) => {
ret... | {
check_call!(ffi::TVMCbArgToReturn(
&mut value as *mut _,
&mut tcode as *mut _
));
} | conditional_block |
to_function.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | Self: Typed<I, O>,
{
let mut fhandle = ptr::null_mut() as ffi::TVMFunctionHandle;
let resource_handle = self.into_raw();
check_call!(ffi::TVMFuncCreateFromCFunc(
Some(Self::tvm_callback),
resource_handle as *mut _,
None, // Some(Self::tvm_finalize... | random_line_split | |
to_function.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | () {
fn two_arg(i: i32, j: i32) -> i32 {
i + j
}
let good = call(two_arg, vec![3.into(), 4.into()]).unwrap();
assert_eq!(i32::try_from(good).unwrap(), 7);
}
}
| test_to_function2 | identifier_name |
unsized2.rs | // run-pass
#![allow(unconditional_recursion)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// Test sized-ness checking in substitution.
use std::marker;
// Unbounded.
fn f1<X:?Sized>(x: &X) {
f1::<X>(x);
}
fn f2<X>(x: &X) {
f1::<X>(x);
f2::<X>(x);
}
// Bounded.
trait T { ... | }
impl T3 for S {
fn f() -> Box<S> {
Box::new(S)
}
}
fn f7<X:?Sized+T3>(x: &X) {
// This is valid, but the unsized bound on X is irrelevant because any type
// which implements T3 must have statically known size.
let _: Box<X> = T3::f();
}
trait T4<X> {
fn dummy(&self) { }
fn m1(&se... | }
trait T3 {
fn f() -> Box<Self>; | random_line_split |
unsized2.rs | // run-pass
#![allow(unconditional_recursion)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// Test sized-ness checking in substitution.
use std::marker;
// Unbounded.
fn f1<X:?Sized>(x: &X) {
f1::<X>(x);
}
fn f2<X>(x: &X) {
f1::<X>(x);
f2::<X>(x);
}
// Bounded.
trait T { ... |
// Self type.
trait T2 {
fn f() -> Box<Self>;
}
struct S;
impl T2 for S {
fn f() -> Box<S> {
Box::new(S)
}
}
fn f5<X:?Sized+T2>(x: &X) {
let _: Box<X> = T2::f();
}
fn f6<X: T2>(x: &X) {
let _: Box<X> = T2::f();
}
trait T3 {
fn f() -> Box<Self>;
}
impl T3 for S {
fn f() -> Box<S> {... | {
f3::<X>(x);
f4::<X>(x);
} | identifier_body |
unsized2.rs | // run-pass
#![allow(unconditional_recursion)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// Test sized-ness checking in substitution.
use std::marker;
// Unbounded.
fn f1<X:?Sized>(x: &X) {
f1::<X>(x);
}
fn f2<X>(x: &X) {
f1::<X>(x);
f2::<X>(x);
}
// Bounded.
trait T { ... | <X:?Sized+T3>(x: &X) {
// This is valid, but the unsized bound on X is irrelevant because any type
// which implements T3 must have statically known size.
let _: Box<X> = T3::f();
}
trait T4<X> {
fn dummy(&self) { }
fn m1(&self, x: &dyn T4<X>, y: X);
fn m2(&self, x: &dyn T5<X>, y: X);
}
trait T... | f7 | identifier_name |
english.rs | #![allow(dead_code)]
use std::convert::From;
use super::frequency_analysis::Histogram;
use super::break_xor_cipher;
use num_rational::Ratio;
pub const FREQUENCY_LIST: [(u8, usize); 53] =
[(b'E', 1041442), (b'e', 1041442), (b'T', 0729357), (b't', 0729357),
(b'A', 0651738), (b'a', 0651738), (b'O', 059... | (cipher_text: &str) -> u8 {
// Converting the frequency table to a histogram every time to score a string is really expensive,
// but I don't know of a better way to do it.
// TODO: Find a better way to do this.
let frequency_table = Histogram::from(FREQUENCY_LIST.as_ref());
let charset = (0x00..0xF... | most_likely_char | identifier_name |
english.rs | #![allow(dead_code)]
use std::convert::From;
use super::frequency_analysis::Histogram;
use super::break_xor_cipher;
use num_rational::Ratio;
pub const FREQUENCY_LIST: [(u8, usize); 53] =
[(b'E', 1041442), (b'e', 1041442), (b'T', 0729357), (b't', 0729357),
(b'A', 0651738), (b'a', 0651738), (b'O', 059... | let frequency_table = Histogram::from(FREQUENCY_LIST.as_ref());
let charset = (0x00..0xFF).collect::<Vec<u8>>();
break_xor_cipher::break_xor_char(&frequency_table, charset.as_ref(), cipher_text).0
}
pub fn most_likely_char(cipher_text: &str) -> u8 {
// Converting the frequency table to a histogram eve... | random_line_split | |
english.rs | #![allow(dead_code)]
use std::convert::From;
use super::frequency_analysis::Histogram;
use super::break_xor_cipher;
use num_rational::Ratio;
pub const FREQUENCY_LIST: [(u8, usize); 53] =
[(b'E', 1041442), (b'e', 1041442), (b'T', 0729357), (b't', 0729357),
(b'A', 0651738), (b'a', 0651738), (b'O', 059... |
pub fn most_likely_key(cipher_text: &[u8], keysize: usize) -> Vec<u8> {
let model = Histogram::from(FREQUENCY_LIST.as_ref());
let charset = (0x00..0xFF).collect::<Vec<u8>>();
break_xor_cipher::break_xor_key(&model, charset.as_ref(), keysize, cipher_text)
}
| {
let model = Histogram::from(FREQUENCY_LIST.as_ref());
break_xor_cipher::score_with(&model, cipher_text)
} | identifier_body |
rand_impls.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 ... | /// and `Open01` for the open interval `(0,1)`.
#[inline]
fn rand<R: Rng>(rng: &mut R) -> $ty {
// using any more than `mantissa_bits` bits will
// cause (e.g.) 0xffff_ffff to correspond to 1
// exactly, so we ne... | /// interval `[0,1)`.
///
/// See `Closed01` for the closed interval `[0,1]`, | random_line_split |
rand_impls.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 ... |
}
impl Rand for bool {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> bool {
rng.gen::<u8>() & 1 == 1
}
}
macro_rules! tuple_impl {
// use variables to indicate the arity of the tuple
($($tyvar:ident),* ) => {
// the trailing commas are for the 1 tuple
impl<
$( $tyv... | {
// a char is 21 bits
static CHAR_MASK: u32 = 0x001f_ffff;
loop {
// Rejection sampling. About 0.2% of numbers with at most
// 21-bits are invalid codepoints (surrogates), so this
// will succeed first go almost every time.
match char::from_u32(rn... | identifier_body |
rand_impls.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 ... | <R: Rng>(rng: &mut R) -> i64 {
rng.next_u64() as i64
}
}
impl Rand for uint {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> uint {
if uint::bits == 32 {
rng.gen::<u32>() as uint
} else {
rng.gen::<u64>() as uint
}
}
}
impl Rand for u8 {
#[inline]... | rand | identifier_name |
rand_impls.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 ... |
}
}
impl<T: Rand> Rand for ~T {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> ~T { ~rng.gen() }
}
impl<T: Rand +'static> Rand for @T {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> @T { @rng.gen() }
}
#[cfg(test)]
mod tests {
use prelude::*;
use rand::{Rng, task_rng, Open01, Closed01};
stru... | {
None
} | conditional_block |
opts.rs | _borders: bool,
/// True if we should paint tiles with overlays based on which thread painted them.
pub show_debug_parallel_paint: bool,
/// True if we should paint borders around flows based on which thread painted them.
pub show_debug_parallel_layout: bool,
/// True if we should paint tiles a r... | /// Profile which events script tasks spend their time on.
pub profile_script_events: bool,
/// Enable all heartbeats for profiling.
pub profile_heartbeats: bool,
/// Paint borders along layer and tile boundaries.
pub show_compositor_borders: bool,
/// Paint borders along fragment boundar... | random_line_split | |
opts.rs | debug_options.dump_display_list_optimized = true,
"dump-layer-tree" => debug_options.dump_layer_tree = true,
"relayout-event" => debug_options.relayout_event = true,
"profile-tasks" => debug_options.profile_tasks = true,
"profile-script-events" => debug_o... | defaults(opt | identifier_name | |
cleanup-arm-conditional.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | { x: int }
impl Test {
fn get_x(&self) -> Option<Box<int>> {
Some(box self.x)
}
}
fn do_something(t: &Test) -> int {
// The cleanup scope for the result of `t.get_x()` should be the
// arm itself and not the match, otherwise we'll (potentially) get
// a crash trying to free an uninitiali... | Test | identifier_name |
cleanup-arm-conditional.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | Some(box self.x)
}
}
fn do_something(t: &Test) -> int {
// The cleanup scope for the result of `t.get_x()` should be the
// arm itself and not the match, otherwise we'll (potentially) get
// a crash trying to free an uninitialized stack slot.
match t {
&Test { x: 2 } if t.get_x().... |
struct Test { x: int }
impl Test {
fn get_x(&self) -> Option<Box<int>> { | random_line_split |
cleanup-arm-conditional.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
_ => { 22 }
}
}
pub fn main() {
let t = Test { x: 1 };
do_something(&t);
}
| {
t.x * 2
} | conditional_block |
mat.rs | use std::ops::{Add, Sub};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32
}
impl Add for Vec3 {
type Output = Vec3;
fn add(self, rhs: Vec3) -> Vec3 {
Vec3 {
x: self.x + rhs.x,
y: self.y + rhs.y,
z: self.z + r... |
}
#[test]
fn check_quadratic() {
assert_eq!(solve_quadratic(1.0, -2.0, -3.0), Some((3.0, -1.0)));
assert_eq!(solve_quadratic(4.0, -24.0, 36.0), Some((3.0, 3.0)));
}
/// Angle stored in radians
#[derive(Debug, PartialEq)]
pub struct Angle(f32);
const RAD_TO_DEG: f32 = 180.0 / ::std::f32::consts::PI;
impl Ang... | { None } | conditional_block |
mat.rs | use std::ops::{Add, Sub};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32
}
impl Add for Vec3 {
type Output = Vec3;
fn add(self, rhs: Vec3) -> Vec3 {
Vec3 {
x: self.x + rhs.x,
y: self.y + rhs.y,
z: self.z + r... | (a: f32, b: f32, c: f32) -> Option<(f32,f32)> {
let det = b*b - 4.0*a*c;
if 0.0 <= det {
let detrt = det.sqrt();
Some(((-b + detrt) / (2.0 * a),
(-b - detrt) / (2.0 * a)))
} else { None }
}
#[test]
fn check_quadratic() {
assert_eq!(solve_quadratic(1.0, -2.0, -3.0), Some((3... | solve_quadratic | identifier_name |
mat.rs | use std::ops::{Add, Sub};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32
}
impl Add for Vec3 {
type Output = Vec3;
fn add(self, rhs: Vec3) -> Vec3 {
Vec3 {
x: self.x + rhs.x,
y: self.y + rhs.y,
z: self.z + r... | z: self.z * factor
}
}
pub fn norm(&self) -> f32 {
self.dot(&self).sqrt()
}
pub fn unit(&self) -> Vec3 {
self.scale(1.0 / self.norm())
}
pub fn dot(&self, rhs: &Vec3) -> f32 {
self.x * rhs.x + self.y * rhs.y + self.z * rhs.z
}
pub fn cross(&sel... |
pub fn scale(&self, factor: f32) -> Vec3 {
Vec3 {
x: self.x * factor,
y: self.y * factor, | random_line_split |
main.rs | /*
cpal (Captive Portal Auto Login).
Utility to automatically log in to a captive portal.
Copyright 2017 Sam Saint-Pettersen.
Released under the MIT License.
*/
mod config;
extern crate clioptions;
extern crate ssid;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
... |
fn display_version() {
println!("cpal v. 0.1.0");
println!("This program depends on curl (https://curl.haxx.se)");
exit(0);
}
fn display_error(program: &str, err: &str) {
println!("Error: {}.\n", err);
display_usage(program, -1);
}
fn display_config_err(err: &str) {
println!("Config Error: {}... | exit(ec);
} | random_line_split |
main.rs | /*
cpal (Captive Portal Auto Login).
Utility to automatically log in to a captive portal.
Copyright 2017 Sam Saint-Pettersen.
Released under the MIT License.
*/
mod config;
extern crate clioptions;
extern crate ssid;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
... | (err: &str) {
println!("Config Error: {}.", err);
exit(-1);
}
fn display_usage(program: &str, code: i32) {
println!("cpal (Captive Portal Auto Login).");
println!("Utility to automatically log in to a captive portal.");
println!("Copyright 2017 Sam Saint-Pettersen.");
println!("\nReleased under... | display_config_err | identifier_name |
main.rs | /*
cpal (Captive Portal Auto Login).
Utility to automatically log in to a captive portal.
Copyright 2017 Sam Saint-Pettersen.
Released under the MIT License.
*/
mod config;
extern crate clioptions;
extern crate ssid;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
... |
}
input.trim().to_owned()
}
fn get_configuration(config: &Configuration) {
println!("{:#?}", config);
}
fn get_status(config: &Configuration) {
let ssid = SSID::new();
println!("Configured SSID is {}", config.get_ssid());
if ssid.is_connected_to(config.get_ssid()) {
println!("Connecte... | {
println!("Stdin Error: {}", error);
exit(-1);
} | conditional_block |
main.rs | /*
cpal (Captive Portal Auto Login).
Utility to automatically log in to a captive portal.
Copyright 2017 Sam Saint-Pettersen.
Released under the MIT License.
*/
mod config;
extern crate clioptions;
extern crate ssid;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
... |
fn display_config_err(err: &str) {
println!("Config Error: {}.", err);
exit(-1);
}
fn display_usage(program: &str, code: i32) {
println!("cpal (Captive Portal Auto Login).");
println!("Utility to automatically log in to a captive portal.");
println!("Copyright 2017 Sam Saint-Pettersen.");
pri... | {
println!("Error: {}.\n", err);
display_usage(program, -1);
} | identifier_body |
lib.rs | // -*- coding: utf-8 -*-
// ------------------------------------------------------------------------------------------------
// Copyright © 2021, tree-sitter-c authors.
// See the LICENSE file in this repo for license details.
// ------------------------------------------------------------------------------------------... | ) {
let mut parser = tree_sitter::Parser::new();
parser
.set_language(super::language())
.expect("Error loading C grammar");
}
}
| an_load_grammar( | identifier_name |
lib.rs | // -*- coding: utf-8 -*-
// ------------------------------------------------------------------------------------------------
// Copyright © 2021, tree-sitter-c authors.
// See the LICENSE file in this repo for license details.
// ------------------------------------------------------------------------------------------... |
/// The source of the C tree-sitter grammar description.
pub const GRAMMAR: &str = include_str!("../../grammar.js");
/// The syntax highlighting query for this language.
pub const HIGHLIGHT_QUERY: &str = include_str!("../../queries/highlights.scm");
/// The content of the [`node-types.json`][] file for this grammar.... |
unsafe { tree_sitter_c() }
}
| identifier_body |
lib.rs | // -*- coding: utf-8 -*-
// ------------------------------------------------------------------------------------------------
// Copyright © 2021, tree-sitter-c authors.
// See the LICENSE file in this repo for license details.
// ------------------------------------------------------------------------------------------... | pub const HIGHLIGHT_QUERY: &str = include_str!("../../queries/highlights.scm");
/// The content of the [`node-types.json`][] file for this grammar.
///
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
pub const NODE_TYPES: &str = include_str!("../../src/node-types.json... |
/// The source of the C tree-sitter grammar description.
pub const GRAMMAR: &str = include_str!("../../grammar.js");
/// The syntax highlighting query for this language. | random_line_split |
borrowed-tuple.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... | () {
let stack_val: (i16, f32) = (-14, -19f32);
let stack_val_ref: &(i16, f32) = &stack_val;
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
let managed_val: @(i16, f32) = @(-16, -21f32);
let managed_val_ref: &(i16, f32) = managed_val;
let unique_val: ~(i16, f32) = ~(-17, -22f32);
let un... | main | identifier_name |
borrowed-tuple.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... |
// debugger:print *stack_val_ref
// check:$1 = {-14, -19}
// debugger:print *ref_to_unnamed
// check:$2 = {-15, -20}
// debugger:print *managed_val_ref
// check:$3 = {-16, -21}
// debugger:print *unique_val_ref
// check:$4 = {-17, -22}
#[allow(unused_variable)];
fn main() {
let stack_val: (i16, f32) = (-14, -... | // debugger:finish | random_line_split |
borrowed-tuple.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... |
fn zzz() {()}
| {
let stack_val: (i16, f32) = (-14, -19f32);
let stack_val_ref: &(i16, f32) = &stack_val;
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
let managed_val: @(i16, f32) = @(-16, -21f32);
let managed_val_ref: &(i16, f32) = managed_val;
let unique_val: ~(i16, f32) = ~(-17, -22f32);
let uniqu... | identifier_body |
dummy.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () -> *mut u8 {
0 as *mut u8
}
pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
intrinsics::abort()
}
pub unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
intrinsics::abort()
}
| payload | identifier_name |
dummy.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
intrinsics::abort()
}
pub unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
intrinsics::abort()
}
| {
0 as *mut u8
} | identifier_body |
dummy.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | //!
//! Right now we don't support this, so this is just stubs
use alloc::boxed::Box;
use core::any::Any;
use core::intrinsics;
pub fn payload() -> *mut u8 {
0 as *mut u8
}
pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
intrinsics::abort()
}
pub unsafe fn panic(_data: Box<dyn Any + Send>) -> ... | // except according to those terms.
//! Unwinding for wasm32 | random_line_split |
mod.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 ... | (&self) -> (Worker<T>, Stealer<T>) {
let a = Arc::new(Deque::new(self.clone()));
let b = a.clone();
(Worker { deque: a }, Stealer { deque: b })
}
fn alloc(&mut self, bits: usize) -> Box<Buffer<T>> {
unsafe {
let mut pool = self.pool.lock().unwrap();
match... | deque | identifier_name |
mod.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! A (mostly) l... | // http://rust-lang.org/COPYRIGHT. | random_line_split |
mod.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 ... |
/// Gets access to the buffer pool that this worker is attached to. This can
/// be used to create more deques which share the same buffer pool as this
/// deque.
pub fn pool<'a>(&'a self) -> &'a BufferPool<T> {
&self.deque.pool
}
}
impl<T: Send +'static> Stealer<T> {
/// Steals work ... | {
unsafe { self.deque.pop() }
} | identifier_body |
f25-abort.rs | /// Figure 10.25 Implementation of POSIX.1 abort
///
/// Status: compiles, not tested yet (assuming this function will be
/// used in the future in the book)
extern crate libc;
extern crate apue;
use libc::{SIG_DFL, SIGABRT, SIG_IGN, SIG_SETMASK};
use libc::{sigaction, fflush, sigdelset, sigfillset, getpid, kill, exi... | if action.sa_sigaction == SIG_DFL {
fflush(null_mut());
}
let mut mask = std::mem::uninitialized();
sigfillset(&mut mask); // block all signals
sigdelset(&mut mask, SIGABRT); // leave only SIGABRT through
sigprocmask(SIG_SETMASK, &mask, null_mut());
kill(getpid(), SIGABRT); // say bye... | {
// Caller can’t ignore SIGABRT, if so reset to default
action.sa_sigaction = SIG_DFL;
sigaction(SIGABRT, &action, null_mut());
}
| conditional_block |
f25-abort.rs | /// Figure 10.25 Implementation of POSIX.1 abort
///
/// Status: compiles, not tested yet (assuming this function will be
/// used in the future in the book)
extern crate libc;
extern crate apue;
use libc::{SIG_DFL, SIGABRT, SIG_IGN, SIG_SETMASK};
use libc::{sigaction, fflush, sigdelset, sigfillset, getpid, kill, exi... | // if we're here, process caught SIGABRT and returned
fflush(null_mut());
action.sa_sigaction = SIG_DFL;
sigaction(SIGABRT, &action, null_mut());
sigprocmask(SIG_SETMASK, &mask, null_mut()); // what, again? Really?
kill(getpid(), SIGABRT);
exit(1); // now THIS should now never be executed
}
... | sigdelset(&mut mask, SIGABRT); // leave only SIGABRT through
sigprocmask(SIG_SETMASK, &mask, null_mut());
kill(getpid(), SIGABRT); // say bye bye to mummy
| random_line_split |
f25-abort.rs | /// Figure 10.25 Implementation of POSIX.1 abort
///
/// Status: compiles, not tested yet (assuming this function will be
/// used in the future in the book)
extern crate libc;
extern crate apue;
use libc::{SIG_DFL, SIGABRT, SIG_IGN, SIG_SETMASK};
use libc::{sigaction, fflush, sigdelset, sigfillset, getpid, kill, exi... | () {
let mut action: sigaction = std::mem::uninitialized();
// load current signal handler and flags into action
sigaction(SIGABRT, null(), &mut action);
if action.sa_sigaction == SIG_IGN {
// Caller can’t ignore SIGABRT, if so reset to default
action.sa_sigaction = SIG_DFL;
siga... | abort | identifier_name |
f25-abort.rs | /// Figure 10.25 Implementation of POSIX.1 abort
///
/// Status: compiles, not tested yet (assuming this function will be
/// used in the future in the book)
extern crate libc;
extern crate apue;
use libc::{SIG_DFL, SIGABRT, SIG_IGN, SIG_SETMASK};
use libc::{sigaction, fflush, sigdelset, sigfillset, getpid, kill, exi... | action.sa_sigaction = SIG_DFL;
sigaction(SIGABRT, &action, null_mut());
sigprocmask(SIG_SETMASK, &mask, null_mut()); // what, again? Really?
kill(getpid(), SIGABRT);
exit(1); // now THIS should now never be executed
}
fn main() {
let _ = abort;
}
| {
let mut action: sigaction = std::mem::uninitialized();
// load current signal handler and flags into action
sigaction(SIGABRT, null(), &mut action);
if action.sa_sigaction == SIG_IGN {
// Caller can’t ignore SIGABRT, if so reset to default
action.sa_sigaction = SIG_DFL;
sigacti... | identifier_body |
issue-62007-assign-differing-fields.rs | // Double-check we didn't go too far with our resolution to issue
// #62007: assigning over a field projection (`list.1 = n;` in this
// case) should kill only borrows of `list.1`; `list.0` can *not*
// necessarily be borrowed on the next iteration through the loop.
#![allow(dead_code)]
struct List<T> {
value: T,... | else {
return result;
}
}
}
fn main() {}
| { //~ ERROR cannot borrow `list.0.next` as mutable
list.1 = n;
} | conditional_block |
issue-62007-assign-differing-fields.rs | // Double-check we didn't go too far with our resolution to issue
// #62007: assigning over a field projection (`list.1 = n;` in this
// case) should kill only borrows of `list.1`; `list.0` can *not*
// necessarily be borrowed on the next iteration through the loop.
#![allow(dead_code)]
struct List<T> {
value: T,... | fn to_refs<'a, T>(mut list: (&'a mut List<T>, &'a mut List<T>)) -> Vec<&'a mut T> {
let mut result = vec![];
loop {
result.push(&mut (list.0).value); //~ ERROR cannot borrow `list.0.value` as mutable
if let Some(n) = (list.0).next.as_mut() { //~ ERROR cannot borrow `list.0.next` as mutable
... | random_line_split | |
issue-62007-assign-differing-fields.rs | // Double-check we didn't go too far with our resolution to issue
// #62007: assigning over a field projection (`list.1 = n;` in this
// case) should kill only borrows of `list.1`; `list.0` can *not*
// necessarily be borrowed on the next iteration through the loop.
#![allow(dead_code)]
struct List<T> {
value: T,... | <'a, T>(mut list: (&'a mut List<T>, &'a mut List<T>)) -> Vec<&'a mut T> {
let mut result = vec![];
loop {
result.push(&mut (list.0).value); //~ ERROR cannot borrow `list.0.value` as mutable
if let Some(n) = (list.0).next.as_mut() { //~ ERROR cannot borrow `list.0.next` as mutable
lis... | to_refs | identifier_name |
issue-62007-assign-differing-fields.rs | // Double-check we didn't go too far with our resolution to issue
// #62007: assigning over a field projection (`list.1 = n;` in this
// case) should kill only borrows of `list.1`; `list.0` can *not*
// necessarily be borrowed on the next iteration through the loop.
#![allow(dead_code)]
struct List<T> {
value: T,... | {} | identifier_body | |
constants.rs | //or calculate only when point is traced and occupied
pub static PRECALCULATE_NORMALS:bool = true;
pub static USE_GAMMA_CORRECTION:bool = false; | pub static NEIGHBOR_RADIUS:f64 = 1.0;
//for 64 bits
//pub static BITS:u8 = 64;
//pub static MAX_LOD:u8 = 9;
//pub static BASE:u8 = 4;
//pub static MORTON_BASE:u8 = 2; //(BASE/2)
//for 8 bits
pub static BITS:u8 = 8;
pub static MAX_LOD:u8 = 21;
pub static BASE:u8 = 2;
pub static MORTON_BASE:u8 = 1; //(BASE/2) | pub static SMOOTHEN_NORMALS:bool = true;
pub static DO_CELLSHADING:bool = false;
pub static SMOOTHING_ITERATION:usize = 0;
//neighbor radius for extraction of neighboring voxels | random_line_split |
main.rs | extern crate structopt;
#[macro_use]
extern crate structopt_derive;
use structopt::StructOpt;
use std::fs::File;
use std::io::Read;
fn part1(input: &str) -> u64 {
let mut jumps = input
.lines()
.map(|line| line.parse::<i64>().expect("Could not parse line"))
.collect::<Vec<_>>();
let mut i... | () {
assert_eq!(part1("0\n3\n0\n1\n-3"), 5)
}
#[test]
fn part2_test() {
assert_eq!(part2("0\n3\n0\n1\n-3"), 10)
}
}
| part1_test | identifier_name |
main.rs | extern crate structopt;
#[macro_use]
extern crate structopt_derive;
use structopt::StructOpt;
use std::fs::File;
use std::io::Read;
fn part1(input: &str) -> u64 {
let mut jumps = input
.lines()
.map(|line| line.parse::<i64>().expect("Could not parse line"))
.collect::<Vec<_>>();
let mut i... | idx += diff;
count += 1;
}
count
}
fn part2(input: &str) -> u64 {
let mut jumps = input
.lines()
.map(|line| line.parse::<i64>().expect("Could not parse line"))
.collect::<Vec<_>>();
let mut idx: i64 = 0;
let mut count = 0;
while idx >= 0 && (idx as usize) <... | let diff = jumps[idx as usize];
jumps[idx as usize] += 1; | random_line_split |
main.rs | extern crate structopt;
#[macro_use]
extern crate structopt_derive;
use structopt::StructOpt;
use std::fs::File;
use std::io::Read;
fn part1(input: &str) -> u64 {
let mut jumps = input
.lines()
.map(|line| line.parse::<i64>().expect("Could not parse line"))
.collect::<Vec<_>>();
let mut i... |
println!("Part 1: {}", part1(&contents));
println!("Part 2: {}", part2(&contents));
}
#[derive(StructOpt, Debug)]
#[structopt(name = "day05", about = "Advent of code 2017 day 05")]
struct Opt {
#[structopt(help = "Input file")] input: String,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
... | {
let mut file = File::open(&opt.input)
.expect(&format!("file {} not found", opt.input));
file.read_to_string(&mut contents)
.expect(&format!("could not read file {}", opt.input));
} | conditional_block |
mod.rs | use crate::types::game::finishmoves::FinishMoveInformations;
use protocol_derive::{Decode, Encode};
#[derive(Clone, PartialEq, Debug, Encode, Decode)]
#[protocol(id = 6703)]
pub struct FinishMoveSetRequestMessage<'a> { | #[derive(Clone, PartialEq, Debug, Encode, Decode)]
#[protocol(id = 6704)]
pub struct FinishMoveListMessage<'a> {
pub finish_moves: std::borrow::Cow<'a, [FinishMoveInformations<'a>]>,
}
#[derive(Clone, PartialEq, Debug, Encode, Decode)]
#[protocol(id = 6702)]
pub struct FinishMoveListRequestMessage<'a> {
pub _p... | pub finish_move_id: u32,
pub finish_move_state: bool,
pub _phantom: std::marker::PhantomData<&'a ()>,
}
| random_line_split |
mod.rs | use crate::types::game::finishmoves::FinishMoveInformations;
use protocol_derive::{Decode, Encode};
#[derive(Clone, PartialEq, Debug, Encode, Decode)]
#[protocol(id = 6703)]
pub struct | <'a> {
pub finish_move_id: u32,
pub finish_move_state: bool,
pub _phantom: std::marker::PhantomData<&'a ()>,
}
#[derive(Clone, PartialEq, Debug, Encode, Decode)]
#[protocol(id = 6704)]
pub struct FinishMoveListMessage<'a> {
pub finish_moves: std::borrow::Cow<'a, [FinishMoveInformations<'a>]>,
}
#[deri... | FinishMoveSetRequestMessage | identifier_name |
mod.rs | /*!
Various BWT-DC compression models
*/
use compress::bwt::dc;
use compress::entropy::ari;
use std::io;
/// A copy of `bbb` model
pub mod bbb;
/// Old Dark-0.51 model
pub mod dark;
/// Original BWT-DC compression model
pub mod exp;
/// Raw output for debugging
pub mod raw;
/// A simplest model to compare with
pub ... | debug!("Actual: {}, Decoded: {}", dist, d2);
assert_eq!(d2, dist);
}
}
fn roundtrip_raw<M: RawModel>(mut m: M, input: &[(Symbol, SymContext)]) {
let mut eh = ari::Encoder::new(Vec::new());
m.reset();
for &(sym, ref ctx) in input.iter() {
debug... | err.unwrap();
m.reset();
let mut dh = ari::Decoder::new(io::BufReader::new(io::Cursor::new(&mem[..])));
for &(dist, ref ctx) in input.iter() {
let d2 = m.decode(ctx, &mut dh).unwrap(); | random_line_split |
mod.rs | /*!
Various BWT-DC compression models
*/
use compress::bwt::dc;
use compress::entropy::ari;
use std::io;
/// A copy of `bbb` model
pub mod bbb;
/// Old Dark-0.51 model
pub mod dark;
/// Original BWT-DC compression model
pub mod exp;
/// Raw output for debugging
pub mod raw;
/// A simplest model to compare with
pub ... | <M: DistanceModel>(m: &mut M, input: &[(Distance, dc::Context)]) {
let mut eh = ari::Encoder::new(Vec::new());
m.reset();
for &(dist, ref ctx) in input.iter() {
debug!("Encode: {}", dist);
m.encode(dist, ctx, &mut eh).unwrap();
}
let (mem, err) = eh.finish... | roundtrip_dc | identifier_name |
mod.rs | /*!
Various BWT-DC compression models
*/
use compress::bwt::dc;
use compress::entropy::ari;
use std::io;
/// A copy of `bbb` model
pub mod bbb;
/// Old Dark-0.51 model
pub mod dark;
/// Original BWT-DC compression model
pub mod exp;
/// Raw output for debugging
pub mod raw;
/// A simplest model to compare with
pub ... |
fn gen_data_dc(size: usize, max_dist: Distance) -> Vec<(Distance, dc::Context)> {
let mut rng = StdRng::new().unwrap();
(0..size).map(|_| {
let sym: Symbol = rng.gen();
let ctx = dc::Context::new(sym, 0, max_dist as usize);
(rng.gen_range(0, max_dist), ctx)
... | {
let mut eh = ari::Encoder::new(Vec::new());
m.reset();
for &(sym, ref ctx) in input.iter() {
debug!("Encode: {}", sym);
m.encode(sym, ctx, &mut eh).unwrap();
}
let (mem, err) = eh.finish();
err.unwrap();
m.reset();
let mut dh = ar... | identifier_body |
request.rs | use std::borrow::Cow;
use reqwest::{
header::{
HeaderMap as Headers,
HeaderValue,
AUTHORIZATION,
CONTENT_LENGTH,
CONTENT_TYPE,
USER_AGENT,
},
Url,
};
use reqwest::{Client, RequestBuilder as ReqwestRequestBuilder};
use tracing::instrument;
use super::{routing... | builder = builder.body(Vec::from(bytes));
}
let mut headers = Headers::with_capacity(4);
headers.insert(USER_AGENT, HeaderValue::from_static(constants::USER_AGENT));
headers
.insert(AUTHORIZATION, HeaderValue::from_str(token).map_err(HttpError::InvalidHeader)?);
... |
let mut builder = client.request(method.reqwest_method(), Url::parse(&path)?);
if let Some(bytes) = body { | random_line_split |
request.rs | use std::borrow::Cow;
use reqwest::{
header::{
HeaderMap as Headers,
HeaderValue,
AUTHORIZATION,
CONTENT_LENGTH,
CONTENT_TYPE,
USER_AGENT,
},
Url,
};
use reqwest::{Client, RequestBuilder as ReqwestRequestBuilder};
use tracing::instrument;
use super::{routing... | <'a> {
pub(super) body: Option<&'a [u8]>,
pub(super) headers: Option<Headers>,
pub(super) route: RouteInfo<'a>,
}
impl<'a> Request<'a> {
pub fn new(builder: RequestBuilder<'a>) -> Self {
let RequestBuilder {
body,
headers,
route,
} = builder;
... | Request | identifier_name |
request.rs | use std::borrow::Cow;
use reqwest::{
header::{
HeaderMap as Headers,
HeaderValue,
AUTHORIZATION,
CONTENT_LENGTH,
CONTENT_TYPE,
USER_AGENT,
},
Url,
};
use reqwest::{Client, RequestBuilder as ReqwestRequestBuilder};
use tracing::instrument;
use super::{routing... |
}
| {
&mut self.route
} | identifier_body |
request.rs | use std::borrow::Cow;
use reqwest::{
header::{
HeaderMap as Headers,
HeaderValue,
AUTHORIZATION,
CONTENT_LENGTH,
CONTENT_TYPE,
USER_AGENT,
},
Url,
};
use reqwest::{Client, RequestBuilder as ReqwestRequestBuilder};
use tracing::instrument;
use super::{routing... |
headers.insert(
CONTENT_LENGTH,
HeaderValue::from_str(&body.unwrap_or(&Vec::new()).len().to_string())
.map_err(HttpError::InvalidHeader)?,
);
if let Some(ref request_headers) = request_headers {
headers.extend(request_headers.clone());
... | {
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
} | conditional_block |
lib.rs | extern crate mtbl;
extern crate rand;
extern crate tempfile;
extern crate test;
use mtbl::{Read, Write};
use rand::distributions::{IndependentSample, Range};
use test::Bencher;
#[bench]
fn | (bench: &mut Bencher) {
let tempfile_writer = tempfile::NamedTempFile::new().unwrap();
let tempfile_reader = tempfile_writer.reopen().unwrap();
let n_keys = 100000;
{
let mut writer = mtbl::Writer::create_from_file(tempfile_writer).unwrap();
for i in 0..n_keys {
writer.add(fo... | bench_get | identifier_name |
lib.rs | extern crate mtbl;
extern crate rand;
extern crate tempfile;
extern crate test;
use mtbl::{Read, Write};
use rand::distributions::{IndependentSample, Range};
use test::Bencher;
#[bench]
fn bench_get(bench: &mut Bencher) | {
let tempfile_writer = tempfile::NamedTempFile::new().unwrap();
let tempfile_reader = tempfile_writer.reopen().unwrap();
let n_keys = 100000;
{
let mut writer = mtbl::Writer::create_from_file(tempfile_writer).unwrap();
for i in 0..n_keys {
writer.add(format!("{:09}", i),
... | identifier_body | |
lib.rs | extern crate mtbl;
extern crate rand;
extern crate tempfile;
extern crate test;
use mtbl::{Read, Write};
use rand::distributions::{IndependentSample, Range};
use test::Bencher;
#[bench] | let mut writer = mtbl::Writer::create_from_file(tempfile_writer).unwrap();
for i in 0..n_keys {
writer.add(format!("{:09}", i),
format!("val{:09}", i)).unwrap();
}
}
let reader = mtbl::Reader::open_from_file(&tempfile_reader).unwrap();
let mut rng =... | fn bench_get(bench: &mut Bencher) {
let tempfile_writer = tempfile::NamedTempFile::new().unwrap();
let tempfile_reader = tempfile_writer.reopen().unwrap();
let n_keys = 100000;
{ | random_line_split |
bitmap.rs | //
// Copyright 2017 yvt, all rights reserved.
//
// Licensed under the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>. This file may
// not be copied, modified,or distributed except
// according to those terms.
//
#![feature(test)]
extern crate test;
extern crate unreachable;
extern crate xalloc;
... | let mut v: Vec<_> = (0..512).map(|_| None).collect();
let mut sa = BitmapAlloc::new(512 * 4);
b.iter(|| unsafe {
let mut r = Xorshift32(0x11451419);
for _ in 0..65536 {
let i = ((r.next() >> 8) & 511) as usize;
if v[i].is_some() {
sa.dealloc_relaxed(v[... | #[bench]
fn bitmap_4_random(b: &mut Bencher) { | random_line_split |
bitmap.rs | //
// Copyright 2017 yvt, all rights reserved.
//
// Licensed under the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>. This file may
// not be copied, modified,or distributed except
// according to those terms.
//
#![feature(test)]
extern crate test;
extern crate unreachable;
extern crate xalloc;
... |
}
});
}
#[bench]
fn bitmap_4_random(b: &mut Bencher) {
let mut v: Vec<_> = (0..512).map(|_| None).collect();
let mut sa = BitmapAlloc::new(512 * 4);
b.iter(|| unsafe {
let mut r = Xorshift32(0x11451419);
for _ in 0..65536 {
let i = ((r.next() >> 8) & 511) as usize;
... | {
sa.dealloc_relaxed(x);
} | conditional_block |
bitmap.rs | //
// Copyright 2017 yvt, all rights reserved.
//
// Licensed under the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>. This file may
// not be copied, modified,or distributed except
// according to those terms.
//
#![feature(test)]
extern crate test;
extern crate unreachable;
extern crate xalloc;
... | {
let mut v: Vec<_> = (0..512).map(|_| None).collect();
let mut sa = BitmapAlloc::new(512 * 4);
b.iter(|| unsafe {
let mut r = Xorshift32(0x11451419);
for _ in 0..65536 {
let i = ((r.next() >> 8) & 511) as usize;
if v[i].is_some() {
sa.dealloc_relaxed(... | identifier_body | |
bitmap.rs | //
// Copyright 2017 yvt, all rights reserved.
//
// Licensed under the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>. This file may
// not be copied, modified,or distributed except
// according to those terms.
//
#![feature(test)]
extern crate test;
extern crate unreachable;
extern crate xalloc;
... | (u32);
impl Xorshift32 {
fn next(&mut self) -> u32 {
self.0 ^= self.0 << 13;
self.0 ^= self.0 >> 17;
self.0 ^= self.0 << 5;
!self.0
}
}
#[bench]
fn bitmap_random(b: &mut Bencher) {
let mut v: Vec<_> = (0..512).map(|_| None).collect();
let mut sa = BitmapAlloc::new(512);
... | Xorshift32 | identifier_name |
restrevoker.rs | // The MIT License (MIT)
//
// Copyright (c) 2016 Marvin Böcker
//
// 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, c... | T: Revokable>(&self, cert: &T) -> Result<(), RevokeError> {
use hyper::Client;
use std::io::Read;
use rustc_serialize::json::Json;
// Get the certificate fingerprint.
let bytestr = {
let bytestr: Vec<String> = cert.fingerprint().iter().map(|b| format!("{:02X}", b)).c... | s_revoked< | identifier_name |
restrevoker.rs | // The MIT License (MIT)
//
// Copyright (c) 2016 Marvin Böcker
//
// 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, c... | assert_eq!(true, revoker.is_revoked(&cert).is_ok());
} | random_line_split | |
restrevoker.rs | // The MIT License (MIT)
//
// Copyright (c) 2016 Marvin Böcker
//
// 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, c... | let mut response = String::new();
req.read_to_string(&mut response).expect("Failed to read response");
// trim whitespaces
let response = response.trim();
// parse JSON
let json: Result<Json, _> = Json::from_str(response);
let json: Json = match json {
... |
use hyper::Client;
use std::io::Read;
use rustc_serialize::json::Json;
// Get the certificate fingerprint.
let bytestr = {
let bytestr: Vec<String> = cert.fingerprint().iter().map(|b| format!("{:02X}", b)).collect();
bytestr.join("")
};
... | identifier_body |
context.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/. */
//! Data needed by the layout task.
#![deny(unsafe_code)]
use css::matching::{ApplicableDeclarationsCache, Style... | pub image_cache_sender: ImageCacheChan,
/// The current screen size.
pub screen_size: Size2D<Au>,
/// Screen sized changed?
pub screen_size_changed: bool,
/// A channel up to the constellation.
pub constellation_chan: ConstellationChan,
/// A channel up to the layout task.
pub la... | pub struct SharedLayoutContext {
/// The shared image cache task.
pub image_cache_task: ImageCacheTask,
/// A channel for the image cache to send responses to. | random_line_split |
context.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/. */
//! Data needed by the layout task.
#![deny(unsafe_code)]
use css::matching::{ApplicableDeclarationsCache, Style... | {
/// The shared image cache task.
pub image_cache_task: ImageCacheTask,
/// A channel for the image cache to send responses to.
pub image_cache_sender: ImageCacheChan,
/// The current screen size.
pub screen_size: Size2D<Au>,
/// Screen sized changed?
pub screen_size_changed: bool,
... | SharedLayoutContext | identifier_name |
context.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/. */
//! Data needed by the layout task.
#![deny(unsafe_code)]
use css::matching::{ApplicableDeclarationsCache, Style... |
})
}
/// Layout information shared among all workers. This must be thread-safe.
pub struct SharedLayoutContext {
/// The shared image cache task.
pub image_cache_task: ImageCacheTask,
/// A channel for the image cache to send responses to.
pub image_cache_sender: ImageCacheChan,
/// The curr... | {
let context = Rc::new(LocalLayoutContext {
font_context: RefCell::new(FontContext::new(shared_layout_context.font_cache_task.clone())),
applicable_declarations_cache: RefCell::new(ApplicableDeclarationsCache::new()),
style_sharing_candidate_cache: RefCell::n... | conditional_block |
intrinsicck.rs | // Copyright 2012-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... |
fn visit_expr(&mut self, expr: &ast::Expr) {
if let ast::ExprPath(..) = expr.node {
match ty::resolve_expr(self.tcx, expr) {
DefFn(did, _) if self.def_id_is_transmute(did) => {
let typ = ty::node_id_to_type(self.tcx, expr.id);
match typ.s... | {
match fk {
visit::FkItemFn(..) | visit::FkMethod(..) => {
let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
self.param_envs.push(param_env);
visit::walk_fn(self, fk, fd, b, s);
self.param_envs.pop();
}
... | identifier_body |
intrinsicck.rs | // Copyright 2012-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... | // ```
// fn foo<T, U>() {
// // T=int, U=int
// }
//
// fn bar<T:?Sized, U>() {
// // T=int, U=int
// // T=[int], U=int
// }
//
// fn baz<T:?Sized, U:?Sized>() {
// // T=int, U=int
// // T=[int],... | // exhaustively checking all possible combinations. Here are some examples:
// | random_line_split |
intrinsicck.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&mut self, expr: &ast::Expr) {
if let ast::ExprPath(..) = expr.node {
match ty::resolve_expr(self.tcx, expr) {
DefFn(did, _) if self.def_id_is_transmute(did) => {
let typ = ty::node_id_to_type(self.tcx, expr.id);
match typ.sty {
... | visit_expr | identifier_name |
channel.rs | use std::any::Any;
use std::fmt;
use std::sync::{Arc, Mutex};
use std::collections::VecDeque;
use base::types::{ArcType, Type};
use {Error, Result as VmResult};
use api::record::{Record, HList};
use api::{Generic, VmType, primitive, WithVM, Function, Pushable, RuntimeResult};
use api::generic::A;
use gc::{Traverseabl... | (vm: &Thread) -> ArcType {
let symbol = vm.global_env().get_env().find_type_info("Receiver").unwrap().name.clone();
Type::app(Type::ident(symbol), vec![T::make_type(vm)])
}
}
field_decl!{ sender, receiver }
pub type ChannelRecord<S, R> = Record<HList<(_field::sender, S), HList<(_field::receiver, ... | make_type | identifier_name |
channel.rs | use std::any::Any;
use std::fmt;
use std::sync::{Arc, Mutex};
use std::collections::VecDeque;
use base::types::{ArcType, Type};
use {Error, Result as VmResult};
use api::record::{Record, HList};
use api::{Generic, VmType, primitive, WithVM, Function, Pushable, RuntimeResult};
use api::generic::A;
use gc::{Traverseabl... |
}
impl<T: VmType> VmType for Receiver<T>
where T::Type: Sized,
{
type Type = Receiver<T::Type>;
fn make_type(vm: &Thread) -> ArcType {
let symbol = vm.global_env().get_env().find_type_info("Receiver").unwrap().name.clone();
Type::app(Type::ident(symbol), vec![T::make_type(vm)])
}
}
fi... | {
let symbol = vm.global_env().get_env().find_type_info("Sender").unwrap().name.clone();
Type::app(Type::ident(symbol), vec![T::make_type(vm)])
} | identifier_body |
channel.rs | use std::any::Any;
use std::fmt;
use std::sync::{Arc, Mutex};
use std::collections::VecDeque;
use base::types::{ArcType, Type};
use {Error, Result as VmResult};
use api::record::{Record, HList};
use api::{Generic, VmType, primitive, WithVM, Function, Pushable, RuntimeResult};
use api::generic::A;
use gc::{Traverseabl... | self.queue.lock().unwrap().push_back(value);
}
}
impl<T: Traverseable> Traverseable for Receiver<T> {
fn traverse(&self, gc: &mut Gc) {
self.queue.lock().unwrap().traverse(gc);
}
}
pub struct Receiver<T> {
queue: Arc<Mutex<VecDeque<T>>>,
}
impl<T> Userdata for Receiver<T> where T: An... | fn send(&self, value: T) { | random_line_split |
hessenberg.rs | #[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
use crate::allocator::Allocator;
use crate::base::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN};
use crate::dimension::{DimDiff, DimSub, U1};
use crate::storage::Storage;
use simba::scalar::ComplexField;
use crate::linalg::househo... |
/// Retrieves the upper trapezoidal submatrix `H` of this decomposition.
#[inline]
pub fn unpack_h(mut self) -> MatrixN<N, D> {
let dim = self.hess.nrows();
self.hess.fill_lower_triangle(N::zero(), 2);
self.hess
.slice_mut((1, 0), (dim - 1, dim - 1))
.set_parti... |
let q = self.q();
(q, self.unpack_h())
}
| identifier_body |
hessenberg.rs | #[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
use crate::allocator::Allocator;
use crate::base::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN};
use crate::dimension::{DimDiff, DimSub, U1};
use crate::storage::Storage;
use simba::scalar::ComplexField;
use crate::linalg::househo... | <N: ComplexField, D: DimSub<U1>>
where
DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U1>>,
{
hess: MatrixN<N, D>,
subdiag: VectorN<N, DimDiff<D, U1>>,
}
impl<N: ComplexField, D: DimSub<U1>> Copy for Hessenberg<N, D>
where
DefaultAllocator: Allocator<N, D, D> + Allocator<N, DimDiff<D, U... | Hessenberg | identifier_name |
hessenberg.rs | #[cfg(feature = "serde-serialize")] | use serde::{Deserialize, Serialize};
use crate::allocator::Allocator;
use crate::base::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN};
use crate::dimension::{DimDiff, DimSub, U1};
use crate::storage::Storage;
use simba::scalar::ComplexField;
use crate::linalg::householder;
/// Hessenberg decomposition ... | random_line_split | |
hessenberg.rs | #[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
use crate::allocator::Allocator;
use crate::base::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN};
use crate::dimension::{DimDiff, DimSub, U1};
use crate::storage::Storage;
use simba::scalar::ComplexField;
use crate::linalg::househo... |
for ite in 0..dim.value() - 1 {
householder::clear_column_unchecked(&mut hess, &mut subdiag[ite], ite, 1, Some(work));
}
Hessenberg { hess, subdiag }
}
/// Retrieves `(q, h)` with `q` the orthogonal matrix of this decomposition and `h` the
/// hessenberg matrix.
#[... |
return Hessenberg { hess, subdiag };
}
| conditional_block |
constellation_msg.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/. */
//! The high-level interface from script to constellation. Using this abstract interface helps
//! reduce coupling... | {
Space,
Apostrophe,
Comma,
Minus,
Period,
Slash,
Num0,
Num1,
Num2,
Num3,
Num4,
Num5,
Num6,
Num7,
Num8,
Num9,
Semicolon,
Equal,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
... | Key | identifier_name |
constellation_msg.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/. */
//! The high-level interface from script to constellation. Using this abstract interface helps
//! reduce coupling... | use std::sync::mpsc::{channel, Sender, Receiver};
use style::viewport::ViewportConstraints;
use url::Url;
use webdriver_msg::{WebDriverScriptCommand, LoadStatus};
#[derive(Clone)]
pub struct ConstellationChan(pub Sender<Msg>);
impl ConstellationChan {
pub fn new() -> (Receiver<Msg>, ConstellationChan) {
l... | use util::geometry::{PagePx, ViewportPx};
use std::collections::HashMap; | random_line_split |
overloaded-calls-zero-args.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 s = S {
x: 3,
y: 3,
};
let ans = s();
assert_eq!(ans, 9);
}
| main | identifier_name |
overloaded-calls-zero-args.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 ... | } | x: 3,
y: 3,
};
let ans = s();
assert_eq!(ans, 9); | random_line_split |
bigint.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
//! benchmarking for rlp
//! should be started with:
//! ```bash
//! multirust run nightly cargo bench
//! ```
#![feature(test)]
#![feature(asm)]
extern crate test;
extern crate ethcore_bigint as bigint;
use test::{Bencher, black_box};
use bigint::uint::{U256, U512, Uint, U128};
#[bench]
fn u256_add(b: &mut Benche... | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | random_line_split |
bigint.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
#[bench]
fn u256_full_mul(b: &mut Bencher) {
b.iter(|| {
let n = black_box(10000);
let one = black_box(U256::one());
(0..n).fold(one,
|old, new| {
let new = black_box(new);
let U512(ref u512words) = old.full_mul(U256([new, new, new, new]));
U256([u512words[0], u512words[2], u512words[2], u512wo... | {
b.iter(|| {
let n = black_box(10000);
let one = black_box(U256::one());
(0..n).fold(one, |old, new| { old.overflowing_mul(U256::from(black_box(new))).0 })
});
} | identifier_body |
bigint.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | (b: &mut Bencher) {
b.iter(|| {
let n = black_box(10000);
let zero = black_box(U512::zero());
(0..n).fold(zero,
|old, new| {
let new = black_box(new);
old.overflowing_add(U512([new, new, new, new, new, new, new, new])).0
})
});
}
#[bench]
fn u256_mul(b: &mut Bencher) {
b.iter(|| {
let n = blac... | u512_add | identifier_name |
stratagem_test.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use iml_system_docker_tests::run_fs_test;
use iml_system_test_utils::*;
#[tokio::test]
async fn test_docker_stratagem_setup() -> Result<(), TestError> | .await?;
Ok(())
}
| {
let config: Config = Config::default();
let config: Config = Config {
profile_map: vec![
("stratagem_server".into(), config.mds_servers()),
("base_monitored".into(), config.oss_servers()),
("stratagem_client".into(), config.client_servers()),
],
use_... | identifier_body |
stratagem_test.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use iml_system_docker_tests::run_fs_test;
use iml_system_test_utils::*;
#[tokio::test]
async fn | () -> Result<(), TestError> {
let config: Config = Config::default();
let config: Config = Config {
profile_map: vec![
("stratagem_server".into(), config.mds_servers()),
("base_monitored".into(), config.oss_servers()),
("stratagem_client".into(), config.client_servers... | test_docker_stratagem_setup | identifier_name |
stratagem_test.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use iml_system_docker_tests::run_fs_test;
use iml_system_test_utils::*;
#[tokio::test] | async fn test_docker_stratagem_setup() -> Result<(), TestError> {
let config: Config = Config::default();
let config: Config = Config {
profile_map: vec![
("stratagem_server".into(), config.mds_servers()),
("base_monitored".into(), config.oss_servers()),
("stratagem_c... | random_line_split | |
compare_and_swap.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use crate::storage::kv::{Modify, WriteData};
use crate::storage::lock_manager::LockManager;
use crate::storage::raw;
use crate::storage::raw::ttl::convert_to_expire_ts;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, Typed... |
}
impl<S: Snapshot, L: LockManager> WriteCommand<S, L> for RawCompareAndSwap {
fn process_write(self, snapshot: S, _: WriteContext<'_, L>) -> Result<WriteResult> {
let (cf, key, value, previous_value, ctx) =
(self.cf, self.key, self.value, self.previous_value, self.ctx);
let mut data =... | {
self.key.as_encoded().len() + self.value.len()
} | identifier_body |
compare_and_swap.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use crate::storage::kv::{Modify, WriteData};
use crate::storage::lock_manager::LockManager;
use crate::storage::raw;
use crate::storage::raw::ttl::convert_to_expire_ts;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, Typed... |
fn write_bytes(&self) -> usize {
self.key.as_encoded().len() + self.value.len()
}
}
impl<S: Snapshot, L: LockManager> WriteCommand<S, L> for RawCompareAndSwap {
fn process_write(self, snapshot: S, _: WriteContext<'_, L>) -> Result<WriteResult> {
let (cf, key, value, previous_value, ctx) =
... |
impl CommandExt for RawCompareAndSwap {
ctx!();
tag!(raw_compare_and_swap);
gen_lock!(key); | random_line_split |
compare_and_swap.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use crate::storage::kv::{Modify, WriteData};
use crate::storage::lock_manager::LockManager;
use crate::storage::raw;
use crate::storage::raw::ttl::convert_to_expire_ts;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, Typed... | (&self) -> usize {
self.key.as_encoded().len() + self.value.len()
}
}
impl<S: Snapshot, L: LockManager> WriteCommand<S, L> for RawCompareAndSwap {
fn process_write(self, snapshot: S, _: WriteContext<'_, L>) -> Result<WriteResult> {
let (cf, key, value, previous_value, ctx) =
(self.c... | write_bytes | identifier_name |
compare_and_swap.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use crate::storage::kv::{Modify, WriteData};
use crate::storage::lock_manager::LockManager;
use crate::storage::raw;
use crate::storage::raw::ttl::convert_to_expire_ts;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, Typed... | else {
snapshot.get_cf(cf, &key)?
};
let pr = if old_value == previous_value {
let mut m = Modify::Put(cf, key, value);
if let Some(ts) = expire_ts {
m.with_ttl(ts);
}
data.push(m);
ProcessResult::RawCompareAndSwap... | {
raw::TTLSnapshot::from(snapshot).get_cf(cf, &key)?
} | conditional_block |
executor.rs | //
// Copyright (c) 2016, Boris Popov <popov@whitekefir.ru>
//
// 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 logger;
use env;
use std::process::Command;
pu... |
}
}
fn error__(&self, s: String, l: &logger::Logger) {
l.error(&s);
panic!(s);
}
}
| {
let mut ss = "Error of executing ".to_string();
ss += &es;
ss += " ";
ss += &(format!("{}", e));
self.error__(ss, l);
} | conditional_block |
executor.rs | //
// Copyright (c) 2016, Boris Popov <popov@whitekefir.ru>
//
// 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 logger;
use env;
use std::process::Command;
pu... | pub fn start(&self, l: &logger::Logger, e: &env::Env) {
let es = e.getScript().to_string() + " " + e.getDir();
l.info("Trying execute command...");
let res = Command::new(e.getScript())
.arg(e.getDir()).status();
match res {
Ok(o) => {
if o.succ... | random_line_split | |
executor.rs | //
// Copyright (c) 2016, Boris Popov <popov@whitekefir.ru>
//
// 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 logger;
use env;
use std::process::Command;
pu... | () -> Executor {
Executor{}
}
pub fn start(&self, l: &logger::Logger, e: &env::Env) {
let es = e.getScript().to_string() + " " + e.getDir();
l.info("Trying execute command...");
let res = Command::new(e.getScript())
.arg(e.getDir()).status();
match res {
... | new | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.