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 |
|---|---|---|---|---|
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
static TYPES: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
TYPES.iter().any(|&type_| uri.starts_with(type_))
} | identifier_body | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
#[ignore_heap_size_of = "TODO(#6910) Box value that should be counted but \
the type lives in layout"]
pub ptr: NonZero<*mut RefCell<PartialStyleAndLayoutData>>
}
#[allow(unsafe_code)]
unsafe impl Send for OpaqueStyleAndLayoutData {}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]... | OpaqueStyleAndLayoutData | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | use style::servo::PrivateStyleData;
pub struct PartialStyleAndLayoutData {
pub style_data: PrivateStyleData,
pub restyle_damage: RestyleDamage,
}
#[derive(Copy, Clone, HeapSizeOf)]
pub struct OpaqueStyleAndLayoutData {
#[ignore_heap_size_of = "TODO(#6910) Box value that should be counted but \
... | use ipc_channel::ipc::IpcSender;
use libc::c_void;
use restyle_damage::RestyleDamage;
use style::refcell::RefCell; | random_line_split |
borrowck-pat-enum.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 ... | (_i: int) {
}
fn match_const_reg_unused(v: &const Option<int>) {
match *v {
Some(_) => {impure(0)} // OK because nothing is captured
None => {}
}
}
fn match_const_reg_impure(v: &const Option<int>) {
match *v {
Some(ref i) => {impure(*i)} //~ ERROR cannot borrow
//~^ ERROR unsafe ... | impure | identifier_name |
borrowck-pat-enum.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 ... | {
} | identifier_body | |
borrowck-pat-enum.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
}
fn match_const_reg(v: &const Option<int>) -> int {
match *v {
Some(ref i) => {*i} //~ ERROR cannot borrow
//~^ ERROR unsafe borrow
None => {0}
}
}
fn impure(_i: int) {
}
fn match_const_reg_unused(v: &const Option<int>) {
match *v {
Some(_) => {impure(0)} // OK because n... | {} | conditional_block |
borrowck-pat-enum.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn match_ref(v: ... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | random_line_split |
simple.rs | extern crate klee;
#[test]
fn basic_test() {
let mut a : i32 = 0;
klee::symbol(&mut a, "a");
assert_eq!(a, 56);
}
#[test]
fn other_test() {
let mut a : i32 = 0;
let mut b : i32 = 0;
klee::symbol(&mut a, "a");
klee::symbol(&mut b, "b");
if a == 50 && b == 50 {
panic!("I should happen!");
}
... | }
} | assert_eq!(b, 150000); | random_line_split |
simple.rs | extern crate klee;
#[test]
fn | () {
let mut a : i32 = 0;
klee::symbol(&mut a, "a");
assert_eq!(a, 56);
}
#[test]
fn other_test() {
let mut a : i32 = 0;
let mut b : i32 = 0;
klee::symbol(&mut a, "a");
klee::symbol(&mut b, "b");
if a == 50 && b == 50 {
panic!("I should happen!");
}
}
#[test]
fn yant() {
let a = klee::so... | basic_test | identifier_name |
simple.rs | extern crate klee;
#[test]
fn basic_test() |
#[test]
fn other_test() {
let mut a : i32 = 0;
let mut b : i32 = 0;
klee::symbol(&mut a, "a");
klee::symbol(&mut b, "b");
if a == 50 && b == 50 {
panic!("I should happen!");
}
}
#[test]
fn yant() {
let a = klee::some::<bool>("a");
let b = klee::some::<i32>("b");
let c = if a {
if b... | {
let mut a : i32 = 0;
klee::symbol(&mut a, "a");
assert_eq!(a, 56);
} | identifier_body |
simple.rs | extern crate klee;
#[test]
fn basic_test() {
let mut a : i32 = 0;
klee::symbol(&mut a, "a");
assert_eq!(a, 56);
}
#[test]
fn other_test() {
let mut a : i32 = 0;
let mut b : i32 = 0;
klee::symbol(&mut a, "a");
klee::symbol(&mut b, "b");
if a == 50 && b == 50 |
}
#[test]
fn yant() {
let a = klee::some::<bool>("a");
let b = klee::some::<i32>("b");
let c = if a {
if b > 50 && b < 100 {
true
} else {
false
}
} else {
true
};
assert_eq!(c, false);
}
#[test]
fn another_test() {
let a = klee::some::<i32>("a");
if a > 60 && a < 9... | {
panic!("I should happen!");
} | conditional_block |
mod.rs | use std::ops::BitXor;
use error::{LengthError, LengthResult, LengthErrorKind};
mod builder;
pub use sha::builder::ShaHashBuilder;
/// Length of a SHA-1 hash.
pub const SHA_HASH_LEN: usize = 20;
/// SHA-1 hash wrapper type for performing operations on the hash.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Part... | () {
let first_one_bits = ShaHash::from([255u8; super::SHA_HASH_LEN]);
let second_one_bits = ShaHash::from([255u8; super::SHA_HASH_LEN]);
let xor_hash = first_one_bits ^ second_one_bits;
let leading_zeroes = xor_hash.bits().take_while(|&n| n == XorRep::Same).count();
assert!(le... | positive_all_leading_zeroes | identifier_name |
mod.rs | use std::ops::BitXor;
use error::{LengthError, LengthResult, LengthErrorKind};
mod builder;
pub use sha::builder::ShaHashBuilder;
/// Length of a SHA-1 hash.
pub const SHA_HASH_LEN: usize = 20;
/// SHA-1 hash wrapper type for performing operations on the hash.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Part... |
}
// ----------------------------------------------------------------------------//
/// Representation of a bit after a xor operation.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum XorRep {
/// Bits were equal (1).
Diff,
/// Bits were not equal (0).
Same,
}
/// Iterator over the bits o... | {
for (src, dst) in rhs.hash.iter().zip(self.hash.iter_mut()) {
*dst = *src ^ *dst;
}
self
} | identifier_body |
mod.rs | use std::ops::BitXor;
use error::{LengthError, LengthResult, LengthErrorKind};
mod builder;
pub use sha::builder::ShaHashBuilder;
/// Length of a SHA-1 hash.
pub const SHA_HASH_LEN: usize = 20;
/// SHA-1 hash wrapper type for performing operations on the hash.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Part... | })
}
}
// ----------------------------------------------------------------------------//
/// Representation of a bit.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum BitRep {
/// Bit is set (1).
Set,
/// Bit is not set (0).
Unset,
}
impl PartialEq<XorRep> for BitRep {
fn e... | self.bits.next().map(|n| {
match n {
BitRep::Set => XorRep::Diff,
BitRep::Unset => XorRep::Same,
} | random_line_split |
mod.rs | use std::ops::BitXor;
use error::{LengthError, LengthResult, LengthErrorKind};
mod builder;
pub use sha::builder::ShaHashBuilder;
/// Length of a SHA-1 hash.
pub const SHA_HASH_LEN: usize = 20;
/// SHA-1 hash wrapper type for performing operations on the hash.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Part... |
}
}
// ----------------------------------------------------------------------------//
#[cfg(test)]
mod tests {
use super::{ShaHash, XorRep};
#[test]
fn positive_no_leading_zeroes() {
let zero_bits = ShaHash::from([0u8; super::SHA_HASH_LEN]);
let one_bits = ShaHash::from([255u8; super... | {
None
} | conditional_block |
post_drop_elaboration.rs | use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{self, BasicBlock, Location};
use rustc_middle::ty::TyCtxt;
use rustc_span::{symbol::sym, Span};
use super::check::Qualifs;
use super::ops::{self, NonConstOp};
use super::qualifs::{NeedsNonConstDrop, Qualif};
use super::ConstCx;
/// Returns `true` if we sh... | (tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
let def_id = body.source.def_id().expect_local();
let const_kind = tcx.hir().body_const_context(def_id);
if const_kind.is_none() {
return;
}
if tcx.has_attr(def_id.to_def_id(), sym::rustc_do_not_const_check) {
return;
}
let ccx ... | check_live_drops | identifier_name |
post_drop_elaboration.rs | use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{self, BasicBlock, Location};
use rustc_middle::ty::TyCtxt;
use rustc_span::{symbol::sym, Span};
use super::check::Qualifs;
use super::ops::{self, NonConstOp};
use super::qualifs::{NeedsNonConstDrop, Qualif};
use super::ConstCx;
/// Returns `true` if we sh... |
struct CheckLiveDrops<'mir, 'tcx> {
ccx: &'mir ConstCx<'mir, 'tcx>,
qualifs: Qualifs<'mir, 'tcx>,
}
// So we can access `body` and `tcx`.
impl std::ops::Deref for CheckLiveDrops<'mir, 'tcx> {
type Target = ConstCx<'mir, 'tcx>;
fn deref(&self) -> &Self::Target {
&self.ccx
}
}
impl CheckL... | {
let def_id = body.source.def_id().expect_local();
let const_kind = tcx.hir().body_const_context(def_id);
if const_kind.is_none() {
return;
}
if tcx.has_attr(def_id.to_def_id(), sym::rustc_do_not_const_check) {
return;
}
let ccx = ConstCx { body, tcx, const_kind, param_env... | identifier_body |
post_drop_elaboration.rs | use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{self, BasicBlock, Location};
use rustc_middle::ty::TyCtxt;
use rustc_span::{symbol::sym, Span};
use super::check::Qualifs;
use super::ops::{self, NonConstOp};
use super::qualifs::{NeedsNonConstDrop, Qualif};
use super::ConstCx;
/// Returns `true` if we sh... | ///
/// This is separate from the rest of the const checking logic because it must run after drop
/// elaboration.
pub fn check_live_drops(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
let def_id = body.source.def_id().expect_local();
let const_kind = tcx.hir().body_const_context(def_id);
if const_kind.is_no... | /// Look for live drops in a const context. | random_line_split |
post_drop_elaboration.rs | use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{self, BasicBlock, Location};
use rustc_middle::ty::TyCtxt;
use rustc_span::{symbol::sym, Span};
use super::check::Qualifs;
use super::ops::{self, NonConstOp};
use super::qualifs::{NeedsNonConstDrop, Qualif};
use super::ConstCx;
/// Returns `true` if we sh... |
ccx.tcx.features().const_precise_live_drops
}
/// Look for live drops in a const context.
///
/// This is separate from the rest of the const checking logic because it must run after drop
/// elaboration.
pub fn check_live_drops(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
let def_id = body.source.def_id().e... | {
return false;
} | conditional_block |
gp.rs | //! Gaussian Processes
//!
//! Provides implementation of gaussian process regression.
//!
//! # Usage
//!
//! ```
//! use rusty_machine::learning::gp;
//! use rusty_machine::learning::SupModel;
//! use rusty_machine::linalg::Matrix;
//! use rusty_machine::linalg::Vector;
//!
//! let mut gaussp = gp::GaussianProcess::d... | /// let mean = gp::ConstMean::default();
/// let gaussp = gp::GaussianProcess::new(ker, mean, 1e-3f64);
/// ```
pub fn new(ker: T, mean: U, noise: f64) -> GaussianProcess<T, U> {
GaussianProcess {
ker: ker,
mean: mean,
noise: noise,
train_mat: None... | /// ```
/// use rusty_machine::learning::gp;
/// use rusty_machine::learning::toolkit::kernel;
///
/// let ker = kernel::SquaredExp::default(); | random_line_split |
gp.rs | //! Gaussian Processes
//!
//! Provides implementation of gaussian process regression.
//!
//! # Usage
//!
//! ```
//! use rusty_machine::learning::gp;
//! use rusty_machine::learning::SupModel;
//! use rusty_machine::linalg::Matrix;
//! use rusty_machine::linalg::Vector;
//!
//! let mut gaussp = gp::GaussianProcess::d... |
}
/// Gaussian Process struct
///
/// Gaussian process with generic kernel and deterministic mean function.
/// Can be used for gaussian process regression with noise.
/// Currently does not support classification.
#[derive(Debug)]
pub struct GaussianProcess<T: Kernel, U: MeanFunc> {
ker: T,
mean: U,
/// ... | {
Vector::zeros(x.rows()) + self.a
} | identifier_body |
gp.rs | //! Gaussian Processes
//!
//! Provides implementation of gaussian process regression.
//!
//! # Usage
//!
//! ```
//! use rusty_machine::learning::gp;
//! use rusty_machine::learning::SupModel;
//! use rusty_machine::linalg::Matrix;
//! use rusty_machine::linalg::Vector;
//!
//! let mut gaussp = gp::GaussianProcess::d... |
panic!("The model has not been trained.");
}
/// Train the model using data and outputs.
fn train(&mut self, inputs: &Matrix<f64>, targets: &Vector<f64>) {
let noise_mat = Matrix::identity(inputs.rows()) * self.noise;
let ker_mat = self.ker_mat(inputs, inputs);
let train... | {
let mean = self.mean.func(inputs.clone());
let post_mean = self.ker_mat(inputs, t_data) * alpha;
return mean + post_mean;
} | conditional_block |
gp.rs | //! Gaussian Processes
//!
//! Provides implementation of gaussian process regression.
//!
//! # Usage
//!
//! ```
//! use rusty_machine::learning::gp;
//! use rusty_machine::learning::SupModel;
//! use rusty_machine::linalg::Matrix;
//! use rusty_machine::linalg::Vector;
//!
//! let mut gaussp = gp::GaussianProcess::d... | (&self, x: Matrix<f64>) -> Vector<f64> {
Vector::zeros(x.rows()) + self.a
}
}
/// Gaussian Process struct
///
/// Gaussian process with generic kernel and deterministic mean function.
/// Can be used for gaussian process regression with noise.
/// Currently does not support classification.
#[derive(Debug)]... | func | identifier_name |
cargo_output_metadata.rs | use std::path::Path;
use rustc_serialize::{Encodable, Encoder};
use core::resolver::Resolve;
use core::{Package, PackageId, PackageSet};
use ops;
use util::config::Config;
use util::CargoResult;
const VERSION: u32 = 1;
pub struct OutputMetadataOptions<'a> {
pub features: Vec<String>,
pub manifest_path: &'a ... | (Resolve);
impl Encodable for MetadataResolve {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
#[derive(RustcEncodable)]
struct EncodableResolve<'a> {
root: &'a PackageId,
nodes: Vec<Node<'a>>,
}
#[derive(RustcEncodable)]
struct No... | MetadataResolve | identifier_name |
cargo_output_metadata.rs | use std::path::Path;
use rustc_serialize::{Encodable, Encoder};
use core::resolver::Resolve;
use core::{Package, PackageId, PackageSet};
use ops;
use util::config::Config;
use util::CargoResult;
const VERSION: u32 = 1;
pub struct OutputMetadataOptions<'a> {
pub features: Vec<String>,
pub manifest_path: &'a ... |
if opt.no_deps {
metadata_no_deps(opt, config)
} else {
metadata_full(opt, config)
}
}
fn metadata_no_deps(opt: OutputMetadataOptions, config: &Config) -> CargoResult<ExportInfo> {
let root = try!(Package::for_path(opt.manifest_path, config));
Ok(ExportInfo {
packages: vec!... | {
bail!("metadata version {} not supported, only {} is currently supported",
opt.version, VERSION);
} | conditional_block |
cargo_output_metadata.rs | use std::path::Path;
use rustc_serialize::{Encodable, Encoder};
use core::resolver::Resolve;
use core::{Package, PackageId, PackageSet};
use ops;
use util::config::Config;
use util::CargoResult;
const VERSION: u32 = 1;
pub struct OutputMetadataOptions<'a> {
pub features: Vec<String>,
pub manifest_path: &'a ... | no_default_features)
} | let package = try!(Package::for_path(manifest, config));
ops::resolve_dependencies(&package,
config,
None,
features, | random_line_split |
cargo_output_metadata.rs | use std::path::Path;
use rustc_serialize::{Encodable, Encoder};
use core::resolver::Resolve;
use core::{Package, PackageId, PackageSet};
use ops;
use util::config::Config;
use util::CargoResult;
const VERSION: u32 = 1;
pub struct OutputMetadataOptions<'a> {
pub features: Vec<String>,
pub manifest_path: &'a ... |
#[derive(RustcEncodable)]
pub struct ExportInfo {
packages: Vec<Package>,
resolve: Option<MetadataResolve>,
version: u32,
}
/// Newtype wrapper to provide a custom `Encodable` implementation.
/// The one from lockfile does not fit because it uses a non-standard
/// format for `PackageId`s
struct Metadata... | {
let deps = try!(resolve_dependencies(opt.manifest_path,
config,
opt.features,
opt.no_default_features));
let (packages, resolve) = deps;
let packages = try!(packages.package_ids()
... | identifier_body |
output.rs | use raii::Raii;
use {ffi, Handle, Return};
use super::types::OdbcType;
/// Indicates that a type can be retrieved using `Cursor::get_data`
pub unsafe trait Output<'a>: Sized {
fn get_data(
stmt: &mut Raii<ffi::Stmt>,
col_or_param_num: u16,
buffer: &'a mut Vec<u8>,
) -> Return<Option<Sel... | else {
let slice = &buffer[..(start_pos + indicator as usize)];
// No truncation. Warning may be due to some other issue.
Return::SuccessWithInfo(Some(T::convert(slice)))
}
}
}
ffi::SQL_E... | {
buffer.resize(indicator as usize + T::null_bytes_count(), 0);
return self.get_partial_data(col_or_param_num, buffer, initial_len - null_offset);
} | conditional_block |
output.rs | use raii::Raii;
use {ffi, Handle, Return};
use super::types::OdbcType;
/// Indicates that a type can be retrieved using `Cursor::get_data`
pub unsafe trait Output<'a>: Sized {
fn get_data(
stmt: &mut Raii<ffi::Stmt>,
col_or_param_num: u16,
buffer: &'a mut Vec<u8>,
) -> Return<Option<Sel... |
}
impl<'p> Raii<'p, ffi::Stmt> {
fn get_data<'a, T>(
&mut self,
col_or_param_num: u16,
buffer: &'a mut Vec<u8>
) -> Return<Option<T>>
where
T: OdbcType<'a>,
{
self.get_partial_data(col_or_param_num, buffer, 0)
}
fn get_partial_data<'a, T>(
&mut ... | {
stmt.get_data(col_or_param_num, buffer)
} | identifier_body |
output.rs | use raii::Raii;
use {ffi, Handle, Return};
use super::types::OdbcType;
/// Indicates that a type can be retrieved using `Cursor::get_data`
pub unsafe trait Output<'a>: Sized {
fn get_data(
stmt: &mut Raii<ffi::Stmt>,
col_or_param_num: u16,
buffer: &'a mut Vec<u8>,
) -> Return<Option<Sel... | T: OdbcType<'a>,
{
if buffer.len() - start_pos == 0 {
panic!("buffer length may not be zero");
}
if buffer.len() - start_pos > ffi::SQLLEN::max_value() as usize {
panic!("buffer is larger than {} bytes", ffi::SQLLEN::max_value());
}
let mut ind... | ) -> Return<Option<T>>
where | random_line_split |
output.rs | use raii::Raii;
use {ffi, Handle, Return};
use super::types::OdbcType;
/// Indicates that a type can be retrieved using `Cursor::get_data`
pub unsafe trait Output<'a>: Sized {
fn get_data(
stmt: &mut Raii<ffi::Stmt>,
col_or_param_num: u16,
buffer: &'a mut Vec<u8>,
) -> Return<Option<Sel... | <'a, T>(
&mut self,
col_or_param_num: u16,
buffer: &'a mut Vec<u8>,
start_pos: usize
) -> Return<Option<T>>
where
T: OdbcType<'a>,
{
if buffer.len() - start_pos == 0 {
panic!("buffer length may not be zero");
}
if buffer.len() - sta... | get_partial_data | identifier_name |
text.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 https://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="text-decoration"
... | )
}
parse_component!(line, text_decoration_line);
% if engine == "gecko":
parse_component!(style, text_decoration_style);
parse_component!(color, text_decoration_color);
if text_decoration_thickness_enabled {
... | {
% if engine == "gecko":
let text_decoration_thickness_enabled =
PropertyId::Longhand(LonghandId::TextDecorationThickness).enabled_for_all_content();
let (mut line, mut style, mut color, mut thickness, mut any) = (None, None, None, None, false);
% else:
... | identifier_body |
text.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 https://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="text-decoration"
... |
Ok(expanded! {
text_decoration_line: unwrap_or_initial!(text_decoration_line, line),
% if engine == "gecko":
text_decoration_style: unwrap_or_initial!(text_decoration_style, style),
text_decoration_color: unwrap_or_initial!(text_decoration_color, color)... | {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
} | conditional_block |
text.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 https://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="text-decoration"
... | continue;
}
}
)
}
parse_component!(line, text_decoration_line);
% if engine == "gecko":
parse_component!(style, text_decoration_style);
parse_component!(color, te... | random_line_split | |
text.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 https://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="text-decoration"
... | <'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
% if engine == "gecko":
let text_decoration_thickness_enabled =
PropertyId::Longhand(LonghandId::TextDecorationThickness).enabled_for_all_content();
... | parse_value | identifier_name |
tests.rs | use crate::Server;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use futures::future;
use nails::execution::{child_channel, ChildInput, Command, ExitCode};
use nails::Config;
use task_executor::Executor;
use tokio::net::TcpStream;
use tokio::runtime::Handle;
use tokio::sync::Notify;
use tokio::... | () {
// A server that waits for a signal to complete a connection.
let connection_accepted = Arc::new(Notify::new());
let should_complete_connection = Arc::new(Notify::new());
let exit_code = ExitCode(42);
let server = Server::new(Executor::new(), 0, {
let connection_accepted = connection_accepted.clone()... | shutdown_awaits_ongoing | identifier_name |
tests.rs | use crate::Server;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use futures::future;
use nails::execution::{child_channel, ChildInput, Command, ExitCode};
use nails::Config;
use task_executor::Executor;
use tokio::net::TcpStream;
use tokio::runtime::Handle;
use tokio::sync::Notify;
use tokio::... |
#[tokio::test]
async fn accept() {
let exit_code = ExitCode(42);
let server = Server::new(Executor::new(), 0, move |_| exit_code)
.await
.unwrap();
// And connect with a client. This Nail will ignore the content of the command, so we're
// only validating the exit code.
let actual_exit_code = run_cli... | {
let server = Server::new(Executor::new(), 0, |_| ExitCode(0))
.await
.unwrap();
// Should have bound a random port.
assert!(0 != server.port());
server.shutdown().await.unwrap();
} | identifier_body |
tests.rs | use crate::Server;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use futures::future;
use nails::execution::{child_channel, ChildInput, Command, ExitCode};
use nails::Config;
use task_executor::Executor;
use tokio::net::TcpStream;
use tokio::runtime::Handle;
use tokio::sync::Notify;
use tokio::... | })
.await
.unwrap();
// Spawn a connection in the background, and once it has been established, kick off shutdown of
// the server.
let mut client_completed = tokio::spawn(run_client(server.port()));
connection_accepted.notified().await;
let mut server_shutdown = tokio::spawn(server.shutdown());
// Co... | exit_code
} | random_line_split |
vrdisplaycapabilities.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 dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding;
use dom::... |
// https://w3c.github.io/webvr/#dom-vrdisplaycapabilities-canpresent
fn CanPresent(&self) -> bool {
self.capabilities.borrow().can_present
}
// https://w3c.github.io/webvr/#dom-vrdisplaycapabilities-maxlayers
fn MaxLayers(&self) -> u32 {
if self.CanPresent() {
1
... | {
self.capabilities.borrow().has_external_display
} | identifier_body |
vrdisplaycapabilities.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 dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding;
use dom::... |
}
}
| {
0
} | conditional_block |
vrdisplaycapabilities.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 dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding;
use dom::... | (&self) -> bool {
self.capabilities.borrow().has_external_display
}
// https://w3c.github.io/webvr/#dom-vrdisplaycapabilities-canpresent
fn CanPresent(&self) -> bool {
self.capabilities.borrow().can_present
}
// https://w3c.github.io/webvr/#dom-vrdisplaycapabilities-maxlayers
f... | HasExternalDisplay | identifier_name |
vrdisplaycapabilities.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 dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding;
use dom::... | )
}
}
impl VRDisplayCapabilitiesMethods for VRDisplayCapabilities {
// https://w3c.github.io/webvr/#dom-vrdisplaycapabilities-hasposition
fn HasPosition(&self) -> bool {
self.capabilities.borrow().has_position
}
// https://w3c.github.io/webvr/#dom-vrdisplaycapabilities-hasorientati... | random_line_split | |
mod.rs | //! Multiplexed RPC protocols.
//!
//! See the crate-level docs for an overview.
mod client;
pub use self::client::ClientProto;
pub use self::client::ClientService;
mod server;
pub use self::server::ServerProto;
/// Identifies a request / response thread
pub type RequestId = u64;
/// A marker used to flag protocols... | }
impl<T, InnerItem, E> Stream for LiftTransport<T, E> where
E:'static,
T: Stream<Item = (RequestId, InnerItem), Error = io::Error>,
{
type Item = Frame<InnerItem, (), E>;
type Error = io::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, io::Error> {
... | fut: F,
marker: PhantomData<(A, E)>, | random_line_split |
mod.rs | //! Multiplexed RPC protocols.
//!
//! See the crate-level docs for an overview.
mod client;
pub use self::client::ClientProto;
pub use self::client::ClientService;
mod server;
pub use self::server::ServerProto;
/// Identifies a request / response thread
pub type RequestId = u64;
/// A marker used to flag protocols... |
}
impl<T, InnerSink, E> Sink for LiftTransport<T, E> where
E:'static,
T: Sink<SinkItem = (RequestId, InnerSink), SinkError = io::Error>
{
type SinkItem = Frame<InnerSink, (), E>;
type SinkError = io::Error;
fn start_send(&mut self, request: Self::SinkItem)
... | {
let (id, msg) = match try_ready!(self.0.poll()) {
Some(msg) => msg,
None => return Ok(None.into()),
};
Ok(Some(Frame::Message {
message: msg,
body: false,
solo: false,
id: id,
... | identifier_body |
mod.rs | //! Multiplexed RPC protocols.
//!
//! See the crate-level docs for an overview.
mod client;
pub use self::client::ClientProto;
pub use self::client::ClientService;
mod server;
pub use self::server::ServerProto;
/// Identifies a request / response thread
pub type RequestId = u64;
/// A marker used to flag protocols... | ;
// This is a submodule so that `LiftTransport` can be marked `pub`, to satisfy
// the no-private-in-public checker.
mod lift {
use std::io;
use std::marker::PhantomData;
use super::RequestId;
use streaming::multiplex::{Frame, Transport};
use futures::{Future, Stream, Sink, StartSend, Poll, Async... | Multiplex | identifier_name |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... | (&self) -> bool {
self.0.iter().all(|r| match *r {
CssRule::Namespace(..) | CssRule::Import(..) => true,
_ => false,
})
}
/// <https://drafts.csswg.org/cssom/#remove-a-css-rule>
pub fn remove_rule(&mut self, index: usize) -> Result<(), RulesMutateError> {
// ... | only_ns_or_import | identifier_name |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... | let read_guard = lock.read();
let rules = self.read_with(&read_guard);
// Step 1, 2
if index > rules.0.len() {
return Err(RulesMutateError::IndexSize);
}
// Computes the parser state at the given index
let state = if n... | random_line_split | |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... |
{
// Step 3
let ref rule = self.0[index];
// Step 4
if let CssRule::Namespace(..) = *rule {
if!self.only_ns_or_import() {
return Err(RulesMutateError::InvalidState);
}
}
}
// Step ... | {
return Err(RulesMutateError::IndexSize);
} | conditional_block |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... | .unwrap_or(State::Body)
};
let insert_rule_context = InsertRuleContext {
rule_list: &rules.0,
index,
};
// Steps 3, 4, 5, 6
CssRule::parse(
&rule,
insert_rule_context,
... | {
let new_rule = {
let read_guard = lock.read();
let rules = self.read_with(&read_guard);
// Step 1, 2
if index > rules.0.len() {
return Err(RulesMutateError::IndexSize);
}
// Computes the parser state at the given index
... | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)]
extern crate euclid;
extern crate gfx_traits;
extern crate gleam;
extern crate image;
exter... | {
pub pipeline: CompositionPipeline,
pub size: Option<TypedSize2D<f32, CSSPixel>>,
pub children: Vec<SendableFrameTree>,
}
/// The subset of the pipeline that is needed for layer composition.
#[derive(Clone)]
pub struct CompositionPipeline {
pub id: PipelineId,
pub top_level_browsing_context_id: T... | SendableFrameTree | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)]
extern crate euclid;
extern crate gfx_traits;
extern crate gleam;
extern crate image;
exter... | pub struct CompositionPipeline {
pub id: PipelineId,
pub top_level_browsing_context_id: TopLevelBrowsingContextId,
pub script_chan: IpcSender<ConstellationControlMsg>,
pub layout_chan: IpcSender<LayoutControlMsg>,
} |
/// The subset of the pipeline that is needed for layer composition.
#[derive(Clone)] | random_line_split |
cleanup-shortcircuit.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 args: Vec<String> = env::args().collect();
// Here, the rvalue `"signal".to_string()` requires cleanup. Older versions
// of the code had a problem that the cleanup scope for this
// expression was the end of the `if`, and as the `"signal".to_string()`
// expression was never evaluated, we... | main | identifier_name |
cleanup-shortcircuit.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 ... | // Raise a segfault.
unsafe { *(0 as *mut int) = 0; }
}
} | if args.len() >= 2 && args[1] == "signal" { | random_line_split |
cleanup-shortcircuit.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 args: Vec<String> = env::args().collect();
// Here, the rvalue `"signal".to_string()` requires cleanup. Older versions
// of the code had a problem that the cleanup scope for this
// expression was the end of the `if`, and as the `"signal".to_string()`
// expression was never evaluated, we wo... | identifier_body | |
cleanup-shortcircuit.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 ... |
}
| {
// Raise a segfault.
unsafe { *(0 as *mut int) = 0; }
} | conditional_block |
shootout-spectralnorm.rs | // The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2012-2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted... |
fn mult_Av(v: &[f64], out: &mut [f64]) {
parallel(out, |start, out| mult(v, out, start, |i, j| A(i, j)));
}
fn mult_Atv(v: &[f64], out: &mut [f64]) {
parallel(out, |start, out| mult(v, out, start, |i, j| A(j, i)));
}
fn mult<F>(v: &[f64], out: &mut [f64], start: usize, a: F)
where F: Fn(usize, us... | {
mult_Av(v, tmp);
mult_Atv(tmp, out);
} | identifier_body |
shootout-spectralnorm.rs | // The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2012-2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted... | (v: &[f64], out: &mut [f64]) {
parallel(out, |start, out| mult(v, out, start, |i, j| A(i, j)));
}
fn mult_Atv(v: &[f64], out: &mut [f64]) {
parallel(out, |start, out| mult(v, out, start, |i, j| A(j, i)));
}
fn mult<F>(v: &[f64], out: &mut [f64], start: usize, a: F)
where F: Fn(usize, usize) -> f64 ... | mult_Av | identifier_name |
shootout-spectralnorm.rs | // The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2012-2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted... | // written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNE... | // the name of "The Computer Language Shootout Benchmarks" nor the
// names of its contributors may be used to endorse or promote
// products derived from this software without specific prior | random_line_split |
tempfile.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... |
// Ideally this would be in core, but needs TempFile
pub fn test_rmdir_recursive_ok() {
let rwx = io::UserRWX;
let tmpdir = TempDir::new("test").expect("test_rmdir_recursive_ok: \
couldn't create temp dir");
let tmpdir = tmpdir.path();
let root = tmpdir.j... | {
let path = Path::new("./frob/baz");
let cwd = os::getcwd();
println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(),
cwd.display(), path.exists());
fs::mkdir_recursive(&path, io::UserRWX);
assert!(path.is_dir());
assert!(path.dir_path().is_dir());
let path2... | identifier_body |
tempfile.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... | () {
let path = {
let p = TempDir::new_in(&Path::new("."), "foobar").unwrap();
let p = p.path();
assert!(p.as_vec().ends_with(bytes!("foobar")));
p.clone()
};
assert!(!path.exists());
}
fn test_rm_tempdir() {
let (tx, rx) = channel();
let f: proc():Send = proc() {
... | test_tempdir | identifier_name |
tempfile.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... | // normal test infrastructure. If the tests change the current working
// directory, then *all* tests which require relative paths suddenly break b/c
// they're in a different location than before. Hence, these tests are all run
// serially here.
use std::io::{fs, TempDir};
use std::io;
use std::os;
use std::task;
fn... |
// These tests are here to exercise the functionality of the `tempfile` module.
// One might expect these tests to be located in that module, but sadly they
// cannot. The tests need to invoke `os::change_dir` which cannot be done in the | random_line_split |
merge_parallel.rs | #![crate_id = "Parallel_merge"]
#![crate_type = "bin"]
//! Parallel merge sort, using the green library to get scheduled threads.
extern crate getopts;
extern crate green;
use green::{SchedPool, PoolConfig};
use green::sched::PinnedTask;
use getopts::{reqopt, optflag, getopts, OptGroup};
use std::os;
use std::task::T... | i += min_size;
}
split_array.push((i, length - 1));
split_array.shift();
//removes first value that initialized split_array
return split_array;
}
/// prints a help message
pub fn print_usage(program: &str, _opts: &[OptGroup]) {
println!("Usage: {} [options]", program);
println!("... | {
let mut number_of_sub_arrays = 1;
loop {
if array.len() % (number_of_sub_arrays * 2) != 0 { break }
if number_of_sub_arrays > 256 { break }
number_of_sub_arrays *= 2;
}
let mut i = 0;
let length = array.len();
let min_size = length / number_of_sub_arrays;
let m... | identifier_body |
merge_parallel.rs | #![crate_id = "Parallel_merge"]
#![crate_type = "bin"]
//! Parallel merge sort, using the green library to get scheduled threads.
extern crate getopts;
extern crate green;
use green::{SchedPool, PoolConfig};
use green::sched::PinnedTask;
use getopts::{reqopt, optflag, getopts, OptGroup};
use std::os;
use std::task::T... | child_tx.send(merged_sub);
});
handle.send(PinnedTask(task));
drop(handle);
array_array[j] = rx.recv();
i += 2;
j += 1;
}
pool.shutdown();
array_array = array_array.slice(0, j).to_owned();
return merge_wrapper(array_array);
}
/// Takes an a... | let sub_array2 = array_array[i + 1].clone();
let child_tx = tx.clone();
let task = pool.task(TaskOpts::new(), proc() {
let merged_sub = merge(sub_array1.clone(), sub_array2.clone()); | random_line_split |
merge_parallel.rs | #![crate_id = "Parallel_merge"]
#![crate_type = "bin"]
//! Parallel merge sort, using the green library to get scheduled threads.
extern crate getopts;
extern crate green;
use green::{SchedPool, PoolConfig};
use green::sched::PinnedTask;
use getopts::{reqopt, optflag, getopts, OptGroup};
use std::os;
use std::task::T... | (program: &str, _opts: &[OptGroup]) {
println!("Usage: {} [options]", program);
println!("-f,\t--file\t\t Input file");
}
fn main() {
let args = os::args();
let program = args[0].clone();
let opts = ~[
reqopt("f", "file", "input file name", "FILENAME"),
optflag("h", "help", "print ... | print_usage | identifier_name |
merge_parallel.rs | #![crate_id = "Parallel_merge"]
#![crate_type = "bin"]
//! Parallel merge sort, using the green library to get scheduled threads.
extern crate getopts;
extern crate green;
use green::{SchedPool, PoolConfig};
use green::sched::PinnedTask;
use getopts::{reqopt, optflag, getopts, OptGroup};
use std::os;
use std::task::T... |
number_of_sub_arrays *= 2;
}
let mut i = 0;
let length = array.len();
let min_size = length / number_of_sub_arrays;
let mut split_array: ~[(uint, uint)] = ~[(0, 0)];
//initializes array
while i + min_size < length {
let sub_array2 = i + min_size - 1;
split_array.... | { break } | conditional_block |
tcpclientsrc.rs | // Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
// Copyright (C) 2018 LEE Dongjun <redongjun@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// ... | ) {
init();
let (listening_tx, listening_rx) = mpsc::channel();
let handler = thread::spawn(move || {
use std::net;
let listener = net::TcpListener::bind("0.0.0.0:5000").unwrap();
listening_tx.send(()).unwrap();
let stream = listener.incoming().next().unwrap();
let ... | est_push( | identifier_name |
tcpclientsrc.rs | // Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
// Copyright (C) 2018 LEE Dongjun <redongjun@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// ... |
let listener = net::TcpListener::bind("0.0.0.0:5000").unwrap();
listening_tx.send(()).unwrap();
let stream = listener.incoming().next().unwrap();
let buffer = [0; 160];
let mut socket = stream.unwrap();
for _ in 0..3 {
let _ = socket.write(&buffer);
... |
let (listening_tx, listening_rx) = mpsc::channel();
let handler = thread::spawn(move || {
use std::net; | random_line_split |
tcpclientsrc.rs | // Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
// Copyright (C) 2018 LEE Dongjun <redongjun@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// ... | let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc", None).unwrap();
let appsink = gst::ElementFactory::make("appsink", None).unwrap();
appsink.set_property("sync", &false).unwrap();
appsink.set_property("async", &false).unwrap();
pipeline.add_many(&[&tcpclientsrc, &appsink]).unwrap();
... |
init();
let (listening_tx, listening_rx) = mpsc::channel();
let handler = thread::spawn(move || {
use std::net;
let listener = net::TcpListener::bind("0.0.0.0:5000").unwrap();
listening_tx.send(()).unwrap();
let stream = listener.incoming().next().unwrap();
let buf... | identifier_body |
console.rs | extern crate libc;
use self::libc::c_void;
use self::libc::{__errno_location, read, write, STDIN_FILENO, STDOUT_FILENO};
use containers::String;
use io::{Disposable, IoError, Stream};
use memory::{Page, Region};
pub struct Console {}
impl Console {
pub fn write(_pr: &Region, s: String) {
let _r = Region::... | pub fn open_standard_output(_rp: *mut Page) -> *mut Stream {
unsafe { (*_rp).allocate(ConsoleStream {}) }
}
}
pub struct ConsoleStream {}
impl Disposable for ConsoleStream {
fn dispose(&self) {}
}
impl Stream for ConsoleStream {
fn read_byte(&mut self) -> Result<i32, IoError> {
let mu... | }
| random_line_split |
console.rs | extern crate libc;
use self::libc::c_void;
use self::libc::{__errno_location, read, write, STDIN_FILENO, STDOUT_FILENO};
use containers::String;
use io::{Disposable, IoError, Stream};
use memory::{Page, Region};
pub struct Console {}
impl Console {
pub fn write(_pr: &Region, s: String) {
let _r = Region::... |
}
#[test]
fn test_console() {
use memory::Heap;
use memory::StackBucket;
let mut heap = Heap::create();
let root_stack_bucket = StackBucket::create(&mut heap);
let r1 = Region::create_from_page(Page::get(root_stack_bucket as usize));
{
let root_page = Page::get(root_stack_bucket as usi... | {
unsafe {
let bytes_written = write(STDOUT_FILENO, &the_byte as *const u8 as *const c_void, 1);
if bytes_written == 1 {
Ok(())
} else {
Err(IoError {
error_code: (*__errno_location() as i32),
})
... | identifier_body |
console.rs | extern crate libc;
use self::libc::c_void;
use self::libc::{__errno_location, read, write, STDIN_FILENO, STDOUT_FILENO};
use containers::String;
use io::{Disposable, IoError, Stream};
use memory::{Page, Region};
pub struct Console {}
impl Console {
pub fn write(_pr: &Region, s: String) {
let _r = Region::... | {}
impl Disposable for ConsoleStream {
fn dispose(&self) {}
}
impl Stream for ConsoleStream {
fn read_byte(&mut self) -> Result<i32, IoError> {
let mut the_byte: u8 = 0;
unsafe {
let bytes_read = read(STDIN_FILENO, &mut the_byte as *mut u8 as *mut c_void, 1);
if bytes_... | ConsoleStream | identifier_name |
console.rs | extern crate libc;
use self::libc::c_void;
use self::libc::{__errno_location, read, write, STDIN_FILENO, STDOUT_FILENO};
use containers::String;
use io::{Disposable, IoError, Stream};
use memory::{Page, Region};
pub struct Console {}
impl Console {
pub fn write(_pr: &Region, s: String) {
let _r = Region::... |
if bytes_read == 0 {
return Ok(-1);
}
}
Ok(the_byte as i32)
}
fn write_byte(&mut self, the_byte: u8) -> Result<(), IoError> {
unsafe {
let bytes_written = write(STDOUT_FILENO, &the_byte as *const u8 as *const c_void, 1);
... | {
return Err(IoError {
error_code: (*__errno_location() as i32),
});
} | conditional_block |
stream.rs | //
// Test vectors adapted from libsodium
//
#![allow(non_upper_case_globals)]
extern crate tweetnacl;
const firstkey: [u8; 32]
= [ 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, 0x62, 0xcd, 0x51,
0x19, 0x7a, 0x9a, 0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64,
0x74, 0xf2, 0x06, 0xc4, 0xee, 0x0... | 0x32, 0xfc, 0x76, 0xce, 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a, 0xc0, 0xdf, 0xc1, 0x7c,
0x98, 0xdc, 0xe8, 0x7b, 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2, 0x27, 0x0d, 0x6f, 0xb8,
... | {
let m: [u8; 163]
= [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0xbe, 0x07, 0x5f, 0xc5,
0x3c, 0x81, 0xf2, 0xd5, 0xcf, 0x14, 0x13, 0x16, 0xeb, 0... | identifier_body |
stream.rs | //
// Test vectors adapted from libsodium
//
#![allow(non_upper_case_globals)]
extern crate tweetnacl;
const firstkey: [u8; 32]
= [ 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, 0x62, 0xcd, 0x51,
0x19, 0x7a, 0x9a, 0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64,
0x74, 0xf2, 0x06, 0xc4, 0xee, 0x0... | 0x98, 0xdc, 0xe8, 0x7b, 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2, 0x27, 0x0d, 0x6f, 0xb8,
0x63, 0xd5, 0x17, 0x38, 0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a,
0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae, 0x90, 0x22, 0x43, 0x68,
... |
let test: [u8; 131]
= [ 0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73, 0xc2, 0x96, 0x50, 0xba,
0x32, 0xfc, 0x76, 0xce, 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a, 0xc0, 0xdf, 0xc1, 0x7c, | random_line_split |
stream.rs | //
// Test vectors adapted from libsodium
//
#![allow(non_upper_case_globals)]
extern crate tweetnacl;
const firstkey: [u8; 32]
= [ 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, 0x62, 0xcd, 0x51,
0x19, 0x7a, 0x9a, 0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64,
0x74, 0xf2, 0x06, 0xc4, 0xee, 0x0... | () {
let m: [u8; 163]
= [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0xbe, 0x07, 0x5f, 0xc5,
0x3c, 0x81, 0xf2, 0xd5, 0xcf, 0x14, 0x13, 0x16, 0xeb... | stream4 | identifier_name |
regions-lifetime-of-struct-or-enum-variant.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 ... |
struct Test;
enum MyEnum {
Variant1
}
fn structLifetime<'a>() -> &'a Test {
let testValue = &Test; //~ ERROR borrowed value does not live long enough
testValue
}
fn variantLifetime<'a>() -> &'a MyEnum {
let testValue = &Variant1; //~ ERROR borrowed value does not live long enough
testValue
}
fn main()... | // This tests verifies that unary structs and enum variants
// are treated as rvalues and their lifetime is not bounded to
// the static scope. | random_line_split |
regions-lifetime-of-struct-or-enum-variant.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 ... | {
Variant1
}
fn structLifetime<'a>() -> &'a Test {
let testValue = &Test; //~ ERROR borrowed value does not live long enough
testValue
}
fn variantLifetime<'a>() -> &'a MyEnum {
let testValue = &Variant1; //~ ERROR borrowed value does not live long enough
testValue
}
fn main() {}
| MyEnum | identifier_name |
regions-lifetime-of-struct-or-enum-variant.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 | |
minwindef.rs | // Copyright © 2015, Peter Atashian
// Licensed under the MIT License <LICENSE.md>
//! Basic Windows Type Definitions for minwin partition
pub type ULONG = ::c_ulong;
pub type PULONG = *mut ULONG;
pub type USHORT = ::c_ushort;
pub type PUSHORT = *mut USHORT;
pub type UCHAR = ::c_uchar;
pub type PUCHAR = *mut UCHAR;
pub... | pub fn HIWORD(l: DWORD) -> WORD {
((l >> 16) & 0xffff) as WORD
}
pub fn LOBYTE(l: WORD) -> BYTE {
(l & 0xff) as BYTE
}
pub fn HIBYTE(l: WORD) -> BYTE {
((l >> 8) & 0xff) as BYTE
}
pub type SPHANDLE = *mut ::HANDLE;
pub type LPHANDLE = *mut ::HANDLE;
pub type HGLOBAL = ::HANDLE;
pub type HLOCAL = ::HANDLE;
p... |
(l & 0xffff) as WORD
}
| identifier_body |
minwindef.rs | // Copyright © 2015, Peter Atashian
// Licensed under the MIT License <LICENSE.md>
//! Basic Windows Type Definitions for minwin partition
pub type ULONG = ::c_ulong;
pub type PULONG = *mut ULONG;
pub type USHORT = ::c_ushort;
pub type PUSHORT = *mut USHORT;
pub type UCHAR = ::c_uchar;
pub type PUCHAR = *mut UCHAR;
pub... | l: DWORD) -> WORD {
(l & 0xffff) as WORD
}
pub fn HIWORD(l: DWORD) -> WORD {
((l >> 16) & 0xffff) as WORD
}
pub fn LOBYTE(l: WORD) -> BYTE {
(l & 0xff) as BYTE
}
pub fn HIBYTE(l: WORD) -> BYTE {
((l >> 8) & 0xff) as BYTE
}
pub type SPHANDLE = *mut ::HANDLE;
pub type LPHANDLE = *mut ::HANDLE;
pub type HG... | OWORD( | identifier_name |
minwindef.rs | // Copyright © 2015, Peter Atashian
// Licensed under the MIT License <LICENSE.md>
//! Basic Windows Type Definitions for minwin partition
pub type ULONG = ::c_ulong;
pub type PULONG = *mut ULONG;
pub type USHORT = ::c_ushort;
pub type PUSHORT = *mut USHORT;
pub type UCHAR = ::c_uchar;
pub type PUCHAR = *mut UCHAR;
pub... | DECLARE_HANDLE!(HSPRITE, HSPRITE__);
DECLARE_HANDLE!(HLSURF, HLSURF__);
DECLARE_HANDLE!(HSTR, HSTR__);
DECLARE_HANDLE!(HTASK, HTASK__);
DECLARE_HANDLE!(HWINSTA, HWINSTA__);
DECLARE_HANDLE!(HKL, HKL__);
pub type HFILE = ::c_int;
STRUCT!{struct FILETIME {
dwLowDateTime: DWORD,
dwHighDateTime: DWORD,
}}
pub type P... | DECLARE_HANDLE!(HMETAFILE, HMETAFILE__);
DECLARE_HANDLE!(HINSTANCE, HINSTANCE__);
pub type HMODULE = HINSTANCE;
DECLARE_HANDLE!(HRGN, HRGN__);
DECLARE_HANDLE!(HRSRC, HRSRC__); | random_line_split |
kahansum.rs | // Implements http://rosettacode.org/wiki/Kahan_summation
#![feature(permutations)]
extern crate num;
| fn find_max(lst: &[f32]) -> Option<f32> {
if lst.is_empty() { return None }
let max = lst.iter().fold(f32::NEG_INFINITY,
|a, &b| Float::max(a, b));
Some(max)
}
fn with_bits(val: f32, digits: usize) -> f32 {
let num = format!("{:.*}", digits, val);
num.parse::<f32>().un... | use std::f32;
use num::Float;
| random_line_split |
kahansum.rs | // Implements http://rosettacode.org/wiki/Kahan_summation
#![feature(permutations)]
extern crate num;
use std::f32;
use num::Float;
fn find_max(lst: &[f32]) -> Option<f32> {
if lst.is_empty() { return None }
let max = lst.iter().fold(f32::NEG_INFINITY,
|a, &b| Float::max(a, b));
... | (vec: &[f32]) -> Vec<f32> {
let mut res = Vec::new();
let mut perms = vec.permutations();
loop {
let v = perms.next();
match v {
Some(_v) => {
let mut sum = 0.0f32;
for e in &_v {
sum += with_bits(*e, 1);
}
... | all_sums | identifier_name |
kahansum.rs | // Implements http://rosettacode.org/wiki/Kahan_summation
#![feature(permutations)]
extern crate num;
use std::f32;
use num::Float;
fn find_max(lst: &[f32]) -> Option<f32> {
if lst.is_empty() { return None }
let max = lst.iter().fold(f32::NEG_INFINITY,
|a, &b| Float::max(a, b));
... |
#[test]
fn test_kahansum() {
let v = [10000.0f32, 3.14159, 2.71828];
let sums = all_sums(&v);
let res = kahan_sum(&v).unwrap();
let max = find_max(&sums[..]).unwrap();
assert!(max < res);
}
#[test]
fn test_withbits() {
let v = 3.123345f32;
let res = with_bits(v, 3);
assert!(res == 3.1... | {
let v = [10000.0f32, 3.14159, 2.71828];
let sums = all_sums(&v);
let res = kahan_sum(&v).unwrap();
let max = find_max(&sums[..]).unwrap();
println!("max: {} res: {}", max, res);
} | identifier_body |
cache.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.... | {
/// Size of rocksDB cache. Almost all goes to the state column.
db: u32,
/// Size of blockchain cache.
blockchain: u32,
/// Size of transaction queue cache.
queue: u32,
/// Size of traces cache.
traces: u32,
/// Size of the state cache.
state: u32,
}
impl Default for CacheConfig {
fn default() -> Self {
... | CacheConfig | identifier_name |
cache.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.... | // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::cmp::max;
const MIN_BC_CACHE_MB: u32 = 4;
const MIN_DB_CACHE_MB: u32 = 2;
const MIN_BLOCK_QUEUE_SIZE_LIMIT_MB: u32 = 16;
const DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB: u32 = 50;
c... | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
| random_line_split |
svgelement.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 crate::dom::bindings::inheritance::Castable;
use crate::dom::document::Document;
use crate::dom::element::Elem... | {
element: Element,
}
impl SVGElement {
pub fn new_inherited_with_state(
state: ElementState,
tag_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> SVGElement {
SVGElement {
element: Element::new_inherited_with_state(state, tag_name, ns!... | SVGElement | identifier_name |
svgelement.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 crate::dom::bindings::inheritance::Castable;
use crate::dom::document::Document;
use crate::dom::element::Elem... | pub struct SVGElement {
element: Element,
}
impl SVGElement {
pub fn new_inherited_with_state(
state: ElementState,
tag_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> SVGElement {
SVGElement {
element: Element::new_inherited_with_state... | use style::element_state::ElementState;
#[dom_struct] | random_line_split |
svgelement.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 crate::dom::bindings::inheritance::Castable;
use crate::dom::document::Document;
use crate::dom::element::Elem... |
}
impl VirtualMethods for SVGElement {
fn super_type(&self) -> Option<&dyn VirtualMethods> {
Some(self.upcast::<Element>() as &dyn VirtualMethods)
}
}
| {
SVGElement {
element: Element::new_inherited_with_state(state, tag_name, ns!(svg), prefix, document),
}
} | identifier_body |
preview.rs | // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use crate::{
card::CardQueue,
config::SchedulerVersion,
prelude::*,
scheduler::states::{CardState, IntervalKind, PreviewState},
};
use super::{CardStateUpdater, RevlogEntryP... |
}
Ok(RevlogEntryPartial::maybe_new(
current,
next.into(),
0.0,
self.secs_until_rollover(),
))
}
}
#[cfg(test)]
mod test {
use crate::collection::open_test_collection;
use super::*;
use crate::{
card::CardType,
sc... | {
// unsupported
} | conditional_block |
preview.rs | // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use crate::{
card::CardQueue,
config::SchedulerVersion,
prelude::*,
scheduler::states::{CardState, IntervalKind, PreviewState},
};
use super::{CardStateUpdater, RevlogEntryP... | next.current,
CardState::Filtered(FilteredState::Preview(_))
));
// the exit state should have a 0 second interval, which will show up as (end)
assert!(matches!(
next.easy,
CardState::Filtered(FilteredState::Preview(PreviewState {
s... | {
let mut col = open_test_collection();
let mut c = Card {
deck_id: DeckID(1),
ctype: CardType::Learn,
queue: CardQueue::DayLearn,
remaining_steps: 2,
due: 123,
..Default::default()
};
col.add_card(&mut c)?;
... | identifier_body |
preview.rs | // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use crate::{
card::CardQueue,
config::SchedulerVersion,
prelude::*,
scheduler::states::{CardState, IntervalKind, PreviewState},
};
use super::{CardStateUpdater, RevlogEntryP... | assert_eq!(col.rebuild_filtered_deck(filtered_deck.id)?, 1);
let next = col.get_next_card_states(c.id)?;
assert!(matches!(
next.current,
CardState::Filtered(FilteredState::Preview(_))
));
// the exit state should have a 0 second interval, which will show ... |
// pull the card into a preview deck
let mut filtered_deck = Deck::new_filtered();
filtered_deck.filtered_mut()?.reschedule = false;
col.add_or_update_deck(&mut filtered_deck)?; | random_line_split |
preview.rs | // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use crate::{
card::CardQueue,
config::SchedulerVersion,
prelude::*,
scheduler::states::{CardState, IntervalKind, PreviewState},
};
use super::{CardStateUpdater, RevlogEntryP... | (
&mut self,
current: CardState,
next: PreviewState,
) -> Result<Option<RevlogEntryPartial>> {
if next.finished {
self.card
.remove_from_filtered_deck_restoring_queue(SchedulerVersion::V2);
return Ok(None);
}
self.card.queue = C... | apply_preview_state | identifier_name |
cleanup-copy-mode.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 ... | () {
assert!(task::try(proc() {
adder(box(GC) 2, failer()); ()
}).is_err());
}
| main | identifier_name |
cleanup-copy-mode.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn failer() -> Gc<int> { fail!(); }
pub fn main() {
assert!(task::try(proc() {
adder(box(GC) 2, failer()); ()
}).is_err());
}
| { return *x + *y; } | identifier_body |
cleanup-copy-mode.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 | // option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::task;
use std::gc::{GC, Gc};
fn adder(x: Gc<int>, y: Gc<int>) -> int { return *x + *y; }
fn failer() -> Gc<int> { fail!(); }
pub fn main() {
assert!(task::try(proc() {
adder(box(GC) 2, failer());... | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
process.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 ... |
if writable {
flags |= uvll::STDIO_WRITABLE_PIPE as libc::c_int;
}
let handle = pipe.pipe.as_stream().native_handle();
uvll::set_stdio_container_flags(dst, flags);
uvll::set_stdio_container_stream(dst, handle);
Some(pipe.bind())
... | {
flags |= uvll::STDIO_READABLE_PIPE as libc::c_int;
} | conditional_block |
process.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 ... |
}
unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t,
io: StdioContainer) -> Option<UvPipeStream> {
match io {
Ignored => {
uvll::set_stdio_container_flags(dst, uvll::STDIO_IGNORE);
None
}
InheritFd(fd) => {
uvll::set_stdio_containe... | {
{
let mut this = self;
let data = this.get_watcher_data();
assert!(data.close_cb.is_none());
data.close_cb = Some(cb);
}
unsafe { uvll::close(self.native_handle(), close_cb); }
extern fn close_cb(handle: *uvll::uv_process_t) {
... | identifier_body |
process.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 ... | (handle: *uvll::uv_process_t) -> Process {
Process(handle)
}
fn native_handle(&self) -> *uvll::uv_process_t {
match self { &Process(ptr) => ptr }
}
}
| from_native_handle | identifier_name |
process.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
impl uv::NativeHandle<*uvll::uv_process_t> for Process {
fn from_native_handle(handle: *uvll::uv_process_t) -> Process {
Process(handle)
}
fn native_handle(&self) -> *uvll::uv_process_t {
match self { &Process(ptr) => ptr }
}
} | for s in envp.iter() {
c_envp.push(s.with_ref(|p| p));
}
c_envp.push(ptr::null());
c_envp.as_imm_buf(|buf, _| f(buf)) | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.