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 |
|---|---|---|---|---|
init.rs | use std::sync::{Arc, Mutex};
use std::io;
use std::ptr;
use std::mem;
use std::thread;
use super::callback;
use super::Window;
use super::MonitorId;
use super::WindowWrapper;
use super::Context;
use Api;
use CreationError;
use CreationError::OsError;
use CursorState;
use GlAttributes;
use GlRequest;
use PixelFormatRe... |
user32::TranslateMessage(&msg);
user32::DispatchMessageW(&msg); // calls `callback` (see the callback module)
}
}
});
rx.recv().unwrap()
}
unsafe fn init(title: Vec<u16>, window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
opengl:... | break;
} | random_line_split |
init.rs | use std::sync::{Arc, Mutex};
use std::io;
use std::ptr;
use std::mem;
use std::thread;
use super::callback;
use super::Window;
use super::MonitorId;
use super::WindowWrapper;
use super::Context;
use Api;
use CreationError;
use CreationError::OsError;
use CursorState;
use GlAttributes;
use GlRequest;
use PixelFormatRe... | Err(e) => {
tx.send(Err(e)).ok();
return;
}
};
// now that the `Window` struct is initialized, the main `Window::new()` function will
// return and this events loop will run in parallel
loop {
... | {
let egl = egl.map(|e| e.clone());
let window = window.clone();
let pf_reqs = pf_reqs.clone();
let opengl = opengl.clone();
// initializing variables to be sent to the task
let title = OsStr::new(&window.title).encode_wide().chain(Some(0).into_iter())
... | identifier_body |
TestNativeExp2.rs | /*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by app... |
float4 __attribute__((kernel)) testNativeExp2Float4Float4(float4 inV) {
return native_exp2(inV);
}
half __attribute__((kernel)) testNativeExp2HalfHalf(half inV) {
return native_exp2(inV);
}
half2 __attribute__((kernel)) testNativeExp2Half2Half2(half2 inV) {
return native_exp2(inV);
}
half3 __attribute__... | random_line_split | |
reader.rs | // Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By ... |
}
}
| {
debug!(
"Reading {len} bytes of data from file starting at offset of {pos} bytes ...",
len = length,
pos = position
);
self.self_encryptor
.read(position, length)
.map_err(From::from)
.i... | conditional_block |
reader.rs | // Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By ... | position,
length
);
if (position + length) > self.size() {
err!(NfsError::InvalidRange)
} else {
debug!(
"Reading {len} bytes of data from file starting at offset of {pos} bytes...",
len = length,
po... | random_line_split | |
reader.rs | // Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By ... | <T> {
client: Client<T>,
self_encryptor: SelfEncryptor<SelfEncryptionStorage<T>>,
}
impl<T:'static> Reader<T> {
/// Create a new instance of Reader
pub fn new(
client: Client<T>,
storage: SelfEncryptionStorage<T>,
file: &File,
encryption_key: Option<shared_secretbox::Key... | Reader | identifier_name |
flush.rs | use core::marker::PhantomData;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use futures_sink::Sink;
/// Future for the [`flush`](super::SinkExt::flush) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Flush<'a, Si:... | (
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Self::Output> {
Pin::new(&mut self.sink).poll_flush(cx)
}
}
| poll | identifier_name |
flush.rs | use core::marker::PhantomData;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use futures_sink::Sink;
/// Future for the [`flush`](super::SinkExt::flush) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Flush<'a, Si:... |
}
impl<Si: Sink<Item> + Unpin +?Sized, Item> Future for Flush<'_, Si, Item> {
type Output = Result<(), Si::Error>;
fn poll(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Self::Output> {
Pin::new(&mut self.sink).poll_flush(cx)
}
}
| {
Flush {
sink,
_phantom: PhantomData,
}
} | identifier_body |
flush.rs | use core::marker::PhantomData;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use futures_sink::Sink;
/// Future for the [`flush`](super::SinkExt::flush) method. | }
// Pin is never projected to a field.
impl<Si: Unpin +?Sized, Item> Unpin for Flush<'_, Si, Item> {}
/// A future that completes when the sink has finished processing all
/// pending requests.
///
/// The sink itself is returned after flushing is complete; this adapter is
/// intended to be used when you want to st... | #[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Flush<'a, Si: ?Sized, Item> {
sink: &'a mut Si,
_phantom: PhantomData<fn(Item)>, | random_line_split |
body_exp_euler_integrator.rs | //! Explicit Euler integrator.
use na::Transformation;
use math::Scalar;
use object::RigidBody;
use integration::Integrator;
use integration::euler;
/// An explicit Euler integrator.
///
/// Do not use this, prefer the `BodySmpEulerIntegrator` instead.
pub struct BodyExpEulerIntegrator;
impl BodyExpEulerIntegrator {... |
}
| {
if rb.can_move() {
let (t, lv, av) = euler::explicit_integrate(
dt.clone(),
rb.position(),
rb.center_of_mass(),
&rb.lin_vel(),
&rb.ang_vel(),
&rb.lin_acc(),
&rb.ang_acc());
... | identifier_body |
body_exp_euler_integrator.rs | //! Explicit Euler integrator.
use na::Transformation;
use math::Scalar;
use object::RigidBody;
use integration::Integrator;
use integration::euler;
/// An explicit Euler integrator.
///
/// Do not use this, prefer the `BodySmpEulerIntegrator` instead.
pub struct BodyExpEulerIntegrator;
impl BodyExpEulerIntegrator {... |
}
}
| {
let (t, lv, av) = euler::explicit_integrate(
dt.clone(),
rb.position(),
rb.center_of_mass(),
&rb.lin_vel(),
&rb.ang_vel(),
&rb.lin_acc(),
&rb.ang_acc());
rb.append_transformation(&t... | conditional_block |
body_exp_euler_integrator.rs | //! Explicit Euler integrator.
use na::Transformation; | use object::RigidBody;
use integration::Integrator;
use integration::euler;
/// An explicit Euler integrator.
///
/// Do not use this, prefer the `BodySmpEulerIntegrator` instead.
pub struct BodyExpEulerIntegrator;
impl BodyExpEulerIntegrator {
/// Creates a new `BodyExpEulerIntegrator`.
#[inline]
pub fn ... | use math::Scalar; | random_line_split |
body_exp_euler_integrator.rs | //! Explicit Euler integrator.
use na::Transformation;
use math::Scalar;
use object::RigidBody;
use integration::Integrator;
use integration::euler;
/// An explicit Euler integrator.
///
/// Do not use this, prefer the `BodySmpEulerIntegrator` instead.
pub struct BodyExpEulerIntegrator;
impl BodyExpEulerIntegrator {... | () -> BodyExpEulerIntegrator {
BodyExpEulerIntegrator
}
}
impl Integrator<RigidBody> for BodyExpEulerIntegrator {
#[inline]
fn update(&mut self, dt: Scalar, rb: &mut RigidBody) {
if rb.can_move() {
let (t, lv, av) = euler::explicit_integrate(
dt.clone(),
... | new | identifier_name |
iterable.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/. */
#![allow(unsafe_code)]
//! Implementation of `iterable<...>` and `iterable<...,...>` WebIDL declarations.
use c... | unsafe {
self.iterable
.get_key_at_index(index)
.to_jsval(*cx, key.handle_mut());
self.iterable
.get_value_at_index(index)
.to_jsval(*cx, value.... | {
match self.type_ {
IteratorType::Keys => {
unsafe {
self.iterable
.get_key_at_index(index)
.to_jsval(*cx, value.handle_mut());
}
dict_return(cx, rval.... | conditional_block |
iterable.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/. */
#![allow(unsafe_code)]
//! Implementation of `iterable<...>` and `iterable<...,...>` WebIDL declarations.
use c... | .to_jsval(*cx, value.handle_mut());
}
dict_return(cx, rval.handle_mut(), false, value.handle())
},
IteratorType::Entries => {
rooted!(in(*cx) let mut key = UndefinedValue());
unsafe... | {
let index = self.index.get();
rooted!(in(*cx) let mut value = UndefinedValue());
rooted!(in(*cx) let mut rval = ptr::null_mut::<JSObject>());
let result = if index >= self.iterable.get_iterable_length() {
dict_return(cx, rval.handle_mut(), true, value.handle())
} el... | identifier_body |
iterable.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/. */
#![allow(unsafe_code)]
//! Implementation of `iterable<...>` and `iterable<...,...>` WebIDL declarations.
use c... |
/// The values that an iterator will iterate over.
#[derive(JSTraceable, MallocSizeOf)]
pub enum IteratorType {
/// The keys of the iterable object.
Keys,
/// The values of the iterable object.
Values,
/// The keys and values of the iterable object combined.
Entries,
}
/// A DOM object that ca... | use std::cell::Cell;
use std::ptr;
use std::ptr::NonNull; | random_line_split |
iterable.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/. */
#![allow(unsafe_code)]
//! Implementation of `iterable<...>` and `iterable<...,...>` WebIDL declarations.
use c... | (&self, cx: JSContext) -> Fallible<NonNull<JSObject>> {
let index = self.index.get();
rooted!(in(*cx) let mut value = UndefinedValue());
rooted!(in(*cx) let mut rval = ptr::null_mut::<JSObject>());
let result = if index >= self.iterable.get_iterable_length() {
dict_return(cx,... | Next | identifier_name |
client.rs | extern crate env_logger;
extern crate tokio_core;
extern crate futures;
extern crate tokio_solicit;
use std::str;
use std::io::{self};
use futures::{Future, Stream};
use futures::future::{self};
use tokio_core::reactor::{Core};
use tokio_solicit::client::H2Client;
// Shows the usage of `H2Client` when establishing... | println!("receiving a new chunk of size {}", chunk.body.len());
vec.extend(chunk.body.into_iter());
future::ok::<_, io::Error>(vec)
})
});
// Finally, yield a future that resolves once both requests are complete (and both bodies
// ar... | {
let mut core = Core::new().expect("event loop required");
let handle = core.handle();
let addr = "127.0.0.1:8080".parse().expect("valid IP address");
let future_client = H2Client::cleartext_connect("localhost", &addr, &handle);
let future_response = future_client.and_then(|mut client| {
... | identifier_body |
client.rs | extern crate env_logger;
extern crate tokio_core;
extern crate futures;
extern crate tokio_solicit;
use std::str;
use std::io::{self};
use futures::{Future, Stream};
use futures::future::{self};
use tokio_core::reactor::{Core};
use tokio_solicit::client::H2Client;
// Shows the usage of `H2Client` when establishing... | () {
println!();
println!("---- streaming request example ----");
use std::iter;
use tokio_solicit::client::HttpRequestBody;
use futures::Sink;
let mut core = Core::new().expect("event loop required");
let handle = core.handle();
let addr = "127.0.0.1:8080".parse().expect("valid IP addr... | do_streaming_request | identifier_name |
client.rs | extern crate env_logger;
extern crate tokio_core;
extern crate futures;
extern crate tokio_solicit;
use std::str;
use std::io::{self};
use futures::{Future, Stream};
use futures::future::{self};
use tokio_core::reactor::{Core};
use tokio_solicit::client::H2Client;
// Shows the usage of `H2Client` when establishing... | let future_client = H2Client::cleartext_connect("localhost", &addr, &handle);
let future_response = future_client.and_then(|mut client| {
let (post, tx) = client.streaming_request(b"POST", b"/post", iter::empty());
tx
.send(Ok(HttpRequestBody::new(b"HELLO ".to_vec())))
.an... | let handle = core.handle();
let addr = "127.0.0.1:8080".parse().expect("valid IP address"); | random_line_split |
pslldq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn pslldq_1() |
fn pslldq_2() {
run_test(&Instruction { mnemonic: Mnemonic::PSLLDQ, operand1: Some(Direct(XMM6)), operand2: Some(Literal8(32)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 115, 254, 32], OperandSize::Qword)
}
| {
run_test(&Instruction { mnemonic: Mnemonic::PSLLDQ, operand1: Some(Direct(XMM4)), operand2: Some(Literal8(90)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 115, 252, 90], OperandSize::Dword)
} | identifier_body |
pslldq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn pslldq_1() {
run_test(&Instruction { mnemonic: Mnemonic::PSLLDQ, operand1: Some(Direct(XMM4)), operand2: Some(Literal8(... | () {
run_test(&Instruction { mnemonic: Mnemonic::PSLLDQ, operand1: Some(Direct(XMM6)), operand2: Some(Literal8(32)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 115, 254, 32], OperandSize::Qword)
}
| pslldq_2 | identifier_name |
pslldq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn pslldq_1() {
run_test(&Instruction { mnemonic: Mnemonic::PSLLDQ, operand1: Some(Direct(XMM4)), operand2: Some(Literal8(... | run_test(&Instruction { mnemonic: Mnemonic::PSLLDQ, operand1: Some(Direct(XMM6)), operand2: Some(Literal8(32)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 115, 254, 32], OperandSize::Qword)
} | }
fn pslldq_2() { | random_line_split |
legacy.rs | use core::char;
use core::fmt;
/// Representation of a demangled symbol name.
pub struct Demangle<'a> {
inner: &'a str,
/// The number of ::-separated elements in the original name.
elements: usize,
}
/// De-mangles a Rust symbol into a more readable version
///
/// All Rust symbols by default are mangled... | //
// Note that this demangler isn't quite as fancy as it could be. We have lots
// of other information in our symbols like hashes, version, type information,
// etc. Additionally, this doesn't handle glue symbols at all.
pub fn demangle(s: &str) -> Result<(Demangle, &str), ()> {
// First validate the symbol. If i... | // We're the ones printing our backtraces, so we can't rely on anything else to
// demangle our symbols. It's *much* nicer to look at demangled symbols, so
// this function is implemented to give us nice pretty output. | random_line_split |
legacy.rs | use core::char;
use core::fmt;
/// Representation of a demangled symbol name.
pub struct Demangle<'a> {
inner: &'a str,
/// The number of ::-separated elements in the original name.
elements: usize,
}
/// De-mangles a Rust symbol into a more readable version
///
/// All Rust symbols by default are mangled... | let digits = &escape[1..];
let all_lower_hex = digits.chars().all(|c| match c {
'0'..='9' | 'a'..='f' => true,
_ => false,
});
... | {
let (escape, after_escape) = if let Some(end) = rest[1..].find('$') {
(&rest[1..=end], &rest[end + 2..])
} else {
break;
};
// see src/librustc_codegen_utils/symbol_names/legacy.rs for thes... | conditional_block |
legacy.rs | use core::char;
use core::fmt;
/// Representation of a demangled symbol name.
pub struct Demangle<'a> {
inner: &'a str,
/// The number of ::-separated elements in the original name.
elements: usize,
}
/// De-mangles a Rust symbol into a more readable version
///
/// All Rust symbols by default are mangled... | e_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h059a991a004536adE",
"issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo"
);
}
}
| "_ZN11issu | identifier_name |
legacy.rs | use core::char;
use core::fmt;
/// Representation of a demangled symbol name.
pub struct Demangle<'a> {
inner: &'a str,
/// The number of ::-separated elements in the original name.
elements: usize,
}
/// De-mangles a Rust symbol into a more readable version
///
/// All Rust symbols by default are mangled... | #[test]
fn demangle_utf8_idents() {
t_nohash!(
"_ZN11utf8_idents157_$u10e1$$u10d0$$u10ed$$u10db$$u10d4$$u10da$$u10d0$$u10d3$_$u10d2$$u10d4$$u10db$$u10e0$$u10d8$$u10d4$$u10da$$u10d8$_$u10e1$$u10d0$$u10d3$$u10d8$$u10da$$u10d8$17h21634fd5714000aaE",
"utf8_idents::საჭმელად_გემრიელი_ს... | t!(
"_ZN88_$LT$core..result..Result$LT$$u21$$C$$u20$E$GT$$u20$as$u20$std..process..Termination$GT$6report17hfc41d0da4a40b3e8E",
"<core::result::Result<!, E> as std::process::Termination>::report::hfc41d0da4a40b3e8"
);
}
| identifier_body |
build.rs | extern crate rustc_version;
extern crate semver;
use std::fs::File;
use std::io::Write;
use std::{env, path};
use semver::Identifier;
use rustc_version::{version_meta, Channel};
fn identifier_to_source(id: &Identifier) -> String {
match *id {
Identifier::Numeric(ref n) => format!("semver::Identifier::Num... | (ids: &Vec<Identifier>) -> String {
let mut r = "vec![".as_bytes().to_vec();
for id in ids {
write!(r, "{}, ", identifier_to_source(id)).unwrap();
}
write!(r, "]").unwrap();
String::from_utf8(r).unwrap()
}
fn main() {
let mut path = path::PathBuf::from(env::var_os("OUT_DIR").unwrap());
... | identifiers_to_source | identifier_name |
build.rs | extern crate rustc_version;
extern crate semver;
use std::fs::File;
use std::io::Write;
use std::{env, path};
use semver::Identifier;
use rustc_version::{version_meta, Channel};
fn identifier_to_source(id: &Identifier) -> String |
fn identifiers_to_source(ids: &Vec<Identifier>) -> String {
let mut r = "vec![".as_bytes().to_vec();
for id in ids {
write!(r, "{}, ", identifier_to_source(id)).unwrap();
}
write!(r, "]").unwrap();
String::from_utf8(r).unwrap()
}
fn main() {
let mut path = path::PathBuf::from(env::var... | {
match *id {
Identifier::Numeric(ref n) => format!("semver::Identifier::Numeric({})", n),
Identifier::AlphaNumeric(ref n) => format!("semver::Identifier::AlphaNumeric({:?}.to_owned())", n),
}
} | identifier_body |
build.rs | extern crate rustc_version;
extern crate semver;
use std::fs::File;
use std::io::Write;
use std::{env, path};
use semver::Identifier;
use rustc_version::{version_meta, Channel};
fn identifier_to_source(id: &Identifier) -> String {
match *id {
Identifier::Numeric(ref n) => format!("semver::Identifier::Num... | } | random_line_split | |
vm_config.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::on_chain_config::OnChainConfig;
use anyhow::{format_err, Result};
use move_core_types::gas_schedule::{CostTable, GasConstants};
use serde::{Deserialize, Serialize};
/// Defines all the on chain configuration data needed by V... | (bytes: &[u8]) -> Result<Self> {
let raw_vm_config = bcs::from_bytes::<VMConfigInner>(&bytes).map_err(|e| {
format_err!(
"Failed first round of deserialization for VMConfigInner: {}",
e
)
})?;
let gas_schedule = raw_vm_config.gas_schedule.a... | deserialize_into_config | identifier_name |
vm_config.rs | // Copyright (c) The Diem Core Contributors | // SPDX-License-Identifier: Apache-2.0
use crate::on_chain_config::OnChainConfig;
use anyhow::{format_err, Result};
use move_core_types::gas_schedule::{CostTable, GasConstants};
use serde::{Deserialize, Serialize};
/// Defines all the on chain configuration data needed by VM.
#[derive(Clone, Debug, Deserialize, Parti... | random_line_split | |
ps.rs | extern crate arg_parser;
extern crate extra;
use std::env;
use std::fs::File;
use std::io::{stdout, stderr, copy, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{ps} */ r#"
NAME
ps - report a snapshot of the current processes
... | {
let stdout = stdout();
let mut stdout = stdout.lock();
let mut stderr = stderr();
let mut parser = ArgParser::new(1)
.add_flag(&["h", "help"]);
parser.parse(env::args());
if parser.found("help") {
stdout.write(MAN_PAGE.as_bytes()).try(&mut stderr);
stdout.flush().try(&... | identifier_body | |
ps.rs | extern crate arg_parser;
extern crate extra;
use std::env;
use std::fs::File;
use std::io::{stdout, stderr, copy, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{ps} */ r#"
NAME
ps - report a snapshot of the current processes
... | () {
let stdout = stdout();
let mut stdout = stdout.lock();
let mut stderr = stderr();
let mut parser = ArgParser::new(1)
.add_flag(&["h", "help"]);
parser.parse(env::args());
if parser.found("help") {
stdout.write(MAN_PAGE.as_bytes()).try(&mut stderr);
stdout.flush().try... | main | identifier_name |
ps.rs | extern crate arg_parser;
extern crate extra;
use std::env;
use std::fs::File;
use std::io::{stdout, stderr, copy, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt; |
SYNOPSIS
ps [ -h | --help]
DESCRIPTION
Displays information about processes and threads that are currently active
OPTIONS
-h
--help
display this help and exit
"#; /* @MANEND */
fn main() {
let stdout = stdout();
let mut stdout = stdout.lock();
let mut stderr = stderr();
let m... |
const MAN_PAGE: &'static str = /* @MANSTART{ps} */ r#"
NAME
ps - report a snapshot of the current processes | random_line_split |
ps.rs | extern crate arg_parser;
extern crate extra;
use std::env;
use std::fs::File;
use std::io::{stdout, stderr, copy, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{ps} */ r#"
NAME
ps - report a snapshot of the current processes
... |
let mut file = File::open("sys:/context").try(&mut stderr);
copy(&mut file, &mut stdout).try(&mut stderr);
}
| {
stdout.write(MAN_PAGE.as_bytes()).try(&mut stderr);
stdout.flush().try(&mut stderr);
exit(0);
} | 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/. */
//! Text layout.
#![deny(unsafe_block)]
use fragment::{Fragment, ScannedTextFragmentInfo, UnscannedTextFragment}... |
}
/// Returns the metrics of the font represented by the given `FontStyle`, respectively.
///
/// `#[inline]` because often the caller only needs a few fields from the font metrics.
#[inline]
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<FontStyle>)
-> Fo... | {
// This does nothing, but it will fail to build
// when more values are added to the `text-orientation` CSS property.
// This will be a reminder to update the code below.
let dummy: Option<text_orientation::T> = None;
match dummy {
Some(text_orientation::sideways_right) |
Some(tex... | 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/. */
//! Text layout.
#![deny(unsafe_block)]
use fragment::{Fragment, ScannedTextFragmentInfo, UnscannedTextFragment}... | // First, transform/compress text of all the nodes.
let mut run_text = String::new();
for in_fragment in self.clump.iter() {
let in_fragment = match in_fragment.specific {
UnscannedTextFragment(ref text_fragment_info) => &text_fragment_info.text,
... | white_space::normal | white_space::nowrap => CompressWhitespaceNewline,
white_space::pre => CompressNone,
}
}
| 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/. */
//! Text layout.
#![deny(unsafe_block)]
use fragment::{Fragment, ScannedTextFragmentInfo, UnscannedTextFragment}... | (metrics: &RunMetrics, writing_mode: WritingMode)
-> LogicalSize<Au> {
// This does nothing, but it will fail to build
// when more values are added to the `text-orientation` CSS property.
// This will be a reminder to update the code below.
let dummy: Option<text_orient... | bounding_box_for_run_metrics | identifier_name |
interval_timer.rs | //! Timer to keep track of repeating intervals.
/// This struct keeps track of passage of repeated intervals (like bars of music).
pub struct IntervalTimer {
every: u64,
next: u64,
}
impl IntervalTimer {
#[allow(missing_docs)]
pub fn new(every: u64, next: u64) -> IntervalTimer {
IntervalTimer {
ever... | #[inline]
/// Returns the number of intervals that have elapsed since last `update`.
pub fn update(&mut self, current: u64) -> u64 {
if current < self.next {
0
} else {
let r = 1 + (current - self.next) / self.every;
self.next += self.every * r;
r
}
}
}
#[test]
fn simple() {... | }
}
| random_line_split |
interval_timer.rs | //! Timer to keep track of repeating intervals.
/// This struct keeps track of passage of repeated intervals (like bars of music).
pub struct IntervalTimer {
every: u64,
next: u64,
}
impl IntervalTimer {
#[allow(missing_docs)]
pub fn | (every: u64, next: u64) -> IntervalTimer {
IntervalTimer {
every: every,
next: next,
}
}
#[inline]
/// Returns the number of intervals that have elapsed since last `update`.
pub fn update(&mut self, current: u64) -> u64 {
if current < self.next {
0
} else {
let r = 1 + (... | new | identifier_name |
interval_timer.rs | //! Timer to keep track of repeating intervals.
/// This struct keeps track of passage of repeated intervals (like bars of music).
pub struct IntervalTimer {
every: u64,
next: u64,
}
impl IntervalTimer {
#[allow(missing_docs)]
pub fn new(every: u64, next: u64) -> IntervalTimer {
IntervalTimer {
ever... | else {
let r = 1 + (current - self.next) / self.every;
self.next += self.every * r;
r
}
}
}
#[test]
fn simple() {
let mut timer = IntervalTimer::new(3, 3);
let mut time = 2;
assert_eq!(timer.update(time), 0);
time += 2;
assert_eq!(timer.update(time), 1);
time += 2;
assert_eq!(tim... | {
0
} | conditional_block |
issue-2111.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 | match (a,b) {
//~^ ERROR: non-exhaustive patterns: `(None, None)` not covered
(Some(a), Some(b)) if a == b => { }
(Some(_), None) |
(None, Some(_)) => { }
}
}
fn main() {
foo(None, None);
} | // <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 foo(a: Option<uint>, b: Option<uint>) { | random_line_split |
issue-2111.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 ... | () {
foo(None, None);
}
| main | identifier_name |
issue-2111.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 ... | {
foo(None, None);
} | identifier_body | |
custom_stream.rs | use std::io::Result as IoResult;
use std::io::{Read, Write};
pub struct | <R, W> {
reader: R,
writer: W,
}
impl<R, W> CustomStream<R, W>
where
R: Read,
W: Write,
{
pub fn new(reader: R, writer: W) -> CustomStream<R, W> {
CustomStream { reader, writer }
}
}
impl<R, W> Read for CustomStream<R, W>
where
R: Read,
{
fn read(&mut self, buf: &mut [u8]) -> I... | CustomStream | identifier_name |
custom_stream.rs | use std::io::Result as IoResult;
use std::io::{Read, Write};
pub struct CustomStream<R, W> {
reader: R,
writer: W,
}
impl<R, W> CustomStream<R, W>
where
R: Read,
W: Write,
{
pub fn new(reader: R, writer: W) -> CustomStream<R, W> {
CustomStream { reader, writer }
}
}
impl<R, W> Read fo... | } | }
fn flush(&mut self) -> IoResult<()> {
self.writer.flush()
} | random_line_split |
expander.rs | // Our use cases
use super::stream;
pub const WAVE_FORMAT_PCM: usize = 1;
#[derive(Default)]
pub struct WaveFormatEx {
pub format_tag: u16,
pub channels: u16,
pub samples_per_second: i32,
pub average_bytes_per_second: i32,
pub block_align: u16,
pub bits_per_sample: u16,
pub cb_size: u16,
}... | () -> SoundExpander {
let wave_format: WaveFormatEx = Default::default();
SoundExpander {
memb_20: 0,
memb_24: 0,
memb_28: 0,
memb_30: 0,
memb_34: 0,
memb_40: 0,
memb_48: 0,
memb_4C: 0,
memb_54: 0,
memb_58: 0,
memb_5C: 0,
memb_64: 0,
memb_68: 0,
memb_70: 0,
memb_7... | new | identifier_name |
expander.rs | // Our use cases
use super::stream;
pub const WAVE_FORMAT_PCM: usize = 1;
#[derive(Default)]
pub struct WaveFormatEx {
pub format_tag: u16,
pub channels: u16,
pub samples_per_second: i32,
pub average_bytes_per_second: i32,
pub block_align: u16,
pub bits_per_sample: u16,
pub cb_size: u16,
}... | }
} | some_var_6680EC: 0,
some_var_6680E8: 0,
previous: Box::new(SoundExpander::new()),
next: Box::new(SoundExpander::new()),
} | random_line_split |
record.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 api::{ApiMsg, FrameMsg, SceneMsg};
use bincode::serialize;
use byteorder::{LittleEndian, WriteBytesExt};
use s... |
fn write_length_and_data(&mut self, data: &[u8]) {
self.file.write_u32::<LittleEndian>(data.len() as u32).ok();
self.file.write(data).ok();
}
}
impl ApiRecordingReceiver for BinaryRecorder {
fn write_msg(&mut self, _: u32, msg: &ApiMsg) {
if should_record_msg(msg) {
le... | {
let mut file = File::create(dest).unwrap();
// write the header
let apimsg_type_id = unsafe {
assert!(mem::size_of::<TypeId>() == mem::size_of::<u64>());
mem::transmute::<TypeId, u64>(TypeId::of::<ApiMsg>())
};
file.write_u64::<LittleEndian>(WEBRENDER_R... | identifier_body |
record.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 api::{ApiMsg, FrameMsg, SceneMsg};
use bincode::serialize;
use byteorder::{LittleEndian, WriteBytesExt};
use s... | (&mut self, _: u32, msg: &ApiMsg) {
if should_record_msg(msg) {
let buf = serialize(msg).unwrap();
self.write_length_and_data(&buf);
}
}
fn write_payload(&mut self, _: u32, data: &[u8]) {
// signal payload with a 0 length
self.file.write_u32::<LittleEndia... | write_msg | identifier_name |
record.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 api::{ApiMsg, FrameMsg, SceneMsg};
use bincode::serialize;
use byteorder::{LittleEndian, WriteBytesExt};
use s... | SceneMsg::SetDisplayList {.. } |
SceneMsg::SetRootPipeline {.. } => return true,
_ => {}
}
}
for msg in &msgs.frame_ops {
match *msg {
FrameMsg::GetScrollNodeState(..) |
... | }
for msg in &msgs.scene_ops {
match *msg { | random_line_split |
gamepad.rs | //! Gamepad utility functions.
//!
//! This is going to be a bit of a work-in-progress as gamepad input
//! gets fleshed out. The `gilrs` crate needs help to add better
//! cross-platform support. Why not give it a hand?
//!
//! TODO: All of this.
use std::fmt;
use gilrs::{Event, Gamepad, Gilrs};
use crate::contex... | assert!(GilrsGamepadContext::new().is_ok());
}
} | mod tests {
use super::*;
#[test]
fn gilrs_init() { | random_line_split |
gamepad.rs | //! Gamepad utility functions.
//!
//! This is going to be a bit of a work-in-progress as gamepad input
//! gets fleshed out. The `gilrs` crate needs help to add better
//! cross-platform support. Why not give it a hand?
//!
//! TODO: All of this.
use std::fmt;
use gilrs::{Event, Gamepad, Gilrs};
use crate::contex... | () -> GameResult<Self> {
let gilrs = Gilrs::new()?;
Ok(GilrsGamepadContext { gilrs })
}
}
impl GamepadContext for GilrsGamepadContext {
fn next_event(&mut self) -> Option<Event> {
self.gilrs.next_event()
}
fn gamepad(&self, id: usize) -> Option<&Gamepad> {
self.gilrs.ge... | new | identifier_name |
c_types.rs | #![allow(dead_code, non_camel_case_types)]
extern crate libc;
use self::libc::{
c_char,
c_int,
uid_t,
time_t
};
use self::libc::funcs::posix88::unistd::getgroups;
use std::vec::Vec;
use std::ptr::read;
use std::str::raw::from_c_str;
pub struct c_passwd {
pub pw_name: *c_char, /* user name... | pub struct utsname {
pub sysname: [c_char,..256],
pub nodename: [c_char,..256],
pub release: [c_char,..256],
pub version: [c_char,..256],
pub machine: [c_char,..256]
}
#[cfg(target_os = "linux")]
pub struct utsname {
pub sysname: [c_char,..65],
pub nodename: [c_char,..65],
pub release: ... | random_line_split | |
c_types.rs | #![allow(dead_code, non_camel_case_types)]
extern crate libc;
use self::libc::{
c_char,
c_int,
uid_t,
time_t
};
use self::libc::funcs::posix88::unistd::getgroups;
use std::vec::Vec;
use std::ptr::read;
use std::str::raw::from_c_str;
pub struct c_passwd {
pub pw_name: *c_char, /* user name... | else {
ngroups = unsafe {
getgroups(NGROUPS, groups.as_mut_ptr() as *mut u32)
};
}
unsafe { groups.set_len(ngroups as uint) };
for &g in groups.iter() {
if nflag {
let group = unsafe { getgrgid(g as u32) };
if group.is_not_null() {
... | {
ngroups = NGROUPS;
unsafe {
getgrouplist(
possible_pw.unwrap().pw_name,
possible_pw.unwrap().pw_gid,
groups.as_ptr(),
&mut ngroups);
}
} | conditional_block |
c_types.rs | #![allow(dead_code, non_camel_case_types)]
extern crate libc;
use self::libc::{
c_char,
c_int,
uid_t,
time_t
};
use self::libc::funcs::posix88::unistd::getgroups;
use std::vec::Vec;
use std::ptr::read;
use std::str::raw::from_c_str;
pub struct c_passwd {
pub pw_name: *c_char, /* user name... | {
pub sysname: [c_char,..256],
pub nodename: [c_char,..256],
pub release: [c_char,..256],
pub version: [c_char,..256],
pub machine: [c_char,..256]
}
#[cfg(target_os = "linux")]
pub struct utsname {
pub sysname: [c_char,..65],
pub nodename: [c_char,..65],
pub release: [c_char,..65],
... | utsname | identifier_name |
ffi.rs | use std::fmt;
// this extern block links to the libm library
#[link(name = "m")]
extern {
// this is a foreign function
// that computes the square root of a single precision complex number
fn csqrtf(z: Complex) -> Complex;
}
fn main() {
// z = -1 + 0i
let z = Complex { re: -1., im: 0. };
// ... | {
re: f32,
im: f32,
}
impl fmt::Show for Complex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.im < 0. {
write!(f, "{}-{}i", self.re, -self.im)
} else {
write!(f, "{}+{}i", self.re, self.im)
}
}
}
| Complex | identifier_name |
ffi.rs | use std::fmt;
// this extern block links to the libm library
#[link(name = "m")]
extern {
// this is a foreign function
// that computes the square root of a single precision complex number
fn csqrtf(z: Complex) -> Complex;
}
fn main() {
// z = -1 + 0i
let z = Complex { re: -1., im: 0. };
// ... | write!(f, "{}-{}i", self.re, -self.im)
} else {
write!(f, "{}+{}i", self.re, self.im)
}
}
} | if self.im < 0. { | random_line_split |
ffi.rs | use std::fmt;
// this extern block links to the libm library
#[link(name = "m")]
extern {
// this is a foreign function
// that computes the square root of a single precision complex number
fn csqrtf(z: Complex) -> Complex;
}
fn main() {
// z = -1 + 0i
let z = Complex { re: -1., im: 0. };
// ... |
}
}
| {
write!(f, "{}+{}i", self.re, self.im)
} | conditional_block |
ffi.rs | use std::fmt;
// this extern block links to the libm library
#[link(name = "m")]
extern {
// this is a foreign function
// that computes the square root of a single precision complex number
fn csqrtf(z: Complex) -> Complex;
}
fn main() |
// Minimal implementation of single precision complex numbers
#[repr(C)]
struct Complex {
re: f32,
im: f32,
}
impl fmt::Show for Complex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.im < 0. {
write!(f, "{}-{}i", self.re, -self.im)
} else {
write... | {
// z = -1 + 0i
let z = Complex { re: -1., im: 0. };
// calling a foreign function is an unsafe operation
let z_sqrt = unsafe {
csqrtf(z)
};
println!("the square root of {} is {}", z, z_sqrt);
} | identifier_body |
main.rs | #![feature(slice_patterns, convert, vec_push_all)]
extern crate md5;
mod keys;
use keys::*;
fn | () {
// capture arguments
let key = match get_key_from_args() {
Ok(k) => k,
Err(why) => {
handle_errors(why);
return;
},
};
// separate key into segments xxxxx-xxxxx-xxxxx
let segments = match get_key_segments(key.as_ref()) {
Ok(s) => s,
Err(why) => {
handle_errors(why);
return;
},
};
/... | main | identifier_name |
main.rs | #![feature(slice_patterns, convert, vec_push_all)]
extern crate md5;
mod keys;
use keys::*;
fn main() {
// capture arguments
let key = match get_key_from_args() {
Ok(k) => k,
Err(why) => {
handle_errors(why);
return;
},
};
// separate key into segments xxxxx-xxxxx-xxxxx
let segments = match get_key_... | },
};
// check segment 3
let _ = match check_segment3(segments.as_ref(), &mut mod_key) {
Ok(_) => {},
Err(why) => {
handle_errors(why);
return;
},
};
if check_final(mod_key.as_ref()) {
print_key(&segments);
print_key(&mod_key);
} else {
println!("You failed to enter the correct key");
}
} | Ok(_) => {},
Err(why) => {
handle_errors(why);
return; | random_line_split |
main.rs | #![feature(slice_patterns, convert, vec_push_all)]
extern crate md5;
mod keys;
use keys::*;
fn main() | let mut mod_key = match check_segment1(segments.as_ref()) {
Ok(s) => s,
Err(why) => {
handle_errors(why);
return;
},
};
// check segment 2 and store result in seg
let _ = match check_segment2(segments.as_ref(), &mut mod_key) {
Ok(_) => {},
Err(why) => {
handle_errors(why);
return;
},
};
... | {
// capture arguments
let key = match get_key_from_args() {
Ok(k) => k,
Err(why) => {
handle_errors(why);
return;
},
};
// separate key into segments xxxxx-xxxxx-xxxxx
let segments = match get_key_segments(key.as_ref()) {
Ok(s) => s,
Err(why) => {
handle_errors(why);
return;
},
};
// c... | identifier_body |
apic.rs | use common::*;
use arch::init::{LOCAL_APIC_PAGE_VADDR, IO_APIC_PAGE_VADDR};
use util::{Mutex};
use super::{InterruptVector};
/// Local APIC pointer.
#[derive(Debug)]
pub struct LocalAPIC {
address: VAddr,
}
/// I/O APIC pointer.
#[derive(Debug)]
pub struct IOAPIC {
address: VAddr,
}
/// The local APIC static... | /// `reg` must be valid.
unsafe fn write(&mut self, reg: u32, value: u32) {
use core::intrinsics::{volatile_store};
volatile_store((self.address.into(): usize + reg as usize) as *mut u32, value);
}
/// APIC id.
pub fn id(&self) -> u32 {
unsafe { self.read(0x20) }
}
... | /// Write a value to the local APIC.
///
/// # Safety
/// | random_line_split |
apic.rs | use common::*;
use arch::init::{LOCAL_APIC_PAGE_VADDR, IO_APIC_PAGE_VADDR};
use util::{Mutex};
use super::{InterruptVector};
/// Local APIC pointer.
#[derive(Debug)]
pub struct LocalAPIC {
address: VAddr,
}
/// I/O APIC pointer.
#[derive(Debug)]
pub struct IOAPIC {
address: VAddr,
}
/// The local APIC static... | (&self) -> u32 {
unsafe { self.read(0x1) }
}
/// I/O APIC arbitration id.
pub fn arbitration_id(&self) -> u32 {
unsafe { self.read(0x2) }
}
/// Set IRQ to an interrupt vector.
pub fn set_irq(&mut self, irq: u8, apic_id: u8, vector: InterruptVector) {
let vector = vector... | version | identifier_name |
apic.rs | use common::*;
use arch::init::{LOCAL_APIC_PAGE_VADDR, IO_APIC_PAGE_VADDR};
use util::{Mutex};
use super::{InterruptVector};
/// Local APIC pointer.
#[derive(Debug)]
pub struct LocalAPIC {
address: VAddr,
}
/// I/O APIC pointer.
#[derive(Debug)]
pub struct IOAPIC {
address: VAddr,
}
/// The local APIC static... |
/// I/O APIC arbitration id.
pub fn arbitration_id(&self) -> u32 {
unsafe { self.read(0x2) }
}
/// Set IRQ to an interrupt vector.
pub fn set_irq(&mut self, irq: u8, apic_id: u8, vector: InterruptVector) {
let vector = vector as u8;
let low_index: u32 = 0x10 + (irq as u32... | {
unsafe { self.read(0x1) }
} | identifier_body |
issue-29037.rs | // Copyright 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-MIT or ... |
fn b<'r, 'w>(x: &'w &'static str) -> &'w &'r str {
x
}
fn c<'r>(x: Arc<&'static str>) -> Arc<&'r str> {
x
}
fn d<'r>(x: Rc<&'static str>) -> Rc<&'r str> {
x
}
fn main() {} | x
} | random_line_split |
issue-29037.rs | // Copyright 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-MIT or ... |
fn main() {}
| {
x
} | identifier_body |
issue-29037.rs | // Copyright 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-MIT or ... | () {}
| main | identifier_name |
main.rs | // Copyright 2015 Google Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, ... | (text: &str, opts: Options) -> String {
let mut s = String::with_capacity(text.len() * 3 / 2);
let p = Parser::new_ext(&text, opts);
html::push_html(&mut s, p);
s
}
fn dry_run(text:&str, opts: Options) {
let p = Parser::new_ext(&text, opts);
/*
let events = p.collect::<Vec<_>>();
let co... | render_html | identifier_name |
main.rs | // Copyright 2015 Google Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, ... | else if line_count > 0 {
print!(" ");
}
print!("[{}]", test_number);
} else if line_count > 0 && (test_number % 10) == 5 {
print!(" ");
}
let our_html = render_html(&source.replace("→", "\t").replace("\n", "\r\n"), ... | {
println!("");
line_count = 0;
} | conditional_block |
main.rs | // Copyright 2015 Google Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, ... | run_spec(&read_file(&filename), &matches.free, opts);
} else if let Some(filename) = matches.opt_str("bench") {
let inp = read_file(&filename);
for _ in 0..1000 {
let _ = render_html(&inp, opts);
}
} else {
let mut input = String::new();
match io::stdi... | let args: Vec<_> = env::args().collect();
let mut opts = getopts::Options::new();
opts.optflag("d", "dry-run", "dry run, produce no output");
opts.optflag("e", "events", "print event sequence instead of rendering");
opts.optflag("T", "enable-tables", "enable GitHub-style tables");
opts.optflag("... | identifier_body |
main.rs | // Copyright 2015 Google Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, ... | } else {
print!("X");
}
tests_failed += 1;
}
let _ = io::stdout().flush();
tests_run += 1;
line_count += 1;
}
tail = rest;
test_number += 1;
}
println!("\n{}/{} tests passe... | if tests_failed == 0 {
print!("FAIL {}:\n---input---\n{}\n---wanted---\n{}\n---got---\n{}",
test_number, source, html, our_html); | random_line_split |
chunks.rs | use std::ops::{ Index, IndexMut };
use std::collections::HashMap;
use cgmath::{ Point, Point3 };
use super::chunk::Chunk;
pub type ChunkPos = Point3<i32>;
#[derive(Debug)]
pub struct Chunks {
chunks: HashMap<ChunkPos, Chunk>,
empty: Chunk,
}
impl Chunks {
pub fn new() -> Chunks {
Chunks {
... |
}
| {
self.chunks.entry(index).or_insert_with(Chunk::new)
} | identifier_body |
chunks.rs | use std::ops::{ Index, IndexMut };
use std::collections::HashMap;
use cgmath::{ Point, Point3 };
use super::chunk::Chunk;
pub type ChunkPos = Point3<i32>;
#[derive(Debug)]
pub struct Chunks {
chunks: HashMap<ChunkPos, Chunk>,
empty: Chunk,
}
impl Chunks {
pub fn | () -> Chunks {
Chunks {
chunks: HashMap::new(),
empty: Chunk::new(),
}
}
pub fn around(dist: u8, center: ChunkPos) -> Vec<ChunkPos> {
let mut res = Vec::new();
let dist = dist as i32;
for x in -dist + 1..dist {
for y in -dist + 1..dist... | new | identifier_name |
chunks.rs | use std::ops::{ Index, IndexMut };
use std::collections::HashMap;
use cgmath::{ Point, Point3 };
use super::chunk::Chunk;
pub type ChunkPos = Point3<i32>;
#[derive(Debug)]
pub struct Chunks {
chunks: HashMap<ChunkPos, Chunk>,
empty: Chunk,
} | Chunks {
chunks: HashMap::new(),
empty: Chunk::new(),
}
}
pub fn around(dist: u8, center: ChunkPos) -> Vec<ChunkPos> {
let mut res = Vec::new();
let dist = dist as i32;
for x in -dist + 1..dist {
for y in -dist + 1..dist {
... |
impl Chunks {
pub fn new() -> Chunks { | random_line_split |
build.rs | use std::env;
use std::process::Command;
fn main() {
if std::env::var("DOCS_RS").is_ok() {
// Skip everything when building docs on docs.rs
return;
}
// On Windows Rust always links against release version of MSVC runtime, thus requires Release
// build here.
let build_type = if cf... | println!("cargo:rustc-link-lib=static=mediasoup-worker");
println!("cargo:rustc-link-search=native={}", out_dir);
}
| // Clean
if !Command::new("make")
.arg("clean-all")
.env("MEDIASOUP_OUT_DIR", &mediasoup_out_dir)
.spawn()
.expect("Failed to start")
.wait()
.expect("Wasn't running")
.success()
{
panic!("Failed to cl... | conditional_block |
build.rs | use std::env;
use std::process::Command;
fn | () {
if std::env::var("DOCS_RS").is_ok() {
// Skip everything when building docs on docs.rs
return;
}
// On Windows Rust always links against release version of MSVC runtime, thus requires Release
// build here.
let build_type = if cfg!(all(debug_assertions, not(windows))) {
... | main | identifier_name |
build.rs | use std::env;
use std::process::Command;
fn main() | {
let path = Command::new(env::var("CXX").unwrap_or_else(|_| "c++".to_string()))
.arg("--print-file-name=libstdc++.a")
.output()
.expect("Failed to start")
.stdout;
println!(
"cargo:rustc-link-search=native={}",
String::from_utf8_lo... | {
if std::env::var("DOCS_RS").is_ok() {
// Skip everything when building docs on docs.rs
return;
}
// On Windows Rust always links against release version of MSVC runtime, thus requires Release
// build here.
let build_type = if cfg!(all(debug_assertions, not(windows))) {
"D... | identifier_body |
build.rs | use std::env; |
fn main() {
if std::env::var("DOCS_RS").is_ok() {
// Skip everything when building docs on docs.rs
return;
}
// On Windows Rust always links against release version of MSVC runtime, thus requires Release
// build here.
let build_type = if cfg!(all(debug_assertions, not(windows))) {... | use std::process::Command; | random_line_split |
config.rs | // Copyright 2020 The Exonum Team
//
// 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 agreed to i... | .build();
(testkit, mock_provider)
}
/// Creates block with `ConfigPropose` tx and returns `Result` with new
/// configuration or corresponding `ExecutionError`.
async fn propose_configuration(
testkit: &mut TestKit,
config: Config,
) -> Result<(), ExecutionError> {
let tx = ConfigPropose::imm... | {
let mock_provider = MockTimeProvider::new(SystemTime::now().into());
let time_service = TimeServiceFactory::with_provider(mock_provider.clone());
let mut time_service =
Spec::new(time_service).with_instance(TIME_SERVICE_ID, TIME_SERVICE_NAME, ());
if second_time_service {
time_service ... | identifier_body |
config.rs | // Copyright 2020 The Exonum Team
//
// 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 agreed to i... | (second_time_service: bool) -> (TestKit, MockTimeProvider) {
let mock_provider = MockTimeProvider::new(SystemTime::now().into());
let time_service = TimeServiceFactory::with_provider(mock_provider.clone());
let mut time_service =
Spec::new(time_service).with_instance(TIME_SERVICE_ID, TIME_SERVICE_NA... | init_testkit | identifier_name |
config.rs | // Copyright 2020 The Exonum Team
//
// 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 agreed to i... |
// Propose configuration with invalid time service name.
let err = propose_configuration(&mut testkit, config)
.await
.expect_err("Configuration proposal should fail.");
let expected_err =
ErrorMatch::from_fail(&CoreError::IncorrectInstanceId).with_any_descrip... | random_line_split | |
config.rs | // Copyright 2020 The Exonum Team
//
// 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 agreed to i... |
let config = Config {
time_service_name: TIME_SERVICE_NAME.to_owned(),
};
let timestamping =
Spec::new(TimestampingService).with_instance(SERVICE_ID, SERVICE_NAME, config);
let testkit = TestKitBuilder::validator()
.with(Supervisor::simple())
.with(time_service)
.... | {
time_service =
time_service.with_instance(SECOND_TIME_SERVICE_ID, SECOND_TIME_SERVICE_NAME, ());
} | conditional_block |
regex.rs | #![allow(unused)]
#![warn(clippy::invalid_regex, clippy::trivial_regex)]
extern crate regex;
use regex::bytes::{Regex as BRegex, RegexBuilder as BRegexBuilder, RegexSet as BRegexSet};
use regex::{Regex, RegexBuilder, RegexSet};
const OPENING_PAREN: &str = "(";
const NOT_A_REAL_REGEX: &str = "foobar";
fn syntax_erro... | {
syntax_error();
trivial_regex();
}
| in() | identifier_name |
regex.rs | #![allow(unused)]
#![warn(clippy::invalid_regex, clippy::trivial_regex)]
extern crate regex;
use regex::bytes::{Regex as BRegex, RegexBuilder as BRegexBuilder, RegexSet as BRegexSet};
use regex::{Regex, RegexBuilder, RegexSet};
const OPENING_PAREN: &str = "(";
const NOT_A_REAL_REGEX: &str = "foobar";
fn syntax_erro... | let trivial_eq_builder = RegexBuilder::new("^foobar$");
let trivial_starts_with = Regex::new("^foobar");
let trivial_ends_with = Regex::new("foobar$");
let trivial_contains = Regex::new("foobar");
let trivial_contains = Regex::new(NOT_A_REAL_REGEX);
let trivial_backslash = Regex::new("a\\.b... |
fn trivial_regex() {
let trivial_eq = Regex::new("^foobar$");
| random_line_split |
regex.rs | #![allow(unused)]
#![warn(clippy::invalid_regex, clippy::trivial_regex)]
extern crate regex;
use regex::bytes::{Regex as BRegex, RegexBuilder as BRegexBuilder, RegexSet as BRegexSet};
use regex::{Regex, RegexBuilder, RegexSet};
const OPENING_PAREN: &str = "(";
const NOT_A_REAL_REGEX: &str = "foobar";
fn syntax_erro... | ]);
let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]);
let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]);
let raw_string_error = Regex::new(r"[...\/...]");
let raw_string_error = Regex::new(r#"[...\/...]"#);
}
fn trivial_regex() {
let trivial_... | {
let pipe_in_wrong_position = Regex::new("|");
let pipe_in_wrong_position_builder = RegexBuilder::new("|");
let wrong_char_ranice = Regex::new("[z-a]");
let some_unicode = Regex::new("[é-è]");
let some_regex = Regex::new(OPENING_PAREN);
let binary_pipe_in_wrong_position = BRegex::new("|");
... | identifier_body |
htmlstyleelement.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 cssparser::Parser as CssParser;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTM... | fn super_type(&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
fn children_changed(&self, mutation: &ChildrenMutation) {
if let Some(ref s) = self.super_type() {
s.children_changed(mutation);
}
if self.upcast::<Node>().i... | random_line_split | |
htmlstyleelement.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 cssparser::Parser as CssParser;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTM... |
if tree_in_doc {
self.parse_own_css();
}
}
}
| {
s.bind_to_tree(tree_in_doc);
} | conditional_block |
htmlstyleelement.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 cssparser::Parser as CssParser;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTM... |
#[allow(unrooted_must_root)]
pub fn new(local_name: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLStyleElement> {
Node::reflect_node(box HTMLStyleElement::new_inherited(local_name, prefix, document),
document,
... | {
HTMLStyleElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
stylesheet: DOMRefCell::new(None),
}
} | identifier_body |
htmlstyleelement.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 cssparser::Parser as CssParser;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTM... | (&self) {
let node = self.upcast::<Node>();
let element = self.upcast::<Element>();
assert!(node.is_in_doc());
let win = window_from_node(node);
let url = win.get_url();
let mq_attribute = element.get_attribute(&ns!(), &atom!("media"));
let mq_str = match mq_att... | parse_own_css | identifier_name |
common.rs | use std::io::Read;
use std::io::Write;
use std::fs::File;
use std::fs::OpenOptions;
use std::fs;
use std::path::PathBuf;
use std::path::Path;
const IT_PATH: &str = "it";
pub const BINARY_PATH: &str = "target/debug/prep";
pub fn get_file_content(file: &str) -> String {
let path_buf = pb(file);
let mut file = F... | TestFs::create(&entities)
} | random_line_split | |
common.rs | use std::io::Read;
use std::io::Write;
use std::fs::File;
use std::fs::OpenOptions;
use std::fs;
use std::path::PathBuf;
use std::path::Path;
const IT_PATH: &str = "it";
pub const BINARY_PATH: &str = "target/debug/prep";
pub fn get_file_content(file: &str) -> String {
let path_buf = pb(file);
let mut file = F... | {
TestFs::create(&entities)
} | identifier_body | |
common.rs | use std::io::Read;
use std::io::Write;
use std::fs::File;
use std::fs::OpenOptions;
use std::fs;
use std::path::PathBuf;
use std::path::Path;
const IT_PATH: &str = "it";
pub const BINARY_PATH: &str = "target/debug/prep";
pub fn get_file_content(file: &str) -> String {
let path_buf = pb(file);
let mut file = F... |
&FsEntity::File(ref pb) => {
File::create(pb).unwrap();
}
}
}
TestFs {}
}
}
pub fn pb<P: AsRef<Path>>(p: P) -> PathBuf {
let mut pb = PathBuf::from("it/");
pb.push(p);
pb
}
pub fn td<P: AsRef<Path>>(p: P) -> FsEntity {
... | {
fs::create_dir_all(pb).unwrap();
} | conditional_block |
common.rs | use std::io::Read;
use std::io::Write;
use std::fs::File;
use std::fs::OpenOptions;
use std::fs;
use std::path::PathBuf;
use std::path::Path;
const IT_PATH: &str = "it";
pub const BINARY_PATH: &str = "target/debug/prep";
pub fn get_file_content(file: &str) -> String {
let path_buf = pb(file);
let mut file = F... | <P: AsRef<Path>>(p: P) -> PathBuf {
let mut pb = PathBuf::from("it/");
pb.push(p);
pb
}
pub fn td<P: AsRef<Path>>(p: P) -> FsEntity {
FsEntity::Dir(pb(p))
}
pub fn tf<P: AsRef<Path>>(p: P) -> FsEntity {
FsEntity::File(pb(p))
}
pub fn setup(entities: &[FsEntity]) -> TestFs {
TestFs::create(&ent... | pb | identifier_name |
msid.rs | #[doc = "Register `MSID[%s]` reader"]
pub struct R(crate::R<MSID_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<MSID_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<MSID_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<MSI... | (&self) -> INDEX_R {
INDEX_R::new((self.bits & 0x3f) as u8)
}
}
#[doc = "Message Index Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [msid](index.html) module"]
pub struct MSI... | index | identifier_name |
msid.rs | #[doc = "Register `MSID[%s]` reader"]
pub struct R(crate::R<MSID_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<MSID_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<MSID_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<MSI... | INDEX_R::new((self.bits & 0x3f) as u8)
}
}
#[doc = "Message Index Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [msid](index.html) module"]
pub struct MSID_SPEC;
impl crate::R... | #[inline(always)]
pub fn index(&self) -> INDEX_R { | random_line_split |
main.rs | use std::error;
use std::io;
fn get_sum(input: String) -> Result<i32, Box<dyn error::Error>> {
let numbers = input
.split_whitespace()
.map(|number| number.parse())
.collect::<Result<Vec<i32>, _>>()?;
if numbers.len() == 2 | else {
Err("Please enter 2 integers".into())
}
}
fn main() -> Result<(), Box<dyn error::Error>> {
let mut input = String::new();
io::stdin().read_line(&mut input)?;
let sum = get_sum(input)?;
println!("{}", sum);
Ok(())
}
#[cfg(test)]
mod tests {
use super::get_sum;
#[test]
... | {
Ok(numbers.iter().sum())
} | conditional_block |
main.rs | use std::error;
use std::io;
fn get_sum(input: String) -> Result<i32, Box<dyn error::Error>> {
let numbers = input
.split_whitespace()
.map(|number| number.parse())
.collect::<Result<Vec<i32>, _>>()?;
if numbers.len() == 2 {
Ok(numbers.iter().sum())
} else {
Err("Pleas... | let output = get_sum(input);
assert_eq!(output.is_err(), true);
}
} | let output = get_sum(input);
assert_eq!(output.is_err(), true);
let input = "".to_string(); | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.