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 |
|---|---|---|---|---|
format.rs | use super::{
Attributes, Data, Event, EventFormatDeserializerV03, EventFormatDeserializerV10,
EventFormatSerializerV03, EventFormatSerializerV10,
};
use crate::event::{AttributesReader, ExtensionValue};
use serde::de::{Error, IntoDeserializer};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use ... | map: &mut Map<String, Value>,
) -> Result<Attributes, E>;
fn deserialize_data<E: serde::de::Error>(
content_type: &str,
map: &mut Map<String, Value>,
) -> Result<Option<Data>, E>;
fn deserialize_event<E: serde::de::Error>(mut map: Map<String, Value>) -> Result<Event, E> {
... | fn deserialize_attributes<E: serde::de::Error>( | random_line_split |
clear.rs | use fbo::{self, ValidatedAttachments};
use context::Context;
use ContextExt;
use Rect;
use Surface;
use Api;
use version::Version;
use gl;
pub fn clear(context: &Context, framebuffer: Option<&ValidatedAttachments>,
rect: Option<&Rect>, color: Option<(f32, f32, f32, f32)>, depth: Option<f32>,
... |
}
if let Some(stencil) = stencil {
let stencil = stencil as gl::types::GLint;
flags |= gl::STENCIL_BUFFER_BIT;
if ctxt.state.clear_stencil!= stencil {
ctxt.gl.ClearStencil(stencil);
ctxt.state.clear_stencil = stencil;
}
... | {
ctxt.gl.DepthMask(gl::TRUE);
ctxt.state.depth_mask = true;
} | conditional_block |
clear.rs | use fbo::{self, ValidatedAttachments};
use context::Context;
use ContextExt;
use Rect;
use Surface;
use Api;
use version::Version;
use gl;
pub fn clear(context: &Context, framebuffer: Option<&ValidatedAttachments>,
rect: Option<&Rect>, color: Option<(f32, f32, f32, f32)>, depth: Option<f32>,
... | if ctxt.version >= &Version(Api::Gl, 3, 0) {
ctxt.gl.EndConditionalRender();
} else if ctxt.extensions.gl_nv_conditional_render {
ctxt.gl.EndConditionalRenderNV();
} else {
unreachable!();
}
ctxt.state.condition... | {
unsafe {
let mut ctxt = context.make_current();
let fbo_id = context.get_framebuffer_objects()
.get_framebuffer_for_drawing(framebuffer, &mut ctxt);
fbo::bind_framebuffer(&mut ctxt, fbo_id, true, false);
if ctxt.state.enabled_rasterizer_discard {
... | identifier_body |
clear.rs | use fbo::{self, ValidatedAttachments};
use context::Context;
use ContextExt;
use Rect;
use Surface;
use Api;
use version::Version;
use gl;
pub fn clear(context: &Context, framebuffer: Option<&ValidatedAttachments>,
rect: Option<&Rect>, color: Option<(f32, f32, f32, f32)>, depth: Option<f32>,
... | {
unsafe {
let mut ctxt = context.make_current();
let fbo_id = context.get_framebuffer_objects()
.get_framebuffer_for_drawing(framebuffer, &mut ctxt);
fbo::bind_framebuffer(&mut ctxt, fbo_id, true, false);
if ctxt.state.enabled_rasterizer_discard {
... | random_line_split | |
clear.rs | use fbo::{self, ValidatedAttachments};
use context::Context;
use ContextExt;
use Rect;
use Surface;
use Api;
use version::Version;
use gl;
pub fn | (context: &Context, framebuffer: Option<&ValidatedAttachments>,
rect: Option<&Rect>, color: Option<(f32, f32, f32, f32)>, depth: Option<f32>,
stencil: Option<i32>)
{
unsafe {
let mut ctxt = context.make_current();
let fbo_id = context.get_framebuffer_objects()
... | clear | identifier_name |
imp.rs | use glib::prelude::*;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use std::ffi::CString;
use std::os::raw::c_char;
use std::sync::Mutex;
pub use gstreamer_rtp::rtp_buffer::compare_seqnum;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer... | // Create and add pad templates for our sink and source pad. These
// are later used for actually creating the pads and beforehand
// already provide information to GStreamer about all possible
// pads that could exist for this type.
//
// Actual instances can create pads based on those pad temp... | random_line_split | |
imp.rs | use glib::prelude::*;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use std::ffi::CString;
use std::os::raw::c_char;
use std::sync::Mutex;
pub use gstreamer_rtp::rtp_buffer::compare_seqnum;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer... |
}
| {
gst_info!(CAT, obj: element, "Changing state {:?}", transition);
// Call the parent class' implementation of ::change_state()
self.parent_change_state(element, transition)
} | identifier_body |
imp.rs | use glib::prelude::*;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use std::ffi::CString;
use std::os::raw::c_char;
use std::sync::Mutex;
pub use gstreamer_rtp::rtp_buffer::compare_seqnum;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer... | else if fls.contains(gst::PadFlags::FLUSHING) {
println!("screamtxbw FL {:?}", fls);
return;
}
let mut buffer = gst::Buffer::new_rtp_with_sizes(len, 4, 0).unwrap();
{
let buffer = buffer.get_mut().unwrap();
let mut rtp_buffer = RTPBuffer::from_buf... | {
println!("screamtxbw EOS {:?}", fls);
return;
} | conditional_block |
imp.rs | use glib::prelude::*;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use std::ffi::CString;
use std::os::raw::c_char;
use std::sync::Mutex;
pub use gstreamer_rtp::rtp_buffer::compare_seqnum;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer;
pub use gstreamer_rtp::rtp_buffer::RTPBuffer... | {
params: Option<String>,
bitrate: u32,
}
impl Default for Settings {
fn default() -> Self {
Settings {
params: None,
bitrate: DEFAULT_BITRATE,
}
}
}
// static STREAMTX_PTR: Option<&Screamtxbw> = None;
// Struct containing all the element data
#[repr(C)]
pub ... | Settings | identifier_name |
rustc.rs | use crate::command_prelude::*;
use cargo::ops;
pub fn | () -> App {
subcommand("rustc")
.setting(AppSettings::TrailingVarArg)
.about("Compile a package, and pass extra options to the compiler")
.arg(opt("quiet", "No output printed to stdout").short("q"))
.arg(Arg::with_name("args").multiple(true).help("Rustc flags"))
.arg_package("Pack... | cli | identifier_name |
rustc.rs | use crate::command_prelude::*;
use cargo::ops;
pub fn cli() -> App {
subcommand("rustc")
.setting(AppSettings::TrailingVarArg)
.about("Compile a package, and pass extra options to the compiler")
.arg(opt("quiet", "No output printed to stdout").short("q"))
.arg(Arg::with_name("args").mu... | )
}
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mode = match args.value_of("profile") {
Some("dev") | None => CompileMode::Build,
Some("test") => CompileMode::Test,
Some("bench") => CompileMode::Bench,
Some... | `build.rustflags` configuration option.
", | random_line_split |
rustc.rs | use crate::command_prelude::*;
use cargo::ops;
pub fn cli() -> App | .arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_features()
.arg_target_triple("Target triple which compiles will be for")
.arg_target_dir()
.arg_manifest_path()
.arg_message_format()
... | {
subcommand("rustc")
.setting(AppSettings::TrailingVarArg)
.about("Compile a package, and pass extra options to the compiler")
.arg(opt("quiet", "No output printed to stdout").short("q"))
.arg(Arg::with_name("args").multiple(true).help("Rustc flags"))
.arg_package("Package t... | identifier_body |
ffi.rs | // Copyright 2014-2015 Sam Doshi (sam@metal-fish.co.uk)
// Copyright 2013-2014 Philippe Delrieu (philippe.delrieu@free.fr)
//
// Licensed under the MIT License <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
use libc::{c_char, c... | -9996 => Some(PmError::PmBufferOverflow),
-9995 => Some(PmError::PmBadPtr),
-9994 => Some(PmError::PmBadData),
-9993 => Some(PmError::PmInternalError),
-9992 => Some(PmError::PmBufferMaxSize),
_ => None
}
}
#[link(name = "portmidi")]
extern "C" {
pub fn Pm_Initia... | 1 => Some(PmError::PmGotData),
-10000 => Some(PmError::PmHostError),
-9999 => Some(PmError::PmInvalidDeviceId),
-9998 => Some(PmError::PmInsufficientMemory),
-9997 => Some(PmError::PmBufferTooSmall), | random_line_split |
ffi.rs | // Copyright 2014-2015 Sam Doshi (sam@metal-fish.co.uk)
// Copyright 2013-2014 Philippe Delrieu (philippe.delrieu@free.fr)
//
// Licensed under the MIT License <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
use libc::{c_char, c... | {
pub message : PmMessage,
pub timestamp : PmTimestamp,
}
#[repr(C)]
pub struct PmDeviceInfo {
pub struct_version: i32, /* < this internal structure version */
pub interf : *const c_char, /* < underlying MIDI API, e.g. MMSystem or DirectX */
pub name : *const c_char, /* < device name, e.g. USB ... | PmEvent | identifier_name |
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
use dom::bindings::cell::DOMRefCell;
... | (());
impl Console {
fn send_to_devtools(global: GlobalRef, level: LogLevel, message: DOMString) {
if let Some(chan) = global.devtools_chan() {
let console_message = prepare_message(level, message);
let devtools_message = ScriptToDevtoolsControlMsg::ConsoleAPI(
globa... | Console | identifier_name |
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
use dom::bindings::cell::DOMRefCell;
... |
}
}
impl Console {
// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
pub fn Log(global: GlobalRef, messages: Vec<DOMString>) {
for message in messages {
println!("{}", message);
Self::send_to_devtools(global, LogLevel::Log, message);
}
}
// ht... | {
let console_message = prepare_message(level, message);
let devtools_message = ScriptToDevtoolsControlMsg::ConsoleAPI(
global.pipeline_id(),
console_message,
global.get_worker_id());
chan.send(devtools_message).unwrap();
} | conditional_block |
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
use dom::bindings::cell::DOMRefCell;
... | }
impl Console {
// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
pub fn Log(global: GlobalRef, messages: Vec<DOMString>) {
for message in messages {
println!("{}", message);
Self::send_to_devtools(global, LogLevel::Log, message);
}
}
// https://d... | console_message,
global.get_worker_id());
chan.send(devtools_message).unwrap();
}
} | random_line_split |
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
use dom::bindings::cell::DOMRefCell;
... |
}
| {
self.0.borrow_mut().remove(label).ok_or(()).map(|start| {
timestamp_in_ms(get_time()) - start
})
} | identifier_body |
parser.rs | use crate::plugins;
use comrak::{
format_html,
nodes::{AstNode, NodeHtmlBlock, NodeValue},
parse_document, ComrakExtensionOptions, ComrakOptions, ComrakParseOptions,
ComrakRenderOptions,
};
use std::string::FromUtf8Error;
use std::{
collections::BTreeMap,
sync::{Arc, Mutex},
};
use syntect::{
... | else {
format!("/#{}", url5)
};
log::info!("url6: {}", url6);
let mut new_nodelink = nodelink.clone();
new_nodelink.url = url6.into_bytes();
NodeValue::Link(new_no... | {
// leave as it
url5
} | conditional_block |
parser.rs | use crate::plugins;
use comrak::{
format_html,
nodes::{AstNode, NodeHtmlBlock, NodeValue},
parse_document, ComrakExtensionOptions, ComrakOptions, ComrakParseOptions,
ComrakRenderOptions,
};
use std::string::FromUtf8Error;
use std::{
collections::BTreeMap,
sync::{Arc, Mutex},
};
use syntect::{
... | (lang: &str, literal: &str) -> Option<NodeValue> {
let lang_name = match lang {
"rust" => "Rust",
_ => "text",
};
let ss = SyntaxSet::load_defaults_newlines();
let ts = ThemeSet::load_defaults();
let theme = &ts.themes["base16-ocean.light"];
let _c = theme.settings.background.un... | format_source_code | identifier_name |
parser.rs | use crate::plugins;
use comrak::{
format_html,
nodes::{AstNode, NodeHtmlBlock, NodeValue},
parse_document, ComrakExtensionOptions, ComrakOptions, ComrakParseOptions,
ComrakRenderOptions,
};
use std::string::FromUtf8Error;
use std::{
collections::BTreeMap,
sync::{Arc, Mutex},
};
use syntect::{
... | } else {
None
}
} else {
None
};
Ok(Html {
title,
content: render_html,
})
} else {
Err(ParseError::MdParseError)
}
}
fn format_source_code(lang: &str, literal: &str) -> Option<NodeValue> {
l... | if let Some(ref got) = *got {
Some(got.to_string()) | random_line_split |
parser.rs | use crate::plugins;
use comrak::{
format_html,
nodes::{AstNode, NodeHtmlBlock, NodeValue},
parse_document, ComrakExtensionOptions, ComrakOptions, ComrakParseOptions,
ComrakRenderOptions,
};
use std::string::FromUtf8Error;
use std::{
collections::BTreeMap,
sync::{Arc, Mutex},
};
use syntect::{
... |
}
pub fn parse(arg: &str) -> Result<Html, ParseError> {
let referred_files = pre_parse_get_embedded_files(arg);
let embed_files = if let Ok(referred_files) = referred_files {
let file_contents = plugins::fetch_file_contents(referred_files);
Some(file_contents)
} else {
None
};
... | {
Settings { base_dir: None }
} | identifier_body |
utils.rs | use std::fmt;
use std::path::{Path, PathBuf}; | use rustc_serialize::{Encodable, Encoder};
use url::Url;
use git2::{self, ObjectType};
use core::GitReference;
use util::{CargoResult, ChainError, human, ToUrl, internal};
#[derive(PartialEq, Clone, Debug)]
pub struct GitRevision(git2::Oid);
impl fmt::Display for GitRevision {
fn fmt(&self, f: &mut fmt::Formatte... | use std::fs::{self, File};
| random_line_split |
utils.rs | use std::fmt;
use std::path::{Path, PathBuf};
use std::fs::{self, File};
use rustc_serialize::{Encodable, Encoder};
use url::Url;
use git2::{self, ObjectType};
use core::GitReference;
use util::{CargoResult, ChainError, human, ToUrl, internal};
#[derive(PartialEq, Clone, Debug)]
pub struct GitRevision(git2::Oid);
i... | (&self) -> CargoResult<()> {
// If we're interrupted while performing this reset (e.g. we die because
// of a signal) Cargo needs to be sure to try to check out this repo
// again on the next go-round.
//
// To enable this we have a dummy file in our checkout,.cargo-ok, which
... | reset | identifier_name |
utils.rs | use std::fmt;
use std::path::{Path, PathBuf};
use std::fs::{self, File};
use rustc_serialize::{Encodable, Encoder};
use url::Url;
use git2::{self, ObjectType};
use core::GitReference;
use util::{CargoResult, ChainError, human, ToUrl, internal};
#[derive(PartialEq, Clone, Debug)]
pub struct GitRevision(git2::Oid);
i... | let head_and_repo = child.open().and_then(|repo| {
let target = try!(repo.head()).target();
Ok((target, repo))
});
let repo = match head_and_repo {
Ok((head, repo)) => {
if child.head_id()... | {
info!("update submodules for: {:?}", repo.workdir().unwrap());
for mut child in try!(repo.submodules()).into_iter() {
try!(child.init(false));
let url = try!(child.url().chain_error(|| {
internal("non-utf8 url for submodule")
... | identifier_body |
realloc-16687.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... |
unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
if PRINT {
println!("reallocate(ptr=0x{:010x} old_size={} size={} align={})",
ptr as usize, old_size, size, align);
}
let ret = heap::reallocate(ptr, old_size, size,... | {
if PRINT { println!("deallocate(ptr=0x{:010x} size={} align={})",
ptr as usize, size, align);
}
heap::deallocate(ptr, size, align);
} | identifier_body |
realloc-16687.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... | }
// Test 2: turn the square back into a triangle, top to bottom.
unsafe fn test_2(ascend: &mut [*mut u8]) {
let old_size = idx_to_size(COUNT-1);
for i in 0..COUNT / 2 {
let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(new_size < old_siz... | random_line_split | |
realloc-16687.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... |
if PRINT {
println!("reallocate(ptr=0x{:010x} old_size={} size={} align={}) \
ret: 0x{:010x}",
ptr as usize, old_size, size, align, ret as usize);
}
ret
}
fn idx_to_size(i: usize) -> usize { (i+1) * 10 }
// Allocate pairs of ... | { alloc::oom() } | conditional_block |
realloc-16687.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... | (ascend: &mut [*mut u8]) {
let new_size = idx_to_size(COUNT-1);
for i in 0..COUNT / 2 {
let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(old_size < new_size);
ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN);
sanity_ch... | test_1 | identifier_name |
issue-53789-2.rs | // Regression test for #53789.
//
// compile-pass
#![feature(nll)]
#![allow(unused_variables)]
use std::collections::BTreeMap;
use std::ops::Range;
use std::cmp::Ord;
macro_rules! valuetree {
() => {
type ValueTree =
<Self::Strategy as $crate::Strategy>::Value;
};
}
macro_rules! product_... | <S, F> {
source: S,
fun: F,
}
impl<S, F> Map<S, F> {
pub fn new(source: S, fun: F) -> Self {
unimplemented!()
}
}
}
fn main() { }
| Map | identifier_name |
issue-53789-2.rs | // Regression test for #53789.
//
// compile-pass
#![feature(nll)]
#![allow(unused_variables)]
use std::collections::BTreeMap;
use std::ops::Range;
use std::cmp::Ord;
macro_rules! valuetree {
() => {
type ValueTree =
<Self::Strategy as $crate::Strategy>::Value;
};
}
macro_rules! product_... | #[derive(Clone)]
pub struct Map<S, F> {
source: S,
fun: F,
}
impl<S, F> Map<S, F> {
pub fn new(source: S, fun: F) -> Self {
unimplemented!()
}
}
}
fn main() { } | unimplemented!()
}
}
| random_line_split |
util.rs | //! Contains utility things used in glium's internals
use std::default::Default;
use std::hash::Hasher;
/// A speedy hash algorithm for node ids and def ids. The hashmap in
/// libcollections by default uses SipHash which isn't quite as speedy as we
/// want. In the compiler we're not really worried about DOS attempt... | let FnvHasher(mut hash) = *self;
for byte in bytes {
hash = hash ^ (*byte as u64);
hash = hash * 0x100000001b3;
}
*self = FnvHasher(hash);
}
fn finish(&self) -> u64 { self.0 }
} | impl Hasher for FnvHasher {
fn write(&mut self, bytes: &[u8]) { | random_line_split |
util.rs | //! Contains utility things used in glium's internals
use std::default::Default;
use std::hash::Hasher;
/// A speedy hash algorithm for node ids and def ids. The hashmap in
/// libcollections by default uses SipHash which isn't quite as speedy as we
/// want. In the compiler we're not really worried about DOS attempt... | (u64);
impl Default for FnvHasher {
fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) }
}
impl Hasher for FnvHasher {
fn write(&mut self, bytes: &[u8]) {
let FnvHasher(mut hash) = *self;
for byte in bytes {
hash = hash ^ (*byte as u64);
hash = hash * 0x100000001... | FnvHasher | identifier_name |
lib.rs | extern crate bazel_protos;
extern crate digest;
extern crate grpcio;
extern crate protobuf;
extern crate sha2;
use std::collections::BTreeMap;
pub mod local;
pub mod remote;
#[cfg(test)]
mod test_server;
///
/// A process to be executed.
///
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct ExecuteProcessReque... | pub stderr: Vec<u8>,
pub exit_code: i32,
} | #[derive(Clone, Debug, Eq, PartialEq)]
pub struct ExecuteProcessResult {
pub stdout: Vec<u8>, | random_line_split |
lib.rs | extern crate bazel_protos;
extern crate digest;
extern crate grpcio;
extern crate protobuf;
extern crate sha2;
use std::collections::BTreeMap;
pub mod local;
pub mod remote;
#[cfg(test)]
mod test_server;
///
/// A process to be executed.
///
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct | {
///
/// The arguments to execute.
///
/// The first argument should be an absolute or relative path to the binary to execute.
///
/// No PATH lookup will be performed unless a PATH environment variable is specified.
///
/// No shell expansion will take place.
///
pub argv: Vec<String>,
///
//... | ExecuteProcessRequest | identifier_name |
udp.rs | extern crate futures;
#[macro_use]
extern crate tokio_core;
use std::io;
use std::net::SocketAddr;
use futures::{Future, Poll};
use tokio_core::net::UdpSocket;
use tokio_core::reactor::Core;
macro_rules! t {
($e:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {:?}", stringify!($... |
struct SendMessage {
socket: UdpSocket,
addr: SocketAddr,
}
impl Future for SendMessage {
type Item = ();
type Error = io::Error;
fn poll(&mut self) -> Poll<(), io::Error> {
let n = try_nb!(self.socket.send_to(b"1234", &self.addr));
assert_eq!(n, 4);
Ok(().into())
}
}... | {
let mut l = t!(Core::new());
let a = t!(UdpSocket::bind(&t!("127.0.0.1:0".parse()), &l.handle()));
let b = t!(UdpSocket::bind(&t!("127.0.0.1:0".parse()), &l.handle()));
let a_addr = t!(a.local_addr());
let b_addr = t!(b.local_addr());
let send = SendMessage { socket: a, addr: b_addr };
le... | identifier_body |
udp.rs | extern crate futures;
#[macro_use]
extern crate tokio_core;
use std::io;
use std::net::SocketAddr;
use futures::{Future, Poll};
use tokio_core::net::UdpSocket;
use tokio_core::reactor::Core;
macro_rules! t {
($e:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {:?}", stringify!($... | (&mut self) -> Poll<(), io::Error> {
let mut buf = [0; 32];
let (n, addr) = try_nb!(self.socket.recv_from(&mut buf));
assert_eq!(n, 4);
assert_eq!(&buf[..4], b"1234");
assert_eq!(addr, self.expected_addr);
Ok(().into())
}
}
| poll | identifier_name |
udp.rs | extern crate futures;
#[macro_use]
extern crate tokio_core;
| use std::io;
use std::net::SocketAddr;
use futures::{Future, Poll};
use tokio_core::net::UdpSocket;
use tokio_core::reactor::Core;
macro_rules! t {
($e:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {:?}", stringify!($e), e),
})
}
#[test]
fn send_messages() {
let mut l ... | random_line_split | |
build.rs | extern crate gcc;
use std::env;
fn main() | } else if cfg!(target_os = "macos") {
minidfs_config
.include(format!("{}/include/darwin", val));
}
// TODO - to be changed to consider a dependent platform.
},
Err(e) => { panic!("JAVA_HOME shell environment must be set: {}", e); }
}
minidfs_config.compile("libminidfs.a"... | {
// for libhdfs.a
match env::var("HADOOP_HOME") {
Ok(val) => {
println!("cargo:rustc-link-search=native={}/lib/native", val);
},
Err(e) => { panic!("HADOOP_HOME shell environment must be set: {}", e); }
}
// for jvm.h and linking to jni libraries
let mut minidfs_config = gcc::Config::ne... | identifier_body |
build.rs | extern crate gcc;
use std::env;
fn | () {
// for libhdfs.a
match env::var("HADOOP_HOME") {
Ok(val) => {
println!("cargo:rustc-link-search=native={}/lib/native", val);
},
Err(e) => { panic!("HADOOP_HOME shell environment must be set: {}", e); }
}
// for jvm.h and linking to jni libraries
let mut minidfs_config = gcc::Config:... | main | identifier_name |
build.rs | extern crate gcc;
use std::env;
fn main() {
// for libhdfs.a
match env::var("HADOOP_HOME") {
Ok(val) => {
println!("cargo:rustc-link-search=native={}/lib/native", val);
},
Err(e) => { panic!("HADOOP_HOME shell environment must be set: {}", e); }
}
// for jvm.h and linking to jni librarie... | minidfs_config.compile("libminidfs.a");
} | random_line_split | |
build.rs | extern crate gcc;
use std::env;
fn main() {
// for libhdfs.a
match env::var("HADOOP_HOME") {
Ok(val) => {
println!("cargo:rustc-link-search=native={}/lib/native", val);
},
Err(e) => { panic!("HADOOP_HOME shell environment must be set: {}", e); }
}
// for jvm.h and linking to jni librarie... |
}
minidfs_config.compile("libminidfs.a");
}
| { panic!("JAVA_HOME shell environment must be set: {}", e); } | conditional_block |
service.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... | {
pub opcode: u64,
pub sess: u64,
pub data: ExchangeData,
}
/// The delegate/obtain reply message
#[repr(C, packed)]
pub struct ExchangeReply {
pub res: u64,
pub data: ExchangeData,
}
/// The close request message
#[repr(C, packed)]
pub struct Close {
pub opcode: u64,
pub sess: u64,
}
//... | Exchange | identifier_name |
service.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... |
/// The delegate/obtain reply message
#[repr(C, packed)]
pub struct ExchangeReply {
pub res: u64,
pub data: ExchangeData,
}
/// The close request message
#[repr(C, packed)]
pub struct Close {
pub opcode: u64,
pub sess: u64,
}
/// The shutdown request message
#[repr(C, packed)]
pub struct Shutdown {
... | pub data: ExchangeData,
} | random_line_split |
service.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... |
}
write!(f, "]")
}
}
impl Unmarshallable for ExchangeData {
fn unmarshall(s: &mut Source) -> Self {
let mut res = ExchangeData {
caps: s.pop_word(),
args: unsafe { intrinsics::uninit() },
};
res.args.count = s.pop_word();
for i in 0..res.... | {
write!(f, ", ")?;
} | conditional_block |
path.rs | use std::fmt;
use std::hash::{Hash, Hasher};
use std::slice::{Iter, IterMut};
#[derive(Clone, PartialEq, Hash, Debug)]
pub enum Fragment {
Index(usize),
Name(String)
}
impl fmt::Display for Fragment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Fragment::Index(... | (&self) -> usize {
self.fragments.len()
}
pub fn from_str(path: &str) -> Option<Path> {
if path.is_empty() {
return None;
}
let is_relative = path.starts_with('.');
// If the path is relative remove the first dot
let new_path = if is_relative {
... | len | identifier_name |
path.rs | #[derive(Clone, PartialEq, Hash, Debug)]
pub enum Fragment {
Index(usize),
Name(String)
}
impl fmt::Display for Fragment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Fragment::Index(ref index) => write!(f, "{}", index),
Fragment::Name(ref name) => w... | use std::fmt;
use std::hash::{Hash, Hasher};
use std::slice::{Iter, IterMut};
| random_line_split | |
path.rs | use std::fmt;
use std::hash::{Hash, Hasher};
use std::slice::{Iter, IterMut};
#[derive(Clone, PartialEq, Hash, Debug)]
pub enum Fragment {
Index(usize),
Name(String)
}
impl fmt::Display for Fragment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Fragment::Index(... |
return self.fragments == other.fragments;
}
}
impl Hash for Path {
fn hash<H: Hasher>(&self, state: &mut H) {
self.to_string().hash(state);
}
} | {
return false;
} | conditional_block |
path.rs | use std::fmt;
use std::hash::{Hash, Hasher};
use std::slice::{Iter, IterMut};
#[derive(Clone, PartialEq, Hash, Debug)]
pub enum Fragment {
Index(usize),
Name(String)
}
impl fmt::Display for Fragment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Fragment::Index(... |
pub fn iter(&self) -> Iter<Fragment> {
self.fragments.iter()
}
pub fn len(&self) -> usize {
self.fragments.len()
}
pub fn from_str(path: &str) -> Option<Path> {
if path.is_empty() {
return None;
}
let is_relative = path.starts_with('.');
... | {
self.fragments.last()
} | identifier_body |
lib.rs | #![feature(str_checked_slicing)]
const DIGITS: [&str; 10] = [
" _ | ||_| ", // 0
" | | ", // 1
" _ _||_ ", // 2
" _ _| _| ", // 3
" |_| | ", // 4
" _ |_ _| ", // 5
" _ |_ |_| ", // 6
" _ | | ", // 7
" _ |_||_| ", // 8
" _ |_| _| ", // 9
];
con... | (input: &str) -> Result<String, String> {
let v = input.split(|x| x == '\n').collect::<Vec<_>>();
let lines = v.len();
if lines == 0 || lines % DIGITS_LINES!= 0 {
return Err("Invalid lines".to_string());
}
let rows = v[0].len();
if rows == 0 || rows % DIGITS_ROWS!= 0 {
return E... | convert | identifier_name |
lib.rs | #![feature(str_checked_slicing)]
const DIGITS: [&str; 10] = [
" _ | ||_| ", // 0
" | | ", // 1
" _ _||_ ", // 2
" _ _| _| ", // 3
" |_| | ", // 4
" _ |_ _| ", // 5
" _ |_ |_| ", // 6
" _ | | ", // 7
" _ |_||_| ", // 8
" _ |_| _| ", // 9
];
con... | let line = i * DIGITS_LINES;
let number = format!(
"{}{}{}{}",
v[line].get(row..row + DIGITS_ROWS).unwrap(),
v[line + 1].get(row..row + DIGITS_ROWS).unwrap(),
v[line + 2].get(row..row + DIGITS_ROWS).unwrap(),
v[line... | {
let v = input.split(|x| x == '\n').collect::<Vec<_>>();
let lines = v.len();
if lines == 0 || lines % DIGITS_LINES != 0 {
return Err("Invalid lines".to_string());
}
let rows = v[0].len();
if rows == 0 || rows % DIGITS_ROWS != 0 {
return Err(format!("Invalid {} row at line 1",... | identifier_body |
lib.rs | #![feature(str_checked_slicing)]
const DIGITS: [&str; 10] = [
" _ | ||_| ", // 0
" | | ", // 1
" _ _||_ ", // 2
" _ _| _| ", // 3
" |_| | ", // 4
" _ |_ _| ", // 5
" _ |_ |_| ", // 6
" _ | | ", // 7
" _ |_||_| ", // 8
" _ |_| _| ", // 9
];
con... |
if v.iter().any(|x| x.len()!= rows) {
return Err("Invalid rows".to_string());
}
let mut result = String::new();
for i in 0..lines / DIGITS_LINES {
for j in 0..rows / DIGITS_ROWS {
let row = j * DIGITS_ROWS;
let line = i * DIGITS_LINES;
let number = ... | {
return Err(format!("Invalid {} row at line 1", rows));
} | conditional_block |
lib.rs | #![feature(str_checked_slicing)]
const DIGITS: [&str; 10] = [
" _ | ||_| ", // 0
" | | ", // 1
" _ _||_ ", // 2
" _ _| _| ", // 3
" |_| | ", // 4
" _ |_ _| ", // 5
" _ |_ |_| ", // 6 | const DIGITS_ROWS: usize = 3;
const DIGITS_LINES: usize = 4;
pub fn convert(input: &str) -> Result<String, String> {
let v = input.split(|x| x == '\n').collect::<Vec<_>>();
let lines = v.len();
if lines == 0 || lines % DIGITS_LINES!= 0 {
return Err("Invalid lines".to_string());
}
let rows... | " _ | | ", // 7
" _ |_||_| ", // 8
" _ |_| _| ", // 9
];
| random_line_split |
mod.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the F... | //
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General ... | random_line_split | |
lib.rs | /*!
This crate provides a number of conversion traits with more specific semantics than those provided by `as` or `From`/`Into`.
The goal with the traits provided here is to be more specific about what generic code can rely on, as well as provide reasonably self-describing alternatives to the standard `From`/`Into` tr... | # Examples
```
# extern crate conv;
# use conv::*;
# fn main() {
// This *cannot* fail, so we can use `unwrap_ok` to discard the `Result`.
assert_eq!(u8::value_from(0u8).unwrap_ok(), 0u8);
// This *can* fail. Specifically, it can underflow.
assert_eq!(u8::value_from(0i8), Ok(0u8));
assert_eq!(u8::value_from(-1i8... | random_line_split | |
lib.rs | /*!
This crate provides a number of conversion traits with more specific semantics than those provided by `as` or `From`/`Into`.
The goal with the traits provided here is to be more specific about what generic code can rely on, as well as provide reasonably self-describing alternatives to the standard `From`/`Into` tr... | oxScheme for Wrapping {}
// TODO: RoundToNearest, RoundToPosInf, RoundToNegInf, RoundToZero
/**
This trait is used to perform a conversion between different semantic types which might fail.
# Details
Typically, this should be used in cases where you are converting between values whose ranges and/or representations ... | mpl Appr | identifier_name |
lib.rs | /*!
This crate provides a number of conversion traits with more specific semantics than those provided by `as` or `From`/`Into`.
The goal with the traits provided here is to be more specific about what generic code can rely on, as well as provide reasonably self-describing alternatives to the standard `From`/`Into` tr... | is the dual of `ApproxFrom`; see that trait for information.
*/
pub trait ApproxInto<Dst, Scheme=DefaultApprox> where Scheme: ApproxScheme {
/// The error type produced by a failed conversion.
type Err;
/// Convert the subject into an approximately equivalent representation.
fn approx_into(self) -> Res... | src)
}
}
/**
This | identifier_body |
stmt.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 self,
mut block: BasicBlock,
expr: Expr<'tcx>,
opt_stmt_span: Option<StatementSpan>)
-> BlockAnd<()>
{
let this = self;
let expr_span = expr.span;
let source_info = this.source_info(expr.span);
... | stmt_expr | identifier_name |
stmt.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 ... | let rhs = this.hir.mirror(rhs);
let lhs_span = lhs.span;
// Note: we evaluate assignments right-to-left. This
// is better for borrowck interaction with overloaded
// operators like x[j] = x[i].
debug!("stmt_expr Assign bl... | {
let this = self;
let expr_span = expr.span;
let source_info = this.source_info(expr.span);
// Handle a number of expressions that don't need a destination at all. This
// avoids needing a mountain of temporary `()` variables.
let expr2 = expr.clone();
match expr... | identifier_body |
stmt.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 ... |
None => {
this.cfg
.push_assign_unit(block, source_info, &Place::Local(RETURN_PLACE));
block
}
};
let region_scope = this.region_scope_of_return_scope();
le... | {
debug!("stmt_expr Return val block_context.push(SubExpr) : {:?}", expr2);
this.block_context.push(BlockFrame::SubExpr);
let result = unpack!(this.into(&Place::Local(RETURN_PLACE), block, value));
this.block_context.pop();
... | conditional_block |
stmt.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 ... | .collect::<Vec<_>>()
.into_boxed_slice();
let inputs = inputs
.into_iter()
.map(|input| {
(
input.span(),
unpack!(block = this.as_local_operand(bloc... | debug!("stmt_expr InlineAsm block_context.push(SubExpr) : {:?}", expr2);
this.block_context.push(BlockFrame::SubExpr);
let outputs = outputs
.into_iter()
.map(|output| unpack!(block = this.as_place(block, output))) | random_line_split |
thread.rs | use alloc::boxed::Box;
use syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, CLONE_VM, CLONE_FS, CLONE_FILES, TimeSpec};
use time::Duration;
//TODO: Mutex the result
pub struct JoinHandle<T> {
result_ptr: *mut Option<T>,
}
impl<T> JoinHandle<T> {
pub fn join(self) -> Option<T> {
unsafe {
... | sys_yield();
}
* Box::from_raw(self.result_ptr)
}
}
}
// Sleep for a duration
pub fn sleep(duration: Duration) {
let req = TimeSpec {
tv_sec: duration.secs,
tv_nsec: duration.nanos,
};
let mut rem = TimeSpec {
tv_sec: 0,
... | random_line_split | |
thread.rs | use alloc::boxed::Box;
use syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, CLONE_VM, CLONE_FS, CLONE_FILES, TimeSpec};
use time::Duration;
//TODO: Mutex the result
pub struct JoinHandle<T> {
result_ptr: *mut Option<T>,
}
impl<T> JoinHandle<T> {
pub fn join(self) -> Option<T> {
unsafe {
... |
JoinHandle {
result_ptr: result_ptr
}
}
}
| {
*result_ptr = Some(f());
sys_exit(0);
} | conditional_block |
thread.rs | use alloc::boxed::Box;
use syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, CLONE_VM, CLONE_FS, CLONE_FILES, TimeSpec};
use time::Duration;
//TODO: Mutex the result
pub struct JoinHandle<T> {
result_ptr: *mut Option<T>,
}
impl<T> JoinHandle<T> {
pub fn join(self) -> Option<T> {
unsafe {
... |
// Sleep for a number of milliseconds
pub fn sleep_ms(ms: u32) {
let secs = ms as i64 / 1000;
let nanos = (ms % 1000) as i32 * 1000000;
sleep(Duration::new(secs, nanos))
}
//TODO: Catch panic
pub fn spawn<F, T>(f: F) -> JoinHandle<T> where F: FnOnce() -> T, F: Send +'static, T: Send +'static {
unsafe... | {
let req = TimeSpec {
tv_sec: duration.secs,
tv_nsec: duration.nanos,
};
let mut rem = TimeSpec {
tv_sec: 0,
tv_nsec: 0
};
unsafe { sys_nanosleep(&req, &mut rem) };
//Duration::new(rem.tv_sec, rem.tv_nsec)
} | identifier_body |
thread.rs | use alloc::boxed::Box;
use syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, CLONE_VM, CLONE_FS, CLONE_FILES, TimeSpec};
use time::Duration;
//TODO: Mutex the result
pub struct JoinHandle<T> {
result_ptr: *mut Option<T>,
}
impl<T> JoinHandle<T> {
pub fn join(self) -> Option<T> {
unsafe {
... | (ms: u32) {
let secs = ms as i64 / 1000;
let nanos = (ms % 1000) as i32 * 1000000;
sleep(Duration::new(secs, nanos))
}
//TODO: Catch panic
pub fn spawn<F, T>(f: F) -> JoinHandle<T> where F: FnOnce() -> T, F: Send +'static, T: Send +'static {
unsafe {
let result_ptr: *mut Option<T> = Box::into_r... | sleep_ms | identifier_name |
schedule.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | else { 10 },
sha3_gas: 30,
sha3_word_gas: 6,
sload_gas: 200,
sstore_set_gas: 20000,
sstore_reset_gas: 5000,
sstore_refund_gas: 15000,
jumpdest_gas: 1,
log_gas: 375,
log_data_gas: 8,
log_topic_gas: 37... | { 50 } | conditional_block |
schedule.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | create_data_gas: 200,
create_data_limit: max_code_size,
tx_gas: 21000,
tx_create_gas: 53000,
tx_data_zero_gas: 4,
tx_data_non_zero_gas: 68,
copy_gas: 3,
extcodesize_gas: 700,
extcodecopy_base_gas: 700,
... | random_line_split | |
schedule.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | () -> Schedule {
Self::new(false, false, 21000)
}
/// Schedule for the Homestead-era of the Ethereum main net.
pub fn new_homestead() -> Schedule {
Self::new(true, true, 53000)
}
/// Schedule for the post-EIP-150-era of the Ethereum main net.
pub fn new_post_eip150(max_code_siz... | new_frontier | identifier_name |
schedule.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | call_gas: 700,
call_stipend: 2300,
call_value_transfer_gas: 9000,
call_new_account_gas: 25000,
suicide_refund_gas: 24000,
memory_gas: 3,
quad_coeff_div: 512,
create_data_gas: 200,
create_data_limit: max_code_size... | {
Schedule {
exceptional_failed_code_deposit: true,
have_delegate_call: true,
stack_limit: 1024,
max_depth: 1024,
tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0],
exp_gas: 10,
exp_byte_gas: if fix_exp { 50 } else { 10 },
s... | identifier_body |
stats.rs | // rpc-perf - RPC Performance Testing
// Copyright 2015 Twitter, Inc
//
// 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
//
// Unle... | {
pub start: u64,
pub stop: u64,
pub status: Status,
}
| Stat | identifier_name |
stats.rs | // rpc-perf - RPC Performance Testing
// Copyright 2015 Twitter, Inc
//
// 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
//
// Unle... | Hit,
Miss,
Ok,
Closed,
}
#[derive(Clone)]
pub struct Stat {
pub start: u64,
pub stop: u64,
pub status: Status,
} | #[derive(Clone)]
pub enum Status {
Error, | random_line_split |
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 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_prefix(b: &mut Bencher) {
let re = regex!("^abcdefghijklmnopqrstuvwxyz.*$");
let text = "abcdefghijklmnopqrstuvwxyz";
... | {
let re = regex!("^.bc(?:d|e)*$");
let text = "abcddddddeeeededd";
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 ... | (n: uint) -> String {
let mut rng = task_rng();
let mut bytes = rng.gen_ascii_chars().map(|n| n as u8).take(n)
.collect::<Vec<u8>>();
for (i, b) in bytes.mut_iter().enumerate() {
if i % 20 == 0 {
*b = '\n' as u8
}
}
String::from_utf8(bytes).unwrap()
... | gen_text | 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 ... |
}
String::from_utf8(bytes).unwrap()
}
throughput!(easy0_32, easy0(), 32)
throughput!(easy0_1K, easy0(), 1<<10)
throughput!(easy0_32K, easy0(), 32<<10)
throughput!(easy1_32, easy1(), 32)
throughput!(easy1_1K, easy1(), 1<<10)
throughput!(easy1_32K, easy1(), 32<<10)
throughput!(medium_32, medium(), 32)
through... | {
*b = '\n' as u8
} | 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 ... | let text = "abcdefghijklmnopqrstuvwxyz".repeat(15);
b.iter(|| re.is_match(text.as_slice()));
}
#[bench]
fn one_pass_short_a(b: &mut Bencher) {
let re = regex!("^.bc(d|e)*$");
let text = "abcddddddeeeededd";
b.iter(|| re.is_match(text));
}
#[bench]
fn one_pass_short_a_not(b: &mut Bencher) {
let... | let re = regex!("^.bc(d|e)"); | random_line_split |
macro.rs | #[macro_use]
extern crate double;
// Traits which only return types that implement `Default`.
trait Calculator: Clone {
fn multiply(&self, x: i32, y: i32) -> i32;
}
trait BalanceSheet: Clone {
fn profit(&self, revenue: u32, costs: u32) -> i32;
fn loss(&self, revenue: u32, costs: u32) -> i32;
}
trait Gree... | get_user(i32) -> Result<User, String>,
delete_user(i32) -> Result<(), String>);
impl UserStore for MockUserStore {
mock_method!(get_user(&self, id: i32) -> Result<User, String>);
mock_method!(delete_user(&self, id: i32) -> Result<(), String>);
}
fn main() {
// Test individual return values
let... |
mock_trait_no_default!(
MockUserStore, | random_line_split |
macro.rs | #[macro_use]
extern crate double;
// Traits which only return types that implement `Default`.
trait Calculator: Clone {
fn multiply(&self, x: i32, y: i32) -> i32;
}
trait BalanceSheet: Clone {
fn profit(&self, revenue: u32, costs: u32) -> i32;
fn loss(&self, revenue: u32, costs: u32) -> i32;
}
trait Gree... | () {
// Test individual return values
let mock = MockBalanceSheet::default();
mock.profit.return_value(42);
mock.profit.return_value_for((0, 0), 9001);
let value = mock.profit(10, 20);
assert_eq!(42, value);
mock.profit.has_calls_exactly_in_order(vec!((10, 20)));
let value = mock.profi... | main | identifier_name |
signal_handler.rs | // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use libc::{
c_int, c_void, siginfo_t, SIGBUS, SIGHUP, SIGILL, SIGPIPE, SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ,
};
use crate::{ExitCode, FC_EXIT_CODE_UNEXPECTED_ERROR};
use logger::{error, IncMetric, StoreM... | unsafe {
syscall(libc::SYS_kill, process::id(), SIGSEGV);
}
// Call SIGXFSZ signal handler.
assert_eq!(METRICS.signals.sigxfsz.fetch(), 0);
unsafe {
syscall(libc::SYS_kill, process::id(), SIGXFSZ);
}
//... | {
let child = thread::spawn(move || {
assert!(register_signal_handlers().is_ok());
let filter = make_test_seccomp_bpf_filter();
assert!(seccompiler::apply_filter(&filter).is_ok());
assert_eq!(METRICS.seccomp.num_faults.fetch(), 0);
// Call the forbi... | identifier_body |
signal_handler.rs | // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use libc::{
c_int, c_void, siginfo_t, SIGBUS, SIGHUP, SIGILL, SIGPIPE, SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ,
};
use crate::{ExitCode, FC_EXIT_CODE_UNEXPECTED_ERROR};
use logger::{error, IncMetric, StoreM... |
// Other signals which might do async unsafe things incompatible with the rest of this
// function are blocked due to the sa_mask used when registering the signal handler.
let syscall = unsafe { *(info as *const i32).offset(SI_OFF_SYSCALL) as usize };
error!(
"Shutting down VM after intercepti... | {
// We received a SIGSYS for a reason other than `bad syscall`.
exit_with_code(FC_EXIT_CODE_UNEXPECTED_ERROR);
} | conditional_block |
signal_handler.rs | // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use libc::{
c_int, c_void, siginfo_t, SIGBUS, SIGHUP, SIGILL, SIGPIPE, SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ,
};
use crate::{ExitCode, FC_EXIT_CODE_UNEXPECTED_ERROR};
use logger::{error, IncMetric, StoreM... | error!("Received signal {}, code {}.", si_signo, si_code);
}
/// Registers all the required signal handlers.
///
/// Custom handlers are installed for: `SIGBUS`, `SIGSEGV`, `SIGSYS`
/// `SIGXFSZ` `SIGXCPU` `SIGPIPE` `SIGHUP` and `SIGILL`.
pub fn register_signal_handlers() -> utils::errno::Result<()> {
// Call ... | }
METRICS.signals.sigpipe.inc();
| random_line_split |
signal_handler.rs | // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use libc::{
c_int, c_void, siginfo_t, SIGBUS, SIGHUP, SIGILL, SIGPIPE, SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ,
};
use crate::{ExitCode, FC_EXIT_CODE_UNEXPECTED_ERROR};
use logger::{error, IncMetric, StoreM... | (num: c_int, info: *mut siginfo_t, _unused: *mut c_void) {
// Just record the metric and allow the process to continue, the EPIPE error needs
// to be handled at caller level.
// Safe because we're just reading some fields from a supposedly valid argument.
let si_signo = unsafe { (*info).si_signo };
... | sigpipe_handler | identifier_name |
mixer.rs | use std::ptr;
use std::ffi::CStr;
use std::ffi::CString;
use std::cmp::min;
use libc::c_int;
use libc::c_uint;
use libc::c_void;
use format::error::DriverError;
use alsa::device::AlsaDevice;
use alsa::device::create_error;
use alsa::ffi::*;
pub type SndSize = snd_pcm_uframes_t;
pub struct Params {
hw_params: *mut ... |
}
}
| {
return None;
} | conditional_block |
mixer.rs | use std::ptr;
use std::ffi::CStr;
use std::ffi::CString;
use std::cmp::min;
use libc::c_int;
use libc::c_uint;
use libc::c_void;
use format::error::DriverError;
use alsa::device::AlsaDevice;
use alsa::device::create_error;
use alsa::ffi::*;
pub type SndSize = snd_pcm_uframes_t;
pub struct Params {
hw_params: *mut ... |
pub fn format(&self, dev: &AlsaDevice, rate_in: c_uint, channels: c_uint, format: c_int) -> Option<DriverError> {
let pcm = dev.get_pcm();
let mut err = 0;
let mut rate: c_uint = rate_in;
unsafe {
err = snd_pcm_hw_params_set_rate_resample(pcm, self.hw_params, 1);
err = snd_pcm_hw_params_set_access... | {
let pcm = dev.get_pcm();
let mut err = 0;
unsafe {
err = snd_pcm_hw_params_any(pcm, self.hw_params);
}
if err < 0 {
return Some(create_error("snd_pcm_hw_params_any", err));
}
else {
return None;
}
} | identifier_body |
mixer.rs | use std::ptr;
use std::ffi::CStr;
use std::ffi::CString;
use std::cmp::min;
use libc::c_int;
use libc::c_uint;
use libc::c_void;
use format::error::DriverError;
use alsa::device::AlsaDevice;
use alsa::device::create_error;
use alsa::ffi::*;
pub type SndSize = snd_pcm_uframes_t;
pub struct Params {
hw_params: *mut ... | (&self) -> Result<SndSize, DriverError> {
let mut size: snd_pcm_uframes_t = 0;
let mut err = 0;
unsafe {
err = snd_pcm_hw_params_get_buffer_size(self.hw_params, &mut size);
}
if err < 0 {
return Err(create_error("snd_pcm_hw_params_get_buffer_size", err));
}
else {
println!("Buffer size: {}", size... | buffer_size | identifier_name |
mixer.rs | use std::ptr;
use std::ffi::CStr;
use std::ffi::CString;
use std::cmp::min;
use libc::c_int;
use libc::c_uint;
use libc::c_void;
use format::error::DriverError;
use alsa::device::AlsaDevice;
use alsa::device::create_error;
use alsa::ffi::*;
pub type SndSize = snd_pcm_uframes_t;
pub struct Params {
hw_params: *mut ... |
pub fn any(&self, dev: &AlsaDevice) -> Option<DriverError> {
let pcm = dev.get_pcm();
let mut err = 0;
unsafe {
err = snd_pcm_hw_params_any(pcm, self.hw_params);
}
if err < 0 {
return Some(create_error("snd_pcm_hw_params_any", err));
}
else {
return None;
}
}
pub fn format(&self, dev:... | }
} | random_line_split |
logger.rs | extern crate log4rs;
extern crate log;
extern crate libc;
use std::error::Error;
use indy;
pub struct IndyCliLogger;
impl IndyCliLogger {
pub fn | (path: &str) -> Result<(), String> {
log4rs::init_file(path, Default::default())
.map_err(|err| format!("Cannot init Indy CLI logger: {}", err.description()))?;
indy::logger::set_logger(log::logger())
.map_err(|_| "Cannot init Libindy logger".to_string())
}
}
#[macro_export]
... | init | identifier_name |
logger.rs | extern crate log4rs;
extern crate log;
extern crate libc;
use std::error::Error;
use indy;
pub struct IndyCliLogger;
impl IndyCliLogger {
pub fn init(path: &str) -> Result<(), String> {
log4rs::init_file(path, Default::default())
.map_err(|err| format!("Cannot init Indy CLI logger: {}", err.d... | }
#[macro_export]
macro_rules! try_log {
($expr:expr) => (match $expr {
Ok(val) => val,
Err(err) => {
error!("try_log! | {}", err);
return Err(From::from(err))
}
})
}
macro_rules! _log_err {
($lvl:expr, $expr:expr) => (
|err| {
log!($lvl,... |
indy::logger::set_logger(log::logger())
.map_err(|_| "Cannot init Libindy logger".to_string())
} | random_line_split |
logger.rs | extern crate log4rs;
extern crate log;
extern crate libc;
use std::error::Error;
use indy;
pub struct IndyCliLogger;
impl IndyCliLogger {
pub fn init(path: &str) -> Result<(), String> |
}
#[macro_export]
macro_rules! try_log {
($expr:expr) => (match $expr {
Ok(val) => val,
Err(err) => {
error!("try_log! | {}", err);
return Err(From::from(err))
}
})
}
macro_rules! _log_err {
($lvl:expr, $expr:expr) => (
|err| {
log!($lvl... | {
log4rs::init_file(path, Default::default())
.map_err(|err| format!("Cannot init Indy CLI logger: {}", err.description()))?;
indy::logger::set_logger(log::logger())
.map_err(|_| "Cannot init Libindy logger".to_string())
} | identifier_body |
contrast.rs | /*
* Copyright (C) 2012 The Android Open Source Project
*
* 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
* | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ip.rsh"
#pragma rs_fp_relaxed
static float brightM = 0.f;
static float brightC = 0.f;
void setBright(float v) {
bright... | * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, | random_line_split |
linux.rs | extern crate libxdo;
extern crate itertools;
use std::borrow::Cow;
use self::itertools::Itertools;
use self::libxdo::XDo;
use super::{Physical, Key};
const DELAY: u32 = 12_000; // microseconds
// Keysyms can be found via the xev tool or here:
// https://cgit.freedesktop.org/xorg/proto/x11proto/tree/
fn get_physical_... | (key: Key) {
if let Ok(xdo) = XDo::new(None) {
let sym = get_keysym(key);
let _ = xdo.send_keysequence_down(&sym, DELAY);
}
}
pub fn release_key(key: Key) {
if let Ok(xdo) = XDo::new(None) {
let sym = get_keysym(key);
let _ = xdo.send_keysequence_up(&sym, DELAY);
}
}
pu... | press_key | identifier_name |
linux.rs | extern crate libxdo;
extern crate itertools;
use std::borrow::Cow;
use self::itertools::Itertools;
use self::libxdo::XDo;
use super::{Physical, Key};
const DELAY: u32 = 12_000; // microseconds
// Keysyms can be found via the xev tool or here:
// https://cgit.freedesktop.org/xorg/proto/x11proto/tree/
fn get_physical_... | send_str(&c.to_string());
}
/// Send a string as keyboard events. Unsupported chars are silently ignored.
pub fn send_str(msg: &str) {
if let Ok(xdo) = XDo::new(None) {
let _ = xdo.enter_text(msg, DELAY);
}
} | }
}
/// Send a unicode character. Unsupported chars are silently ignored.
pub fn send_char(c: char) { | random_line_split |
linux.rs | extern crate libxdo;
extern crate itertools;
use std::borrow::Cow;
use self::itertools::Itertools;
use self::libxdo::XDo;
use super::{Physical, Key};
const DELAY: u32 = 12_000; // microseconds
// Keysyms can be found via the xev tool or here:
// https://cgit.freedesktop.org/xorg/proto/x11proto/tree/
fn get_physical_... | {
if let Ok(xdo) = XDo::new(None) {
let _ = xdo.enter_text(msg, DELAY);
}
} | identifier_body | |
rensa_coef_tracker.rs | use field_bit::FieldBit;
use rensa_tracker::RensaTracker;
use score;
pub struct RensaCoefTracker {
pub num_erased: [usize; 20],
pub long_bonus_coef: [usize; 20],
pub color_bonus_coef: [usize; 20],
}
impl RensaCoefTracker {
pub fn new() -> RensaCoefTracker {
RensaCoefTracker {
num_e... |
fn track_drop(&mut self, _old_low_bits: u64, _old_high_bits: u64, _new_low_bits: u64, _new_high_bits: u64) {}
}
#[cfg(test)]
mod tests {
use super::RensaCoefTracker;
use rensa_tracker::RensaTracker;
#[test]
fn test_score() {
let mut tracker = RensaCoefTracker::new();
tracker.track... | {} | identifier_body |
rensa_coef_tracker.rs | use field_bit::FieldBit;
use rensa_tracker::RensaTracker;
use score;
pub struct RensaCoefTracker {
pub num_erased: [usize; 20],
pub long_bonus_coef: [usize; 20],
pub color_bonus_coef: [usize; 20],
}
impl RensaCoefTracker {
pub fn new() -> RensaCoefTracker {
RensaCoefTracker {
num_e... |
assert_eq!(4, tracker.num_erased[1]);
assert_eq!(4, tracker.num_erased[2]);
assert_eq!(4, tracker.num_erased[3]);
assert_eq!(4, tracker.num_erased[4]);
assert_eq!(5, tracker.num_erased[5]);
assert_eq!(1, tracker.coef(1));
assert_eq!(8, tracker.coef(2));
... | let mut tracker = RensaCoefTracker::new();
let rensa_result = bf.simulate_with_tracker(&mut tracker);
assert_eq!(5, rensa_result.chain); | random_line_split |
rensa_coef_tracker.rs | use field_bit::FieldBit;
use rensa_tracker::RensaTracker;
use score;
pub struct RensaCoefTracker {
pub num_erased: [usize; 20],
pub long_bonus_coef: [usize; 20],
pub color_bonus_coef: [usize; 20],
}
impl RensaCoefTracker {
pub fn new() -> RensaCoefTracker {
RensaCoefTracker {
num_e... | (&mut self, nth_chain: usize, num_erased: usize, long_bonus_coef: usize, color_bonus_coef: usize) {
self.num_erased[nth_chain] = num_erased;
self.long_bonus_coef[nth_chain] = long_bonus_coef;
self.color_bonus_coef[nth_chain] = color_bonus_coef;
}
fn track_vanish(&mut self, _nth_chain: us... | track_coef | identifier_name |
mod.rs | #[derive(PartialEq, Debug)]
pub enum BinaryType {
ELF,
COFF,
PE,
DOS,
UNKNOWN,
}
pub fn detect(bytes: &[u8]) -> BinaryType {
if scan_elf(bytes) | else {
BinaryType::UNKNOWN
}
}
// TODO: Can the other 12 bytes be utilized for more confirmation?
fn scan_elf(bytes: &[u8]) -> bool {
let ident: &[u8] = &bytes[0..15];
// [0x7F, 0x45, 0x4C, 0x46] = [0x7F, 'E', 'L', 'F']
ident[0..4] == [0x7F, 0x45, 0x4C, 0x46]
}
// fn scan_coff
// fn... | {
BinaryType::ELF
} | conditional_block |
mod.rs | #[derive(PartialEq, Debug)]
pub enum BinaryType {
ELF,
COFF,
PE,
DOS,
UNKNOWN,
}
pub fn | (bytes: &[u8]) -> BinaryType {
if scan_elf(bytes) {
BinaryType::ELF
} else {
BinaryType::UNKNOWN
}
}
// TODO: Can the other 12 bytes be utilized for more confirmation?
fn scan_elf(bytes: &[u8]) -> bool {
let ident: &[u8] = &bytes[0..15];
// [0x7F, 0x45, 0x4C, 0x46] = [0x7F, 'E', 'L... | detect | identifier_name |
mod.rs | #[derive(PartialEq, Debug)]
pub enum BinaryType {
ELF,
COFF,
PE,
DOS,
UNKNOWN,
}
pub fn detect(bytes: &[u8]) -> BinaryType {
if scan_elf(bytes) {
BinaryType::ELF
} else { | }
}
// TODO: Can the other 12 bytes be utilized for more confirmation?
fn scan_elf(bytes: &[u8]) -> bool {
let ident: &[u8] = &bytes[0..15];
// [0x7F, 0x45, 0x4C, 0x46] = [0x7F, 'E', 'L', 'F']
ident[0..4] == [0x7F, 0x45, 0x4C, 0x46]
}
// fn scan_coff
// fn scan_pe | BinaryType::UNKNOWN | random_line_split |
exp2f64.rs | #![feature(core, core_intrinsics, core_float)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::exp2f64;
use core::num::Float;
use core::f64;
// pub fn exp2f64(x: f64) -> f64;
#[test]
fn expf64_test1() {
let x: f64 = f64::nan();
let result: f64 = unsafe { exp2f64(x) };
... | () {
let x: f64 = f64::infinity();
let result: f64 = unsafe { exp2f64(x) };
assert_eq!(result, f64::infinity());
}
#[test]
fn expf64_test3() {
let x: f64 = f64::neg_infinity();
let result: f64 = unsafe { exp2f64(x) };
assert_eq!(result, 0.0);
}
#[test]
fn expf64_test4() {
let x: f64 =... | expf64_test2 | identifier_name |
exp2f64.rs | #![feature(core, core_intrinsics, core_float)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::exp2f64;
use core::num::Float;
use core::f64;
// pub fn exp2f64(x: f64) -> f64;
#[test]
fn expf64_test1() {
let x: f64 = f64::nan();
let result: f64 = unsafe { exp2f64(x) };
... |
#[test]
fn expf64_test4() {
let x: f64 = 10.0;
let result: f64 = unsafe { exp2f64(x) };
assert_eq!(result, 1024.0);
}
}
| {
let x: f64 = f64::neg_infinity();
let result: f64 = unsafe { exp2f64(x) };
assert_eq!(result, 0.0);
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.