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 |
|---|---|---|---|---|
data.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use construct::ConstructionResult;
use script_layout_interface::restyle_damage::RestyleDamage;
use style::data::Pe... | {
/// Data that the style system associates with a node. When the
/// style system is being used standalone, this is all that hangs
/// off the node. This must be first to permit the various
/// transmutations between PersistentStyleData and PersistentLayoutData.
pub style_data: PersistentStyleData... | PersistentLayoutData | identifier_name |
ktestq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn | () {
run_test(&Instruction { mnemonic: Mnemonic::KTESTQ, operand1: Some(Direct(K7)), operand2: Some(Direct(K6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 225, 248, 153, 254], OperandSize::Dword)
}
fn ktestq_2() {
run_t... | ktestq_1 | identifier_name |
ktestq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn ktestq_1() {
run_test(&Instruction { mnemonic: Mnemonic::KTESTQ, operand1: Some(Direct(K7)), operand2: Some(Direct(K6))... | } | }
fn ktestq_2() {
run_test(&Instruction { mnemonic: Mnemonic::KTESTQ, operand1: Some(Direct(K5)), operand2: Some(Direct(K6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 225, 248, 153, 238], OperandSize::Qword) | random_line_split |
ktestq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn ktestq_1() |
fn ktestq_2() {
run_test(&Instruction { mnemonic: Mnemonic::KTESTQ, operand1: Some(Direct(K5)), operand2: Some(Direct(K6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 225, 248, 153, 238], OperandSize::Qword)
}
| {
run_test(&Instruction { mnemonic: Mnemonic::KTESTQ, operand1: Some(Direct(K7)), operand2: Some(Direct(K6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 225, 248, 153, 254], OperandSize::Dword)
} | identifier_body |
rustup-init.rs | //! The main rustup commandline application
//!
//! The rustup binary is a chimera, changing its behavior based on the
//! name of the binary. This is used most prominently to enable
//! rustup's tool 'proxies' - that is, rustup itself and the rustup
//! proxies are the same binary; when the binary is called 'rustup' o... |
Some(n) if n.starts_with("rustup-gc-") => {
// This is the final uninstallation stage on windows where
// rustup deletes its own exe
self_update::complete_windows_uninstall()
}
Some(_) => proxy_mode::main(),
None => {
// Weird case. No arg... | {
// NB: The above check is only for the prefix of the file
// name. Browsers rename duplicates to
// e.g. rustup-setup(2), and this allows all variations
// to work.
setup_mode::main()
} | conditional_block |
rustup-init.rs | //! The main rustup commandline application
//!
//! The rustup binary is a chimera, changing its behavior based on the
//! name of the binary. This is used most prominently to enable
//! rustup's tool 'proxies' - that is, rustup itself and the rustup
//! proxies are the same binary; when the binary is called 'rustup' o... | () -> Result<utils::ExitCode> {
if let Ok(dir) = process().var("RUSTUP_TRACE_DIR") {
open_trace_file!(dir)?;
}
let result = run_rustup_inner();
if process().var("RUSTUP_TRACE_DIR").is_ok() {
close_trace_file!();
}
result
}
fn run_rustup_inner() -> Result<utils::ExitCode> {
/... | run_rustup | identifier_name |
rustup-init.rs | //! The main rustup commandline application
//!
//! The rustup binary is a chimera, changing its behavior based on the
//! name of the binary. This is used most prominently to enable
//! rustup's tool 'proxies' - that is, rustup itself and the rustup
//! proxies are the same binary; when the binary is called 'rustup' o... | utils::current_exe()?;
// The name of arg0 determines how the program is going to behave
let arg0 = match process().var("RUSTUP_FORCE_ARG0") {
Ok(v) => Some(v),
Err(_) => process().args().next(),
}
.map(PathBuf::from);
let name = arg0
.as_ref()
.and_then(|a| a.file_... | process().current_dir()?; | random_line_split |
rustup-init.rs | //! The main rustup commandline application
//!
//! The rustup binary is a chimera, changing its behavior based on the
//! name of the binary. This is used most prominently to enable
//! rustup's tool 'proxies' - that is, rustup itself and the rustup
//! proxies are the same binary; when the binary is called 'rustup' o... |
match name {
Some("rustup") => rustup_mode::main(),
Some(n) if n.starts_with("rustup-setup") || n.starts_with("rustup-init") => {
// NB: The above check is only for the prefix of the file
// name. Browsers rename duplicates to
// e.g. rustup-setup(2), and this al... | {
// Guard against infinite proxy recursion. This mostly happens due to
// bugs in rustup.
do_recursion_guard()?;
// Before we do anything else, ensure we know where we are and who we
// are because otherwise we cannot proceed usefully.
process().current_dir()?;
utils::current_exe()?;
... | identifier_body |
panicking.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 ... | (expr_file_line: &(&'static str, &'static str, u32)) ->! {
// Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
// reduce size overhead. The format_args! macro uses str's Display trait to
// write expr, which calls Formatter::pad, which must accommodate string
// truncation and pa... | panic | identifier_name |
panicking.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 ... | #![allow(dead_code, missing_docs)]
use fmt;
#[cold] #[inline(never)] // this is the slow path, always
#[lang="panic"]
pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) ->! {
// Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
// reduce size overhead. The format_args! mac... | random_line_split | |
panicking.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 ... | {
#[allow(improper_ctypes)]
extern {
#[lang = "panic_fmt"]
fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: u32) -> !;
}
let (file, line) = *file_line;
unsafe { panic_impl(fmt, file, line) }
} | identifier_body | |
swap-overlapping.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 ... | {
desc: TestDesc,
testfn: TestFn,
}
| TestDescAndFn | identifier_name |
swap-overlapping.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. | // 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.
// Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
use ... | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
input.rs | use engine::components::{Movable, Move};
use engine::resources::{ReplayMode, Skip};
use engine::ActionInput;
use specs::prelude::*;
use specs::world::Index;
use scaii_defs::protos::Action as ScaiiAction;
#[derive(SystemData)]
pub struct InputSystemData<'a> {
movable: ReadStorage<'a, Movable>,
input: FetchMut<... | () -> Self {
InputSystem {}
}
}
impl<'a> System<'a> for InputSystem {
type SystemData = InputSystemData<'a>;
fn run(&mut self, mut sys_data: Self::SystemData) {
use engine::components::{MoveBehavior, MoveTarget};
use std::mem;
let actions = mem::replace(&mut sys_data.input... | new | identifier_name |
input.rs | use engine::components::{Movable, Move};
use engine::resources::{ReplayMode, Skip};
use engine::ActionInput;
use specs::prelude::*;
use specs::world::Index;
use scaii_defs::protos::Action as ScaiiAction;
#[derive(SystemData)]
pub struct InputSystemData<'a> {
movable: ReadStorage<'a, Movable>,
input: FetchMut<... |
}
impl<'a> System<'a> for InputSystem {
type SystemData = InputSystemData<'a>;
fn run(&mut self, mut sys_data: Self::SystemData) {
use engine::components::{MoveBehavior, MoveTarget};
use std::mem;
let actions = mem::replace(&mut sys_data.input.0, None);
let actions = if actio... | {
InputSystem {}
} | identifier_body |
input.rs | use engine::components::{Movable, Move};
use engine::resources::{ReplayMode, Skip};
use engine::ActionInput;
use specs::prelude::*;
use specs::world::Index;
use scaii_defs::protos::Action as ScaiiAction;
#[derive(SystemData)]
pub struct InputSystemData<'a> {
movable: ReadStorage<'a, Movable>,
input: FetchMut<... | InputSystem {}
}
}
impl<'a> System<'a> for InputSystem {
type SystemData = InputSystemData<'a>;
fn run(&mut self, mut sys_data: Self::SystemData) {
use engine::components::{MoveBehavior, MoveTarget};
use std::mem;
let actions = mem::replace(&mut sys_data.input.0, None);
... | pub fn new() -> Self { | random_line_split |
input.rs | use engine::components::{Movable, Move};
use engine::resources::{ReplayMode, Skip};
use engine::ActionInput;
use specs::prelude::*;
use specs::world::Index;
use scaii_defs::protos::Action as ScaiiAction;
#[derive(SystemData)]
pub struct InputSystemData<'a> {
movable: ReadStorage<'a, Movable>,
input: FetchMut<... | ;
for action in actions {
let entity = sys_data.ids.entity(action.unit_id);
// Maybe set an error state later?
if!sys_data.ids.is_alive(entity) {
continue;
}
if!sys_data.movable.get(entity).is_some() {
continue;
... | {
return;
} | conditional_block |
scanner.rs | use std::io;
use std::io::prelude::*;
use std::sync::{ Arc, Mutex };
use std::sync::mpsc::{ channel, Sender, Receiver };
use std::thread;
use std::error;
// State Function
pub struct | <E: error::Error, T>(pub fn(l: &mut Scanner<E, T>)->Result<Option<StateFn<E, T>>, E>);
pub trait StateMachine<E: error::Error, T> {
fn start_state(self)->Result<Option<StateFn<E, T>>, E>;
}
#[derive(Clone, Debug)]
pub struct Pos {
pos: u64,
line: u64,
col: u64
}
// Position
impl Pos {
fn new()->Pos {
Pos {
... | StateFn | identifier_name |
scanner.rs | use std::io;
use std::io::prelude::*;
use std::sync::{ Arc, Mutex };
use std::sync::mpsc::{ channel, Sender, Receiver };
use std::thread;
use std::error;
// State Function
pub struct StateFn<E: error::Error, T>(pub fn(l: &mut Scanner<E, T>)->Result<Option<StateFn<E, T>>, E>);
pub trait StateMachine<E: error::Error, T... | ;
self.buf.push(c); // Push to unemitted buffer
self.pos.next(c); // Update position
Ok(c)
}
fn back(&mut self) {
let c = self.buf.pop().unwrap();
self.backbuf.push(c);
self.pos.back(c);
}
fn emit(&mut self, typ: T) {
let t = self.send.as_ref().unwrap().send(Token{
pos: self.pos.clone(),
typ: ... | {
self.backbuf.pop().unwrap()
} | conditional_block |
scanner.rs | use std::io;
use std::io::prelude::*;
use std::sync::{ Arc, Mutex };
use std::sync::mpsc::{ channel, Sender, Receiver };
use std::thread;
use std::error;
// State Function
pub struct StateFn<E: error::Error, T>(pub fn(l: &mut Scanner<E, T>)->Result<Option<StateFn<E, T>>, E>);
pub trait StateMachine<E: error::Error, T... | fn emit(&mut self, typ: T);
}
// State Machine
pub struct ReadScanner<R: io::Read+Send, T: Send> {
// Current position
pos: Pos,
// Input character stream
input: Arc<Mutex<io::Chars<R>>>,
// Back buffer
backbuf: Vec<char>,
// Unemitted buffer
buf: String,
// State machine position
state: StateFn<io::CharsEr... | fn next(&mut self)->Result<char, E>;
fn back(&mut self); | random_line_split |
scanner.rs | use std::io;
use std::io::prelude::*;
use std::sync::{ Arc, Mutex };
use std::sync::mpsc::{ channel, Sender, Receiver };
use std::thread;
use std::error;
// State Function
pub struct StateFn<E: error::Error, T>(pub fn(l: &mut Scanner<E, T>)->Result<Option<StateFn<E, T>>, E>);
pub trait StateMachine<E: error::Error, T... |
fn next(&mut self, c: char) {
self.pos += 1;
match c {
'\n' => {
self.line += 1;
self.col = 0;
},
_ => self.col += 1
}
}
fn back(&mut self, c: char) {
self.pos -= 1;
match c {
// Don't back over newlines.
'\n' => {},
_ => self.col -= 1
}
}
}
#[derive(Debug)]
pub struct Toke... | {
Pos {
pos: 0,
line: 0,
col: 0
}
} | identifier_body |
ipc.rs | //! IPC module will hold all massive (that is why IPC) internal messages
//! which occur due to data collection, its start and its end.
use super::{
audio_info::{AudioInfo, AudioInfoKey},
IFInternalCollectionOutputData,
};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct IFCollectionOutput... |
#[derive(Serialize, Deserialize, Debug)]
pub enum IPC {
DoneSearching(IFCollectionOutputData),
PublishSingleAudioDataRecord(AudioInfoKey, AudioInfo),
} | }
} | random_line_split |
ipc.rs | //! IPC module will hold all massive (that is why IPC) internal messages
//! which occur due to data collection, its start and its end.
use super::{
audio_info::{AudioInfo, AudioInfoKey},
IFInternalCollectionOutputData,
};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct IFCollectionOutput... | {
DoneSearching(IFCollectionOutputData),
PublishSingleAudioDataRecord(AudioInfoKey, AudioInfo),
}
| IPC | identifier_name |
ipc.rs | //! IPC module will hold all massive (that is why IPC) internal messages
//! which occur due to data collection, its start and its end.
use super::{
audio_info::{AudioInfo, AudioInfoKey},
IFInternalCollectionOutputData,
};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct IFCollectionOutput... |
}
#[derive(Serialize, Deserialize, Debug)]
pub enum IPC {
DoneSearching(IFCollectionOutputData),
PublishSingleAudioDataRecord(AudioInfoKey, AudioInfo),
}
| {
Self {
nr_searched_files: internal.nr_searched_files,
nr_found_songs: internal.nr_found_songs,
nr_internal_duplicates: internal.nr_internal_duplicates,
size_of_data_in_kb: 0,
}
} | identifier_body |
weighted_random_bools.rs |
fn weighted_random_bools_helper(
p_numerator: u64,
p_denominator: u64,
expected_values: &[bool],
expected_common_values: &[(bool, usize)],
expected_median: (bool, Option<bool>),
) {
let xs = weighted_random_bools(EXAMPLE_SEED, p_numerator, p_denominator);
let values = xs.clone().take(20).co... | use itertools::Itertools;
use malachite_base::bools::random::weighted_random_bools;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base_test_util::stats::common_values_map::common_values_map;
use malachite_base_test_util::stats::median; | random_line_split | |
weighted_random_bools.rs | use itertools::Itertools;
use malachite_base::bools::random::weighted_random_bools;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base_test_util::stats::common_values_map::common_values_map;
use malachite_base_test_util::stats::median;
fn | (
p_numerator: u64,
p_denominator: u64,
expected_values: &[bool],
expected_common_values: &[(bool, usize)],
expected_median: (bool, Option<bool>),
) {
let xs = weighted_random_bools(EXAMPLE_SEED, p_numerator, p_denominator);
let values = xs.clone().take(20).collect_vec();
let common_valu... | weighted_random_bools_helper | identifier_name |
weighted_random_bools.rs | use itertools::Itertools;
use malachite_base::bools::random::weighted_random_bools;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base_test_util::stats::common_values_map::common_values_map;
use malachite_base_test_util::stats::median;
fn weighted_random_bools_helper(
p_numerator: u64,
p_denominator:... |
#[test]
fn test_weighted_random_bools() {
// p = 0
weighted_random_bools_helper(0, 1, &[false; 20], &[(false, 1000000)], (false, None));
// p = 1
weighted_random_bools_helper(1, 1, &[true; 20], &[(true, 1000000)], (true, None));
// p = 1/2
weighted_random_bools_helper(
1,
2,
... | {
let xs = weighted_random_bools(EXAMPLE_SEED, p_numerator, p_denominator);
let values = xs.clone().take(20).collect_vec();
let common_values = common_values_map(1000000, 10, xs.clone());
let median = median(xs.take(1000000));
assert_eq!(
(values.as_slice(), common_values.as_slice(), median)... | identifier_body |
wav.rs | use std::char;
use std::error::Error;
use std::fmt::{Debug, Formatter};
use std::fs::File;
use std::io::prelude::*;
use std::mem;
use std::path::Path;
use std::slice;
const RIFF: [u8; 4] = ['R' as u8, 'I' as u8, 'F' as u8, 'F' as u8];
const WAVE: [u8; 4] = ['W' as u8, 'A' as u8, 'V' as u8, 'E' as u8];
const FMT: [u8;... | "ChunkHeader {{ id: \"{}{}{}{}\", chunk_size: {} }}",
char::from_u32(self.id[0] as u32).unwrap(),
char::from_u32(self.id[1] as u32).unwrap(),
char::from_u32(self.id[2] as u32).unwrap(),
char::from_u32(self.id[3] as u32).unwrap(),
... | impl Debug for ChunkHeader {
fn fmt(&self, f: &mut Formatter) -> Result<(), ::std::fmt::Error> {
write!(f, | random_line_split |
wav.rs | use std::char;
use std::error::Error;
use std::fmt::{Debug, Formatter};
use std::fs::File;
use std::io::prelude::*;
use std::mem;
use std::path::Path;
use std::slice;
const RIFF: [u8; 4] = ['R' as u8, 'I' as u8, 'F' as u8, 'F' as u8];
const WAVE: [u8; 4] = ['W' as u8, 'A' as u8, 'V' as u8, 'E' as u8];
const FMT: [u8;... | (file: &mut File, header: ChunkHeader) -> Result<FormatChunk, ::std::io::Error> {
assert_eq!(header.chunk_size as usize, mem::size_of::<Self>());
let mut chunk: Self = unsafe { mem::uninitialized() };
let mut buffer = unsafe {
let base_ptr: *mut u8 = mem::transmute(&mut chunk);
... | from_stream | identifier_name |
wav.rs | use std::char;
use std::error::Error;
use std::fmt::{Debug, Formatter};
use std::fs::File;
use std::io::prelude::*;
use std::mem;
use std::path::Path;
use std::slice;
const RIFF: [u8; 4] = ['R' as u8, 'I' as u8, 'F' as u8, 'F' as u8];
const WAVE: [u8; 4] = ['W' as u8, 'A' as u8, 'V' as u8, 'E' as u8];
const FMT: [u8;... | ,
DATA => {
self.data = try!(DataChunk::from_stream(file, header));
},
_ => panic!("unknow chunk header: {:?}", header),
}
Ok(())
}
}
| {
let chunk = try!(FormatChunk::from_stream(file, header));
self.format = chunk;
} | conditional_block |
rustc.rs | use std::path::Path;
use util::{self, CargoResult, internal, ChainError};
pub struct Rustc {
pub verbose_version: String,
pub host: String,
pub cap_lints: bool,
}
impl Rustc {
/// Run the compiler at `path` to learn varioues pieces of information about
/// it.
///
/// If successful this f... | }));
triple.to_string()
};
Ok(ret)
}
pub fn blank() -> Rustc {
Rustc {
verbose_version: String::new(),
host: String::new(),
cap_lints: false,
}
}
}
| {
let mut cmd = try!(util::process(path.as_ref()));
cmd.arg("-vV");
let mut ret = Rustc::blank();
let mut first = cmd.clone();
first.arg("--cap-lints").arg("allow");
let output = match first.exec_with_output() {
Ok(output) => { ret.cap_lints = true; output }
... | identifier_body |
rustc.rs | use std::path::Path;
use util::{self, CargoResult, internal, ChainError};
pub struct Rustc {
pub verbose_version: String,
pub host: String,
pub cap_lints: bool,
}
impl Rustc {
/// Run the compiler at `path` to learn varioues pieces of information about
/// it.
///
/// If successful this f... | () -> Rustc {
Rustc {
verbose_version: String::new(),
host: String::new(),
cap_lints: false,
}
}
}
| blank | identifier_name |
rustc.rs | use std::path::Path;
use util::{self, CargoResult, internal, ChainError};
pub struct Rustc {
pub verbose_version: String,
pub host: String,
pub cap_lints: bool,
}
impl Rustc {
/// Run the compiler at `path` to learn varioues pieces of information about
/// it.
///
/// If successful this f... | }).map(|l| &l[6..]).next();
let triple = try!(triple.chain_error(|| {
internal("rustc -v didn't have a line for `host:`")
}));
triple.to_string()
};
Ok(ret)
}
pub fn blank() -> Rustc {
Rustc {
verbose_version: S... | internal("rustc -v didn't return utf8 output")
}));
ret.host = {
let triple = ret.verbose_version.lines().filter(|l| {
l.starts_with("host: ") | random_line_split |
scheduler.rs | //! The main scheduler logic.
//!
//! The scheduler is implemented as a singleton in order to make it easy for code anywhere in the
//! project to make use of async functionality. The actual scheduler instance is not publicly
//! accessible, instead we use various standalone functions like `start()` and `wait_for()` to... |
Scheduler::with(move |scheduler| scheduler.schedule_work(Work {
func: work_proc,
id: work_id,
}));
Async {
work: work_id,
receiver: receiver,
_phantom: PhantomData,
}
}
/// Suspends the current fiber and makes the wait fiber active.
///
/// Generally you should... | erase_lifetime(move || {
let result = func();
sender.try_send(result).expect("Failed to send async result");
})
}; | random_line_split |
scheduler.rs | //! The main scheduler logic.
//!
//! The scheduler is implemented as a singleton in order to make it easy for code anywhere in the
//! project to make use of async functionality. The actual scheduler instance is not publicly
//! accessible, instead we use various standalone functions like `start()` and `wait_for()` to... |
}
enum NextWork {
Work(Work),
Fiber(Fiber),
}
struct Scheduler {
/// Work units that are currently pending or in progress.
current_work: HashSet<WorkId>,
work_map: HashMap<FiberId, WorkId>,
/// New units of work that haven't been started on a fiber yet.
///
/// These are ready to be... | {
write!(formatter, "Work {{ id: {:?} }}", self.id)
} | identifier_body |
scheduler.rs | //! The main scheduler logic.
//!
//! The scheduler is implemented as a singleton in order to make it easy for code anywhere in the
//! project to make use of async functionality. The actual scheduler instance is not publicly
//! accessible, instead we use various standalone functions like `start()` and `wait_for()` to... | (suspended: Fiber) ->! {
stopwatch::switch_context(suspended.id(), fiber::current().unwrap());
// The current fiber has been resumed. Let the scheduler know that the previous fiber is no
// longer active.
Scheduler::with(|scheduler| schedu... | fiber_proc | identifier_name |
scheduler.rs | //! The main scheduler logic.
//!
//! The scheduler is implemented as a singleton in order to make it easy for code anywhere in the
//! project to make use of async functionality. The actual scheduler instance is not publicly
//! accessible, instead we use various standalone functions like `start()` and `wait_for()` to... |
}
for ready_work in ready {
let (maybe_fiber, _) = self.dependencies.remove(&ready_work).unwrap();
if let Some(ready_fiber) = maybe_fiber {
self.ready_fibers.push_back(ready_fiber);
CONDVAR.borrow().notify_one();
}
}
... | {
ready.push(pending_fiber);
} | conditional_block |
saturating_neg.rs | use malachite_base::num::basic::signeds::PrimitiveSigned; | let test = |n: T, out| {
assert_eq!(n.saturating_neg(), out);
let mut n = n;
n.saturating_neg_assign();
assert_eq!(n, out);
};
test(T::ZERO, T::ZERO);
test(T::ONE, T::NEGATIVE_ONE);
test(T::exact_from(100), T::exact_from(-100));
test(T::MAX, T::MIN + T::ONE);
... | use malachite_base_test_util::generators::signed_gen;
fn saturating_neg_assign_helper<T: PrimitiveSigned>() { | random_line_split |
saturating_neg.rs | use malachite_base::num::basic::signeds::PrimitiveSigned;
use malachite_base_test_util::generators::signed_gen;
fn saturating_neg_assign_helper<T: PrimitiveSigned>() {
let test = |n: T, out| {
assert_eq!(n.saturating_neg(), out);
let mut n = n;
n.saturating_neg_assign();
assert_eq!... | () {
apply_fn_to_signeds!(saturating_neg_properties_helper);
}
| saturating_neg_properties | identifier_name |
saturating_neg.rs | use malachite_base::num::basic::signeds::PrimitiveSigned;
use malachite_base_test_util::generators::signed_gen;
fn saturating_neg_assign_helper<T: PrimitiveSigned>() |
#[test]
fn test_saturating_neg_assign() {
apply_fn_to_signeds!(saturating_neg_assign_helper);
}
fn saturating_neg_properties_helper<T: PrimitiveSigned>() {
signed_gen::<T>().test_properties(|n| {
let mut neg = n;
neg.saturating_neg_assign();
assert_eq!(neg, n.saturating_neg());
... | {
let test = |n: T, out| {
assert_eq!(n.saturating_neg(), out);
let mut n = n;
n.saturating_neg_assign();
assert_eq!(n, out);
};
test(T::ZERO, T::ZERO);
test(T::ONE, T::NEGATIVE_ONE);
test(T::exact_from(100), T::exact_from(-100));
test(T::MAX, T::MIN + T::ONE);
... | identifier_body |
saturating_neg.rs | use malachite_base::num::basic::signeds::PrimitiveSigned;
use malachite_base_test_util::generators::signed_gen;
fn saturating_neg_assign_helper<T: PrimitiveSigned>() {
let test = |n: T, out| {
assert_eq!(n.saturating_neg(), out);
let mut n = n;
n.saturating_neg_assign();
assert_eq!... |
assert_eq!(neg == n, n == T::ZERO);
});
}
#[test]
fn saturating_neg_properties() {
apply_fn_to_signeds!(saturating_neg_properties_helper);
}
| {
assert_eq!(neg.saturating_neg(), n);
} | conditional_block |
store.rs | use libc::{c_ulong, c_ulonglong, c_void};
use super::super::error_type::ErrorType;
use super::super::operation::Operation;
use super::super::instance::Instance;
use super::format_error;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct StoreInternal {
pub cookie: *mut c_void,
pub key: *const c_void,
pu... | {
pub key: Option<String>,
pub cas: u64,
pub rc: ErrorType,
pub version: u16,
pub rflags: u16,
pub operation: Operation
}
impl Store {
pub fn new(internal: &StoreInternal) -> Store {
Store {
key: internal.key(),
cas: internal.cas,
rc: internal.rc... | Store | identifier_name |
store.rs | use libc::{c_ulong, c_ulonglong, c_void};
use super::super::error_type::ErrorType;
use super::super::operation::Operation;
use super::super::instance::Instance;
use super::format_error;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct StoreInternal {
pub cookie: *mut c_void,
pub key: *const c_void,
pu... | impl Store {
pub fn new(internal: &StoreInternal) -> Store {
Store {
key: internal.key(),
cas: internal.cas,
rc: internal.rc,
version: internal.version,
rflags: internal.rflags,
operation: internal.operation
}
}
} | random_line_split | |
closest_nodes_iter.rs | use std::sync::{Arc, Mutex, Condvar};
use std::sync::mpsc::Receiver;
use std::thread::spawn;
use node::{Node, NodeId};
#[cfg(test)]
use node::NODEID_BYTELEN;
#[derive(Clone)]
pub struct ClosestNodesIter {
key: Arc<NodeId>,
count: usize, // ask at least <count> nodes
processed_nodes: Arc<Mutex<Vec<Node>>>,
unproc... | (&mut self) -> Option<Self::Item> {
let key = &*self.key;
loop {
// wait for lock
let &(ref lock, ref cvar) = &*self.unprocessed_nodes;
let mut pair = lock.lock().unwrap();
let mut unprocessed_nodes = pair.0.len();
let mut pending_receivers = pair.1;
// either we have unprocessed_nodes or we wa... | next | identifier_name |
closest_nodes_iter.rs | use std::sync::{Arc, Mutex, Condvar};
use std::sync::mpsc::Receiver;
use std::thread::spawn;
use node::{Node, NodeId};
#[cfg(test)]
use node::NODEID_BYTELEN;
#[derive(Clone)]
pub struct ClosestNodesIter {
key: Arc<NodeId>,
count: usize, // ask at least <count> nodes
processed_nodes: Arc<Mutex<Vec<Node>>>,
unproc... | }
}
impl Iterator for ClosestNodesIter {
type Item = Node;
fn next(&mut self) -> Option<Self::Item> {
let key = &*self.key;
loop {
// wait for lock
let &(ref lock, ref cvar) = &*self.unprocessed_nodes;
let mut pair = lock.lock().unwrap();
let mut unprocessed_nodes = pair.0.len();
let mut pendi... | random_line_split | |
closest_nodes_iter.rs | use std::sync::{Arc, Mutex, Condvar};
use std::sync::mpsc::Receiver;
use std::thread::spawn;
use node::{Node, NodeId};
#[cfg(test)]
use node::NODEID_BYTELEN;
#[derive(Clone)]
pub struct ClosestNodesIter {
key: Arc<NodeId>,
count: usize, // ask at least <count> nodes
processed_nodes: Arc<Mutex<Vec<Node>>>,
unproc... |
assert_eq!(iter.next(), None);
}
}
| {
assert_eq!(iter.next(), Some(node0xff));
} | conditional_block |
closest_nodes_iter.rs | use std::sync::{Arc, Mutex, Condvar};
use std::sync::mpsc::Receiver;
use std::thread::spawn;
use node::{Node, NodeId};
#[cfg(test)]
use node::NODEID_BYTELEN;
#[derive(Clone)]
pub struct ClosestNodesIter {
key: Arc<NodeId>,
count: usize, // ask at least <count> nodes
processed_nodes: Arc<Mutex<Vec<Node>>>,
unproc... |
#[test]
fn clone() {
let key = [0; NODEID_BYTELEN];
let node = Node::new("127.0.0.1:2134", [0x00; NODEID_BYTELEN]).unwrap();
let mut iter1 = ClosestNodesIter::new(key, 10, vec![node.clone()]);
let mut iter2 = iter1.clone();
assert_eq!(iter2.next(), Some(node));
assert_eq!(iter1.next(), None);
assert_eq!(iter... | {
let key = [0; NODEID_BYTELEN];
let mut iter = ClosestNodesIter::new(key, 10, vec![]);
assert_eq!(iter.next(), None);
} | identifier_body |
rtl8139.rs | use alloc::boxed::Box;
use arch::memory;
use collections::slice;
use collections::string::ToString;
use collections::vec::Vec;
use collections::vec_deque::VecDeque;
use core::ptr;
use common::debug;
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Pio};
use network::common::*;
use network::scheme::*;
u... |
pub struct Rtl8139 {
pci: PciConfig,
base: usize,
memory_mapped: bool,
irq: u8,
resources: Intex<Vec<*mut NetworkResource>>,
inbound: VecDeque<Vec<u8>>,
outbound: VecDeque<Vec<u8>>,
txds: Vec<Txd>,
txd_i: usize,
port: Rtl8139Port,
}
impl Rtl8139 {
pub fn new(mut pci: PciCon... | } | random_line_split |
rtl8139.rs | use alloc::boxed::Box;
use arch::memory;
use collections::slice;
use collections::string::ToString;
use collections::vec::Vec;
use collections::vec_deque::VecDeque;
use core::ptr;
use common::debug;
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Pio};
use network::common::*;
use network::scheme::*;
u... | (&mut self, _: Url, _: usize) -> Result<Box<Resource>> {
Ok(NetworkResource::new(self))
}
fn on_irq(&mut self, irq: u8) {
if irq == self.irq {
let isr = self.port.isr.read();
self.port.isr.write(isr);
// dh(isr as usize);
// dl();
se... | open | identifier_name |
rtl8139.rs | use alloc::boxed::Box;
use arch::memory;
use collections::slice;
use collections::string::ToString;
use collections::vec::Vec;
use collections::vec_deque::VecDeque;
use core::ptr;
use common::debug;
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Pio};
use network::common::*;
use network::scheme::*;
u... | else {
debug::dl();
debug::d("RTL8139: Frame too long for transmit: ");
debug::dd(bytes.len());
debug::dl();
}
} else {
debug::d("RTL8139: TXD Overflow!\n");
self.txd_i = 0;
... | {
while !txd.status_port.readf(RTL8139_TSR_OWN) {}
debug::d("Send ");
debug::dh(self.txd_i as usize);
debug::d(" ");
debug::dh(txd.status_port.read() as usize);
debug::d(" ");
deb... | conditional_block |
text.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for text properties.
use app_units::Au;
use cssparser::Parser;
use parser::ParserContext;
use p... | <'i, 't, F>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
parse: F)
-> Result<Self, ParseError<'i>>
where F: FnOnce(&ParserContext, &mut Parser<'i, 't>) -> Result<Value, ParseError<'i>>
{
if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
... | parse_with | identifier_name |
text.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for text properties.
use app_units::Au;
use cssparser::Parser;
use parser::ParserContext;
use p... | }
impl<Value> Spacing<Value> {
/// Returns `normal`.
#[inline]
pub fn normal() -> Self {
Spacing::Normal
}
/// Parses.
#[inline]
pub fn parse_with<'i, 't, F>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
parse: F)
-> Result<Self, ParseError<'... | pub enum Spacing<Value> {
/// `normal`
Normal,
/// `<value>`
Value(Value), | random_line_split |
text.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for text properties.
use app_units::Au;
use cssparser::Parser;
use parser::ParserContext;
use p... |
}
impl<V> ToAnimatedZero for Spacing<V>
where
V: From<Au>,
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
}
/// A generic value for the `line-height` property.
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, HasViewportPercen... | {
let zero = V::from(Au(0));
let this = self.value().unwrap_or(&zero);
let other = other.value().unwrap_or(&zero);
this.compute_squared_distance(other)
} | identifier_body |
text.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for text properties.
use app_units::Au;
use cssparser::Parser;
use parser::ParserContext;
use p... |
let zero = Value::from(Au(0));
let this = self.value().unwrap_or(&zero);
let other = other.value().unwrap_or(&zero);
this.add_weighted(other, self_portion, other_portion).map(Spacing::Value)
}
}
impl<V> ComputeSquaredDistance for Spacing<V>
where
V: ComputeSquaredDistance + Fro... | {
return Ok(Spacing::Normal);
} | conditional_block |
layout_debug.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/. */
//! Supports writing a trace file created during each layout scope
//! that can be viewed by an external tool to m... | (name: String) -> Scope {
STATE_KEY.with(|ref r| {
match *r.borrow_mut() {
Some(ref mut state) => {
let flow_trace = json::encode(&flow::base(&*state.flow_root)).unwrap();
let data = box ScopeData::new(name.clone(), flow_trace);
... | new | identifier_name |
layout_debug.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/. */
//! Supports writing a trace file created during each layout scope
//! that can be viewed by an external tool to m... | }
/// A layout debugging scope. The entire state of the flow tree
/// will be output at the beginning and end of this scope.
impl Scope {
pub fn new(name: String) -> Scope {
STATE_KEY.with(|ref r| {
match *r.borrow_mut() {
Some(ref mut state) => {
let flow_tr... | scope_stack: Vec<Box<ScopeData>>, | random_line_split |
helpers.rs | use crate::pp::Printer;
use std::borrow::Cow;
impl Printer {
pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) {
self.word(w);
self.space();
}
pub fn popen(&mut self) {
self.word("(");
}
pub fn pclose(&mut self) { | self.word(")");
}
pub fn hardbreak_if_not_bol(&mut self) {
if!self.is_beginning_of_line() {
self.hardbreak()
}
}
pub fn space_if_not_bol(&mut self) {
if!self.is_beginning_of_line() {
self.space();
}
}
pub fn nbsp(&mut self) {
... | random_line_split | |
helpers.rs | use crate::pp::Printer;
use std::borrow::Cow;
impl Printer {
pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) {
self.word(w);
self.space();
}
pub fn popen(&mut self) {
self.word("(");
}
pub fn pclose(&mut self) {
self.word(")");
}
pub fn hard... |
}
pub fn space_if_not_bol(&mut self) {
if!self.is_beginning_of_line() {
self.space();
}
}
pub fn nbsp(&mut self) {
self.word(" ")
}
pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S) {
self.word(w);
self.nbsp()
}
}
| {
self.hardbreak()
} | conditional_block |
helpers.rs | use crate::pp::Printer;
use std::borrow::Cow;
impl Printer {
pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) |
pub fn popen(&mut self) {
self.word("(");
}
pub fn pclose(&mut self) {
self.word(")");
}
pub fn hardbreak_if_not_bol(&mut self) {
if!self.is_beginning_of_line() {
self.hardbreak()
}
}
pub fn space_if_not_bol(&mut self) {
if!self.is_beg... | {
self.word(w);
self.space();
} | identifier_body |
helpers.rs | use crate::pp::Printer;
use std::borrow::Cow;
impl Printer {
pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) {
self.word(w);
self.space();
}
pub fn popen(&mut self) {
self.word("(");
}
pub fn pclose(&mut self) {
self.word(")");
}
pub fn | (&mut self) {
if!self.is_beginning_of_line() {
self.hardbreak()
}
}
pub fn space_if_not_bol(&mut self) {
if!self.is_beginning_of_line() {
self.space();
}
}
pub fn nbsp(&mut self) {
self.word(" ")
}
pub fn word_nbsp<S: Into<Cow<'s... | hardbreak_if_not_bol | identifier_name |
lib.rs | #![recursion_limit = "128"]
#[macro_use]
extern crate log;
#[macro_use]
extern crate quick_error;
mod bearer_token_client;
mod blob_sas_builder;
pub mod client;
mod client_endpoint;
mod connection_string;
mod connection_string_builder;
mod container_sas_builder;
mod hyper_client_endpoint;
mod into_azure_path;
pub mod ... | (headers: &HeaderMap) -> Result<CopyId, AzureError> {
let copy_id = headers
.get_as_str(COPY_ID)
.ok_or_else(|| AzureError::HeaderNotFound(COPY_ID.to_owned()))?;
Ok(uuid::Uuid::parse_str(copy_id)?)
}
| copy_id_from_headers | identifier_name |
lib.rs | #![recursion_limit = "128"]
#[macro_use]
extern crate log;
#[macro_use]
extern crate quick_error;
mod bearer_token_client;
mod blob_sas_builder;
pub mod client;
mod client_endpoint;
mod connection_string;
mod connection_string_builder;
mod container_sas_builder;
mod hyper_client_endpoint;
mod into_azure_path;
pub mod ... | Ok(uuid::Uuid::parse_str(copy_id)?)
} | let copy_id = headers
.get_as_str(COPY_ID)
.ok_or_else(|| AzureError::HeaderNotFound(COPY_ID.to_owned()))?; | random_line_split |
lib.rs | // DO NOT EDIT!
// This file was generated automatically from'src/mako/api/lib.rs.mako'
// DO NOT EDIT!
//! This documentation was generated from *logging* crate version *0.1.8+20150326*, where *20150326* is the exact revision of the *logging:v1beta3* schema built by the [mako](http://www.makotemplates.org/) code gene... | //! # Structure of this Library
//!
//! The API is structured into the following primary items:
//!
//! * **[Hub](struct.Logging.html)**
//! * a central object to maintain state and allow accessing all *Activities*
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
//! allow acce... | //!
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html).
//! | random_line_split |
functions.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Lightweight utilities. To optimize compile time, do not put complex
//! functions or functions depending on other crates here.
use cpyth... | Ok(PyNone)
} | py.allow_threads(|| {
std::thread::sleep(duration);
});
} | random_line_split |
functions.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Lightweight utilities. To optimize compile time, do not put complex
//! functions or functions depending on other crates here.
use cpyth... | (py: Python, seconds: f64, gil: bool) -> PyResult<PyNone> {
let duration = std::time::Duration::from_micros((seconds * 1e6) as u64);
if gil {
std::thread::sleep(duration);
} else {
py.allow_threads(|| {
std::thread::sleep(duration);
});
}
Ok(PyNone)
}
| sleep | identifier_name |
functions.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Lightweight utilities. To optimize compile time, do not put complex
//! functions or functions depending on other crates here.
use cpyth... | {
let duration = std::time::Duration::from_micros((seconds * 1e6) as u64);
if gil {
std::thread::sleep(duration);
} else {
py.allow_threads(|| {
std::thread::sleep(duration);
});
}
Ok(PyNone)
} | identifier_body | |
functions.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Lightweight utilities. To optimize compile time, do not put complex
//! functions or functions depending on other crates here.
use cpyth... |
Ok(PyNone)
}
| {
py.allow_threads(|| {
std::thread::sleep(duration);
});
} | conditional_block |
threads.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Modules/syscalls/threads.rs
//! Thread management calls
use kernel::prelude::*;
use ObjectHandle;
use Error;
use values;
use SyscallArg;
use kernel::memory::freeze::FreezeMut;
//use kernel::threads::get_process_local;
/// Current process type (provides an ... | (&self, flags: u32, obj: &mut ::kernel::threads::SleepObject) -> u32 {
let mut ret = 0;
// Wait for child process to terminate
if flags & values::EV_PROCESS_TERMINATED!= 0 {
self.0.bind_wait_terminate(obj);
ret += 1;
}
ret
}
fn clear_wait(&self, flags: u32, obj: &mut ::kernel::threads::SleepO... | bind_wait | identifier_name |
threads.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Modules/syscalls/threads.rs
//! Thread management calls
use kernel::prelude::*;
use ObjectHandle;
use Error;
use values;
use SyscallArg;
use kernel::memory::freeze::FreezeMut;
//use kernel::threads::get_process_local;
/// Current process type (provides an ... | // Wait for child process to terminate
if flags & values::EV_PROCESS_TERMINATED!= 0 {
self.0.bind_wait_terminate(obj);
ret += 1;
}
ret
}
fn clear_wait(&self, flags: u32, obj: &mut ::kernel::threads::SleepObject) -> u32 {
let mut ret = 0;
// Wait for child process to terminate
if flags &... | random_line_split | |
threads.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Modules/syscalls/threads.rs
//! Thread management calls
use kernel::prelude::*;
use ObjectHandle;
use Error;
use values;
use SyscallArg;
use kernel::memory::freeze::FreezeMut;
//use kernel::threads::get_process_local;
/// Current process type (provides an ... | }
else {
waiter.wait();
}
}
Ok( events.iter_mut().fold(0, |total,ev| total + ::objects::clear_wait(ev.object, ev.flags, &mut waiter).unwrap()) )
}
| {
let mut waiter = ::kernel::threads::SleepObject::new("wait");
let mut num_bound = 0;
for ev in events.iter() {
num_bound += try!(::objects::wait_on_object(ev.object, ev.flags, &mut waiter));
}
if num_bound == 0 && wake_time_mono == !0 {
// Attempting to sleep on no events with an infinite timeout! Would sle... | identifier_body |
threads.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Modules/syscalls/threads.rs
//! Thread management calls
use kernel::prelude::*;
use ObjectHandle;
use Error;
use values;
use SyscallArg;
use kernel::memory::freeze::FreezeMut;
//use kernel::threads::get_process_local;
/// Current process type (provides an ... |
ret
}
}
::objects::new_object( Process(process) )
}
// ret: number of events triggered
#[inline(never)]
pub fn wait(events: &mut [values::WaitItem], wake_time_mono: u64) -> Result<u32,Error>
{
let mut waiter = ::kernel::threads::SleepObject::new("wait");
let mut num_bound = 0;
for ev in events.iter() {
n... | {
if self.0.clear_wait_terminate(obj) {
ret |= values::EV_PROCESS_TERMINATED;
}
} | conditional_block |
pointing.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("Pointing", inherited=True, gecko_... |
#[cfg(feature = "gecko")]
fn parse_image(context: &ParserContext, input: &mut Parser) -> Result<computed_value::Image, ()> {
Ok(computed_value::Image {
url: try!(SpecifiedUrl::parse(context, input)),
hotspot: match input.try(|input| input.expect_number()) {
Ok(nu... | Cursor::from_css_keyword(&ident).map(computed_value::Keyword::SpecifiedCursor)
}
}
} | random_line_split |
pointing.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("Pointing", inherited=True, gecko_... |
/// cursor: [<url> [<number> <number>]?]# [auto | default |...]
#[cfg(feature = "gecko")]
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
let mut images = vec![];
loop {
match input.try(|input| parse_image(context, input)) {
... | {
computed_value::Keyword::parse(context, input)
} | identifier_body |
pointing.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("Pointing", inherited=True, gecko_... | <W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
for url in &self.images {
try!(url.to_css(dest));
try!(dest.write_str(", "));
}
self.keyword.to_css(dest)
}
}
}
#[cfg(not(feature = "gecko"))... | to_css | identifier_name |
alias.rs | use crate::{
analysis::{namespaces, rust_type::rust_type},
codegen::general,
config::gobjects::GObject,
env::Env,
file_saver,
library::*,
traits::*,
};
use std::{
io::{prelude::*, Result},
path::Path,
};
pub fn | (env: &Env, root_path: &Path, mod_rs: &mut Vec<String>) {
let configs: Vec<&GObject> = env
.config
.objects
.values()
.filter(|c| {
c.status.need_generate() && c.type_id.map_or(false, |tid| tid.ns_id == namespaces::MAIN)
})
.collect();
let mut has_any = fal... | generate | identifier_name |
alias.rs | use crate::{
analysis::{namespaces, rust_type::rust_type},
codegen::general,
config::gobjects::GObject,
env::Env,
file_saver,
library::*,
traits::*,
};
use std::{
io::{prelude::*, Result},
path::Path,
};
pub fn generate(env: &Env, root_path: &Path, mod_rs: &mut Vec<String>) {
le... | {
let typ = rust_type(env, alias.typ).into_string();
writeln!(w, "pub type {} = {};", alias.name, typ)?;
Ok(())
} | identifier_body | |
alias.rs | use crate::{
analysis::{namespaces, rust_type::rust_type},
codegen::general,
config::gobjects::GObject,
env::Env,
file_saver,
library::*,
traits::*,
};
use std::{
io::{prelude::*, Result},
path::Path,
};
pub fn generate(env: &Env, root_path: &Path, mod_rs: &mut Vec<String>) {
le... | }
Ok(())
});
}
fn generate_alias(env: &Env, w: &mut dyn Write, alias: &Alias, _: &GObject) -> Result<()> {
let typ = rust_type(env, alias.typ).into_string();
writeln!(w, "pub type {} = {};", alias.name, typ)?;
Ok(())
} | mod_rs.push(format!("pub use self::alias::{};", alias.name));
generate_alias(env, w, alias, config)?;
} | random_line_split |
alias.rs | use crate::{
analysis::{namespaces, rust_type::rust_type},
codegen::general,
config::gobjects::GObject,
env::Env,
file_saver,
library::*,
traits::*,
};
use std::{
io::{prelude::*, Result},
path::Path,
};
pub fn generate(env: &Env, root_path: &Path, mod_rs: &mut Vec<String>) {
le... |
let path = root_path.join("alias.rs");
file_saver::save_to_file(path, env.config.make_backup, |w| {
general::start_comments(w, &env.config)?;
writeln!(w)?;
writeln!(w, "#[allow(unused_imports)]")?;
writeln!(w, "use auto::*;")?;
writeln!(w)?;
mod_rs.push("\nmod ... | {
return;
} | conditional_block |
whoami.rs | #![crate_id(name="whoami", version="1.0.0", author="KokaKiwi")]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced wi... | (args: Vec<String>) {
let program = args.get(0).as_slice();
let opts = [
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),
];
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => m,
... | uumain | identifier_name |
whoami.rs | #![crate_id(name="whoami", version="1.0.0", author="KokaKiwi")]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced wi... |
exec();
}
pub fn exec() {
unsafe {
let username = getusername();
println!("{:s}", username);
}
}
| {
println!("whoami 1.0.0");
return;
} | conditional_block |
whoami.rs | #![crate_id(name="whoami", version="1.0.0", author="KokaKiwi")]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced wi... |
pub fn uumain(args: Vec<String>) {
let program = args.get(0).as_slice();
let opts = [
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),
];
let matches = match getopts::getopts(args.tail(), opts) {
... | { uumain(os::args()); } | identifier_body |
whoami.rs | #![crate_id(name="whoami", version="1.0.0", author="KokaKiwi")]
/*
* This file is part of the uutils coreutils package.
* | *
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: whoami (GNU coreutils) 8.21 */
#![allow(non_camel_case_types)]
#![feature(macro_rules)]
extern crate getopts;
extern crate libc;
use std::io::print;
use std::os... | * (c) Jordi Boggiano <j.boggiano@seld.be> | random_line_split |
mod.rs | mod control_handle;
mod control_base;
mod window;
mod button;
mod check_box;
mod radio_button;
mod text_input;
mod label;
mod image_frame;
#[cfg(feature = "textbox")]
mod text_box;
#[cfg(feature = "rich-textbox")]
mod rich_text_box;
#[cfg(feature = "rich-textbox")]
mod rich_label;
#[cfg(feature = "status-bar")]
mod... | pub use handle_from_control::*; | random_line_split | |
kernel_log.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/gui/kernel_log.rs
/// Kernel log output (and debug terminal)
//
// Manages a set of windows giving a view into the kernel
// - Kernel log (current) : Contains the most recent kernel log messages
// - Logo
// - TODO: Kernel log (history) : A searchable/fi... | () -> KernelLog
{
// TODO: Register to somehow be informed when dimensions change
// - Is this particular call bad for bypassing the GUI? Or is this acceptable
let max_dims = match ::kernel::metadevs::video::get_display_for_pos( Pos::new(0,0) )
{
Some(display) => display.dims(),
None => {
log_warnin... | new | identifier_name |
kernel_log.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/gui/kernel_log.rs
/// Kernel log output (and debug terminal)
//
// Manages a set of windows giving a view into the kernel
// - Kernel log (current) : Contains the most recent kernel log messages
// - Logo
// - TODO: Kernel log (history) : A searchable/fi... |
}
impl LogWriter
{
pub fn new() -> LogWriter
{
let mut log = S_KERNEL_LOG.lock();
log.scroll_up();
LogWriter {
pos: CharPos(log.cur_line-1,0),
colour: Colour::def_white(),
log: log,
}
}
pub fn set_colour(&mut self, colour: Colour)
{
self.colour = colour;
}
}
impl fmt::Write for LogWriter
{
... | {
Pos::new( (self.1 * C_CELL_DIMS.w) as u32, (self.0 * C_CELL_DIMS.h) as u32 )
} | identifier_body |
kernel_log.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/gui/kernel_log.rs
/// Kernel log output (and debug terminal)
//
// Manages a set of windows giving a view into the kernel
// - Kernel log (current) : Contains the most recent kernel log messages
// - Logo
// - TODO: Kernel log (history) : A searchable/fi... | {
// Poke the WM and tell it to reblit us
self.wh.redraw();
}
/// Writes a single codepoint to the display
///
/// Returns true if the character caused a cell change (i.e. it wasn't a combining character)
fn putc(&mut self, pos: CharPos, colour: Colour, c: char) -> bool
{
// If the character was a combin... | fn flush(&mut self) | random_line_split |
closable_tcp_stream.rs | // Copyright 2015 The tiny-http Contributors
//
// 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... |
}
}
impl Read for ClosableTcpStream {
fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
self.stream.read(buf)
}
}
impl Write for ClosableTcpStream {
fn write(&mut self, buf: &[u8]) -> IoResult<usize> {
self.stream.write(buf)
}
fn flush(&mut self) -> IoResult<()> {
... | {
self.stream.shutdown(Shutdown::Write).ok(); // ignoring outcome
} | conditional_block |
closable_tcp_stream.rs | // Copyright 2015 The tiny-http Contributors
//
// 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... | impl Drop for ClosableTcpStream {
fn drop(&mut self) {
if self.close_read {
self.stream.shutdown(Shutdown::Read).ok(); // ignoring outcome
}
if self.close_write {
self.stream.shutdown(Shutdown::Write).ok(); // ignoring outcome
}
}
}
impl Read for... | random_line_split | |
closable_tcp_stream.rs | // Copyright 2015 The tiny-http Contributors
//
// 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... |
}
impl Write for ClosableTcpStream {
fn write(&mut self, buf: &[u8]) -> IoResult<usize> {
self.stream.write(buf)
}
fn flush(&mut self) -> IoResult<()> {
self.stream.flush()
}
}
| {
self.stream.read(buf)
} | identifier_body |
closable_tcp_stream.rs | // Copyright 2015 The tiny-http Contributors
//
// 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... | {
stream: TcpStream,
close_read: bool,
close_write: bool,
}
impl ClosableTcpStream {
pub fn new(stream: TcpStream, close_read: bool, close_write: bool) -> ClosableTcpStream {
ClosableTcpStream {
stream: stream,
close_read: close_read,
close_write: close_writ... | ClosableTcpStream | identifier_name |
mod.rs | use alloc::boxed::Box;
use alloc::{BTreeMap, Vec};
use core::{cmp, str};
use core::sync::atomic::{AtomicUsize, Ordering};
use spin::RwLock;
use syscall::data::Stat;
use syscall::error::{Error, EBADF, EINVAL, ENOENT, Result};
use syscall::flag::{MODE_DIR, MODE_FILE, SEEK_CUR, SEEK_END, SEEK_SET};
use syscall::scheme::S... | (&self, id: usize) -> Result<usize> {
self.handles.write().remove(&id).ok_or(Error::new(EBADF)).and(Ok(0))
}
}
| close | identifier_name |
mod.rs | use alloc::boxed::Box;
use alloc::{BTreeMap, Vec};
use core::{cmp, str};
use core::sync::atomic::{AtomicUsize, Ordering};
use spin::RwLock;
use syscall::data::Stat;
use syscall::error::{Error, EBADF, EINVAL, ENOENT, Result};
use syscall::flag::{MODE_DIR, MODE_FILE, SEEK_CUR, SEEK_END, SEEK_SET};
use syscall::scheme::S... | }
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
let handles = self.handles.read();
let handle = handles.get(&id).ok_or(Error::new(EBADF))?;
let mut i = 0;
let scheme_path = b"sys:";
while i < buf.len() && i < scheme_path.len() {
buf[i] = sche... | random_line_split | |
mod.rs | use alloc::boxed::Box;
use alloc::{BTreeMap, Vec};
use core::{cmp, str};
use core::sync::atomic::{AtomicUsize, Ordering};
use spin::RwLock;
use syscall::data::Stat;
use syscall::error::{Error, EBADF, EINVAL, ENOENT, Result};
use syscall::flag::{MODE_DIR, MODE_FILE, SEEK_CUR, SEEK_END, SEEK_SET};
use syscall::scheme::S... |
fn seek(&self, id: usize, pos: usize, whence: usize) -> Result<usize> {
let mut handles = self.handles.write();
let handle = handles.get_mut(&id).ok_or(Error::new(EBADF))?;
handle.seek = match whence {
SEEK_SET => cmp::min(handle.data.len(), pos),
SEEK_CUR => cmp::... | {
let mut handles = self.handles.write();
let handle = handles.get_mut(&id).ok_or(Error::new(EBADF))?;
let mut i = 0;
while i < buffer.len() && handle.seek < handle.data.len() {
buffer[i] = handle.data[handle.seek];
i += 1;
handle.seek += 1;
}... | identifier_body |
traversal.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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | // flow construction:
// (1) They child doesn't yet have layout data (preorder traversal initializes it).
// (2) The parent element has restyle damage (so the text flow also needs fixup).
None => child.get_raw_data().is_none() ||
parent.as_node().to_th... | random_line_split | |
traversal.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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | let parent = node.parent_node().unwrap().as_element();
let bf = take_thread_local_bloom_filter(parent, self.root, self.context.shared_context());
put_thread_local_bloom_filter(bf, &node.to_unsafe(), self.context.shared_context());
}
else {
let el = node.as_elemen... | {
// FIXME(bholley): Stop doing this silly work to maintain broken bloom filter
// invariants.
//
// Longer version: The bloom filter is entirely busted for parallel traversal. Because
// parallel traversal is breadth-first, each sibling rejects the bloom filt... | conditional_block |
traversal.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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | <'a> {
pub layout_context: &'a SharedLayoutContext,
}
impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> {
#[inline]
fn process(&self, flow: &mut Flow) {
flow.compute_absolute_position(self.layout_context);
}
}
pub struct BuildDisplayList<'a> {
pub state: DisplayListBuildState... | ComputeAbsolutePositions | identifier_name |
traversal.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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... |
}
/// A bottom-up, parallelizable traversal.
pub trait PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> {
/// The operation to perform. Return true to continue or false to stop.
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode);
}
/// The flow construction traversal, whi... | {
self.context.local_context()
} | identifier_body |
rtdeps.rs | // Copyright 2013-2015 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... | #[cfg(all(target_os = "linux", not(target_env = "musl")))]
#[link(name = "dl")]
#[link(name = "pthread")]
extern {}
#[cfg(target_os = "android")]
#[link(name = "dl")]
#[link(name = "log")]
extern {}
#[cfg(target_os = "freebsd")]
#[link(name = "execinfo")]
#[link(name = "pthread")]
extern {}
#[cfg(any(target_os = "dr... | // libm. Hence, we must explicitly link to it.
//
// On Linux, librt and libdl are indirect dependencies via std,
// and binutils 2.22+ won't add them automatically | random_line_split |
applicable_declarations.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/. */
//! Applicable declarations management.
use properties::PropertyDeclarationBlock;
use rule_tree::{CascadeLevel, S... | (
declarations: Arc<Locked<PropertyDeclarationBlock>>,
level: CascadeLevel,
) -> Self {
ApplicableDeclarationBlock {
source: StyleSource::Declarations(declarations),
order_and_level: SourceOrderAndCascadeLevel::new(0, level),
specificity: 0,
}
... | from_declarations | identifier_name |
applicable_declarations.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/. */
//! Applicable declarations management.
use properties::PropertyDeclarationBlock;
use rule_tree::{CascadeLevel, S... |
}
/// A property declaration together with its precedence among rules of equal
/// specificity so that we can sort them.
///
/// This represents the declarations in a given declaration block for a given
/// importance.
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
pub struct ApplicableDeclarationBlock {
/// Th... | {
f.debug_struct("SourceOrderAndCascadeLevel")
.field("order", &self.order())
.field("level", &self.level())
.finish()
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.