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 |
|---|---|---|---|---|
process.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
impl fmt::Display for ExitStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "exit code: {}", self.0)
}
}
fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO {
libc::types::os::arch::extra::STARTUPINFO {
cb: 0,
lpReserved: ptr::null_mut(),... | {
Some(self.0)
} | identifier_body |
process.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | Stdio::Piped(ref pipe) => {
pipe.handle().duplicate(0, true, DUPLICATE_SAME_ACCESS)
}
// Similarly to unix, we don't actually leave holes for the
// stdio file descriptors, but rather open up /dev/null
// equivalents. These equivalents are dra... | Stdio::Handle(ref handle) => {
handle.duplicate(0, true, DUPLICATE_SAME_ACCESS)
} | random_line_split |
regions-out-of-scope-slice.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | // except according to those terms.
// compile-flags: -Z parse-only
// ignore-test blk region isn't supported in the front-end
fn foo(cond: bool) {
// Here we will infer a type that uses the
// region of the if stmt then block, but in the scope:
let mut x; //~ ERROR foo
if cond {
x = &'blk [... | random_line_split | |
regions-out-of-scope-slice.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
fn main() {}
| {
x = &'blk [1,2,3];
} | conditional_block |
regions-out-of-scope-slice.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {} | identifier_body | |
regions-out-of-scope-slice.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (cond: bool) {
// Here we will infer a type that uses the
// region of the if stmt then block, but in the scope:
let mut x; //~ ERROR foo
if cond {
x = &'blk [1,2,3];
}
}
fn main() {}
| foo | identifier_name |
thread_local.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 ... |
}
}
}
| {
TlsSetValue(key, 0 as *mut _);
dtor(ptr as *mut _);
any_run = true;
} | conditional_block |
thread_local.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 ... | }
}
} | } | random_line_split |
thread_local.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 mut any_run = true;
for _ in range(0, 5i) {
if!any_run { break }
any_run = false;
let dtors = {
DTOR_LOCK.lock();
let ret = if DTORS.is_null() {
Vec::new()
} else {
(*DTORS).iter().map(|s| *s).collect()
... | run_dtors | identifier_name |
thread_local.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 ... |
unsafe fn run_dtors() {
let mut any_run = true;
for _ in range(0, 5i) {
if!any_run { break }
any_run = false;
let dtors = {
DTOR_LOCK.lock();
let ret = if DTORS.is_null() {
Vec::new()
} else {
(*DTORS).iter().map(|s| *... | {
const DLL_THREAD_DETACH: DWORD = 3;
const DLL_PROCESS_DETACH: DWORD = 0;
if dwReason == DLL_THREAD_DETACH || dwReason == DLL_PROCESS_DETACH {
run_dtors();
}
} | identifier_body |
x86.rs | extern crate capstone_sys;
use std::os::raw::c_char;
use capstone_sys::*;
use capstone_sys::x86::*;
const X86_CODE16: &'static [u8] = b"\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x05\x23\x01\x00\x00\x36\x8b\x84\x91\x23\x01\x00\x00\x41\x8d\x84\x39\x89\x67\x00\x00\x8d\x87\x89\x67\x00\x00\xb4\xc6";
const X86_CODE3... | () {
generic(CS_ARCH_X86, CS_MODE_64, X86_CODE64, 2, ("push", "rbp", &[X86_OP_REG]));
}
| test_x86_64 | identifier_name |
x86.rs | extern crate capstone_sys;
use std::os::raw::c_char;
use capstone_sys::*;
use capstone_sys::x86::*;
const X86_CODE16: &'static [u8] = b"\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x05\x23\x01\x00\x00\x36\x8b\x84\x91\x23\x01\x00\x00\x41\x8d\x84\x39\x89\x67\x00\x00\x8d\x87\x89\x67\x00\x00\xb4\xc6"; | const X86_CODE32: &'static [u8] = b"\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x05\x23\x01\x00\x00\x36\x8b\x84\x91\x23\x01\x00\x00\x41\x8d\x84\x39\x89\x67\x00\x00\x8d\x87\x89\x67\x00\x00\xb4\xc6";
const X86_CODE64: &'static [u8] = b"\x55\x48\x8b\x05\xb8\x13\x00\x00";
fn to_str(raw: &[c_char]) -> &str {
unsaf... | random_line_split | |
x86.rs | extern crate capstone_sys;
use std::os::raw::c_char;
use capstone_sys::*;
use capstone_sys::x86::*;
const X86_CODE16: &'static [u8] = b"\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x05\x23\x01\x00\x00\x36\x8b\x84\x91\x23\x01\x00\x00\x41\x8d\x84\x39\x89\x67\x00\x00\x8d\x87\x89\x67\x00\x00\xb4\xc6";
const X86_CODE3... |
#[test]
fn test_x86_32() {
generic(CS_ARCH_X86, CS_MODE_32, X86_CODE32, 9, ("lea", "ecx, dword ptr [edx + esi + 8]", &[X86_OP_REG, X86_OP_MEM]));
}
#[test]
fn test_x86_64() {
generic(CS_ARCH_X86, CS_MODE_64, X86_CODE64, 2, ("push", "rbp", &[X86_OP_REG]));
}
| {
generic(CS_ARCH_X86, CS_MODE_16, X86_CODE16, 15, ("lea", "cx, word ptr [si + 0x32]", &[X86_OP_REG, X86_OP_MEM]));
} | identifier_body |
platform.rs | // Provides the abstraction layer: calls into the appropriate platform-native functions.
use ValidationResult;
#[cfg(target_os = "macos")]
use osx::validate_cert_chain as backend;
#[cfg(windows)]
use windows::validate_cert_chain as backend;
/// Validate a chain of certificates.
///
/// Given a chain of DER-encoded X.... | } | random_line_split | |
platform.rs | // Provides the abstraction layer: calls into the appropriate platform-native functions.
use ValidationResult;
#[cfg(target_os = "macos")]
use osx::validate_cert_chain as backend;
#[cfg(windows)]
use windows::validate_cert_chain as backend;
/// Validate a chain of certificates.
///
/// Given a chain of DER-encoded X.... | {
backend(encoded_certs, hostname)
} | identifier_body | |
platform.rs | // Provides the abstraction layer: calls into the appropriate platform-native functions.
use ValidationResult;
#[cfg(target_os = "macos")]
use osx::validate_cert_chain as backend;
#[cfg(windows)]
use windows::validate_cert_chain as backend;
/// Validate a chain of certificates.
///
/// Given a chain of DER-encoded X.... | (encoded_certs: &[&[u8]], hostname: &str) -> ValidationResult {
backend(encoded_certs, hostname)
}
| validate_cert_chain | identifier_name |
desc.rs | }
}
impl Id {
pub fn is_valid(self) -> bool {
self.0!= 0
}
pub fn to_type_id(self) -> TypeId {
TypeId(self.0)
}
pub fn to_value_id(self) -> ValueId {
ValueId(self.0)
}
pub fn to_result_id(self) -> ResultId {
ResultId(self.0)
}
}
impl TypeId {
pub... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Result({})", self.0)
}
}
impl fmt::Debug for TypeId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Type({})", self.0)
}
}
impl fmt::Debug for ValueId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result ... | fmt | identifier_name |
desc.rs |
}
}
impl Id {
pub fn is_valid(self) -> bool {
self.0!= 0
}
pub fn to_type_id(self) -> TypeId {
TypeId(self.0)
}
pub fn to_value_id(self) -> ValueId {
ValueId(self.0)
}
pub fn to_result_id(self) -> ResultId {
ResultId(self.0)
}
}
impl TypeId {
pu... | CompositeExtract = 81,
CompositeInsert = 82,
CopyObject = 83,
Transpose = 84,
SampledImage = 86,
ImageSampleImplicitLod = 87,
ImageSampleExplicitLod = 88,
ImageSampleDrefImplicitLod = 89,
ImageSampleDrefExplicitLod = 90,
ImageSampleProjImplicitLod = 91,
ImageSampleProjExplici... | VectorExtractDynamic = 77,
VectorInsertDynamic = 78,
VectorShuffle = 79,
CompositeConstruct = 80, | random_line_split |
desc.rs | }
}
impl Id {
pub fn is_valid(self) -> bool {
self.0!= 0
}
pub fn to_type_id(self) -> TypeId {
TypeId(self.0)
}
pub fn to_value_id(self) -> ValueId {
ValueId(self.0)
}
pub fn to_result_id(self) -> ResultId {
ResultId(self.0)
}
}
impl TypeId {
pub... |
}
impl ValueId {
pub fn is_valid(self) -> bool {
self.0!= 0
}
}
impl ResultId {
pub fn to_type_id(self) -> TypeId {
TypeId(self.0)
}
pub fn to_value_id(self) -> ValueId {
ValueId(self.0)
}
pub fn is_valid(self) -> bool {
self.0!= 0
}
}
impl fmt::Debug ... | {
self.0 != 0
} | identifier_body |
span_encoding.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 ... | (span: Span) -> SpanData {
let val = span.0;
// Extract a field at position `pos` having size `size`.
let extract = |pos: u32, size: u32| {
let mask = ((!0u32) as u64 >> (32 - size)) as u32; // Can't shift u32 by 32
(val >> pos) & mask
};
let (base, len, ctxt) = if val & TAG_MASK =... | decode | identifier_name |
span_encoding.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 ... |
}
// If an interner exists, return it. Otherwise, prepare a fresh one.
#[inline]
fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T {
GLOBALS.with(|globals| f(&mut *globals.span_interner.lock()))
}
| {
&self.span_data[index as usize]
} | identifier_body |
span_encoding.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. | // except according to those terms.
// Spans are encoded using 1-bit tag and 2 different encoding formats (one for each tag value).
// One format is used for keeping span data inline,
// another contains index into an out-of-line span interner.
// The encoding format for inline spans were obtained by optimizing over c... | //
// 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 | random_line_split |
span_encoding.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 ... | else {
let index = with_span_interner(|interner| interner.intern(sd));
(index << INTERNED_INDEX_OFFSET) | TAG_INTERNED
};
Span(val)
}
#[inline]
fn decode(span: Span) -> SpanData {
let val = span.0;
// Extract a field at position `pos` having size `size`.
let extract = |pos: u32, s... | {
(base << INLINE_OFFSETS[BASE_INDEX]) | (len << INLINE_OFFSETS[LEN_INDEX]) |
(ctxt << INLINE_OFFSETS[CTXT_INDEX]) | TAG_INLINE
} | conditional_block |
func_translator.rs | //! Stand-alone WebAssembly to Cretonne IL translator.
//!
//! This module defines the `FuncTranslator` type which can translate a single WebAssembly
//! function to Cretonne IL guided by a `FuncEnvironment` which provides information about the
//! WebAssembly module and the runtime environment.
use code_translator::t... | () {
// Same as above, but with an explicit return instruction.
//
// (func $small2 (param i32) (result i32)
// (return (i32.add (get_local 0) (i32.const 1)))
// )
const BODY: [u8; 8] = [
0x00, // local decl count
0x20, 0x00, // get_local... | small2 | identifier_name |
func_translator.rs | //! Stand-alone WebAssembly to Cretonne IL translator.
//!
//! This module defines the `FuncTranslator` type which can translate a single WebAssembly
//! function to Cretonne IL guided by a `FuncEnvironment` which provides information about the
//! WebAssembly module and the runtime environment.
use code_translator::t... | translate_operator(op, builder, state, environ);
}
// The final `End` operator left us in the exit block where we need to manually add a return
// instruction.
//
// If the exit block is unreachable, it may not have the correct arguments, so we would
// generate a return instruction tha... | let op = reader.read_operator().map_err(|_| CtonError::InvalidInput)?; | random_line_split |
func_translator.rs | //! Stand-alone WebAssembly to Cretonne IL translator.
//!
//! This module defines the `FuncTranslator` type which can translate a single WebAssembly
//! function to Cretonne IL guided by a `FuncEnvironment` which provides information about the
//! WebAssembly module and the runtime environment.
use code_translator::t... |
/// Translate a binary WebAssembly function.
///
/// The `code` slice contains the binary WebAssembly *function code* as it appears in the code
/// section of a WebAssembly module, not including the initial size of the function code. The
/// slice is expected to contain two parts:
///
/// ... | {
Self {
func_ctx: FunctionBuilderContext::new(),
state: TranslationState::new(),
}
} | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)]
#![feature(track_caller)]
#[macro_use]
extern crate log;
pub use crate::compositor::Compo... | {
pub id: PipelineId,
pub top_level_browsing_context_id: TopLevelBrowsingContextId,
pub script_chan: IpcSender<ConstellationControlMsg>,
pub layout_chan: IpcSender<LayoutControlMsg>,
}
/// Messages to the constellation.
pub enum ConstellationMsg {
/// Exit the constellation.
Exit,
/// Requ... | CompositionPipeline | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)]
#![feature(track_caller)]
#[macro_use]
extern crate log;
pub use crate::compositor::Compo... | SelectBrowser(..) => "SelectBrowser",
ForwardEvent(..) => "ForwardEvent",
SetCursor(..) => "SetCursor",
EnableProfiler(..) => "EnableProfiler",
DisableProfiler => "DisableProfiler",
ExitFullScreen(..) => "ExitFullScreen",
MediaSessionAc... | {
use self::ConstellationMsg::*;
let variant = match *self {
Exit => "Exit",
GetBrowsingContext(..) => "GetBrowsingContext",
GetPipeline(..) => "GetPipeline",
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
IsReadyToSa... | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)]
#![feature(track_caller)]
#[macro_use]
extern crate log;
pub use crate::compositor::Compo... | mod touch;
pub mod windowing;
pub struct SendableFrameTree {
pub pipeline: CompositionPipeline,
pub children: Vec<SendableFrameTree>,
}
/// The subset of the pipeline that is needed for layer composition.
#[derive(Clone)]
pub struct CompositionPipeline {
pub id: PipelineId,
pub top_level_browsing_cont... | pub mod compositor_thread;
#[cfg(feature = "gl")]
mod gl; | random_line_split |
main.rs | extern crate twox_hash;
extern crate rand;
use std::fs;
use std::hash::Hasher;
use std::io;
use std::io::Read;
use rand::isaac::Isaac64Rng;
use rand::{Rng, SeedableRng};
const ALPHA: &'static [u8] =
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789{}[]-_=+()@#$^&<>?";
fn hash(p: &[u8], l: u64) ->... | else {
break;
}
}
Ok(h.finish())
}
fn encode(c: &[u8], v: &[u8], l: usize) -> String {
let mut i = 0usize;
let mut j = 0usize;
let mut a = 0u32;
let c_l = c.len() as u32;
let mut s: Vec<u8> = Vec::with_capacity(l);
while i < l {
a += v[j] as u32;
... | {
h.write(&buf[..sz]);
} | conditional_block |
main.rs | extern crate twox_hash;
extern crate rand;
use std::fs;
use std::hash::Hasher;
use std::io;
use std::io::Read;
use rand::isaac::Isaac64Rng;
use rand::{Rng, SeedableRng};
const ALPHA: &'static [u8] =
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789{}[]-_=+()@#$^&<>?";
fn hash(p: &[u8], l: u64) ->... |
fn encode(c: &[u8], v: &[u8], l: usize) -> String {
let mut i = 0usize;
let mut j = 0usize;
let mut a = 0u32;
let c_l = c.len() as u32;
let mut s: Vec<u8> = Vec::with_capacity(l);
while i < l {
a += v[j] as u32;
while a >= c_l {
let r = a % c_l;
s.push... | {
let mut h = twox_hash::XxHash::with_seed(l);
let mut buf = [0u8; 512];
let mut f = try!(fs::File::open(p));
loop {
let sz = try!(f.read(&mut buf));
if sz > 0 {
h.write(&buf[..sz]);
} else {
break;
}
}
Ok(h.finish())
} | identifier_body |
main.rs | extern crate twox_hash;
extern crate rand;
use std::fs;
use std::hash::Hasher;
use std::io;
use std::io::Read;
use rand::isaac::Isaac64Rng;
use rand::{Rng, SeedableRng};
const ALPHA: &'static [u8] =
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789{}[]-_=+()@#$^&<>?";
fn | (p: &[u8], l: u64) -> u64 {
let mut h = twox_hash::XxHash::with_seed(l);
h.write(p);
h.finish()
}
fn hash_file<T>(p: T, l: u64) -> Result<u64, io::Error>
where T: AsRef<std::path::Path>
{
let mut h = twox_hash::XxHash::with_seed(l);
let mut buf = [0u8; 512];
let mut f = try!(fs::File::open(... | hash | identifier_name |
main.rs | extern crate twox_hash;
extern crate rand;
use std::fs;
use std::hash::Hasher;
use std::io;
use std::io::Read;
use rand::isaac::Isaac64Rng;
use rand::{Rng, SeedableRng};
const ALPHA: &'static [u8] =
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789{}[]-_=+()@#$^&<>?";
fn hash(p: &[u8], l: u64) ->... | while let Some(filename) = args.next() {
let a = hash_file(filename, length).unwrap();
file_hash ^= a;
}
let hs = file_hash ^ hash(name.as_bytes(), length);
let mut rr = Isaac64Rng::from_seed(&[hs]);
let mut buf = [0u8; 64];
rr.fill_bytes(&mut buf);
let s = encode(ALPHA, &bu... | random_line_split | |
mod.rs | //! http server for semantic engines
use iron::prelude::*;
use ::Config;
mod definition;
mod file;
mod completion;
mod ping;
use ::engine::SemanticEngine;
use iron::typemap::Key;
use iron_hmac::Hmac256Authentication;
use iron_hmac::SecretKey;
/// Errors occurring in the http module
#[derive(Debug)]
pub enum Error... |
if let Some(hmac) = hmac_after {
chain.link_after(hmac);
}
// log_after must be last middleware in after chain
if config.print_http_logs {
chain.link_after(log_after);
}
let app = Iron::new(chain);
Ok(Server {
inner: try!(app.http((&config.addr[..], config.port)... | {
chain.link_before(hmac);
} | conditional_block |
mod.rs | //! http server for semantic engines
use iron::prelude::*;
use ::Config;
mod definition;
mod file;
mod completion;
mod ping;
use ::engine::SemanticEngine;
use iron::typemap::Key;
use iron_hmac::Hmac256Authentication;
use iron_hmac::SecretKey;
/// Errors occurring in the http module
#[derive(Debug)]
pub enum Error... | (err: ::hyper::Error) -> Error {
Error::HttpServer(err)
}
}
pub type Result<T> = ::std::result::Result<T, Error>;
// -------------------------------------------------------------------------------------------------
/// Iron middleware responsible for attaching a semantic engine to each request
#[derive(De... | from | identifier_name |
mod.rs | //! http server for semantic engines
use iron::prelude::*;
use ::Config;
mod definition;
mod file;
mod completion;
mod ping;
use ::engine::SemanticEngine;
use iron::typemap::Key;
use iron_hmac::Hmac256Authentication;
use iron_hmac::SecretKey;
/// Errors occurring in the http module
#[derive(Debug)]
pub enum Error... | pub type Result<T> = ::std::result::Result<T, Error>;
// -------------------------------------------------------------------------------------------------
/// Iron middleware responsible for attaching a semantic engine to each request
#[derive(Debug, Clone)]
pub struct EngineProvider;
impl Key for EngineProvider {
... | }
| random_line_split |
mod.rs | //! http server for semantic engines
use iron::prelude::*;
use ::Config;
mod definition;
mod file;
mod completion;
mod ping;
use ::engine::SemanticEngine;
use iron::typemap::Key;
use iron_hmac::Hmac256Authentication;
use iron_hmac::SecretKey;
/// Errors occurring in the http module
#[derive(Debug)]
pub enum Error... |
// Get HMAC Middleware
let (hmac_before, hmac_after) = if config.secret_file.is_some() {
let secret = SecretKey::new(&config.read_secret_file());
let hmac_header = "x-racerd-hmac";
let (before, after) = Hmac256Authentication::middleware(secret, hmac_header);
(Some(before), Some(... | {
use persistent::{Read, Write};
use logger::Logger;
use logger::format::Format;
let mut chain = Chain::new(router!(
post "/parse_file" => file::parse,
post "/find_definition" => definition::find,
post "/list_completions" => completion::list,
get "/ping" ... | identifier_body |
example_with_default_router.rs | extern crate serialize;
extern crate nickel;
extern crate http;
use nickel::{Nickel, Request, Response, HttpRouter};
use std::io::net::ip::Ipv4Addr;
fn main() {
let mut server = Nickel::new();
fn | (_request: &Request, response: &mut Response) {
response.send("This is the /bar handler");
}
// go to http://localhost:6767/bar to see this route in action
server.get("/bar", bar_handler);
fn foo_handler (request: &Request, _response: &mut Response) -> String {
format!("Foo is '{}'", ... | bar_handler | identifier_name |
example_with_default_router.rs | extern crate serialize;
extern crate nickel;
extern crate http;
use nickel::{Nickel, Request, Response, HttpRouter};
use std::io::net::ip::Ipv4Addr;
fn main() { | fn bar_handler (_request: &Request, response: &mut Response) {
response.send("This is the /bar handler");
}
// go to http://localhost:6767/bar to see this route in action
server.get("/bar", bar_handler);
fn foo_handler (request: &Request, _response: &mut Response) -> String {
forma... | let mut server = Nickel::new();
| random_line_split |
example_with_default_router.rs | extern crate serialize;
extern crate nickel;
extern crate http;
use nickel::{Nickel, Request, Response, HttpRouter};
use std::io::net::ip::Ipv4Addr;
fn main() | {
let mut server = Nickel::new();
fn bar_handler (_request: &Request, response: &mut Response) {
response.send("This is the /bar handler");
}
// go to http://localhost:6767/bar to see this route in action
server.get("/bar", bar_handler);
fn foo_handler (request: &Request, _response: &... | identifier_body | |
basic-types-metadata.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... | {panic!()} | identifier_body | |
basic-types-metadata.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... | // gdb-check:type = ()
// gdb-command:whatis b
// gdb-check:type = bool
// gdb-command:whatis i
// gdb-check:type = isize
// gdb-command:whatis c
// gdb-check:type = char
// gdb-command:whatis i8
// gdb-check:type = i8
// gdb-command:whatis i16
// gdb-check:type = i16
// gdb-command:whatis i32
// gdb-check:type = i32
/... |
// compile-flags:-g
// gdb-command:run
// gdb-command:whatis unit | random_line_split |
basic-types-metadata.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
fn _zzz() {()}
fn _yyy() ->! {panic!()}
| { _yyy(); } | conditional_block |
basic-types-metadata.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... | () ->! {panic!()}
| _yyy | identifier_name |
build.rs | use std::env;
use std::process::Command;
use std::str::{self, FromStr};
fn | () {
// Decide ideal limb width for arithmetic in the float parser. Refer to
// src/lexical/math.rs for where this has an effect.
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
match target_arch.as_str() {
"aarch64" | "mips64" | "powerpc64" | "x86_64" => {
println!("ca... | main | identifier_name |
build.rs | use std::env;
use std::process::Command;
use std::str::{self, FromStr};
fn main() {
// Decide ideal limb width for arithmetic in the float parser. Refer to
// src/lexical/math.rs for where this has an effect.
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
match target_arch.as_str() {
... | }
fn rustc_minor_version() -> Option<u32> {
let rustc = env::var_os("RUSTC")?;
let output = Command::new(rustc).arg("--version").output().ok()?;
let version = str::from_utf8(&output.stdout).ok()?;
let mut pieces = version.split('.');
if pieces.next()!= Some("rustc 1") {
return None;
}
... | // BTreeMap::retain
// https://blog.rust-lang.org/2021/06/17/Rust-1.53.0.html#stabilized-apis
if minor < 53 {
println!("cargo:rustc-cfg=no_btreemap_retain");
} | random_line_split |
build.rs | use std::env;
use std::process::Command;
use std::str::{self, FromStr};
fn main() | if minor < 40 {
println!("cargo:rustc-cfg=no_btreemap_get_key_value");
}
// BTreeMap::remove_entry
// https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html#library-changes
if minor < 45 {
println!("cargo:rustc-cfg=no_btreemap_remove_entry");
}
// BTreeMap::retain
// ht... | {
// Decide ideal limb width for arithmetic in the float parser. Refer to
// src/lexical/math.rs for where this has an effect.
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
match target_arch.as_str() {
"aarch64" | "mips64" | "powerpc64" | "x86_64" => {
println!("cargo... | identifier_body |
build.rs | use std::env;
use std::process::Command;
use std::str::{self, FromStr};
fn main() {
// Decide ideal limb width for arithmetic in the float parser. Refer to
// src/lexical/math.rs for where this has an effect.
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
match target_arch.as_str() {
... |
let next = pieces.next()?;
u32::from_str(next).ok()
}
| {
return None;
} | conditional_block |
mod.rs | //! API for tracing applications and libraries.
//!
//! The `trace` module includes types for tracking the progression of a single
//! request while it is handled by services that make up an application. A trace
//! is a tree of [`Span`]s which are objects that represent the work being done
//! by individual services o... | timestamp: crate::time::now(),
attributes: Vec::new(),
dropped_attributes_count: 0,
}
}
}
/// During the `Span` creation user MUST have the ability to record links to other `Span`s. Linked
/// `Span`s can be from the same or a different trace.
#[derive(Clone, Debug, Part... | random_line_split | |
mod.rs | //! API for tracing applications and libraries.
//!
//! The `trace` module includes types for tracking the progression of a single
//! request while it is handled by services that make up an application. A trace
//! is a tree of [`Span`]s which are objects that represent the work being done
//! by individual services o... |
/// The span context of the linked span
pub fn span_context(&self) -> &SpanContext {
&self.span_context
}
/// Attributes of the span link
pub fn attributes(&self) -> &Vec<KeyValue> {
&self.attributes
}
/// Dropped attributes count
pub fn dropped_attributes_count(&self... | {
Link {
span_context,
attributes,
dropped_attributes_count: 0,
}
} | identifier_body |
mod.rs | //! API for tracing applications and libraries.
//!
//! The `trace` module includes types for tracking the progression of a single
//! request while it is handled by services that make up an application. A trace
//! is a tree of [`Span`]s which are objects that represent the work being done
//! by individual services o... | {
/// Export failed with the error returned by the exporter
#[error("Exporter {} encountered the following error(s): {0}",.0.exporter_name())]
ExportFailed(Box<dyn ExportError>),
/// Export failed to finish after certain period and processor stopped the export.
#[error("Exporting timed out after {... | TraceError | identifier_name |
lib.rs | /*!
A macro for declaring lazily evaluated statics.
Using this macro, it is possible to have `static`s that require code to be
executed at runtime in order to be initialized.
This includes anything requiring heap allocations, like vectors or hash maps,
as well as anything that requires function calls to be computed.
... | }
}
}
lazy_static!($($t)*);
};
(@MAKE TY, PUB, $(#[$attr:meta])*, $N:ident) => {
#[allow(missing_copy_implementations)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
$(#[$attr])*
pub struct $N {__private_field: ()}
... | }
__stability() | random_line_split |
key_templates.rs | // Copyright 2020 The Tink-Rust 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 or ag... | {
TEMPLATE_GENERATORS
.read()
.unwrap() // safe: lock
.keys()
.cloned()
.collect()
} | identifier_body | |
key_templates.rs | // Copyright 2020 The Tink-Rust 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 or ag... |
/// Find a key template generator function by name.
pub fn get_template_generator(name: &str) -> Option<KeyTemplateGenerator> {
TEMPLATE_GENERATORS.read().unwrap().get(name).copied() // safe: lock
}
/// Return all available key template generator names.
pub fn template_names() -> Vec<String> {
TEMPLATE_GENERA... | .unwrap() // safe: lock
.insert(name.to_string(), generator);
} | random_line_split |
key_templates.rs | // Copyright 2020 The Tink-Rust 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 or ag... | (name: &str) -> Option<KeyTemplateGenerator> {
TEMPLATE_GENERATORS.read().unwrap().get(name).copied() // safe: lock
}
/// Return all available key template generator names.
pub fn template_names() -> Vec<String> {
TEMPLATE_GENERATORS
.read()
.unwrap() // safe: lock
.keys()
.cloned()... | get_template_generator | identifier_name |
selection.rs | use crate::session::{Session, State, AES_IV_LEN};
use log::{debug, error};
use protocol::messages::connection::ServerSelectionMessage;
impl Session {
pub async fn select_server(&mut self, server_id: i16) -> std::io::Result<u8> {
use protocol::constants::server_connection_error;
use protocol::consta... | <'a>(
&'a mut self,
msg: ServerSelectionMessage<'a>,
) -> std::io::Result<()> {
use protocol::messages::connection::SelectedServerRefusedMessage;
let reason = self.select_server(msg.server_id as _).await?;
if reason!= 0 {
self.stream
.send(Selected... | handle_server_selection | identifier_name |
selection.rs | use crate::session::{Session, State, AES_IV_LEN};
use log::{debug, error};
use protocol::messages::connection::ServerSelectionMessage;
| impl Session {
pub async fn select_server(&mut self, server_id: i16) -> std::io::Result<u8> {
use protocol::constants::server_connection_error;
use protocol::constants::server_status;
use protocol::messages::connection::SelectedServerDataMessage;
let (aes_key, ticket) = match &self.... | random_line_split | |
selection.rs | use crate::session::{Session, State, AES_IV_LEN};
use log::{debug, error};
use protocol::messages::connection::ServerSelectionMessage;
impl Session {
pub async fn select_server(&mut self, server_id: i16) -> std::io::Result<u8> {
use protocol::constants::server_connection_error;
use protocol::consta... | }
}
| {
use protocol::messages::connection::SelectedServerRefusedMessage;
let reason = self.select_server(msg.server_id as _).await?;
if reason != 0 {
self.stream
.send(SelectedServerRefusedMessage {
server_id: msg.server_id,
error: ... | identifier_body |
filter.rs | use crate::fmt;
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
use crate::ops::Try;
/// An iterator that filters the elements of `iter` with `predicate`.
///
/// This `struct` is created by the [`filter`] method on [`Iterator`]. See its
/// documentation for more.
///
/// [`filter`]: Iterator... |
}
fn filter_try_fold<'a, T, Acc, R: Try<Output = Acc>>(
predicate: &'a mut impl FnMut(&T) -> bool,
mut fold: impl FnMut(Acc, T) -> R + 'a,
) -> impl FnMut(Acc, T) -> R + 'a {
move |acc, item| if predicate(&item) { fold(acc, item) } else { try { acc } }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl... | { acc } | conditional_block |
filter.rs | use crate::fmt;
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
use crate::ops::Try;
/// An iterator that filters the elements of `iter` with `predicate`.
///
/// This `struct` is created by the [`filter`] method on [`Iterator`]. See its
/// documentation for more.
///
/// [`filter`]: Iterator... | <Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R
where
Self: Sized,
Fold: FnMut(Acc, Self::Item) -> R,
R: Try<Output = Acc>,
{
self.iter.try_rfold(init, filter_try_fold(&mut self.predicate, fold))
}
#[inline]
fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> A... | try_rfold | identifier_name |
filter.rs | use crate::fmt;
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
use crate::ops::Try;
/// An iterator that filters the elements of `iter` with `predicate`.
///
/// This `struct` is created by the [`filter`] method on [`Iterator`]. See its
/// documentation for more.
///
/// [`filter`]: Iterator... | }
}
#[stable(feature = "core_impl_debug", since = "1.9.0")]
impl<I: fmt::Debug, P> fmt::Debug for Filter<I, P> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Filter").field("iter", &self.iter).finish()
}
}
fn filter_fold<T, Acc>(
mut predicate: impl FnMut(&T) -> b... | random_line_split | |
filter.rs | use crate::fmt;
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable};
use crate::ops::Try;
/// An iterator that filters the elements of `iter` with `predicate`.
///
/// This `struct` is created by the [`filter`] method on [`Iterator`]. See its
/// documentation for more.
///
/// [`filter`]: Iterator... |
// this special case allows the compiler to make `.filter(_).count()`
// branchless. Barring perfect branch prediction (which is unattainable in
// the general case), this will be much faster in >90% of cases (containing
// virtually all real workloads) and only a tiny bit slower in the rest.
//
... | {
let (_, upper) = self.iter.size_hint();
(0, upper) // can't know a lower bound, due to the predicate
} | identifier_body |
auto-ref-slice-plus-ref.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
// Testing that method lookup does not automatically borrow
// vect... | random_line_split | |
auto-ref-slice-plus-ref.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 ... |
trait MyIter {
fn test_mut(&mut self);
}
impl<'self> MyIter for &'self [int] {
fn test_mut(&mut self) { }
}
| {
// Testing that method lookup does not automatically borrow
// vectors to slices then automatically create a &mut self
// reference. That would allow creating a mutable pointer to a
// temporary, which would be a source of confusion
let mut a = @[0];
a.test_mut(); //~ ERROR does not impleme... | identifier_body |
auto-ref-slice-plus-ref.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 ... | (&mut self) { }
}
| test_mut | identifier_name |
palette.rs | pub mod rgba {
pub const ORIGINAL: [[u8; 4]; 16] = [
// normal
0x000000FF_u32.to_be_bytes(), | 0xCD00CDFF_u32.to_be_bytes(),
0x00CD00FF_u32.to_be_bytes(),
0x00CDCDFF_u32.to_be_bytes(),
0xCDCD00FF_u32.to_be_bytes(),
0xCDCDCDFF_u32.to_be_bytes(),
// bright
0x000000FF_u32.to_be_bytes(),
0x0000FFFF_u32.to_be_bytes(),
0xFF0000FF_u32.to_be_bytes()... | 0x0000CDFF_u32.to_be_bytes(),
0xCD0000FF_u32.to_be_bytes(), | random_line_split |
x86_64.rs | // Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use serde::{Deserialize, Serialize};
use base::{error, Result};
use bit_field::*;
use downcast_rs::impl_downcast;
use vm_memory::GuestAddress;
use c... | {
pub rax: u64,
pub rbx: u64,
pub rcx: u64,
pub rdx: u64,
pub rsi: u64,
pub rdi: u64,
pub rsp: u64,
pub rbp: u64,
pub r8: u64,
pub r9: u64,
pub r10: u64,
pub r11: u64,
pub r12: u64,
pub r13: u64,
pub r14: u64,
pub r15: u64,
pub rip: u64,
pub rflag... | Regs | identifier_name |
x86_64.rs | // Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use serde::{Deserialize, Serialize};
use base::{error, Result};
use bit_field::*;
use downcast_rs::impl_downcast;
use vm_memory::GuestAddress;
use c... | remote_irr: bool,
#[bits = 1]
trigger_mode: TriggerMode,
interrupt_mask: bool, // true iff interrupts are masked.
reserved: BitField39,
dest_id: BitField8,
}
/// Number of pins on the standard KVM/IOAPIC.
pub const NUM_IOAPIC_PINS: usize = 24;
/// Maximum number of pins on the IOAPIC.
pub cons... | #[bits = 1]
dest_mode: DestinationMode,
#[bits = 1]
delivery_status: DeliveryStatus,
polarity: BitField1, | random_line_split |
traced_image.rs | use std::path::Path;
use cgmath::Point2;
use glium::backend::Facade;
use glium::framebuffer::SimpleFrameBuffer;
use glium::texture::{
ClientFormat, MipmapsOption, RawImage2d, SrgbTexture2d, Texture2d, UncompressedFloatFormat,
UncompressedUintFormat, UnsignedTexture2d,
};
use glium::{uniform, DrawParameters, I... | }
fn render<F: Facade, S: Surface>(
&self,
facade: &F,
target: &mut S,
data: &[f32],
n_samples: &[u32],
width: u32,
height: u32,
) {
let data_raw = RawImage2d {
data: std::borrow::Cow::from(data),
width,
hei... | shader,
vertex_buffer,
index_buffer,
tone_map: config.tone_map,
} | random_line_split |
traced_image.rs | use std::path::Path;
use cgmath::Point2;
use glium::backend::Facade;
use glium::framebuffer::SimpleFrameBuffer;
use glium::texture::{
ClientFormat, MipmapsOption, RawImage2d, SrgbTexture2d, Texture2d, UncompressedFloatFormat,
UncompressedUintFormat, UnsignedTexture2d,
};
use glium::{uniform, DrawParameters, I... | tex_coords: [0.0, 1.0],
},
];
let vertex_buffer =
VertexBuffer::new(facade, &vertices).expect("Failed to create vertex buffer!");
let indices = vec![0, 1, 2, 0, 2, 3];
let index_buffer =
IndexBuffer::new(facade, glium::index::PrimitiveT... | {
let vertices = vec![
RawVertex {
pos: [-1.0, -1.0, 0.0],
normal: [0.0, 0.0, 0.0],
tex_coords: [0.0, 0.0],
},
RawVertex {
pos: [1.0, -1.0, 0.0],
normal: [0.0, 0.0, 0.0],
tex_coord... | identifier_body |
traced_image.rs | use std::path::Path;
use cgmath::Point2;
use glium::backend::Facade;
use glium::framebuffer::SimpleFrameBuffer;
use glium::texture::{
ClientFormat, MipmapsOption, RawImage2d, SrgbTexture2d, Texture2d, UncompressedFloatFormat,
UncompressedUintFormat, UnsignedTexture2d,
};
use glium::{uniform, DrawParameters, I... | <F: Facade, S: Surface>(&self, facade: &F, target: &mut S) {
self.visualizer.render(
facade,
target,
&self.pixels,
&self.n_samples,
self.width,
self.height,
);
}
pub fn save<F: Facade>(&self, facade: &F, path: &Path) {
... | render | identifier_name |
svg.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("SVG", inherited=False, gecko_name... | spec="https://drafts.fxtf.org/css-masking/#propdef-mask-origin",
)}
${helpers.predefined_type(
"mask-size",
"background::BackgroundSize",
"computed::BackgroundSize::auto()",
initial_specified_value="specified::BackgroundSize::auto()",
products="gecko",
extra_prefixes="webkit",
spec="htt... | gecko_enum_prefix="StyleGeometryBox",
gecko_inexhaustive=True,
animation_value_type="discrete", | random_line_split |
blob_url_store.rs |
use dom::bindings::js::JS;
use dom::blob::Blob;
use origin::Origin;
use std::collections::HashMap;
use uuid::Uuid;
#[must_root]
#[derive(JSTraceable, HeapSizeOf)]
struct EntryPair(Origin, JS<Blob>);
// HACK: to work around the HeapSizeOf of Uuid
#[derive(PartialEq, HeapSizeOf, Eq, Hash, JSTraceable)]
struct BlobUrlI... | /* 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/. */
#![allow(dead_code)] | random_line_split | |
blob_url_store.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/. */
#![allow(dead_code)]
use dom::bindings::js::JS;
use dom::blob::Blob;
use origin::Origin;
use std::collections::Ha... | {
InvalidKey,
InvalidOrigin,
}
impl BlobURLStore {
pub fn new() -> BlobURLStore {
BlobURLStore {
entries: HashMap::new(),
}
}
pub fn request(&self, id: Uuid, origin: &Origin) -> Result<&Blob, BlobURLStoreError> {
match self.entries.get(&BlobUrlId(id)) {
... | BlobURLStoreError | identifier_name |
lib.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | pub mod rpath;
pub mod svh;
pub mod target_strs;
pub mod x86;
pub mod x86_64;
}
pub mod metadata;
pub mod driver;
pub mod util {
pub mod common;
pub mod ppaux;
pub mod sha2;
pub mod nodemap;
}
pub mod lib {
pub mod llvm;
pub mod llvmdeps;
}
static BUG_REPORT_URL: &'stati... | pub mod archive;
pub mod arm;
pub mod link;
pub mod lto;
pub mod mips; | random_line_split |
lib.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
/// Run a procedure which will detect failures in the compiler and print nicer
/// error messages rather than just failing the test.
///
/// The diagnostic emitter yielded to the procedure should be used for reporting
/// errors of the compiler.
pub fn monitor(f: proc:Send()) {
// FIXME: This is a hack for newsch... | {
let result = match *input {
d::FileInput(ref ifile) => {
parse::parse_crate_attrs_from_file(ifile,
Vec::new(),
&sess.parse_sess)
}
d::StrInput(ref src) => {
parse::parse_cr... | identifier_body |
lib.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
println!("
Available lint options:
-W <foo> Warn about <foo>
-A <foo> Allow <foo>
-D <foo> Deny <foo>
-F <foo> Forbid <foo> (deny, and deny all overrides)
");
let lint_dict = lint::get_lint_dict();
let mut lint_dict = lint_dict.move_iter()
... | describe_warnings | identifier_name |
arithmetic_mean.rs | // http://rosettacode.org/wiki/Averages/Arithmetic_mean
// The mean is not defined for an empty list, so we must return an Option
fn mean(list: &[f64]) -> Option<f64> {
match list.len() {
0 => None,
n => {
let sum = list.iter().fold(0f64, |a, &b| a + b);
Some(sum / n as f64)... | {
let no_nums = [];
assert_eq!(mean(&no_nums), None);
} | identifier_body | |
arithmetic_mean.rs | // http://rosettacode.org/wiki/Averages/Arithmetic_mean
// The mean is not defined for an empty list, so we must return an Option
fn mean(list: &[f64]) -> Option<f64> {
match list.len() {
0 => None,
n => {
let sum = list.iter().fold(0f64, |a, &b| a + b);
Some(sum / n as f64)... | () {
let nums = [1.0, 2.0, 3.0, 4.0, 5.0];
assert_eq!(mean(&nums), Some(3.0));
}
#[test]
fn mean_empty_list() {
let no_nums = [];
assert_eq!(mean(&no_nums), None);
}
| simple_test | identifier_name |
arithmetic_mean.rs | // http://rosettacode.org/wiki/Averages/Arithmetic_mean
// The mean is not defined for an empty list, so we must return an Option
fn mean(list: &[f64]) -> Option<f64> {
match list.len() {
0 => None,
n => {
let sum = list.iter().fold(0f64, |a, &b| a + b);
Some(sum / n as f64)... | #[test]
fn simple_test() {
let nums = [1.0, 2.0, 3.0, 4.0, 5.0];
assert_eq!(mean(&nums), Some(3.0));
}
#[test]
fn mean_empty_list() {
let no_nums = [];
assert_eq!(mean(&no_nums), None);
} | // This should be 3.833333
let mean = mean(&input).unwrap();
println!("{}", mean);
}
| random_line_split |
vec-self-append.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern mod extra... | random_line_split | |
vec-self-append.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 test_loop() {
// Make sure we properly handle repeated self-appends.
let mut a: ~[int] = ~[0];
let mut i = 20;
let mut expected_len = 1u;
while i > 0 {
error2!("{}", a.len());
assert_eq!(a.len(), expected_len);
a = a + a; // FIXME(#3387)---can't write a += a
i -=... | {
// a is entirely on the stack
let mut a = ~[0, 1, 2];
// a spills to the heap
a = a + a; // FIXME(#3387)---can't write a += a
assert_eq!(a.len(), 6u);
assert_eq!(a[0], 0);
assert_eq!(a[1], 1);
assert_eq!(a[2], 2);
assert_eq!(a[3], 0);
assert_eq!(a[4], 1);
assert_eq!(a[5], 2... | identifier_body |
vec-self-append.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_heap_to_heap(); test_stack_to_heap(); test_loop(); }
| main | identifier_name |
macros.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/// Interns the passed string literal and memoizes the result in a static
/// variable. This can be used in performance sensitive... | ///
/// # Example
///
/// ```ignore
/// use common::{Intern, intern, StringKey};
/// pub struct User {
/// name: StringKey,
/// }
/// intern!(User as UserKey); // defines the `UserKey` type
///
/// let name: StringKey = "Joe".intern();
/// let user: User = User { name };
/// let user_key: UserKey = user.intern();
///... | /// type. Calling `FooKey::lookup()` will return a reference to the original
/// `<Foo>` value. | random_line_split |
headers.rs | use std::ops::Range;
use crate::*;
use super::Wrap;
/// Describes the PE headers.
impl<'a, Pe32: pe32::Pe<'a>, Pe64: pe64::Pe<'a>> Wrap<pe32::headers::Headers<Pe32>, pe64::headers::Headers<Pe64>> {
/// Gets the PE instance.
#[inline]
pub fn pe(&self) -> Wrap<Pe32, Pe64> {
match self {
Wrap::T32(headers) => Wra... | (&self) -> u32 {
match self {
Wrap::T32(headers) => headers.check_sum(),
Wrap::T64(headers) => headers.check_sum(),
}
}
/// Gets the code range from the optional header.
#[inline]
pub fn code_range(&self) -> Range<u32> {
match self {
Wrap::T32(headers) => headers.code_range(),
Wrap::T64(headers) =... | check_sum | identifier_name |
headers.rs | use std::ops::Range;
use crate::*;
use super::Wrap;
/// Describes the PE headers.
impl<'a, Pe32: pe32::Pe<'a>, Pe64: pe64::Pe<'a>> Wrap<pe32::headers::Headers<Pe32>, pe64::headers::Headers<Pe64>> {
/// Gets the PE instance.
#[inline]
pub fn pe(&self) -> Wrap<Pe32, Pe64> {
match self {
Wrap::T32(headers) => Wra... | } | } | random_line_split |
headers.rs | use std::ops::Range;
use crate::*;
use super::Wrap;
/// Describes the PE headers.
impl<'a, Pe32: pe32::Pe<'a>, Pe64: pe64::Pe<'a>> Wrap<pe32::headers::Headers<Pe32>, pe64::headers::Headers<Pe64>> {
/// Gets the PE instance.
#[inline]
pub fn pe(&self) -> Wrap<Pe32, Pe64> |
/// Gets the PE headers as a byte slice.
#[inline]
pub fn image(&self) -> &'a [u8] {
match self {
Wrap::T32(headers) => headers.image(),
Wrap::T64(headers) => headers.image(),
}
}
/// Calculates the optional header's CheckSum.
#[inline]
pub fn check_sum(&self) -> u32 {
match self {
Wrap::T32(head... | {
match self {
Wrap::T32(headers) => Wrap::T32(headers.pe()),
Wrap::T64(headers) => Wrap::T64(headers.pe()),
}
} | identifier_body |
view_conversion.rs |
// local imports
use view::MatrixView;
use traits::*;
use sralgebra::MagmaBase;
/// Implements matrix conversion API
impl <'a, T:MagmaBase> Conversion<T> for MatrixView<'a, T> {
/// Converts the view to vector from standard library
fn to_std_vec(&self) -> Vec<T> {
let mut vec: Vec<T> = Vec::with_capac... | (){
let m = matrix_rw_i32(3, 3, &[1, 2, 3,
4, 5, 6,
7, 8, 9]);
let v = m.view(2,1, 1, 1);
assert_eq!(v.to_scalar(), 8);
}
}
| test_view_to_scalar | identifier_name |
view_conversion.rs | // local imports
use view::MatrixView;
use traits::*;
use sralgebra::MagmaBase;
/// Implements matrix conversion API
impl <'a, T:MagmaBase> Conversion<T> for MatrixView<'a, T> {
/// Converts the view to vector from standard library
fn to_std_vec(&self) -> Vec<T> {
let mut vec: Vec<T> = Vec::with_capaci... | }
} | 4, 5, 6,
7, 8, 9]);
let v = m.view(2,1, 1, 1);
assert_eq!(v.to_scalar(), 8); | random_line_split |
view_conversion.rs |
// local imports
use view::MatrixView;
use traits::*;
use sralgebra::MagmaBase;
/// Implements matrix conversion API
impl <'a, T:MagmaBase> Conversion<T> for MatrixView<'a, T> {
/// Converts the view to vector from standard library
fn to_std_vec(&self) -> Vec<T> |
}
#[cfg(test)]
mod test{
use traits::*;
use constructors::*;
#[test]
fn test_view_to_scalar(){
let m = matrix_rw_i32(3, 3, &[1, 2, 3,
4, 5, 6,
7, 8, 9]);
let v = m.view(2,1, 1, 1);
assert_eq!(v.to_scalar(), 8);
}
}
| {
let mut vec: Vec<T> = Vec::with_capacity(self.num_cells());
// We iterate over elements in matrix and push in the vector
let ptr = self.matrix().as_ptr();
for c in 0..self.num_cols(){
for r in 0..self.num_rows(){
let offset = self.cell_to_offset(r, c);
... | identifier_body |
function-prologue-stepping-regular.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | }
fn if_expr(x: u64, y: u64, z: f64) -> u64 {
if x + y < 1000 {
x
} else {
y
}
}
fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
while x + y < 1000 {
x += z
}
return x;
}
fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
loop {
x += z;
if x + y ... | x + y | random_line_split |
function-prologue-stepping-regular.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
}
fn main() {
immediate_args(1, true, 2.5);
non_immediate_args(
BigStruct {
a: 3,
b: 4,
c: 5,
d: 6,
e: 7,
f: 8,
g: 9,
h: 10
},
BigStruct {
a: 11,
b: 12,
... | {
return x;
} | conditional_block |
function-prologue-stepping-regular.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... | (mut x: u64, y: u64, z: u64) -> u64 {
while x + y < 1000 {
x += z
}
return x;
}
fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
loop {
x += z;
if x + y > 1000 {
return x;
}
}
}
fn main() {
immediate_args(1, true, 2.5);
non_immediate_args(
... | while_expr | identifier_name |
function-prologue-stepping-regular.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... | f: 16,
g: 17,
h: 18
}
);
binding(19, 20, 21.5);
assignment(22, 23, 24.5);
function_call(25, 26, 27.5);
identifier(28, 29, 30.5);
return_expr(31, 32, 33.5);
arithmetic_expr(34, 35, 36.5);
if_expr(37, 38, 39.5);
while_expr(40, 41, 42);
l... | {
immediate_args(1, true, 2.5);
non_immediate_args(
BigStruct {
a: 3,
b: 4,
c: 5,
d: 6,
e: 7,
f: 8,
g: 9,
h: 10
},
BigStruct {
a: 11,
b: 12,
c: 13,
... | identifier_body |
color.rs | pub enum ColorName {
Black,
Blue,
Red,
Purple,
Green,
Cyan,
Yellow,
White,
}
pub fn number_to_color(num: u8) -> ColorName {
match num {
0 => ColorName::Black,
1 => ColorName::Blue,
2 => ColorName::Red,
3 => ColorName::Purple,
4 => ColorName::G... | {
blue: bool,
red: bool,
green: bool,
pub value: u8,
}
fn trf(val: bool) -> u16 {
if val { 4095 } else { 0 }
}
impl Color {
pub fn new(name: ColorName) -> Color {
let value = name as u8;
Color {
blue: (value & 1) > 0,
red: (value & 2) > 0,
g... | Color | identifier_name |
color.rs | pub enum ColorName {
Black,
Blue,
Red,
Purple,
Green,
Cyan,
Yellow,
White,
}
pub fn number_to_color(num: u8) -> ColorName {
match num {
0 => ColorName::Black,
1 => ColorName::Blue,
2 => ColorName::Red,
3 => ColorName::Purple,
4 => ColorName::G... | let value = name as u8;
Color {
blue: (value & 1) > 0,
red: (value & 2) > 0,
green: (value & 4) > 0,
value: value,
}
}
pub fn to_array(&self) -> [u16; 3] {
[trf(self.blue), trf(self.red), trf(self.green)]
}
} | random_line_split | |
color.rs | pub enum ColorName {
Black,
Blue,
Red,
Purple,
Green,
Cyan,
Yellow,
White,
}
pub fn number_to_color(num: u8) -> ColorName {
match num {
0 => ColorName::Black,
1 => ColorName::Blue,
2 => ColorName::Red,
3 => ColorName::Purple,
4 => ColorName::G... |
pub fn to_array(&self) -> [u16; 3] {
[trf(self.blue), trf(self.red), trf(self.green)]
}
} | {
let value = name as u8;
Color {
blue: (value & 1) > 0,
red: (value & 2) > 0,
green: (value & 4) > 0,
value: value,
}
} | identifier_body |
offsets.rs | use byteorder::{BigEndian, ReadBytesExt};
use futures::Stream;
use rdkafka::config::{ClientConfig, TopicConfig};
use rdkafka::consumer::stream_consumer::StreamConsumer;
use rdkafka::consumer::{Consumer, EmptyConsumerContext};
use rdkafka::error::KafkaError;
use rdkafka::{Message, Offset, TopicPartitionList};
use cache... | (
brokers: &str,
group_id: &str,
start_offsets: Option<Vec<i64>>,
) -> Result<StreamConsumer<EmptyConsumerContext>> {
let consumer = ClientConfig::new()
.set("group.id", group_id)
.set("bootstrap.servers", brokers)
.set("enable.partition.eof", "false")
.set("enable.auto.commi... | create_consumer | identifier_name |
offsets.rs | use byteorder::{BigEndian, ReadBytesExt};
use futures::Stream;
use rdkafka::config::{ClientConfig, TopicConfig};
use rdkafka::consumer::stream_consumer::StreamConsumer;
use rdkafka::consumer::{Consumer, EmptyConsumerContext};
use rdkafka::error::KafkaError;
use rdkafka::{Message, Offset, TopicPartitionList};
use cache... | // Consumer position is not up to date after start, so we have to merge with the
// existing offsets and take the largest.
let res = consumer
.position()
.map(|current_position| {
let previous_position_vec = cache
... | );
update_global_cache(&cluster_id, &local_cache, &cache.offsets); | random_line_split |
offsets.rs | use byteorder::{BigEndian, ReadBytesExt};
use futures::Stream;
use rdkafka::config::{ClientConfig, TopicConfig};
use rdkafka::consumer::stream_consumer::StreamConsumer;
use rdkafka::consumer::{Consumer, EmptyConsumerContext};
use rdkafka::error::KafkaError;
use rdkafka::{Message, Offset, TopicPartitionList};
use cache... |
}
// TODO: log errors
let _ = cache.insert(
(cluster_id.to_owned(), group.to_owned(), topic.to_owned()),
new_offsets.clone(),
);
}
}
fn commit_offset_position_to_array(tp_list: TopicPartitionList) -> Vec<i64> {
let tp_elements = tp_list.elements_for_topi... | {
// If the new offset is not complete and i have an old one, do the merge
vec_merge_in_place(&mut existing_offsets, &new_offsets, -1, cmp::max);
// for i in 0..(cmp::max(offsets.len(), existing_offsets.len())) {
// let ne... | conditional_block |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.