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 |
|---|---|---|---|---|
session.rs | use prodbg_api::read_write::{Reader, Writer};
use prodbg_api::backend::{CBackendCallbacks};
use plugins::PluginHandler;
use reader_wrapper::{ReaderWrapper, WriterWrapper};
use backend_plugin::{BackendHandle, BackendPlugins};
use libc::{c_void};
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub struct SessionHandle(pub ... | {
instances: Vec<Session>,
current: usize,
session_counter: SessionHandle,
}
impl Sessions {
pub fn new() -> Sessions {
Sessions {
instances: Vec::new(),
current: 0,
session_counter: SessionHandle(0),
}
}
pub fn create_instance(&mut self) ->... | Sessions | identifier_name |
pos.rs | //! Player position in the table
/// One of two teams
#[derive(PartialEq,Clone,Copy,Debug,Serialize,Deserialize)]
pub enum Team {
/// Players P0 and P2
T02,
/// Players P1 and P3
T13,
}
impl Team {
/// Return the team corresponding to the given number.
pub fn from_n(n: usize) -> Self {
... | (self, n: usize) -> PlayerIterator {
PlayerIterator {
current: self,
remaining: n,
}
}
/// Returns the number of turns after `self` to reach `other`.
pub fn distance_until(self, other: PlayerPos) -> usize {
(3 + other as usize - self as usize) % 4 + 1
}
... | until_n | identifier_name |
pos.rs | //! Player position in the table
/// One of two teams
#[derive(PartialEq,Clone,Copy,Debug,Serialize,Deserialize)]
pub enum Team {
/// Players P0 and P2
T02,
/// Players P1 and P3
T13,
}
impl Team {
/// Return the team corresponding to the given number.
pub fn from_n(n: usize) -> Self {
... |
}
/// Returns the previous player.
pub fn prev(self) -> PlayerPos {
match self {
PlayerPos::P0 => PlayerPos::P3,
PlayerPos::P1 => PlayerPos::P0,
PlayerPos::P2 => PlayerPos::P1,
PlayerPos::P3 => PlayerPos::P2,
}
}
/// Returns an itera... | {
PlayerPos::from_n((self as usize + n) % 4)
} | conditional_block |
pos.rs | //! Player position in the table
/// One of two teams
#[derive(PartialEq,Clone,Copy,Debug,Serialize,Deserialize)]
pub enum Team {
/// Players P0 and P2
T02,
/// Players P1 and P3
T13,
}
impl Team {
/// Return the team corresponding to the given number.
pub fn from_n(n: usize) -> Self {
... | }
}
/// A position in the table
#[derive(PartialEq,Clone,Copy,Debug,Serialize,Deserialize)]
pub enum PlayerPos {
/// Player 0
P0,
/// Player 1
P1,
/// Player 2
P2,
/// Player 3
P3,
}
/// Iterates on players
pub struct PlayerIterator {
current: PlayerPos,
remaining: usize,
}... | pub fn opponent(self) -> Team {
match self {
Team::T02 => Team::T13,
Team::T13 => Team::T02,
} | random_line_split |
glut.rs | use super::gl::*;
extern
{
pub fn glutInit(argc:*mut c_int,argc:*const *const c_char);
pub fn glutInitDisplayMode(mode:GLenum);
pub fn glutCreateWindow(x:*const c_char)->c_int;
pub fn glutCreateSubWindow(x:*const c_char)->c_int;
pub fn glutDestroyWindow(x:c_int); | pub fn glutSetWindowTitle(x:*const c_char);
pub fn glutSetIconTitle(x:*const c_char);
pub fn glutReshapeWindow(x:GLint, y:GLint);
pub fn glutPositionWindow(x:c_int,y:c_int);
pub fn glutIconifyWindow();
pub fn glutShowWindow();
pub fn glutHideWindow();
pub fn glutPushWindow();
pub fn glutPopWindow();
pub fn gl... | pub fn glutSetWindow(win:c_int);
pub fn glutGetWindow()->c_int; | random_line_split |
glut.rs | use super::gl::*;
extern
{
pub fn glutInit(argc:*mut c_int,argc:*const *const c_char);
pub fn glutInitDisplayMode(mode:GLenum);
pub fn glutCreateWindow(x:*const c_char)->c_int;
pub fn glutCreateSubWindow(x:*const c_char)->c_int;
pub fn glutDestroyWindow(x:c_int);
pub fn glutSetWindow(win:c_int);
pub fn glutGe... | (){ unsafe {glutCheckLoop();} }
| glutMainLoopEvent | identifier_name |
glut.rs | use super::gl::*;
extern
{
pub fn glutInit(argc:*mut c_int,argc:*const *const c_char);
pub fn glutInitDisplayMode(mode:GLenum);
pub fn glutCreateWindow(x:*const c_char)->c_int;
pub fn glutCreateSubWindow(x:*const c_char)->c_int;
pub fn glutDestroyWindow(x:c_int);
pub fn glutSetWindow(win:c_int);
pub fn glutGe... | { unsafe {glutCheckLoop();} } | identifier_body | |
bench.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 ... |
#[bench]
fn anchored_literal_long_match(b: &mut Bencher) {
let re = regex!("^.bc(d|e)");
let text = "abcdefghijklmnopqrstuvwxyz".repeat(15);
b.iter(|| re.is_match(text));
}
#[bench]
fn one_pass_short_a(b: &mut Bencher) {
let re = regex!("^.bc(d|e)*$");
let text = "abcddddddeeeededd";
b.iter(|... | {
let re = regex!("^.bc(d|e)");
let text = "abcdefghijklmnopqrstuvwxyz";
b.iter(|| re.is_match(text));
} | identifier_body |
bench.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 ... | (b: &mut Bencher) {
let re = regex!("^.bc(?:d|e)*$");
let text = "abcddddddeeeededd";
b.iter(|| re.is_match(text));
}
#[bench]
fn one_pass_short_b_not(b: &mut Bencher) {
let re = regex!(".bc(?:d|e)*$");
let text = "abcddddddeeeededd";
b.iter(|| re.is_match(text));
}
#[bench]
fn one_pass_long_p... | one_pass_short_b | identifier_name |
bench.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 ... | );
}
#[bench]
fn no_exponential(b: &mut Bencher) {
let n = 100;
let re = Regex::new("a?".repeat(n) + "a".repeat(n)).unwrap();
let text = "a".repeat(n);
bench_assert_match(b, re, text);
}
#[bench]
fn literal(b: &mut Bencher) {
let re = regex!("y");
let text = "x".repeat(50) + "y";
bench_ass... | { fail!("no match") } | conditional_block |
bench.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 ... | bench_assert_match(b, re, text);
}
#[bench]
fn match_class(b: &mut Bencher) {
let re = regex!("[abcdw]");
let text = "xxxx".repeat(20) + "w";
bench_assert_match(b, re, text);
}
#[bench]
fn match_class_in_range(b: &mut Bencher) {
// 'b' is between 'a' and 'c', so the class range checking doesn't he... | #[bench]
fn not_literal(b: &mut Bencher) {
let re = regex!(".y");
let text = "x".repeat(50) + "y"; | random_line_split |
mod.rs | //! Types that map to concepts in HTTP.
//!
//! This module exports types that map to HTTP concepts or to the underlying
//! HTTP library when needed. Because the underlying HTTP library is likely to
//! change (see <a | //! [hyper](hyper/index.html) should be considered unstable.
pub mod hyper;
pub mod uri;
#[macro_use]
mod known_media_types;
mod cookies;
mod session;
mod method;
mod media_type;
mod content_type;
mod status;
mod header;
mod accept;
mod raw_str;
pub(crate) mod parse;
// We need to export these for codegen, but other... | //! href="https://github.com/SergioBenitez/Rocket/issues/17">#17</a>), types in | random_line_split |
finally.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 ... | dtor: finally_fn,
};
try_fn(&mut *f.mutate, drop)
}
struct Finallyalizer<'a,A:'a> {
mutate: &'a mut A,
dtor: |&mut A|: 'a
}
#[unsafe_destructor]
impl<'a,A> Drop for Finallyalizer<'a,A> {
#[inline]
fn drop(&mut self) {
(self.dtor)(self.mutate);
}
} | finally_fn: |&mut T|)
-> R {
let f = Finallyalizer {
mutate: mutate, | random_line_split |
finally.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 ... | (&mut self, dtor: ||) -> T {
try_finally(&mut (), self,
|_, f| (*f)(),
|_| dtor())
}
}
impl<T> Finally<T> for fn() -> T {
fn finally(&mut self, dtor: ||) -> T {
try_finally(&mut (), (),
|_, _| (*self)(),
|_| dtor())... | finally | identifier_name |
finally.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> Finally<T> for fn() -> T {
fn finally(&mut self, dtor: ||) -> T {
try_finally(&mut (), (),
|_, _| (*self)(),
|_| dtor())
}
}
/**
* The most general form of the `finally` functions. The function
* `try_fn` will be invoked first; whether or not it pan... | {
try_finally(&mut (), self,
|_, f| (*f)(),
|_| dtor())
} | identifier_body |
build.rs | compiler nor is cc-rs ready for compilation to riscv (at this
// time). This can probably be removed in the future
if!target.contains("wasm32") &&!target.contains("nvptx") &&!target.starts_with("riscv") {
#[cfg(feature = "c")]
c::compile(&llvm_target, &target);
}
}... | (llvm_target: &[&str], target: &String) {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
... | compile | identifier_name |
build.rs |
println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display());
// Activate libm's unstable features to make full use of Nightly.
println!("cargo:rustc-cfg=feature=\"unstable\"");
// Emscripten's runtime includes all the builtins
if target.contains("emscripten") {
return;
}
... | fn main() {
println!("cargo:rerun-if-changed=build.rs");
let target = env::var("TARGET").unwrap();
let cwd = env::current_dir().unwrap(); | random_line_split | |
build.rs | compiler nor is cc-rs ready for compilation to riscv (at this
// time). This can probably be removed in the future
if!target.contains("wasm32") &&!target.contains("nvptx") &&!target.starts_with("riscv") {
#[cfg(feature = "c")]
c::compile(&llvm_target, &target);
}
}... |
fn extend(&mut self, sources: &[(&'static str, &'static str)]) {
// NOTE Some intrinsics have both a generic implementation (e.g.
// `floatdidf.c`) and an arch optimized implementation
// (`x86_64/floatdidf.c`). In those cases, we keep the arch optimized
// impl... | {
Sources {
map: BTreeMap::new(),
}
} | identifier_body |
build.rs | compiler nor is cc-rs ready for compilation to riscv (at this
// time). This can probably be removed in the future
if!target.contains("wasm32") &&!target.contains("nvptx") &&!target.starts_with("riscv") {
#[cfg(feature = "c")]
c::compile(&llvm_target, &target);
}
}... |
// First of all aeabi_cdcmp and aeabi_cfcmp are never called by LLVM.
// Second are little-endian only, so build fail on big-endian targets.
// Temporally workaround: exclude these files for big-endian targets.
if!llvm_target[0].starts_with("thumbeb") &&!llvm_target[0].... | {
sources.extend(&[("__clear_cache", "clear_cache.c")]);
} | conditional_block |
create_user_response.rs | use crate::from_headers::*;
use crate::User;
use azure_sdk_core::errors::AzureError;
use azure_sdk_core::{etag_from_headers, session_token_from_headers};
use http::HeaderMap;
use std::convert::TryInto;
#[derive(Debug, Clone, PartialEq)]
pub struct CreateUserResponse {
pub user: User,
pub charge: f64,
pub a... | let body = value.1;
Ok(Self {
user: body.try_into()?,
charge: request_charge_from_headers(headers)?,
activity_id: activity_id_from_headers(headers)?,
etag: etag_from_headers(headers)?,
session_token: session_token_from_headers(headers)?,
... | type Error = AzureError;
fn try_from(value: (&HeaderMap, &[u8])) -> Result<Self, Self::Error> {
let headers = value.0; | random_line_split |
create_user_response.rs | use crate::from_headers::*;
use crate::User;
use azure_sdk_core::errors::AzureError;
use azure_sdk_core::{etag_from_headers, session_token_from_headers};
use http::HeaderMap;
use std::convert::TryInto;
#[derive(Debug, Clone, PartialEq)]
pub struct CreateUserResponse {
pub user: User,
pub charge: f64,
pub a... |
}
| {
let headers = value.0;
let body = value.1;
Ok(Self {
user: body.try_into()?,
charge: request_charge_from_headers(headers)?,
activity_id: activity_id_from_headers(headers)?,
etag: etag_from_headers(headers)?,
session_token: session_to... | identifier_body |
create_user_response.rs | use crate::from_headers::*;
use crate::User;
use azure_sdk_core::errors::AzureError;
use azure_sdk_core::{etag_from_headers, session_token_from_headers};
use http::HeaderMap;
use std::convert::TryInto;
#[derive(Debug, Clone, PartialEq)]
pub struct | {
pub user: User,
pub charge: f64,
pub activity_id: uuid::Uuid,
pub etag: String,
pub session_token: String,
}
impl std::convert::TryFrom<(&HeaderMap, &[u8])> for CreateUserResponse {
type Error = AzureError;
fn try_from(value: (&HeaderMap, &[u8])) -> Result<Self, Self::Error> {
le... | CreateUserResponse | identifier_name |
spi.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Dzmitry "kvark" Malyshau <kvarkus@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/lice... | }
if self.reg.sr.overrun_flag() {
r |= 1u8<<6;
}
if self.reg.sr.busy_flag() {
r |= 1u8<<7;
}
r
}
}
impl ::hal::spi::Spi for Spi {
fn write(&self, value: u8) {
wait_for!(self.reg.sr.transmit_buffer_empty());
self.reg.dr.set_data(value as u16);
}
fn read(&self) -> u8... | {
//self.reg.sr.raw() //TODO(kvark): #245 doesn't work
let mut r = 0u8;
if self.reg.sr.receive_buffer_not_empty() {
r |= 1u8<<0;
}
if self.reg.sr.transmit_buffer_empty() {
r |= 1u8<<1;
}
if self.reg.sr.channel_side() {
r |= 1u8<<2;
}
if self.reg.sr.underrun_flag() {... | identifier_body |
spi.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Dzmitry "kvark" Malyshau <kvarkus@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/lice... | {
/// Most Significant Bit
MsbFirst = 0,
/// Least Significant Bit
LsbFirst = 1,
}
#[allow(missing_docs)]
#[repr(u8)]
#[derive(Copy)]
pub enum ClockPhase {
Edge1 = 0,
Edge2 = 1,
}
#[allow(missing_docs)]
#[repr(u8)]
#[derive(Copy)]
pub enum ClockPolarity {
Low = 0,
High = 1,
}
/// SPI initialization ... | DataFormat | identifier_name |
spi.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Dzmitry "kvark" Malyshau <kvarkus@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/lice... |
if self.reg.sr.transmit_buffer_empty() {
r |= 1u8<<1;
}
if self.reg.sr.channel_side() {
r |= 1u8<<2;
}
if self.reg.sr.underrun_flag() {
r |= 1u8<<3;
}
if self.reg.sr.crc_error() {
r |= 1u8<<4;
}
if self.reg.sr.mode_fault() {
r |= 1u8<<5;
}
if se... | {
r |= 1u8<<0;
} | conditional_block |
spi.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Dzmitry "kvark" Malyshau <kvarkus@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/lice... | reg.cr1.set_receive_only(direction == Direction::RxOnly);
reg.cr1.set_bidirectional_data_mode(direction == Direction::Rx
|| direction == Direction::Tx);
reg.cr1.set_bidirectional_output_enable(direction == Direction::Tx);
// set role
reg.cr1.set_master(role as bool);
reg.cr1.set_interna... | random_line_split | |
filesize.rs | use std::fmt;
#[derive(Debug)]
enum FileSize {
B,
KB,
MB,
GB,
TB,
}
impl fmt::Display for FileSize {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl FileSize {
fn value(&self) -> u64 |
}
pub fn format_filesize(size: u64) -> String {
let (file_size, unit) = match size {
0...999 => (size as f64, FileSize::B),
1_000...999_999 => (size as f64 / FileSize::KB.value() as f64, FileSize::KB),
1_000_000...999_999_999 => (size as f64 / FileSize::MB.value() as f64, FileSize::MB),
... | {
match *self {
FileSize::B => 1,
FileSize::KB => 1_024,
FileSize::MB => 1_048_576,
FileSize::GB => 1_073_741_824,
FileSize::TB => 1_099_511_627_776,
}
} | identifier_body |
filesize.rs | use std::fmt;
#[derive(Debug)]
enum FileSize {
B,
KB,
MB,
GB,
TB,
}
impl fmt::Display for FileSize {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl FileSize {
fn | (&self) -> u64 {
match *self {
FileSize::B => 1,
FileSize::KB => 1_024,
FileSize::MB => 1_048_576,
FileSize::GB => 1_073_741_824,
FileSize::TB => 1_099_511_627_776,
}
}
}
pub fn format_filesize(size: u64) -> String {
let (file_size, u... | value | identifier_name |
filesize.rs | use std::fmt;
#[derive(Debug)]
enum FileSize {
B,
KB,
MB,
GB,
TB,
}
impl fmt::Display for FileSize {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl FileSize {
fn value(&self) -> u64 {
match *self {
FileSize::B => 1,
... | }
}
}
pub fn format_filesize(size: u64) -> String {
let (file_size, unit) = match size {
0...999 => (size as f64, FileSize::B),
1_000...999_999 => (size as f64 / FileSize::KB.value() as f64, FileSize::KB),
1_000_000...999_999_999 => (size as f64 / FileSize::MB.value() as f64, F... | FileSize::MB => 1_048_576,
FileSize::GB => 1_073_741_824,
FileSize::TB => 1_099_511_627_776, | random_line_split |
regions-variance-covariant-use-covariant.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {}
| {
// OK Because Covariant<'a> <: Covariant<'static> iff 'a <= 'static
let _: Covariant<'static> = c;
} | identifier_body |
regions-variance-covariant-use-covariant.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {} | fn use_<'a>(c: Covariant<'a>) {
// OK Because Covariant<'a> <: Covariant<'static> iff 'a <= 'static
let _: Covariant<'static> = c;
} | random_line_split |
regions-variance-covariant-use-covariant.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <'a>(c: Covariant<'a>) {
// OK Because Covariant<'a> <: Covariant<'static> iff 'a <='static
let _: Covariant<'static> = c;
}
pub fn main() {}
| use_ | identifier_name |
main.rs | #![crate_name = "rtdealer"]
/// Router-to-dealer example
extern crate zmq;
extern crate rand;
use zmq::SNDMORE;
use rand::Rng;
use std::time::{Duration, Instant};
use std::thread;
fn worker_task() {
let mut context = zmq::Context::new();
let mut worker = context.socket(zmq::DEALER).unwrap();
let mut rng = ra... | let mut workers_fired = 0;
loop {
// Next message gives us least recently used worker
let mut identity = zmq::Message::new().unwrap();
broker.recv(&mut identity, 0).unwrap();
broker.send_msg(identity, SNDMORE).unwrap();
let mut envelope = zmq::Message::new().unwrap();
let mut workload = zmq... | {
let worker_pool_size = 10;
let allowed_duration = Duration::new(5, 0);
let mut context = zmq::Context::new();
let mut broker = context.socket(zmq::ROUTER).unwrap();
assert!(broker.bind("tcp://*:5671").is_ok());
// While this example runs in a single process, that is just to make
// it easier to start a... | identifier_body |
main.rs | #![crate_name = "rtdealer"]
/// Router-to-dealer example
extern crate zmq;
extern crate rand;
use zmq::SNDMORE;
use rand::Rng;
use std::time::{Duration, Instant};
use std::thread;
fn worker_task() {
let mut context = zmq::Context::new();
let mut worker = context.socket(zmq::DEALER).unwrap();
let mut rng = ra... | } | random_line_split | |
main.rs | #![crate_name = "rtdealer"]
/// Router-to-dealer example
extern crate zmq;
extern crate rand;
use zmq::SNDMORE;
use rand::Rng;
use std::time::{Duration, Instant};
use std::thread;
fn worker_task() {
let mut context = zmq::Context::new();
let mut worker = context.socket(zmq::DEALER).unwrap();
let mut rng = ra... |
}
}
| {
broker.send_str("Fired!", 0).unwrap();
workers_fired += 1;
if workers_fired >= worker_pool_size {
break;
}
} | conditional_block |
main.rs | #![crate_name = "rtdealer"]
/// Router-to-dealer example
extern crate zmq;
extern crate rand;
use zmq::SNDMORE;
use rand::Rng;
use std::time::{Duration, Instant};
use std::thread;
fn | () {
let mut context = zmq::Context::new();
let mut worker = context.socket(zmq::DEALER).unwrap();
let mut rng = rand::thread_rng();
let identity: String = (0..10).map(|_| rand::random::<u8>() as char).collect();
worker.set_identity(identity.as_bytes()).unwrap();
assert!(worker.connect("tcp://localhost:5671... | worker_task | identifier_name |
level_reader.rs | extern crate csv;
extern crate nalgebra as na;
extern crate ncollide;
use entity::{Entity, EntityType};
use na::{Point2, Vector2};
use std::rc::Rc;
use std::cell::RefCell;
use entity::CollideWorld;
use graphics_component::GraphicsComponent;
pub type Row = [f32; 11];
#[derive(Clone,Debug)]
pub struct LevelReader {
... | } | random_line_split | |
level_reader.rs | extern crate csv;
extern crate nalgebra as na;
extern crate ncollide;
use entity::{Entity, EntityType};
use na::{Point2, Vector2};
use std::rc::Rc;
use std::cell::RefCell;
use entity::CollideWorld;
use graphics_component::GraphicsComponent;
pub type Row = [f32; 11];
#[derive(Clone,Debug)]
pub struct LevelReader {
... | (path: &str) -> Self {
let mut rdr = csv::Reader::from_file(path).unwrap();
let rows = rdr.decode().collect::<csv::Result<Vec<Row>>>().unwrap();
LevelReader {
data: rows
}
}
pub fn load_level(&self, world: &Rc<RefCell<CollideWorld>>) -> Vec<Entity> {
self.da... | new | identifier_name |
main.rs | // Copyright Cryptape Technologies LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed ... | ;
write!(&mut file, "{}", data).unwrap();
}
fn create_key(path: String) -> PubKey {
let keypair = KeyPair::gen_keypair();
let privkey = *keypair.privkey();
let hex_str = to_hex_string(&privkey);
let hex_str_with_0x = String::from("0x") + &hex_str + "\n";
write_to_file(path, &hex_str_with_0x, fa... | {
File::create(path).unwrap()
} | conditional_block |
main.rs | // Copyright Cryptape Technologies LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed ... | let hex_str = to_hex_string(&privkey);
let hex_str_with_0x = String::from("0x") + &hex_str + "\n";
write_to_file(path, &hex_str_with_0x, false);
*keypair.pubkey()
}
fn create_addr(path: String, pubkey: PubKey) {
let hash = pubkey.crypt_hash();
let addr = &hash.0[12..];
let hex_str = to_hex_... | let privkey = *keypair.privkey(); | random_line_split |
main.rs | // Copyright Cryptape Technologies LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed ... | (data: &[u8]) -> String {
let strs: Vec<String> = data.iter().map(|a| format!("{:02x}", a)).collect();
strs.join("")
}
fn write_to_file(path: String, data: &str, append: bool) {
let mut file = if append {
OpenOptions::new()
.create(true)
.append(true)
.open(path)
... | to_hex_string | identifier_name |
main.rs | // Copyright Cryptape Technologies LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed ... |
fn create_key(path: String) -> PubKey {
let keypair = KeyPair::gen_keypair();
let privkey = *keypair.privkey();
let hex_str = to_hex_string(&privkey);
let hex_str_with_0x = String::from("0x") + &hex_str + "\n";
write_to_file(path, &hex_str_with_0x, false);
*keypair.pubkey()
}
fn create_addr(p... | {
let mut file = if append {
OpenOptions::new()
.create(true)
.append(true)
.open(path)
.unwrap()
} else {
File::create(path).unwrap()
};
write!(&mut file, "{}", data).unwrap();
} | identifier_body |
shot.rs | use std::fmt;
use board::Coordinate;
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum HitStatus {
Hit,
Miss
}
impl fmt::Debug for HitStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&HitStatus::Hit => write!(f, "Hit"),
&HitStatus::Miss => write!(f... | } | return hit_status;
} | random_line_split |
shot.rs | use std::fmt;
use board::Coordinate;
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum | {
Hit,
Miss
}
impl fmt::Debug for HitStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&HitStatus::Hit => write!(f, "Hit"),
&HitStatus::Miss => write!(f, "Miss")
}
}
}
pub trait Hit {
fn hits(&self, coordinate: Coordinate) -> HitS... | HitStatus | identifier_name |
score.rs | /// score is responsible for calculating the scores of the similarity between
/// the query and the choice.
///
/// It is modeled after https://github.com/felipesere/icepick.git
use std::cmp::max;
use std::cell::RefCell;
use regex::Regex;
const BONUS_UPPER_MATCH: i64 = 10;
const BONUS_ADJACENCY: i64 = 10;
const BONUS... | pub fn exact_match(choice: &str, pattern: &str) -> Option<((usize, usize), (usize, usize))>{
// search from the start
let start_pos = choice.find(pattern);
if start_pos.is_none() {return None};
let pattern_len = pattern.chars().count();
let first_occur = start_pos.map(|s| {
let start = if ... | // Pattern may appear in sevearl places, return the first and last occurrence | random_line_split |
score.rs | /// score is responsible for calculating the scores of the similarity between
/// the query and the choice.
///
/// It is modeled after https://github.com/felipesere/icepick.git
use std::cmp::max;
use std::cell::RefCell;
use regex::Regex;
const BONUS_UPPER_MATCH: i64 = 10;
const BONUS_ADJACENCY: i64 = 10;
const BONUS... | else { (&choice[0..s]).chars().count() };
(start, start + pattern_len)
}).unwrap();
let last_pos = choice.rfind(pattern);
if last_pos.is_none() {return None};
let last_occur = last_pos.map(|s| {
let start = if s == 0 { 0 } else { (&choice[0..s]).chars().count() };
(start, start... | { 0 } | conditional_block |
score.rs | /// score is responsible for calculating the scores of the similarity between
/// the query and the choice.
///
/// It is modeled after https://github.com/felipesere/icepick.git
use std::cmp::max;
use std::cell::RefCell;
use regex::Regex;
const BONUS_UPPER_MATCH: i64 = 10;
const BONUS_ADJACENCY: i64 = 10;
const BONUS... | {
pub idx: usize,
pub score: i64,
pub final_score: i64,
pub adj_num: usize,
pub back_ref: usize,
}
impl MatchingStatus {
pub fn empty() -> Self {
MatchingStatus {
idx: 0,
score: 0,
final_score: 0,
adj_num: 1,
back_ref: 0,
... | MatchingStatus | identifier_name |
score.rs | /// score is responsible for calculating the scores of the similarity between
/// the query and the choice.
///
/// It is modeled after https://github.com/felipesere/icepick.git
use std::cmp::max;
use std::cell::RefCell;
use regex::Regex;
const BONUS_UPPER_MATCH: i64 = 10;
const BONUS_ADJACENCY: i64 = 10;
const BONUS... |
// Pattern may appear in sevearl places, return the first and last occurrence
pub fn exact_match(choice: &str, pattern: &str) -> Option<((usize, usize), (usize, usize))>{
// search from the start
let start_pos = choice.find(pattern);
if start_pos.is_none() {return None};
let pattern_len = pattern.cha... | {
match *pattern {
Some(ref pat) => {
let ret = pat.find(choice);
if ret.is_none() {
return None;
}
let mat = ret.unwrap();
let (start, end) = (mat.start(), mat.end());
let first = (&choice[0..start]).chars().count();
... | identifier_body |
wtools_lib.rs | #![ warn( missing_docs ) ]
#![ warn( missing_debug_implementations ) ]
// #![ feature( concat_idents ) ]
//!
//! wTools - Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind.
//!
///
/// ... | ///
/// Type checking tools.
///
pub mod typing;
pub use typing::*;
///
/// Exporting/importing serialize/deserialize encoding/decoding macros, algorithms and structures for that.
///
pub mod convert;
pub use convert::*;
///
/// Collection of general purpose time tools.
///
pub mod time;
//
pub use werror as err... | ///
pub mod meta;
pub use meta::*;
| random_line_split |
lib.rs | // Copyright (c) 2015 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publis... | //! let sys = py.import("sys").unwrap();
//! let version: String = sys.get("version").unwrap().extract().unwrap();
//!
//! let os = py.import("os").unwrap();
//! let getenv = os.get("getenv").unwrap();
//! let user: String = getenv.call(("USER",), None).unwrap().extract().unwrap();
//!
//! print... | //!
//! fn main() {
//! let gil = Python::acquire_gil();
//! let py = gil.python();
//! | random_line_split |
lib.rs | // Copyright (c) 2015 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publis... | (
name: *const libc::c_char,
init: for<'p> fn(Python<'p>, &PyModule<'p>) -> PyResult<'p, ()>
) {
abort_on_panic!({
let py = Python::assume_gil_acquired();
ffi::PyEval_InitThreads();
let module = ffi::Py_InitModule(name, ptr::null_mut());
if module.is_null() { return; }
... | py_module_initializer_impl | identifier_name |
lib.rs | // Copyright (c) 2015 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publis... | }
})
}
| {
abort_on_panic!({
let py = Python::assume_gil_acquired();
ffi::PyEval_InitThreads();
let module = ffi::PyModule_Create(def);
if module.is_null() { return module; }
let module = match PyObject::from_owned_ptr(py, module).cast_into::<PyModule>() {
Ok(m) => m,
... | identifier_body |
packed_vec.rs | use base::WORD_SIZE;
use std;
use std::default::Default;
use super::util::vec_resize;
/// Static packed vector of u32 values. Bit size of each element is determined
/// by the size of the largest element.
struct | {
units_: Vec<usize>,
value_size_: usize,
mask_: u32,
size_: usize,
}
impl PackedVec {
fn new() -> PackedVec {
PackedVec {
units_: Default::default(),
value_size_: 0,
mask_: 0,
size_: 0,
}
}
fn build(values: &Vec<u32>) -> Pa... | PackedVec | identifier_name |
packed_vec.rs | use base::WORD_SIZE;
use std;
use std::default::Default;
use super::util::vec_resize;
/// Static packed vector of u32 values. Bit size of each element is determined
/// by the size of the largest element.
struct PackedVec {
units_: Vec<usize>,
value_size_: usize,
mask_: u32,
size_: usize,
}
impl Packe... |
fn is_empty(&self) -> bool {
self.size_ == 0
}
fn size(&self) -> usize {
self.size_
}
fn total_size(&self) -> usize {
self.units_.len() * std::mem::size_of::<usize>()
}
// fn io_size(&self) -> usize {
// units_.io_size()
// + (std::mem::size_of::<u32>... | {
self.mask_
} | identifier_body |
packed_vec.rs | use base::WORD_SIZE;
use std;
use std::default::Default;
use super::util::vec_resize;
/// Static packed vector of u32 values. Bit size of each element is determined
/// by the size of the largest element.
struct PackedVec {
units_: Vec<usize>,
value_size_: usize,
mask_: u32,
size_: usize,
}
impl Packe... | mask_: 0,
size_: 0,
}
}
fn build(values: &Vec<u32>) -> PackedVec {
let mut out = PackedVec::new();
let mut max_value = match values.iter().max() {
Some(x) => *x,
None => { return out; }
};
let mut value_size: usize = 0;
... | units_: Default::default(),
value_size_: 0, | random_line_split |
dealloc-no-unwind.rs | //
// 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.
//
// no-system-l... | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | random_line_split | |
dealloc-no-unwind.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
#[no_mangle]
pub fn a(a: Box<i32>) {
// CHECK-LABEL: define void @a
// CHECK: call void @__rust_dealloc
// CHECK-NEXT: call void @foo
let _a = A;
drop(a);
}
| {
extern { fn foo(); }
unsafe { foo(); }
} | identifier_body |
dealloc-no-unwind.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (a: Box<i32>) {
// CHECK-LABEL: define void @a
// CHECK: call void @__rust_dealloc
// CHECK-NEXT: call void @foo
let _a = A;
drop(a);
}
| a | identifier_name |
test_nfa_utf8bytes.rs | #![cfg_attr(feature = "pattern", feature(pattern))]
macro_rules! regex_new {
($re:expr) => {{
use regex::internal::ExecBuilder;
ExecBuilder::new($re).nfa().bytes(true).build().map(|e| e.into_regex())
}};
}
macro_rules! regex {
($re:expr) => {
regex_new!($re).unwrap()
};
}
macr... | ($res:expr) => {
regex_set_new!($res).unwrap()
};
}
// Must come before other module definitions.
include!("macros_str.rs");
include!("macros.rs");
mod api;
mod api_str;
mod crazy;
mod flags;
mod fowler;
mod multiline;
mod noparse;
mod regression;
mod replace;
mod searcher;
mod set;
mod suffix_reverse... | }
macro_rules! regex_set { | random_line_split |
inherited_text.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 parsing::parse;
use style::values::generics::text::Spacing;
#[test]
fn negative_letter_spacing_should_parse_p... | () {
use style::properties::longhands::line_height;
let result = parse(line_height::parse, "0").unwrap();
assert_eq!(result, parse_longhand!(line_height, "0"));
}
#[test]
fn line_height_should_return_length_on_length_zero() {
use style::properties::longhands::line_height;
let result = parse(line_... | line_height_should_return_number_on_plain_zero | identifier_name |
inherited_text.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 parsing::parse;
use style::values::generics::text::Spacing;
#[test]
fn negative_letter_spacing_should_parse_p... | use style::properties::longhands::line_height;
let result = parse(line_height::parse, "0px").unwrap();
assert_eq!(result, parse_longhand!(line_height, "0px"));
} | }
#[test]
fn line_height_should_return_length_on_length_zero() { | random_line_split |
inherited_text.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 parsing::parse;
use style::values::generics::text::Spacing;
#[test]
fn negative_letter_spacing_should_parse_p... |
#[test]
fn line_height_should_return_length_on_length_zero() {
use style::properties::longhands::line_height;
let result = parse(line_height::parse, "0px").unwrap();
assert_eq!(result, parse_longhand!(line_height, "0px"));
}
| {
use style::properties::longhands::line_height;
let result = parse(line_height::parse, "0").unwrap();
assert_eq!(result, parse_longhand!(line_height, "0"));
} | identifier_body |
operator.rs | //! Operators traits and structures.
pub use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
#[cfg(feature = "decimal")]
use decimal::d128;
use num::Num;
use num_complex::Complex;
/// Trait implemented by types representing abstract operators.
pub trait Operator: Copy {
/// R... | }
macro_rules! impl_additive_inverse(
($($T:ty),* $(,)*) => {$(
impl TwoSidedInverse<Additive> for $T {
fn two_sided_inverse(&self) -> Self {
-*self
}
}
)*}
);
impl_additive_inverse!(i8, i16, i32, i64, isize, f32, f64);
#[cfg(feature = "decimal")]
impl_a... |
AbstractOperator
}
| identifier_body |
operator.rs | //! Operators traits and structures.
pub use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
#[cfg(feature = "decimal")]
use decimal::d128;
use num::Num;
use num_complex::Complex;
/// Trait implemented by types representing abstract operators.
pub trait Operator: Copy {
/// R... | where
T: Neg<Output = T>,
{
} | random_line_split | |
operator.rs | //! Operators traits and structures.
pub use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
#[cfg(feature = "decimal")]
use decimal::d128;
use num::Num;
use num_complex::Complex;
/// Trait implemented by types representing abstract operators.
pub trait Operator: Copy {
/// R... |
impl Operator for Additive {
#[inline]
fn operator_token() -> Self {
Additive
}
}
impl Operator for Multiplicative {
#[inline]
fn operator_token() -> Self {
Multiplicative
}
}
impl Operator for AbstractOperator {
#[inline]
fn operator_token() -> Self {
Abstrac... | bstractOperator; | identifier_name |
issue-37576.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 ... | () {
'test_1: while break 'test_1 {}
while break {}
//~^ ERROR `break` or `continue` with no label
'test_2: while let true = break 'test_2 {}
while let true = break {}
//~^ ERROR `break` or `continue` with no label
loop { 'test_3: while break 'test_3 {} }
loop { while break {} }
//... | main | identifier_name |
issue-37576.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 ... | break;
}
'test_5: while continue 'test_5 {}
while continue {}
//~^ ERROR `break` or `continue` with no label
'test_6: while let true = continue 'test_6 {}
while let true = continue {}
//~^ ERROR `break` or `continue` with no label
loop { 'test_7: while continue 'test_7 {} }
... | {
'test_1: while break 'test_1 {}
while break {}
//~^ ERROR `break` or `continue` with no label
'test_2: while let true = break 'test_2 {}
while let true = break {}
//~^ ERROR `break` or `continue` with no label
loop { 'test_3: while break 'test_3 {} }
loop { while break {} }
//~^ ... | identifier_body |
issue-37576.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 ... | //~^ ERROR `break` or `continue` with no label
loop {
'test_8: while continue 'test_8 {}
continue;
}
loop {
while continue {}
//~^ ERROR `break` or `continue` with no label
continue;
}
} |
loop { 'test_7: while continue 'test_7 {} }
loop { while continue {} } | random_line_split |
server.rs | //
// Copyright 2022 The Project Oak Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law o... |
/// Decrypts a client request, runs [`EncryptedRequestHandler::cleartext_handler`] on the
/// resulting cleartext and encrypts the response.
///
/// Returns `Ok(None)` to indicate that the corresponding gRPC stream has ended.
pub async fn handle_next_request(&mut self) -> anyhow::Result<Option<Str... | {
Self {
request_stream,
encryptor,
cleartext_handler,
}
} | identifier_body |
server.rs | //
// Copyright 2022 The Project Oak Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law o... | (&mut self) -> anyhow::Result<Option<StreamingResponse>> {
if let Some(encrypted_request) = self.request_stream.next().await {
let encrypted_request = encrypted_request.context("Couldn't receive request")?;
let decrypted_request = self
.encryptor
.decrypt(&e... | handle_next_request | identifier_name |
server.rs | //
// Copyright 2022 The Project Oak Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law o... | else {
Ok(None)
}
}
}
/// gRPC Attestation Service implementation.
pub struct AttestationServer<F, L: LogError> {
/// PEM encoded X.509 certificate that signs TEE firmware key.
tee_certificate: Vec<u8>,
/// Processes data from client requests and creates responses.
request_hand... | {
let encrypted_request = encrypted_request.context("Couldn't receive request")?;
let decrypted_request = self
.encryptor
.decrypt(&encrypted_request.body)
.context("Couldn't decrypt request")?;
let response = (self.cleartext_handler.c... | conditional_block |
server.rs | //
// Copyright 2022 The Project Oak Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law o... | let incoming_message = request_stream.next()
.await
.ok_or_else(|| {
error_logger.log_error("Stream stopped preemptively");
Status::internal("")
})?
.map_err(|error| {
... | })?,
additional_info,
);
while !handshaker.is_completed() { | random_line_split |
repeat-to-run-dtor-twice.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 a = Foo { x: 3 };
let _ = [ a; 5 ];
//~^ ERROR the trait `core::marker::Copy` is not implemented for the type `Foo`
}
| main | identifier_name |
repeat-to-run-dtor-twice.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 ... |
fn main() {
let a = Foo { x: 3 };
let _ = [ a; 5 ];
//~^ ERROR the trait `core::marker::Copy` is not implemented for the type `Foo`
} | println!("Goodbye!");
}
} | random_line_split |
pool.rs | //! B+-tree node pool.
#[cfg(test)]
use super::Comparator;
use super::{Forest, Node, NodeData};
use crate::entity::PrimaryMap;
#[cfg(test)]
use core::fmt;
use core::ops::{Index, IndexMut};
/// A pool of nodes, including a free list.
pub(super) struct NodePool<F: Forest> {
nodes: PrimaryMap<Node, NodeData<F>>,
... |
}
#[cfg(test)]
impl<F: Forest> NodePool<F> {
/// Verify the consistency of the tree rooted at `node`.
pub fn verify_tree<C: Comparator<F::Key>>(&self, node: Node, comp: &C)
where
NodeData<F>: fmt::Display,
F::Key: fmt::Display,
{
use crate::entity::SparseSet;
use core::... | {
if let NodeData::Inner { size, tree, .. } = self[node] {
// Note that we have to capture `tree` by value to avoid borrow checker trouble.
#[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_range_loop))]
for i in 0..usize::from(size + 1) {
// Recursi... | identifier_body |
pool.rs | //! B+-tree node pool.
#[cfg(test)]
use super::Comparator;
use super::{Forest, Node, NodeData};
use crate::entity::PrimaryMap;
#[cfg(test)]
use core::fmt;
use core::ops::{Index, IndexMut};
/// A pool of nodes, including a free list.
pub(super) struct NodePool<F: Forest> {
nodes: PrimaryMap<Node, NodeData<F>>,
... | (&self, index: Node) -> &Self::Output {
self.nodes.index(index)
}
}
impl<F: Forest> IndexMut<Node> for NodePool<F> {
fn index_mut(&mut self, index: Node) -> &mut Self::Output {
self.nodes.index_mut(index)
}
}
| index | identifier_name |
pool.rs | //! B+-tree node pool.
#[cfg(test)]
use super::Comparator;
use super::{Forest, Node, NodeData};
use crate::entity::PrimaryMap;
#[cfg(test)]
use core::fmt;
use core::ops::{Index, IndexMut};
/// A pool of nodes, including a free list.
pub(super) struct NodePool<F: Forest> {
nodes: PrimaryMap<Node, NodeData<F>>,
... |
self.free_node(node);
}
}
#[cfg(test)]
impl<F: Forest> NodePool<F> {
/// Verify the consistency of the tree rooted at `node`.
pub fn verify_tree<C: Comparator<F::Key>>(&self, node: Node, comp: &C)
where
NodeData<F>: fmt::Display,
F::Key: fmt::Display,
{
use crate::e... | {
// Note that we have to capture `tree` by value to avoid borrow checker trouble.
#[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_range_loop))]
for i in 0..usize::from(size + 1) {
// Recursively free sub-trees. This recursion can never be deeper than `MAX... | conditional_block |
pool.rs | //! B+-tree node pool.
#[cfg(test)]
use super::Comparator;
use super::{Forest, Node, NodeData};
use crate::entity::PrimaryMap;
#[cfg(test)]
use core::fmt;
use core::ops::{Index, IndexMut};
/// A pool of nodes, including a free list.
pub(super) struct NodePool<F: Forest> {
nodes: PrimaryMap<Node, NodeData<F>>,
... | fn index_mut(&mut self, index: Node) -> &mut Self::Output {
self.nodes.index_mut(index)
}
} | impl<F: Forest> IndexMut<Node> for NodePool<F> { | random_line_split |
regions-fn-subtyping.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {
}
| {
let mut g: @fn<'r>(x: &'r uint) = |_| {};
g = f;
} | identifier_body |
regions-fn-subtyping.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
pub fn main() {
} | // This version is the same as above, except that here, g's type is
// inferred.
fn ok_inferred(f: @fn(x: &uint)) {
let mut g: @fn<'r>(x: &'r uint) = |_| {};
g = f; | random_line_split |
regions-fn-subtyping.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 ... | () {
}
| main | identifier_name |
transaction.rs | //! A trivial global lock transaction system.
//!
//! At the moment, this is really just a global static mutex, that needs to be
//! locked, to ensure the atomicity of a transaction.
use crate::fnbox::FnBox;
use lazy_static::lazy_static;
use std::cell::RefCell;
use std::sync::Mutex;
lazy_static! {
/// The global ... | self.finalizers.push(Box::new(callback));
}
/// Advance transactions by moving out intermediate stage callbacks.
fn finalizers(&mut self) -> Vec<Callback> {
use std::mem;
let mut finalizers = vec![];
mem::swap(&mut finalizers, &mut self.finalizers);
finalizers
}
... | pub fn later<F: FnOnce() + 'static>(&mut self, callback: F) { | random_line_split |
transaction.rs | //! A trivial global lock transaction system.
//!
//! At the moment, this is really just a global static mutex, that needs to be
//! locked, to ensure the atomicity of a transaction.
use crate::fnbox::FnBox;
use lazy_static::lazy_static;
use std::cell::RefCell;
use std::sync::Mutex;
lazy_static! {
/// The global ... | {
finalizers: Vec<Callback>,
}
impl Transaction {
/// Create a new transaction
fn new() -> Transaction {
Transaction { finalizers: vec![] }
}
/// Add a finalizing callback. This should not have far reaching
/// side-effects, and in particular not commit by itself. Typical operations
... | Transaction | identifier_name |
transaction.rs | //! A trivial global lock transaction system.
//!
//! At the moment, this is really just a global static mutex, that needs to be
//! locked, to ensure the atomicity of a transaction.
use crate::fnbox::FnBox;
use lazy_static::lazy_static;
use std::cell::RefCell;
use std::sync::Mutex;
lazy_static! {
/// The global ... |
pub fn later<F: FnOnce() +'static>(action: F) {
with_current(|c| c.later(action))
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn commit_single() {
let mut v = 3;
commit(|| v += 5);
assert_eq!(v, 8);
}
#[test]
fn commit_nested() {
let mut v = 3;
... | {
CURRENT_TRANSACTION.with(|current| match *current.borrow_mut() {
Some(ref mut trans) => action(trans),
_ => panic!("there is no active transaction to register a callback"),
})
} | identifier_body |
vec-dst.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 ... | assert_eq!(x[2], 3);
}
| {
// Tests for indexing into box/& [T; n]
let x: [isize; 3] = [1, 2, 3];
let mut x: Box<[isize; 3]> = box x;
assert_eq!(x[0], 1);
assert_eq!(x[1], 2);
assert_eq!(x[2], 3);
x[1] = 45;
assert_eq!(x[0], 1);
assert_eq!(x[1], 45);
assert_eq!(x[2], 3);
let mut x: [isize; 3] = [1, ... | identifier_body |
vec-dst.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 ... | () {
// Tests for indexing into box/& [T; n]
let x: [isize; 3] = [1, 2, 3];
let mut x: Box<[isize; 3]> = box x;
assert_eq!(x[0], 1);
assert_eq!(x[1], 2);
assert_eq!(x[2], 3);
x[1] = 45;
assert_eq!(x[0], 1);
assert_eq!(x[1], 45);
assert_eq!(x[2], 3);
let mut x: [isize; 3] = [... | main | identifier_name |
vec-dst.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.
// | // 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.
// run-pass
#![feature(box_syntax)]
pub fn main() {
// Tests for indexing into box... | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
parser.rs | use parser;
use filehandler;
use model;
use std::env;
#[test]
fn test_parse_demofile() {
let mut currentWD = env::current_dir().unwrap().display().to_string();
currentWD.push_str("/doc/samples/simple.sjs");
let opts = model::CommandlineOptions {
filename: currentWD.clone(),
target_language:model::Target... | {
let success = parser::Parser::is_valid_name_character(&'u');
let error = parser::Parser::is_valid_name_character(&'{');
assert!(success);
assert!(!error);
} | identifier_body | |
parser.rs | use parser;
use filehandler;
use model;
use std::env;
#[test]
fn test_parse_demofile() {
let mut currentWD = env::current_dir().unwrap().display().to_string();
currentWD.push_str("/doc/samples/simple.sjs");
let opts = model::CommandlineOptions {
filename: currentWD.clone(),
target_language:model::Target... | () {
let success = parser::Parser::is_valid_name_character(&'u');
let error = parser::Parser::is_valid_name_character(&'{');
assert!(success);
assert!(!error);
}
| test_is_valid_name_character | identifier_name |
parser.rs | use parser;
use filehandler;
use model;
use std::env;
#[test]
fn test_parse_demofile() {
let mut currentWD = env::current_dir().unwrap().display().to_string();
currentWD.push_str("/doc/samples/simple.sjs");
let opts = model::CommandlineOptions {
filename: currentWD.clone(),
target_language:model::Target... | let result = p.parse(&mut model);
println!("{:?}", result);
// Testfaelle einbauen:
// panic!("TEST");
}
#[test]
fn test_is_whitespace_or_newline() {
let success = parser::Parser::is_whitespace_or_newline(&' ');
let error = parser::Parser::is_whitespace_or_newline(&'/');
assert!(success);
assert!(!... | let mut p:parser::Parser = parser::Parser::new();
| random_line_split |
font_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/. */
use font::{Font, FontGroup};
use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use styl... |
Err(_) => debug!("Failed to create fallback layout font!")
}
}
}
let font_group = Rc::new(FontGroup::new(fonts));
self.layout_font_group_cache.insert(layout_font_group_cache_key, font_group.clone());
font_group
}
/// Create a pai... | {
let layout_font = Rc::new(RefCell::new(layout_font));
self.fallback_font_cache.push(FallbackFontCacheEntry {
font: layout_font.clone(),
});
fonts.push(layout_font);
} | conditional_block |
font_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/. */
use font::{Font, FontGroup};
use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use styl... | style.font_stretch,
style.font_style == font_style::T::italic ||
style.font_style == font_style::T::oblique);
let mut fonts = SmallVec8::new();
for family in st... | {
let address = &*style as *const SpecifiedFontStyle as usize;
if let Some(ref cached_font_group) = self.layout_font_group_cache.get(&address) {
return (*cached_font_group).clone()
}
let layout_font_group_cache_key = LayoutFontGroupCacheKey {
pointer: style.clone... | identifier_body |
font_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/. */
use font::{Font, FontGroup};
use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use styl... | {
pointer: Arc<SpecifiedFontStyle>,
size: Au,
address: usize,
}
impl PartialEq for LayoutFontGroupCacheKey {
fn eq(&self, other: &LayoutFontGroupCacheKey) -> bool {
self.pointer.font_family == other.pointer.font_family &&
self.pointer.font_stretch == other.pointer.font_stretch &&
... | LayoutFontGroupCacheKey | identifier_name |
font_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 | use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use style::computed_values::{font_style, font_variant};
use font::FontHandleMethods;
use font_cache_task::FontCacheTask;
use font_template::FontTemplateDescriptor;
use fnv::FnvHasher;
use platform::font::FontHandle;
use platform::font_templat... | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use font::{Font, FontGroup}; | random_line_split |
viewport.rs | // This file is part of rgtk.
//
// rgtk 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, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | pub fn new(hadjustment: >k::Adjustment, vadjustment: >k::Adjustment) -> Option<Viewport> {
let tmp_pointer = unsafe { ffi::gtk_viewport_new(hadjustment.get_pointer(), vadjustment.get_pointer()) };
check_pointer!(tmp_pointer, Viewport)
}
pub fn get_shadow_type(&self) -> gtk::ShadowType {... |
/// GtkViewport — An adapter which makes widgets scrollable
struct_Widget!(Viewport)
impl Viewport { | random_line_split |
viewport.rs | // This file is part of rgtk.
//
// rgtk 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, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | mut self, ty: gtk::ShadowType) {
unsafe {
ffi::gtk_viewport_set_shadow_type(GTK_VIEWPORT(self.pointer), ty)
}
}
}
impl_drop!(Viewport)
impl_TraitWidget!(Viewport)
impl gtk::ContainerTrait for Viewport {}
impl gtk::BinTrait for Viewport {}
impl gtk::ScrollableTrait for Viewport {}
impl... | t_shadow_type(& | identifier_name |
viewport.rs | // This file is part of rgtk.
//
// rgtk 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, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | pub fn get_shadow_type(&self) -> gtk::ShadowType {
unsafe {
ffi::gtk_viewport_get_shadow_type(GTK_VIEWPORT(self.pointer))
}
}
pub fn set_shadow_type(&mut self, ty: gtk::ShadowType) {
unsafe {
ffi::gtk_viewport_set_shadow_type(GTK_VIEWPORT(self.pointer), ty)
... | let tmp_pointer = unsafe { ffi::gtk_viewport_new(hadjustment.get_pointer(), vadjustment.get_pointer()) };
check_pointer!(tmp_pointer, Viewport)
}
| identifier_body |
bench.rs | #![feature(test)]
extern crate robots;
extern crate test;
use std::any::Any;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender};
use robots::actors::{Actor, ActorSystem, ActorCell, ActorContext, Props};
use test::Bencher;
#[derive(Copy, Clone, PartialEq)]
enum BenchMessage {
Nothing,
Over,... |
}
#[bench]
/// This bench sends a thousand messages to an actor then waits for an answer on a channel.
/// When the thousandth is handled the actor sends a message on the above channel.
fn send_1000_messages(b: &mut Bencher) {
let actor_system = ActorSystem::new("test".to_owned());
let (tx, rx) = channel();... | {
InternalState { sender: sender }
} | identifier_body |
bench.rs | #![feature(test)]
extern crate robots;
extern crate test;
use std::any::Any;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender};
use robots::actors::{Actor, ActorSystem, ActorCell, ActorContext, Props};
use test::Bencher;
#[derive(Copy, Clone, PartialEq)]
enum BenchMessage {
Nothing,
Over,... | (_: ()) -> Dummy {
Dummy
}
}
#[bench]
/// This bench creates a thousand empty actors.
/// Since actor creation is synchronous this is ok to just call the function mutiple times.
/// The created actor is empty in order to just bench the overhead of creation.
fn create_1000_actors(b: &mut Bencher) {
let ... | new | identifier_name |
bench.rs | #![feature(test)]
extern crate robots;
extern crate test;
use std::any::Any;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender};
use robots::actors::{Actor, ActorSystem, ActorCell, ActorContext, Props};
use test::Bencher;
#[derive(Copy, Clone, PartialEq)]
enum BenchMessage {
Nothing,
Over,... |
}
}
}
impl InternalState {
fn new(sender: Arc<Mutex<Sender<()>>>) -> InternalState {
InternalState { sender: sender }
}
}
#[bench]
/// This bench sends a thousand messages to an actor then waits for an answer on a channel.
/// When the thousandth is handled the actor sends a message on t... | {
let _ = self.sender.lock().unwrap().send(());
} | conditional_block |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.