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 |
|---|---|---|---|---|
cursor.rs | //! Cursor movement.
use std::fmt;
use std::io::{self, Write, Error, ErrorKind, Read};
use async::async_stdin;
use std::time::{SystemTime, Duration};
use raw::CONTROL_SEQUENCE_TIMEOUT;
derive_csi_sequence!("Hide the cursor.", Hide, "?25l");
derive_csi_sequence!("Show the cursor.", Show, "?25h");
derive_csi_sequence!... | #[derive(Copy, Clone, PartialEq, Eq)]
pub struct Up(pub u16);
impl fmt::Display for Up {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, csi!("{}A"), self.0)
}
}
/// Move cursor down.
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Down(pub u16);
impl fmt::Display for Down {
fn ... | }
}
/// Move cursor up. | random_line_split |
cursor.rs | //! Cursor movement.
use std::fmt;
use std::io::{self, Write, Error, ErrorKind, Read};
use async::async_stdin;
use std::time::{SystemTime, Duration};
use raw::CONTROL_SEQUENCE_TIMEOUT;
derive_csi_sequence!("Hide the cursor.", Hide, "?25l");
derive_csi_sequence!("Show the cursor.", Show, "?25h");
derive_csi_sequence!... | (pub u16);
impl fmt::Display for Right {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, csi!("{}C"), self.0)
}
}
/// Move cursor up.
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Up(pub u16);
impl fmt::Display for Up {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | Right | identifier_name |
cursor.rs | //! Cursor movement.
use std::fmt;
use std::io::{self, Write, Error, ErrorKind, Read};
use async::async_stdin;
use std::time::{SystemTime, Duration};
use raw::CONTROL_SEQUENCE_TIMEOUT;
derive_csi_sequence!("Hide the cursor.", Hide, "?25l");
derive_csi_sequence!("Show the cursor.", Show, "?25h");
derive_csi_sequence!... |
}
/// Types that allow detection of the cursor position.
pub trait DetectCursorPos {
/// Get the (1,1)-based cursor position from the terminal.
fn cursor_pos(&mut self) -> io::Result<(u16, u16)>;
}
impl<W: Write> DetectCursorPos for W {
fn cursor_pos(&mut self) -> io::Result<(u16, u16)> {
let mut... | {
write!(f, csi!("{}B"), self.0)
} | identifier_body |
cursor.rs | //! Cursor movement.
use std::fmt;
use std::io::{self, Write, Error, ErrorKind, Read};
use async::async_stdin;
use std::time::{SystemTime, Duration};
use raw::CONTROL_SEQUENCE_TIMEOUT;
derive_csi_sequence!("Hide the cursor.", Hide, "?25l");
derive_csi_sequence!("Show the cursor.", Show, "?25h");
derive_csi_sequence!... |
}
if read_chars.len() == 0 {
return Err(Error::new(ErrorKind::Other, "Cursor position detection timed out."));
}
// The answer will look like `ESC [ Cy ; Cx R`.
read_chars.pop(); // remove trailing R.
let read_str = String::from_utf8(read_chars).unwrap();
... | {
read_chars.push(buf[0]);
} | conditional_block |
union-abi.rs | // ignore-emscripten vectors passed directly
// compile-flags: -C no-prepopulate-passes
// This test that using union forward the abi of the inner type, as
// discussed in #54668
#![crate_type="lib"]
#![feature(repr_simd)]
#[derive(Copy, Clone)]
pub enum Unhab {}
#[repr(simd)]
#[derive(Copy, Clone)]
pub struct i64x... |
pub union UnionF32{a:f32}
// CHECK: define float @test_UnionF32(float %_1)
#[no_mangle]
pub fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }
pub union UnionF32F32{a:f32, b:f32}
// CHECK: define float @test_UnionF32F32(float %_1)
#[no_mangle]
pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} }
... | { loop {} } | identifier_body |
union-abi.rs | // ignore-emscripten vectors passed directly
// compile-flags: -C no-prepopulate-passes
// This test that using union forward the abi of the inner type, as
// discussed in #54668
#![crate_type="lib"]
#![feature(repr_simd)]
#[derive(Copy, Clone)]
pub enum Unhab {}
#[repr(simd)]
#[derive(Copy, Clone)]
pub struct i64x... |
pub union UnionF32U32{a:f32, b:u32}
// CHECK: define i32 @test_UnionF32U32(i32{{( %0)?}})
#[no_mangle]
pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 { loop {} }
pub union UnionU128{a:u128}
// CHECK: define i128 @test_UnionU128(i128 %_1)
#[no_mangle]
pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {}... | #[no_mangle]
pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} } | random_line_split |
union-abi.rs | // ignore-emscripten vectors passed directly
// compile-flags: -C no-prepopulate-passes
// This test that using union forward the abi of the inner type, as
// discussed in #54668
#![crate_type="lib"]
#![feature(repr_simd)]
#[derive(Copy, Clone)]
pub enum Unhab {}
#[repr(simd)]
#[derive(Copy, Clone)]
pub struct i64x... | (b: UnionBool) -> bool { unsafe { b.b } }
// CHECK: %0 = trunc i8 %b to i1
| test_UnionBool | identifier_name |
error.rs | use serde_json::Error as SerdeError;
use std::error::Error as StdError;
use std::fmt;
use std::io::Error as IoError;
#[derive(Debug)]
pub enum LatticeError {
IoError(IoError),
JsonParseError(SerdeError),
InconsistentVertices,
NegativeSize,
}
impl StdError for LatticeError {
fn description(&self) -... |
fn cause(&self) -> Option<&StdError> {
match self {
LatticeError::IoError(err) => Some(err),
LatticeError::JsonParseError(err) => Some(err),
_ => None,
}
}
}
impl fmt::Display for LatticeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | {
match self {
LatticeError::IoError(_) => "There was an error reading your file",
LatticeError::JsonParseError(_) => "There was a problem parsing json",
LatticeError::InconsistentVertices => "These vertices are inconsistent",
LatticeError::NegativeSize => "What a... | identifier_body |
error.rs | use serde_json::Error as SerdeError;
use std::error::Error as StdError;
use std::fmt;
use std::io::Error as IoError;
#[derive(Debug)]
pub enum LatticeError {
IoError(IoError), |
impl StdError for LatticeError {
fn description(&self) -> &str {
match self {
LatticeError::IoError(_) => "There was an error reading your file",
LatticeError::JsonParseError(_) => "There was a problem parsing json",
LatticeError::InconsistentVertices => "These vertices ... | JsonParseError(SerdeError),
InconsistentVertices,
NegativeSize,
} | random_line_split |
error.rs | use serde_json::Error as SerdeError;
use std::error::Error as StdError;
use std::fmt;
use std::io::Error as IoError;
#[derive(Debug)]
pub enum LatticeError {
IoError(IoError),
JsonParseError(SerdeError),
InconsistentVertices,
NegativeSize,
}
impl StdError for LatticeError {
fn description(&self) -... | (err: IoError) -> Self {
LatticeError::IoError(err)
}
}
| from | identifier_name |
archive.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... | (&self) -> Vec<String> {
let output = run_ar(self.handler, &self.maybe_ar_prog, "t", None, [&self.dst]);
let output = str::from_utf8(output.output.as_slice()).unwrap();
// use lines_any because windows delimits output with `\r\n` instead of
// just `\n`
output.lines_any().map(|s|... | files | identifier_name |
archive.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... | run_ar(self.handler, &self.maybe_ar_prog, cmd, None, [&self.dst, file]);
}
/// Removes a file from this archive
pub fn remove_file(&mut self, file: &str) {
run_ar(self.handler, &self.maybe_ar_prog, "d", None, [&self.dst, &Path::new(file)]);
}
/// Updates all symbols in the archive ... | pub fn add_file(&mut self, file: &Path, has_symbols: bool) {
let cmd = if has_symbols {"r"} else {"rS"}; | random_line_split |
archive.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... | ,
Err(e) => {
handler.err(format!("could not exec `{}`: {}", ar.as_slice(),
e).as_slice());
handler.abort_if_errors();
fail!("rustc::back::archive::run_ar() should not reach this point");
}
}
}
impl<'a> Archive<'a> {
/// Initializ... | {
let o = prog.wait_with_output().unwrap();
if !o.status.success() {
handler.err(format!("{} failed with: {}",
cmd,
o.status).as_slice());
handler.note(format!("stdout ---\n{}",
... | conditional_block |
archive.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... |
/// Adds all of the contents of the rlib at the specified path to this
/// archive.
///
/// This ignores adding the bytecode from the rlib, and if LTO is enabled
/// then the object file also isn't added.
pub fn add_rlib(&mut self, rlib: &Path, name: &str,
lto: bool) -> io:... | {
let location = self.find_library(name);
self.add_archive(&location, name, [])
} | identifier_body |
linear-for-loop.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let x = ~[1, 2, 3];
let mut y = 0;
for x.each |i| { debug!(*i); y += *i; }
debug!(y);
assert!((y == 6));
let s = ~"hello there";
let mut i: int = 0;
for str::each(s) |c| {
if i == 0 { assert!((c == 'h' as u8)); }
if i == 1 { assert!((c == 'e' as u8)); }
if i ... | main | identifier_name |
linear-for-loop.rs | // 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... | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | random_line_split | |
linear-for-loop.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 ... |
debug!(y);
assert!((y == 6));
let s = ~"hello there";
let mut i: int = 0;
for str::each(s) |c| {
if i == 0 { assert!((c == 'h' as u8)); }
if i == 1 { assert!((c == 'e' as u8)); }
if i == 2 { assert!((c == 'l' as u8)); }
if i == 3 { assert!((c == 'l' as u8)); }
... | {
let x = ~[1, 2, 3];
let mut y = 0;
for x.each |i| { debug!(*i); y += *i; } | identifier_body |
linear-for-loop.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 ... |
if i == 4 { assert!((c == 'o' as u8)); }
//...
i += 1;
debug!(i);
debug!(c);
}
assert!((i == 11));
}
| { assert!((c == 'l' as u8)); } | conditional_block |
cargo_run.rs | use std::os;
use ops::{self, ExecEngine};
use util::{CargoResult, human, process, ProcessError, ChainError};
use core::manifest::TargetKind;
use core::source::Source;
use sources::PathSource;
pub fn run(manifest_path: &Path,
target_kind: TargetKind,
name: Option<String>,
options: &mut... | human("`cargo run` requires that a project only have one executable. \
Use the `--bin` option to specify which one to run")),
None => {}
}
let compile = try!(ops::compile(manifest_path, options));
let dst = manifest_path.dir_path().join("target");
let dst = match ... | {
let mut src = try!(PathSource::for_path(&manifest_path.dir_path()));
try!(src.update());
let root = try!(src.get_root_package());
let env = options.env;
let mut bins = root.get_manifest().get_targets().iter().filter(|a| {
let matches_kind = match target_kind {
TargetKind::Bin =... | identifier_body |
cargo_run.rs | use std::os;
use ops::{self, ExecEngine};
use util::{CargoResult, human, process, ProcessError, ChainError};
use core::manifest::TargetKind;
use core::source::Source;
use sources::PathSource;
pub fn run(manifest_path: &Path,
target_kind: TargetKind,
name: Option<String>,
options: &mut... |
}
let compile = try!(ops::compile(manifest_path, options));
let dst = manifest_path.dir_path().join("target");
let dst = match options.target {
Some(target) => dst.join(target),
None => dst,
};
let exe = match (bin.get_profile().get_dest(), bin.is_example()) {
(Some(s),... | {} | conditional_block |
cargo_run.rs | use std::os;
use ops::{self, ExecEngine};
use util::{CargoResult, human, process, ProcessError, ChainError};
use core::manifest::TargetKind;
use core::source::Source;
use sources::PathSource;
pub fn | (manifest_path: &Path,
target_kind: TargetKind,
name: Option<String>,
options: &mut ops::CompileOptions,
args: &[String]) -> CargoResult<Option<ProcessError>> {
let mut src = try!(PathSource::for_path(&manifest_path.dir_path()));
try!(src.update());
let root = try... | run | identifier_name |
cargo_run.rs | use std::os;
use ops::{self, ExecEngine};
use util::{CargoResult, human, process, ProcessError, ChainError};
use core::manifest::TargetKind;
use core::source::Source;
use sources::PathSource;
pub fn run(manifest_path: &Path,
target_kind: TargetKind,
name: Option<String>,
options: &mut... | Some(path) => path,
None => exe,
};
let process = try!(try!(compile.target_process(exe, &root))
.into_process_builder())
.args(args)
.cwd(try!(os::getcwd()));
try!(options.shell.status("Running", process.... | (Some(s), false) => dst.join(s).join(bin.get_name()),
(None, true) => dst.join("examples").join(bin.get_name()),
(None, false) => dst.join(bin.get_name()),
};
let exe = match exe.path_relative_from(&try!(os::getcwd())) { | random_line_split |
lib.rs | //! FFI bindings for `energymon-osp-polling.h`.
extern crate libc;
extern crate energymon_sys;
pub use energymon_sys::energymon;
use libc::{c_int, uint64_t, c_char, size_t};
extern "C" {
pub fn energymon_init_osp_polling(em: *mut energymon) -> c_int;
pub fn energymon_read_total_osp_polling(em: *const energy... | pub fn energymon_is_exclusive_osp_polling() -> c_int;
pub fn energymon_get_osp_polling(em: *mut energymon) -> c_int;
} | random_line_split | |
skia.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(non_upper_case_globals)]
#![allow(non_camel_case_types)] | #![allow(non_snake_case)]
use libc::*;
pub type SkiaGrContextRef = *mut c_void;
pub type SkiaGrGLInterfaceRef = *const c_void;
#[link(name = "skia")]
extern {
pub fn SkiaGrGLCreateNativeInterface() -> SkiaGrGLInterfaceRef;
pub fn SkiaGrGLInterfaceRetain(anInterface: SkiaGrGLInterfaceRef);
pub fn SkiaGrGLInterfaceRe... | random_line_split | |
zero.rs | use crate::driver::cmd::Args;
use crate::gc::bump::BumpAllocator;
use crate::gc::{Address, Collector, GcReason, Region};
use crate::os::{self, MemoryPermission};
use crate::vm::VM;
pub struct ZeroCollector {
start: Address,
end: Address,
alloc: BumpAllocator,
}
impl ZeroCollector {
pub fn new(args: &A... | (&self, _vm: &VM, size: usize, _array_ref: bool) -> Address {
self.alloc.bump_alloc(size)
}
fn collect(&self, _: &VM, _: GcReason) {
// do nothing
}
fn minor_collect(&self, _: &VM, _: GcReason) {
// do nothing
}
fn dump_summary(&self, runtime: f32) {
let mutato... | alloc | identifier_name |
zero.rs | use crate::driver::cmd::Args;
use crate::gc::bump::BumpAllocator;
use crate::gc::{Address, Collector, GcReason, Region};
use crate::os::{self, MemoryPermission};
use crate::vm::VM;
pub struct ZeroCollector {
start: Address,
end: Address,
alloc: BumpAllocator,
}
impl ZeroCollector {
pub fn new(args: &A... | else {
Some(ptr.region_start(size))
}
}
fn alloc(&self, _vm: &VM, size: usize, _array_ref: bool) -> Address {
self.alloc.bump_alloc(size)
}
fn collect(&self, _: &VM, _: GcReason) {
// do nothing
}
fn minor_collect(&self, _: &VM, _: GcReason) {
// d... | {
None
} | conditional_block |
zero.rs | use crate::driver::cmd::Args;
use crate::gc::bump::BumpAllocator;
use crate::gc::{Address, Collector, GcReason, Region};
use crate::os::{self, MemoryPermission};
use crate::vm::VM;
pub struct ZeroCollector {
start: Address,
end: Address,
alloc: BumpAllocator,
}
impl ZeroCollector {
pub fn new(args: &A... |
}
impl Collector for ZeroCollector {
fn supports_tlab(&self) -> bool {
true
}
fn alloc_tlab_area(&self, _vm: &VM, size: usize) -> Option<Region> {
let ptr = self.alloc.bump_alloc(size);
if ptr.is_null() {
None
} else {
Some(ptr.region_start(size))
... | {
let heap_size: usize = args.max_heap_size();
let reservation = os::reserve_align(heap_size, 0, false);
let start = reservation.start;
let end = start.offset(heap_size);
os::commit_at(start, heap_size, MemoryPermission::ReadWrite);
ZeroCollector {
start,
... | identifier_body |
zero.rs | use crate::driver::cmd::Args;
use crate::gc::bump::BumpAllocator;
use crate::gc::{Address, Collector, GcReason, Region};
use crate::os::{self, MemoryPermission};
use crate::vm::VM;
pub struct ZeroCollector {
start: Address,
end: Address,
alloc: BumpAllocator,
}
impl ZeroCollector {
pub fn new(args: &A... | // do nothing
}
fn dump_summary(&self, runtime: f32) {
let mutator = runtime;
let gc = 0.0f32;
println!("GC stats: total={:.1}", runtime);
println!("GC stats: mutator={:.1}", mutator);
println!("GC stats: collection={:.1}", gc);
println!(
"G... | fn minor_collect(&self, _: &VM, _: GcReason) { | random_line_split |
position.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/. */
//! CSS handling for the computed value of
//! [`position`][position]s
//!
//! [position]: https://drafts.csswg.or... | <W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
try!(self.horizontal.to_css(dest));
try!(dest.write_str(" "));
try!(self.vertical.to_css(dest));
Ok(())
}
}
| to_css | identifier_name |
position.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/. */
//! CSS handling for the computed value of
//! [`position`][position]s
//!
//! [position]: https://drafts.csswg.or... | #[derive(Debug, Clone, PartialEq, Copy)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct Position {
pub horizontal: LengthOrPercentage,
pub vertical: LengthOrPercentage,
}
impl ToCss for Position {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
try!(self.horizo... | random_line_split | |
lint-dead-code-5.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 ... | Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5`
Variant6(isize), //~ ERROR: variant is never constructed: `Variant6`
_Variant7,
}
enum Enum3 { //~ ERROR: enum is never used
Variant8,
Variant9
}
fn main() {
let v = Enum1::Variant1(1);
match v {
Enum1::Var... | #[allow(dead_code)]
Variant4(isize), | random_line_split |
lint-dead-code-5.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 ... | { //~ ERROR: enum is never used
Variant8,
Variant9
}
fn main() {
let v = Enum1::Variant1(1);
match v {
Enum1::Variant1(_) => (),
Enum1::Variant2 => ()
}
let x = Enum2::Variant3(true);
}
| Enum3 | identifier_name |
space.rs | use parking_lot::Mutex;
use std::sync::atomic::{AtomicUsize, Ordering};
use crate::gc::arena;
use crate::gc::{Address, Region};
use crate::mem;
/// Configuration for a space.
/// This makes it possible to use `Space` both for the
/// code space and the permanent space.
pub struct SpaceConfig {
pub executable: boo... | (&self) -> Region {
self.total.clone()
}
pub fn used_region(&self) -> Region {
let start = self.total.start;
let end = self.top.load(Ordering::Relaxed).into();
Region::new(start, end)
}
}
| total | identifier_name |
space.rs | use parking_lot::Mutex;
use std::sync::atomic::{AtomicUsize, Ordering};
use crate::gc::arena;
use crate::gc::{Address, Region};
use crate::mem;
/// Configuration for a space.
/// This makes it possible to use `Space` both for the
/// code space and the permanent space.
pub struct SpaceConfig {
pub executable: boo... |
let size = size - (end - top);
let size = mem::align_usize(size, self.config.chunk);
let new_end = end + size;
if new_end <= self.total.end.to_usize() {
arena::commit(end.into(), size, self.config.executable);
self.end.store(new_end, Ordering::SeqCst);
... | {
return true;
} | conditional_block |
space.rs | use parking_lot::Mutex;
use std::sync::atomic::{AtomicUsize, Ordering};
use crate::gc::arena;
use crate::gc::{Address, Region};
use crate::mem;
/// Configuration for a space.
/// This makes it possible to use `Space` both for the
/// code space and the permanent space.
pub struct SpaceConfig {
pub executable: boo... | Space {
name,
config,
total: Region::new(space_start, space_end),
top: AtomicUsize::new(space_start.to_usize()),
end: AtomicUsize::new(end.to_usize()),
allocate: Mutex::new(()),
}
}
/// allocate memory in this space. This... |
arena::commit(space_start, config.chunk, config.executable);
let end = space_start.offset(config.chunk);
| random_line_split |
thread_dummy.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 ... | #[deprecated(since = "1.0.0", reason = "use module-level free function")]
#[unstable(feature = "std_misc", reason = "recently introduced")]
pub fn park_timeout(_: Duration) {
}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn unpark(&self) {
}
#[stable(feature = "rust1", since = ... |
}
/// Deprecated: use module-level free function. | random_line_split |
thread_dummy.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 ... |
#[stable(feature = "rust1", since = "1.0.0")]
pub fn yield_now() {
}
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn panicking() -> bool {
unwind::panicking()
}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn park() {
}
#[unstable(feature = "std_misc", reason = "recently introduced, depen... | {
Thread
} | identifier_body |
thread_dummy.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 ... | () -> Thread {
Thread
}
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
#[unstable(feature = "std_misc", reason = "name may change")]
pub fn yield_now() {
}
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
#[inline]
#[stable(f... | current | identifier_name |
logger.rs | // This file is part of zinc64.
// Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved.
// Licensed under the GPLv3. See LICENSE file in the project root for full license text.
use core::fmt::Write;
use log::{LogLevelFilter, LogMetadata, SetLoggerError, ShutdownLoggerError};
pub struct | ;
impl SimpleLogger {
pub fn new() -> Self {
SimpleLogger
}
pub fn init(&self) -> Result<(), SetLoggerError> {
unsafe {
log::set_logger_raw(move |max_log_level| {
max_log_level.set(LogLevelFilter::Info);
self.ptr()
})
}
}
... | SimpleLogger | identifier_name |
logger.rs | // This file is part of zinc64.
// Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved.
// Licensed under the GPLv3. See LICENSE file in the project root for full license text.
use core::fmt::Write;
use log::{LogLevelFilter, LogMetadata, SetLoggerError, ShutdownLoggerError};
pub struct SimpleLogger;
i... | log::shutdown_logger_raw().map(|logger| {
let logger = unsafe { &*(logger as *const SimpleLogger) };
logger.flush();
})
} | }
pub fn shutdown() -> Result<(), ShutdownLoggerError> { | random_line_split |
parser.rs | use std::str;
use combine::*;
use combine::byte::*;
use combine::primitives::RangeStream;
use combine::range::*;
use types::Source;
/// Whether or not a character is valid for a nickname when it is not the first character.
fn is_nick_trailing_char(c: u8) -> bool {
match c {
b'A'...b'Z'
| b'a'...b... | ),
host().map(|host| {
let host = unsafe { str::from_utf8_unchecked(host) };
Source::Server { host: host.into() }
})
)
}
| {
let nick = || recognize((letter(), skip_many(satisfy(is_nick_trailing_char))));
let ident = || take_while1(is_ident_char);
let host = || take_while1(is_host_char);
let user = || (nick().skip(byte(b'!')), ident().skip(byte(b'@')), host());
choice!(
try(
user().and_then(|(nick,... | identifier_body |
parser.rs | use std::str;
use combine::*;
use combine::byte::*;
use combine::primitives::RangeStream;
use combine::range::*;
use types::Source;
/// Whether or not a character is valid for a nickname when it is not the first character.
fn | (c: u8) -> bool {
match c {
b'A'...b'Z'
| b'a'...b'z'
| b'0'...b'9'
| b'['
| b']'
| b'`'
| b'^'
| b'\\'
| b'-'
| b'{'
| b'}' => true,
_ => false,
}
}
/// Whether or not a character is valid for an ident.
///
/// RFC... | is_nick_trailing_char | identifier_name |
parser.rs | use std::str;
use combine::*;
use combine::byte::*;
use combine::primitives::RangeStream;
use combine::range::*;
use types::Source;
/// Whether or not a character is valid for a nickname when it is not the first character.
fn is_nick_trailing_char(c: u8) -> bool {
match c {
b'A'...b'Z'
| b'a'...b... | }
}
/// Parse the source of a message.
pub fn source<'a, I>() -> impl Parser<Input = I, Output = Source>
where
I: RangeStream<Item = u8, Range = &'a [u8]>,
I::Error: ParseError<u8, &'a [u8], I::Position>,
<I::Error as ParseError<I::Item, I::Range, I::Position>>::StreamError: From<str::Utf8Error>,
{
... | _ => true, | random_line_split |
features.rs | //! Feature tests for OS functionality
pub use self::os::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use crate::sys::utsname::uname;
// Features:
// * atomic cloexec on socket: 2.6.27
// * pipe2: 2.6.27
// * accept4: 2.6.28
static VERS_UNKNOWN: usize = 1;
static VE... | () -> bool {
kernel_version() >= VERS_2_6_27
}
#[test]
pub fn test_parsing_kernel_version() {
assert!(kernel_version() > 0);
}
}
#[cfg(any(target_os = "illumos"))]
mod os {
/// Check if the OS supports atomic close-on-exec for sockets
pub fn socket_atomic_cloexec() -> bool {
... | socket_atomic_cloexec | identifier_name |
features.rs | //! Feature tests for OS functionality
pub use self::os::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use crate::sys::utsname::uname;
// Features:
// * atomic cloexec on socket: 2.6.27
// * pipe2: 2.6.27
// * accept4: 2.6.28
static VERS_UNKNOWN: usize = 1;
static VE... | else if major >= 2 {
if minor >= 7 {
VERS_UNKNOWN
} else if minor >= 6 {
if patch >= 28 {
VERS_2_6_28
} else if patch >= 27 {
VERS_2_6_27
} else {
VERS_2_6_18
... | {
VERS_3
} | conditional_block |
features.rs | //! Feature tests for OS functionality
pub use self::os::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use crate::sys::utsname::uname;
// Features:
// * atomic cloexec on socket: 2.6.27
// * pipe2: 2.6.27
// * accept4: 2.6.28
static VERS_UNKNOWN: usize = 1;
static VE... | target_os = "openbsd", target_os = "netbsd",
target_os = "redox", target_os = "fuchsia",
target_os = "solaris"))]
mod os {
/// Check if the OS supports atomic close-on-exec for sockets
pub fn socket_atomic_cloexec() -> bool {
false
}
} | #[cfg(any(target_os = "macos", target_os = "freebsd",
target_os = "dragonfly", target_os = "ios", | random_line_split |
features.rs | //! Feature tests for OS functionality
pub use self::os::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use crate::sys::utsname::uname;
// Features:
// * atomic cloexec on socket: 2.6.27
// * pipe2: 2.6.27
// * accept4: 2.6.28
static VERS_UNKNOWN: usize = 1;
static VE... |
fn parse_kernel_version() -> usize {
let u = uname();
let mut curr: usize = 0;
let mut major: usize = 0;
let mut minor: usize = 0;
let mut patch: usize = 0;
for b in u.release().bytes() {
if curr >= 3 {
break;
}
... | {
*dst *= 10;
*dst += (b - b'0') as usize;
} | identifier_body |
main.rs | mod system;
mod math;
mod renderer;
mod canvas;
use renderer::context::*;
use renderer::mesh;
use renderer::shader::{Program, Shader, ShaderType};
use renderer::texture;
use math::mat4::*;
use math::transform;
use math::vec3::*;
use canvas::Canvas;
extern crate rand;
extern crate time;
extern crate gl;
extern crate ... | (mesh::Mesh);
impl specs::Component for CompMesh{
type Storage = specs::VecStorage<CompMesh>;
}
fn main() {
let mut VERTEX_COL_DATA: [GLfloat; 12] = [
1.0, 1.0, 1.0, 1.0,
1.0, 0.0, 1.0, 1.0,
0.0, 1.0, 1.0, 1.0
];
let mut ctx = Context::new("data/config.json");
let t =... | CompMesh | identifier_name |
main.rs | mod system;
mod math;
mod renderer;
mod canvas; | use renderer::shader::{Program, Shader, ShaderType};
use renderer::texture;
use math::mat4::*;
use math::transform;
use math::vec3::*;
use canvas::Canvas;
extern crate rand;
extern crate time;
extern crate gl;
extern crate specs;
use specs::Join;
use gl::types::*;
use std::mem;
use std::ptr;
use std::ffi::CString;
u... |
use renderer::context::*;
use renderer::mesh; | random_line_split |
main.rs | mod system;
mod math;
mod renderer;
mod canvas;
use renderer::context::*;
use renderer::mesh;
use renderer::shader::{Program, Shader, ShaderType};
use renderer::texture;
use math::mat4::*;
use math::transform;
use math::vec3::*;
use canvas::Canvas;
extern crate rand;
extern crate time;
extern crate gl;
extern crate ... |
//now we update the systems
program.bind();
t.bind();
m0.render();
canvas_program.bind();
canvas1.update(elapsed);
canvas1.render();
ctx.end_frame();
}
}
| {
accum -= 1.0;
// try modifying tri color
for i in 0..12 {
if i % 4 != 0 {
VERTEX_COL_DATA[i] = rng.gen::<f32>();
}
}
m0.update_buffer(mesh::MeshAttrib::Color, &VERTEX_COL_DATA);
} | conditional_block |
lib.rs | // ssdeep-rs: A Rust wrapper for ssdeep.
//
// Copyright (c) 2016 Petr Zemek <s3rvac@gmail.com>
//
// This program 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 y... | /// ```
/// let h = ssdeep::hash(b"Hello there!").unwrap();
/// assert_eq!(h, "3:aNRn:aNRn");
/// ```
///
/// # Panics
///
/// If the size of the buffer is strictly greater than `2^32 - 1` bytes. The
/// reason for this is that the corresponding function from the underlying C
/// library accepts the length of the buffe... | /// returns `None`.
///
/// # Examples
/// | random_line_split |
lib.rs | // ssdeep-rs: A Rust wrapper for ssdeep.
//
// Copyright (c) 2016 Petr Zemek <s3rvac@gmail.com>
//
// This program 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 y... |
fn result_buffer_to_string(mut result: Vec<u8>, rc: i32) -> Option<String> {
if rc!= 0 {
// The function from libfuzzy failed, so there is no result.
return None;
}
// Since the resulting vector that holds the fuzzy hash was populated in
// the underlying C library, we have to adjust ... | {
// From fuzzy.h: "The buffer into which the fuzzy hash is stored has to be
// allocated to hold at least FUZZY_MAX_RESULT bytes."
Vec::with_capacity(raw::FUZZY_MAX_RESULT)
} | identifier_body |
lib.rs | // ssdeep-rs: A Rust wrapper for ssdeep.
//
// Copyright (c) 2016 Petr Zemek <s3rvac@gmail.com>
//
// This program 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 y... |
// Since the resulting vector that holds the fuzzy hash was populated in
// the underlying C library, we have to adjust its length because at this
// point, the vector thinks that its length is zero. We do this by finding
// the first null byte.
unsafe {
let mut len = 0;
for i in 0... | {
// The function from libfuzzy failed, so there is no result.
return None;
} | conditional_block |
lib.rs | // ssdeep-rs: A Rust wrapper for ssdeep.
//
// Copyright (c) 2016 Petr Zemek <s3rvac@gmail.com>
//
// This program 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 y... | (buf: &[u8]) -> Option<String> {
assert!(buf.len() <= uint32_t::max_value() as usize);
let mut result = create_buffer_for_result();
let rc = unsafe {
raw::fuzzy_hash_buf(buf.as_ptr(),
buf.len() as uint32_t,
result.as_mut_ptr() as *mut c_char)
... | hash | identifier_name |
mod.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | pub fn new_expanse() -> Spec { load(include_bytes!("../../res/ethereum/expanse.json")) }
/// Create a new Frontier chain spec as though it never changes to Homestead.
pub fn new_frontier_test() -> Spec { load(include_bytes!("../../res/ethereum/frontier_test.json")) }
/// Create a new Homestead chain spec as though it... | pub fn new_classic() -> Spec { load(include_bytes!("../../res/ethereum/classic.json")) }
/// Create a new Frontier mainnet chain spec without the DAO hardfork. | random_line_split |
mod.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | () -> Spec { load(include_bytes!("../../res/ethereum/frontier_test.json")) }
/// Create a new Homestead chain spec as though it never changed from Frontier.
pub fn new_homestead_test() -> Spec { load(include_bytes!("../../res/ethereum/homestead_test.json")) }
/// Create a new Homestead-EIP150 chain spec as though it ... | new_frontier_test | identifier_name |
mod.rs | // Copyright 2015, 2016 Ethcore (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 later version.... |
/// Create a new Homestead chain spec as though it never changed from Frontier.
pub fn new_homestead_test() -> Spec { load(include_bytes!("../../res/ethereum/homestead_test.json")) }
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
pub fn new_eip150_test() -> Spec { lo... | { load(include_bytes!("../../res/ethereum/frontier_test.json")) } | identifier_body |
display.rs | use mon_gen::monster::{Monster, MonsterAttack};
use mon_gen::battle::{Party, Battle, BattleError, PartyMember};
pub fn display(text: String, left: bool)
{
if left
{
println!("{:>80}", text);
}
else
{
println!("{}", text);
}
}
pub fn display_member(member: Option<PartyMember>, opponent: bool, active: bool)
{... |
else
{
""
};
let active_index = if let Some(num) = index
{
format!("{}", num)
}
else
{
String::new()
};
let form_name = if monster.species().species().forms.len() > 1
{
format!(" ({})", monster.species().species().form(monster.form() as usize))
}
else
{
String::new()
};
display(format!("{}{... | {
"-> "
} | conditional_block |
display.rs | use mon_gen::monster::{Monster, MonsterAttack};
use mon_gen::battle::{Party, Battle, BattleError, PartyMember};
pub fn display(text: String, left: bool)
{
if left
{
println!("{:>80}", text);
}
else
{
println!("{}", text);
}
}
pub fn display_member(member: Option<PartyMember>, opponent: bool, active: bool)
{... | };
println!("Invalid selection: {}", error_str);
} | }
BattleError::SwitchQueued =>
{
"Selected party member is already queued to switch in."
} | random_line_split |
display.rs | use mon_gen::monster::{Monster, MonsterAttack};
use mon_gen::battle::{Party, Battle, BattleError, PartyMember};
pub fn display(text: String, left: bool)
{
if left
{
println!("{:>80}", text);
}
else
{
println!("{}", text);
}
}
pub fn display_member(member: Option<PartyMember>, opponent: bool, active: bool)
{... | (battle: &Battle, active: usize)
{
println!("");
for index in 0..battle.state().parties()[1].active_count()
{
display_member(battle.state().parties()[1].active_member_alive(index), true, false)
}
for index in 0..battle.state().parties()[0].active_count()
{
let active = active == index;
display_member(battle... | display_active | identifier_name |
display.rs | use mon_gen::monster::{Monster, MonsterAttack};
use mon_gen::battle::{Party, Battle, BattleError, PartyMember};
pub fn display(text: String, left: bool)
{
if left
{
println!("{:>80}", text);
}
else
{
println!("{}", text);
}
}
pub fn display_member(member: Option<PartyMember>, opponent: bool, active: bool)
{... |
pub fn display_party(party: &Party, back: bool)
{
println!("Party members:");
println!("");
let mut alternate = true;
for (index, monster) in party.iter().enumerate()
{
alternate =!alternate;
display(format!("{}) {} Lv. {}", index + 1, monster.nick(), monster.level()),
alternate);
display(format!(" H... | {
let mut alternate = true;
for (index, attack) in attacks.iter().enumerate()
{
alternate = !alternate;
display(format!("{}) {}", index + 1, attack.attack().name()), alternate);
display(format!(" {}", attack.attack().element.name()), alternate);
display(format!(" Limit: {}/{}", attack.limit_left(), attac... | identifier_body |
associated-types-sugar-path.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 z: uint = bar(2, 4);
}
| main | identifier_name |
associated-types-sugar-path.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 ... | }
impl Foo for int {
type A = uint;
fn boo(&self) -> uint {
5
}
}
// Using a type via a function.
pub fn bar<T: Foo>(a: T, x: T::A) -> T::A {
let _: T::A = a.boo();
x
}
// Using a type via an impl.
trait C {
fn f();
fn g(&self) { }
}
struct B<X>(X);
impl<T: Foo> C for B<T> {
f... | pub trait Foo {
type A;
fn boo(&self) -> Self::A; | random_line_split |
navigatorinfo.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::str::DOMString;
use std::borrow::Cow;
pub fn Product() -> DOMString {
DOMString::f... | pub fn AppCodeName() -> DOMString {
DOMString::from("Mozilla")
}
#[cfg(target_os = "windows")]
pub fn Platform() -> DOMString {
DOMString::from("Win32")
}
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn Platform() -> DOMString {
DOMString::from("Linux")
}
#[cfg(target_os = "macos")]
pub fn... | random_line_split | |
navigatorinfo.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::str::DOMString;
use std::borrow::Cow;
pub fn Product() -> DOMString {
DOMString::f... |
pub fn AppCodeName() -> DOMString {
DOMString::from("Mozilla")
}
#[cfg(target_os = "windows")]
pub fn Platform() -> DOMString {
DOMString::from("Win32")
}
#[cfg(any(target_os = "android", target_os = "linux"))]
pub fn Platform() -> DOMString {
DOMString::from("Linux")
}
#[cfg(target_os = "macos")]
pub ... | {
DOMString::from("Netscape") // Like Gecko/Webkit
} | identifier_body |
navigatorinfo.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::str::DOMString;
use std::borrow::Cow;
pub fn Product() -> DOMString {
DOMString::f... | () -> DOMString {
DOMString::from("Mac")
}
#[cfg(target_os = "ios")]
pub fn Platform() -> DOMString {
DOMString::from("iOS")
}
pub fn UserAgent(user_agent: Cow<'static, str>) -> DOMString {
DOMString::from(&*user_agent)
}
pub fn AppVersion() -> DOMString {
DOMString::from("4.0")
}
pub fn Language() ... | Platform | identifier_name |
issue-14959.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.
// | // <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.
#![feature(unboxed_closures)]
use std::ops::Fn;
trait Response {}
trait Request {}
trait Ingot<R, S> {
fn enter(&mut self, _: &mut R, _: &mut S, a: ... | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | random_line_split |
issue-14959.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 ... |
}
fn main() {}
| {
let send_file = alloy.find::<SendFile>().unwrap();
send_file(res);
Status::Continue
} | identifier_body |
issue-14959.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 ... | ;
enum Status {
Continue
}
impl Alloy {
fn find<T>(&self) -> Option<T> {
None
}
}
impl<'a, 'b> Fn<(&'b mut (Response+'b),)> for SendFile<'a> {
type Output = ();
extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {}
}
impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for Hel... | Alloy | identifier_name |
errors.rs | // Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation
// Copyright (C) 2020 Stacks Open Internet Foundation
//
// This program 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... |
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.err {
_ => write!(f, "{:?}", self.err),
}?;
if let Some(ref e) = self.pre_expressions {
write!(f, "\nNear:\n{:?}", e)?;
}
Ok(())
}
}
impl er... | {
self.diagnostic.spans = exprs.iter().map(|e| e.span.clone()).collect();
self.pre_expressions.replace(exprs.clone().to_vec());
} | identifier_body |
errors.rs | // Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation
// Copyright (C) 2020 Stacks Open Internet Foundation
//
// This program 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... |
ParseErrors::ProgramTooLarge => format!("Program too large to parse"),
ParseErrors::IllegalContractName(contract_name) => {
format!("Illegal contract name: '{}'", contract_name)
}
ParseErrors::IllegalVariableName(var_name) => {
format!("Il... | {
format!("Whitespace expected after colon (:), Found: '{}'", found)
} | conditional_block |
errors.rs | // Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation
// Copyright (C) 2020 Stacks Open Internet Foundation
//
// This program 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... | (err: ParseErrors) -> ParseError {
let diagnostic = Diagnostic::err(&err);
ParseError {
err,
pre_expressions: None,
diagnostic,
}
}
pub fn has_pre_expression(&self) -> bool {
self.pre_expressions.is_some()
}
pub fn set_pre_expression(... | new | identifier_name |
errors.rs | // Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation
// Copyright (C) 2020 Stacks Open Internet Foundation
//
// This program 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... | ParseErrors::ClosingTupleLiteralExpected => {
format!("Tuple literal {{..}} left opened.")
}
ParseErrors::ColonSeparatorUnexpected => format!("Misplaced colon."),
ParseErrors::CommaSeparatorUnexpected => format!("Misplaced comma."),
ParseErrors... | format!("Tried to close tuple literal which isn't open.")
} | random_line_split |
mod.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&mut self) -> u32 {
self.rng.borrow_mut().next_u32()
}
fn next_u64(&mut self) -> u64 {
self.rng.borrow_mut().next_u64()
}
#[inline]
fn fill_bytes(&mut self, bytes: &mut [u8]) {
self.rng.borrow_mut().fill_bytes(bytes)
}
}
| next_u32 | identifier_name |
mod.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
| {
self.rng.borrow_mut().fill_bytes(bytes)
} | identifier_body |
mod.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | //! There is built-in support for a RNG associated with each thread stored
//! in thread-local storage. This RNG can be accessed via `thread_rng`, or
//! used implicitly via `random`. This RNG is normally randomly seeded
//! from an operating-system source of randomness, e.g. `/dev/urandom` on
//! Unix systems, and wil... | //! # Thread-local RNG
//! | random_line_split |
const-vecs-and-slices.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 ... | } | random_line_split | |
const-vecs-and-slices.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 ... | () {
println!("{:?}", x[1]);
println!("{:?}", y[1]);
assert_eq!(x[1], 2);
assert_eq!(x[3], 4);
assert_eq!(x[3], y[3]);
}
| main | identifier_name |
const-vecs-and-slices.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 ... | {
println!("{:?}", x[1]);
println!("{:?}", y[1]);
assert_eq!(x[1], 2);
assert_eq!(x[3], 4);
assert_eq!(x[3], y[3]);
} | identifier_body | |
stage0-clone-contravariant-lifetime.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 ... | { } | identifier_body | |
stage0-clone-contravariant-lifetime.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// A zero-depend... | random_line_split | |
stage0-clone-contravariant-lifetime.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 ... | <'a>;
impl <'a> ::std::clone::Clone for ContravariantLifetime<'a> {
#[inline]
fn clone(&self) -> ContravariantLifetime<'a> {
match *self { ContravariantLifetime => ContravariantLifetime, }
}
}
fn main() { }
| ContravariantLifetime | identifier_name |
migrations.rs | use failure::format_err;
use log::info;
use rusqlite::{Connection, Transaction};
use crate::db::migrations_code;
use crate::errors::*;
const CREATE_VERSIONS: &str = r#"
create table __version ( current_version integer primary key )
"#;
pub trait Migration {
fn run(&self, tx: &Transaction) -> Result<()>;
}
struc... | } else {
tx.execute(
"UPDATE __version set current_version =?1",
&[&next_version],
)
}
.map_err(|e| format_err!("Error updating version: {}", e))?;
tx.commit()?;
next_version += 1;
}
Ok(())
}
#[cfg(test)]
mod test... | tx.execute("INSERT INTO __version VALUES (?1)", &[&next_version]) | random_line_split |
migrations.rs | use failure::format_err;
use log::info;
use rusqlite::{Connection, Transaction};
use crate::db::migrations_code;
use crate::errors::*;
const CREATE_VERSIONS: &str = r#"
create table __version ( current_version integer primary key )
"#;
pub trait Migration {
fn run(&self, tx: &Transaction) -> Result<()>;
}
struc... | () {
let temp_dir = TempDir::new("users.rs").unwrap();
let db_file = temp_dir.path().join("db.sqlite3");
let mut conn = Connection::open(&db_file).expect("create temp database");
migrate(&mut conn).unwrap();
assert_eq!(
Some((all_migrations().len() as i32) - 1),
... | test_migration_versions | identifier_name |
migrations.rs | use failure::format_err;
use log::info;
use rusqlite::{Connection, Transaction};
use crate::db::migrations_code;
use crate::errors::*;
const CREATE_VERSIONS: &str = r#"
create table __version ( current_version integer primary key )
"#;
pub trait Migration {
fn run(&self, tx: &Transaction) -> Result<()>;
}
struc... |
}
}
| {
panic!("Failed: expected second migration to be a noop: {}", e);
} | conditional_block |
migrations.rs | use failure::format_err;
use log::info;
use rusqlite::{Connection, Transaction};
use crate::db::migrations_code;
use crate::errors::*;
const CREATE_VERSIONS: &str = r#"
create table __version ( current_version integer primary key )
"#;
pub trait Migration {
fn run(&self, tx: &Transaction) -> Result<()>;
}
struc... |
}
| {
let temp_dir = TempDir::new("users.rs").unwrap();
let db_file = temp_dir.path().join("db.sqlite3");
let mut conn = Connection::open(&db_file).expect("create temp database");
// migration #1
migrate(&mut conn).unwrap();
// migration #2
if let Err(e) = migrate(&... | identifier_body |
role.rs | use super::ArgumentConvert;
use crate::{model::prelude::*, prelude::*};
/// Error that can be returned from [`Role::convert`].
#[non_exhaustive]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum RoleParseError {
/// When the operation was invoked outside a guild.
NotInGuild,
/// When the guild's ... |
}
| {
let roles = ctx
.cache
.guild_roles(guild_id.ok_or(RoleParseError::NotInGuild)?)
.await
.ok_or(RoleParseError::NotInCache)?;
if let Some(role_id) = s.parse::<u64>().ok().or_else(|| crate::utils::parse_role(s)) {
if let Some(role) = roles.get... | identifier_body |
role.rs | use super::ArgumentConvert;
use crate::{model::prelude::*, prelude::*};
/// Error that can be returned from [`Role::convert`].
#[non_exhaustive]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum RoleParseError {
/// When the operation was invoked outside a guild.
NotInGuild,
/// When the guild's ... |
Err(RoleParseError::NotFoundOrMalformed)
}
}
| {
return Ok(role.clone());
} | conditional_block |
role.rs | use super::ArgumentConvert;
use crate::{model::prelude::*, prelude::*};
/// Error that can be returned from [`Role::convert`].
#[non_exhaustive]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum RoleParseError {
/// When the operation was invoked outside a guild.
NotInGuild,
/// When the guild's ... | (
ctx: &Context,
guild_id: Option<GuildId>,
_channel_id: Option<ChannelId>,
s: &str,
) -> Result<Self, Self::Err> {
let roles = ctx
.cache
.guild_roles(guild_id.ok_or(RoleParseError::NotInGuild)?)
.await
.ok_or(RoleParseError::NotIn... | convert | identifier_name |
role.rs | use super::ArgumentConvert;
use crate::{model::prelude::*, prelude::*};
/// Error that can be returned from [`Role::convert`].
#[non_exhaustive]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum RoleParseError {
/// When the operation was invoked outside a guild.
NotInGuild,
/// When the guild's ... | type Err = RoleParseError;
async fn convert(
ctx: &Context,
guild_id: Option<GuildId>,
_channel_id: Option<ChannelId>,
s: &str,
) -> Result<Self, Self::Err> {
let roles = ctx
.cache
.guild_roles(guild_id.ok_or(RoleParseError::NotInGuild)?)
... | random_line_split | |
private.rs | // This file was borrowed from https://github.com/nikomatsakis/rayon/blob/master/src/private.rs
// and is subject to the license and copyright from that project.
//! The public parts of this private module are used to create traits
//! that cannot be implemented outside of our own crate. This way we
//! can feel free... | ;
macro_rules! private_decl {
() => {
/// This trait is private; this method exists to make it
/// impossible to implement outside the crate.
#[doc(hidden)]
fn __rayon_private__(&self) -> ::private::PrivateMarker;
}
}
macro_rules! private_impl {
() => {
fn __rayon_p... | PrivateMarker | identifier_name |
private.rs | // This file was borrowed from https://github.com/nikomatsakis/rayon/blob/master/src/private.rs
// and is subject to the license and copyright from that project.
//! The public parts of this private module are used to create traits
//! that cannot be implemented outside of our own crate. This way we
//! can feel free... | }
}
macro_rules! private_impl {
() => {
fn __rayon_private__(&self) -> ::private::PrivateMarker {
::private::PrivateMarker
}
}
} | /// impossible to implement outside the crate.
#[doc(hidden)]
fn __rayon_private__(&self) -> ::private::PrivateMarker; | random_line_split |
macros.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 ... | match $e {
Ok(e) => e,
Err(e) => return Err(e),
}
})
}
/// Use the `format!` syntax to write data into a buffer of type `&mut Write`.
/// See `std::fmt` for more information.
///
/// # Examples
///
/// ```
/// # #![allow(unused_must_use)]
/// use std::io::Write;
///
/// let ... | ($e:expr) => ({
use $crate::result::Result::{Ok, Err};
| random_line_split |
main.rs | extern crate dotenv;
extern crate ctrlc;
extern crate chrono;
extern crate chrono_tz;
extern crate url;
extern crate linkify;
#[macro_use]
extern crate html5ever;
extern crate reqwest;
#[macro_use]
extern crate slog;
extern crate slog_async;
extern crate slog_envlogger;
extern crate slog_scope;
extern crate slog_s... |
_ => error!(root_logger, "Problem with starting the client."; "error" => e.to_string()),
}
}
});
}
| {
info!(root_logger, "Shutting down.")
} | conditional_block |
main.rs | extern crate dotenv;
extern crate ctrlc;
extern crate chrono;
extern crate chrono_tz;
extern crate url;
extern crate linkify;
#[macro_use]
extern crate html5ever;
extern crate reqwest;
#[macro_use]
extern crate slog;
extern crate slog_async;
extern crate slog_envlogger;
extern crate slog_scope;
extern crate slog_s... | () {
dotenv::dotenv().ok();
let decorator = slog_term::TermDecorator::new().stderr().build();
let formatter = slog_term::CompactFormat::new(decorator).build().fuse();
let logger = slog_envlogger::new(formatter);
let drain = slog_async::Async::default(logger);
let root_logger = slog::Logger::ro... | main | identifier_name |
main.rs | extern crate dotenv;
extern crate ctrlc;
extern crate chrono;
extern crate chrono_tz;
extern crate url;
extern crate linkify;
#[macro_use]
extern crate html5ever;
extern crate reqwest;
#[macro_use]
extern crate slog;
extern crate slog_async;
extern crate slog_envlogger;
extern crate slog_scope;
extern crate slog_s... | serenity::Error::Client(serenity::client::ClientError::Shutdown) => {
info!(root_logger, "Shutting down.")
}
_ => error!(root_logger, "Problem with starting the client."; "error" => e.to_string()),
}
}
});
} |
// Start client.
if let Err(e) = client.start_autosharded() {
match e { | random_line_split |
main.rs | extern crate dotenv;
extern crate ctrlc;
extern crate chrono;
extern crate chrono_tz;
extern crate url;
extern crate linkify;
#[macro_use]
extern crate html5ever;
extern crate reqwest;
#[macro_use]
extern crate slog;
extern crate slog_async;
extern crate slog_envlogger;
extern crate slog_scope;
extern crate slog_s... | let _global_logger_guard =
slog_stdlog::init().expect("Couldn't initialize global slog-stdlog logger.");
slog_scope::scope(&root_logger, || {
// Create client.
let token = env::var("DISCORD_TOKEN").expect("token");
let mut bot = Bot::new(root_logger.new(o!("scope" => "Bot")));
... | {
dotenv::dotenv().ok();
let decorator = slog_term::TermDecorator::new().stderr().build();
let formatter = slog_term::CompactFormat::new(decorator).build().fuse();
let logger = slog_envlogger::new(formatter);
let drain = slog_async::Async::default(logger);
let root_logger = slog::Logger::root(... | identifier_body |
day_4.rs | use std::iter::Peekable;
use std::str::Chars;
#[derive(PartialEq)]
enum SymbolGroup {
AlphaNumeric,
WhiteSpace,
Else
}
pub struct Lexer<'a> {
iter: Peekable<Chars<'a>>
}
impl <'a> Lexer<'a> {
pub fn new(line: &'a str) -> Lexer {
Lexer { iter: line.chars().peekable() }
}
pub ... | (&mut self) -> Option<char> {
self.iter.peek().cloned()
}
}
| peek_next_symbol | identifier_name |
day_4.rs | use std::iter::Peekable;
use std::str::Chars;
#[derive(PartialEq)]
enum SymbolGroup {
AlphaNumeric,
WhiteSpace,
Else
}
pub struct Lexer<'a> {
iter: Peekable<Chars<'a>>
}
impl <'a> Lexer<'a> { | pub fn next_lexem(&mut self) -> Option<String> {
let mut value = vec![];
let expected = self.define_symbol_group();
if expected == SymbolGroup::Else {
return None;
}
loop {
let actual = self.define_symbol_group();
let symbol = self.peek_nex... |
pub fn new(line: &'a str) -> Lexer {
Lexer { iter: line.chars().peekable() }
}
| random_line_split |
day_4.rs | use std::iter::Peekable;
use std::str::Chars;
#[derive(PartialEq)]
enum SymbolGroup {
AlphaNumeric,
WhiteSpace,
Else
}
pub struct Lexer<'a> {
iter: Peekable<Chars<'a>>
}
impl <'a> Lexer<'a> {
pub fn new(line: &'a str) -> Lexer {
Lexer { iter: line.chars().peekable() }
}
pub ... |
fn peek_next_symbol(&mut self) -> Option<char> {
self.iter.peek().cloned()
}
}
| {
match self.peek_next_symbol() {
Some('a' ...'z') | Some('A'...'Z') |
Some('_') | Some('0'...'9') => SymbolGroup::AlphaNumeric,
Some(' ') => SymbolGroup::WhiteSpace,
Some(_) | None => SymbolGroup::Else,
}
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.