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 |
|---|---|---|---|---|
applicable_declarations.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Applicable declarations management.
use properties::PropertyDeclarationBlock;
use rule_tree::{CascadeLevel, S... | order_and_level: SourceOrderAndCascadeLevel::new(order, level),
specificity: specificity,
}
}
/// Returns the source order of the block.
#[inline]
pub fn source_order(&self) -> u32 {
self.order_and_level.order()
}
/// Returns the cascade level of the blo... | /// Constructs an applicable declaration block from the given components
#[inline]
pub fn new(source: StyleSource, order: u32, level: CascadeLevel, specificity: u32) -> Self {
ApplicableDeclarationBlock {
source: source, | random_line_split |
asteroid.rs | pub struct Asteroid {
position: (f32, f32),
velocity: (f32, f32),
radius: f32,
}
impl Asteroid {
pub fn update(&mut self) {
self.position.0 += self.velocity.0;
self.position.1 += self.velocity.1;
}
pub fn pos(&self) -> (f32, f32) {
self.position.clone()
}
pub f... | }
pub fn new() -> Asteroid {
Asteroid {
position: (0.0, 0.0),
velocity: (0.0, 0.0),
radius: 10.0,
}
}
pub fn new_with_attr(pos: (f32, f32), vel: (f32, f32), rad: f32) -> Asteroid {
Asteroid {
position: pos,
velocity: v... | self.position.1 > height) | random_line_split |
asteroid.rs | pub struct Asteroid {
position: (f32, f32),
velocity: (f32, f32),
radius: f32,
}
impl Asteroid {
pub fn update(&mut self) {
self.position.0 += self.velocity.0;
self.position.1 += self.velocity.1;
}
pub fn pos(&self) -> (f32, f32) {
self.position.clone()
}
pub f... |
}
pub const INDICES: [u16; 1074] =
[0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 7, 0, 7, 8,
0, 8, 9, 0, 9, 10, 0, 10, 11, 0, 11, 12, 0, 12, 13, 0, 13, 14,
0, 14, 15, 0, 15, 16, 0, 16, 17, 0, 17, 18, 0, 18, 19, 0, 19,
20, 0, 20, 21, 0, 21, 22, 0, 22, 23, 0, 23, 24, 0, 24, 25, 0,
25, 26, ... | {
Asteroid {
position: pos,
velocity: vel,
radius: rad,
}
} | identifier_body |
asteroid.rs | pub struct Asteroid {
position: (f32, f32),
velocity: (f32, f32),
radius: f32,
}
impl Asteroid {
pub fn update(&mut self) {
self.position.0 += self.velocity.0;
self.position.1 += self.velocity.1;
}
pub fn pos(&self) -> (f32, f32) {
self.position.clone()
}
pub f... | (&self) -> f32 {
self.radius
}
pub fn still_alive(&self, width: f32, height: f32) -> bool {
!(self.position.0 < -width || self.position.0 > width || self.position.1 < -height ||
self.position.1 > height)
}
pub fn new() -> Asteroid {
Asteroid {
position: (0.... | radius | identifier_name |
basic-types-globals.rs | // Caveats - gdb prints any 8-bit value (meaning rust I8 and u8 values)
// as its numerical value along with its associated ASCII char, there
// doesn't seem to be any way around this. Also, gdb doesn't know
// about UTF-32 character encoding and will print a rust char as only
// its numerical value.
// min-lldb-versi... | {()} | identifier_body | |
basic-types-globals.rs | // Caveats - gdb prints any 8-bit value (meaning rust I8 and u8 values)
// as its numerical value along with its associated ASCII char, there
// doesn't seem to be any way around this. Also, gdb doesn't know
// about UTF-32 character encoding and will print a rust char as only
// its numerical value.
// min-lldb-versi... | // gdb-check:$1 = false
// gdbg-command:print 'basic_types_globals::I'
// gdbr-command:print I
// gdb-check:$2 = -1
// gdbg-command:print 'basic_types_globals::C'
// gdbr-command:print C
// gdbg-check:$3 = 97
// gdbr-check:$3 = 97 'a'
// gdbg-command:print/d 'basic_types_globals::I8'
// gdbr-command:print I8
// gdb-che... | // gdbr-command:print B | random_line_split |
basic-types-globals.rs | // Caveats - gdb prints any 8-bit value (meaning rust I8 and u8 values)
// as its numerical value along with its associated ASCII char, there
// doesn't seem to be any way around this. Also, gdb doesn't know
// about UTF-32 character encoding and will print a rust char as only
// its numerical value.
// min-lldb-versi... | () {()}
| _zzz | identifier_name |
process-detach.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
unsafe { libc::setsid(); }
let config = process::ProcessConfig {
program : "/bin/sh",
args: &[~"-c", ~"read a"],
detach: true,
.. process::ProcessConfig::new()
};
// we shouldn't die because of an interrupt
let mut l = Listener::new();
l.register(Interrupt).... | main | identifier_name |
process-detach.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 ... | // we shouldn't die because of an interrupt
let mut l = Listener::new();
l.register(Interrupt).unwrap();
// spawn the child
let mut p = process::Process::configure(config).unwrap();
// send an interrupt to everyone in our process group
unsafe { libc::funcs::posix88::signal::kill(0, libc::S... | args: &[~"-c", ~"read a"],
detach: true,
.. process::ProcessConfig::new()
};
| random_line_split |
process-detach.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 ... | // Wait for the child process to die (terminate it's stdin and the read
// should fail).
drop(p.stdin.take());
match p.wait() {
process::ExitStatus(..) => {}
process::ExitSignal(..) => fail!()
}
}
| {
unsafe { libc::setsid(); }
let config = process::ProcessConfig {
program : "/bin/sh",
args: &[~"-c", ~"read a"],
detach: true,
.. process::ProcessConfig::new()
};
// we shouldn't die because of an interrupt
let mut l = Listener::new();
l.register(Interrupt).un... | identifier_body |
shebang.rs | use crate::errors::*;
use crate::errors::{Error, Result};
use crate::filesystem::FileSystem;
use crate::kernel::execve::params::{Arg, ExecveParameters};
use std::ffi::CString;
use std::io::ErrorKind;
use std::os::unix::prelude::OsStrExt;
use std::path::{Path, PathBuf};
use std::{fs::File, io::Read};
use super::LoadRes... | (host_path: &Path) -> Result<ExtractResult> {
let mut file = File::open(host_path)?;
let mut buffer = [0u8; BINPRM_BUF_SIZE];
// Read bytes from the beginning of the file, allowing the file length to be
// smaller than the buffer length.
if let Err(error) = file.read_exact(&mut buffer) {
if... | extract | identifier_name |
shebang.rs | use crate::errors::*;
use crate::errors::{Error, Result};
use crate::filesystem::FileSystem;
use crate::kernel::execve::params::{Arg, ExecveParameters};
use std::ffi::CString;
use std::io::ErrorKind;
use std::os::unix::prelude::OsStrExt;
use std::path::{Path, PathBuf};
use std::{fs::File, io::Read};
use super::LoadRes... |
// refuse to execute this if not start with #!
match (buffer[0], buffer[1]) {
(b'#', b'!') => {}
_ => {
return Err(Error::errno_with_msg(
ENOEXEC,
"file does not start with a shebang",
))
}
}
// First, calculate the posit... | {
if error.kind() != ErrorKind::UnexpectedEof {
Err(error)?
}
} | conditional_block |
shebang.rs | use crate::errors::*;
use crate::errors::{Error, Result};
use crate::filesystem::FileSystem;
use crate::kernel::execve::params::{Arg, ExecveParameters};
use std::ffi::CString;
use std::io::ErrorKind;
use std::os::unix::prelude::OsStrExt;
use std::path::{Path, PathBuf};
use std::{fs::File, io::Read};
use super::LoadRes... | return Err(Error::errno_with_msg(
EACCES,
"path of interpreter is empty",
));
}
let interpreter = PathBuf::from(
std::str::from_utf8(&buffer[interpreter_start..interpreter_end])
.errno(ENOENT)
.context("path of interpreter is not valid")?,
... |
// Read interpreter
if interpreter_start == interpreter_end { | random_line_split |
lib.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
pub fn setup() {
const WORKSPACE: &str = "INSTA_WORKSPACE_ROOT";
const UPDATE: &str = "INSTA_UPDATE";
if std::env::var(WORKSPAC... | ;
println!(
"{:=^80}\n",
format!(" Run `{}` to update snapshots ", command)
);
let file_name = std::path::Path::new(file)
.file_name()
.and_then(|p| p.to_str())
.unwrap();
insta::_macro_support::assert_snapshot(
test_name.into(),
snapshot,
"un... | {
"buck test ... -- --env INSTA_UPDATE=1"
} | conditional_block |
lib.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
pub fn | () {
const WORKSPACE: &str = "INSTA_WORKSPACE_ROOT";
const UPDATE: &str = "INSTA_UPDATE";
if std::env::var(WORKSPACE).is_err() {
let mut root = std::path::PathBuf::from(file!());
root.pop();
root.pop();
std::env::set_var(WORKSPACE, root);
}
if std::env::var(UPDATE).is... | setup | identifier_name |
lib.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
pub fn setup() |
pub fn run(
test_name: &str,
is_cargo: bool,
snapshot: &str,
file: &str,
module: &str,
line: u32,
expr: &str,
) {
let command = if is_cargo {
"INSTA_UPDATE=1 cargo test..."
} else {
"buck test... -- --env INSTA_UPDATE=1"
};
println!(
"{:=^80}\n",
... | {
const WORKSPACE: &str = "INSTA_WORKSPACE_ROOT";
const UPDATE: &str = "INSTA_UPDATE";
if std::env::var(WORKSPACE).is_err() {
let mut root = std::path::PathBuf::from(file!());
root.pop();
root.pop();
std::env::set_var(WORKSPACE, root);
}
if std::env::var(UPDATE).is_er... | identifier_body |
lib.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
pub fn setup() {
const WORKSPACE: &str = "INSTA_WORKSPACE_ROOT";
const UPDATE: &str = "INSTA_UPDATE";
if std::env::var(WORKSPAC... | }
pub fn run(
test_name: &str,
is_cargo: bool,
snapshot: &str,
file: &str,
module: &str,
line: u32,
expr: &str,
) {
let command = if is_cargo {
"INSTA_UPDATE=1 cargo test..."
} else {
"buck test... -- --env INSTA_UPDATE=1"
};
println!(
"{:=^80}\n",
... | random_line_split | |
use_crate.rs | // aux-build:use_crate.rs
// aux-build:use_crate_2.rs
// build-aux-docs
// edition:2018
// compile-flags:--extern use_crate --extern use_crate_2
// During the buildup to Rust 2018, rustdoc would eagerly inline `pub use some_crate;` as if it
// were a module, so we changed it to make `pub use`ing crate roots remain as ... |
// @has-dir local/use_crate_2
// @has local/use_crate_2/index.html
// @has local/index.html '//a/@href' 'use_crate_2/index.html'
#[doc(inline)]
pub use use_crate_2; | random_line_split | |
lib.rs | //! This crate defines the high-level API for accessing Connected Devices.
#![feature(custom_derive, plugin, stmt_expr_attributes)]
#![plugin(serde_macros)]
#![plugin(clippy)]
// To prevent clippy being noisy with derive(...)
#![allow(used_underscore_binding)]
#[macro_use]
extern crate lazy_static;
extern crate chron... | pub mod io; | random_line_split | |
main.rs |
extern crate clap;
extern crate intcode;
// Time Start: Sun, 22 Dec 2019 09:23:38 -0500
// Time Finish 1: Sun, 22 Dec 2019 17:56:37 -0500 (8 hours, 32 minutes, 59 seconds)
// Time Finish 2:
// Time Total:
use clap::{Arg, App};
use intcode::util::{BBox,Direction,Direction::*};
use std::collections::HashMap;
use std... |
pub fn shortest_path(&self, x: i64, y: i64, valid: impl Fn(i64, i64, i64, char) -> bool, wanted: impl Fn(i64, i64, i64, char) -> bool) -> Option<(i64, i64, Vec<Direction>)> {
let mut todo = VecDeque::new();
let mut seen = HashSet::new();
todo.push_back((x, y, 0, Vec::new()));
loop... | {
self.bbox.update(x, y);
self.map.insert((x, y), obj);
} | identifier_body |
main.rs | extern crate clap;
extern crate intcode;
// Time Start: Sun, 22 Dec 2019 09:23:38 -0500
// Time Finish 1: Sun, 22 Dec 2019 17:56:37 -0500 (8 hours, 32 minutes, 59 seconds)
// Time Finish 2:
// Time Total:
use clap::{Arg, App};
use intcode::util::{BBox,Direction,Direction::*};
use std::collections::HashMap;
use std:... | loop {
let (x, y, level, path) = todo.pop_front()?; // or return None
let spot = self.item_at(x, y);
if wanted(x, y, level, spot) {
return Some((x, y, path));
}
if valid(x, y, level, spot) {
for dir in Direction::each() ... | random_line_split | |
main.rs |
extern crate clap;
extern crate intcode;
// Time Start: Sun, 22 Dec 2019 09:23:38 -0500
// Time Finish 1: Sun, 22 Dec 2019 17:56:37 -0500 (8 hours, 32 minutes, 59 seconds)
// Time Finish 2:
// Time Total:
use clap::{Arg, App};
use intcode::util::{BBox,Direction,Direction::*};
use std::collections::HashMap;
use std... | (fname: &str) -> Chart {
let mut chart = Chart::new();
let contents = fs::read_to_string(fname)
.unwrap_or_else(|err| panic!("Error reading {}: {}", fname, err));
for (j, line) in contents.trim_end_matches('\n').split('\n').enumerate() {
for (i, ch) in line.chars().enumer... | load | identifier_name |
main.rs |
extern crate clap;
extern crate intcode;
// Time Start: Sun, 22 Dec 2019 09:23:38 -0500
// Time Finish 1: Sun, 22 Dec 2019 17:56:37 -0500 (8 hours, 32 minutes, 59 seconds)
// Time Finish 2:
// Time Total:
use clap::{Arg, App};
use intcode::util::{BBox,Direction,Direction::*};
use std::collections::HashMap;
use std... | ;
self.put(x0, y0, sym);
self.portals.insert((x0, y0), (x1, y1));
}
fn near_border(&self, x: i64, y: i64, dist: i64) -> bool {
((x-self.bbox.xmin()).abs() <= dist || (x-self.bbox.xmax()).abs() <= dist)
||
((y-self.bbox.ymin()).abs() <= dist || (y-self.bbox.ymax()).ab... | { '=' } | conditional_block |
cond_chain.rs | use super::*;
use super::super::sim::*;
/// Condition list in the form of an AST node
///
/// This is a reimplementation of `CondList`, as an enum with chained
/// nodes. This node has the same expressiveness as the `CondList`,
/// but has the advantage that it _can_ do crossover splicing between
/// parents in the cu... | (&self, sensor_data: &SensorData) -> Command {
match *self {
CondChain::Cond(ref cond, ref then, ref next) => {
if cond.is_true(sensor_data) {
**then
} else {
next.evaluate(sensor_data)
}
},
... | evaluate | identifier_name |
cond_chain.rs | use super::*;
use super::super::sim::*;
/// Condition list in the form of an AST node
///
/// This is a reimplementation of `CondList`, as an enum with chained
/// nodes. This node has the same expressiveness as the `CondList`,
/// but has the advantage that it _can_ do crossover splicing between
/// parents in the cu... |
},
CondChain::Stop => Command::Skip
}
}
}
| {
next.evaluate(sensor_data)
} | conditional_block |
cond_chain.rs | use super::*;
use super::super::sim::*;
| /// but has the advantage that it _can_ do crossover splicing between
/// parents in the current evolutionary framework.
///
/// A downside of this node type is that the programs tend to grow
/// without bounds, as there is no height control on the crossover
/// operation and crossovers tend to be done most of the time... | /// Condition list in the form of an AST node
///
/// This is a reimplementation of `CondList`, as an enum with chained
/// nodes. This node has the same expressiveness as the `CondList`, | random_line_split |
partition_slice.rs | //! Rearrange the elements in a slice according to a predicate.
/// Rearrange the elements of the mutable slice `s` such that elements where `p(t)` is true precede
/// the elements where `p(t)` is false.
///
/// The order of elements is not preserved, unless the slice is already partitioned.
///
/// Returns the number... |
#[test]
fn longer() {
check(&[1, 2, 3], &[1, 2, 3]);
check(&[1, 2, 10], &[10, 2, 1]); // Note: 2, 1 order not required.
check(&[1, 10, 2], &[10, 1, 2]); // Note: 1, 2 order not required.
check(&[1, 20, 10], &[20, 10, 1]);
check(&[1, 20, 3, 10], &[20, 10, 3, 1]);
... | {
check(&[0, 0], &[0, 0]);
check(&[0, 5], &[0, 5]);
check(&[5, 0], &[0, 5]);
check(&[5, 4], &[5, 4]);
} | identifier_body |
partition_slice.rs | //! Rearrange the elements in a slice according to a predicate.
/// Rearrange the elements of the mutable slice `s` such that elements where `p(t)` is true precede
/// the elements where `p(t)` is false.
///
/// The order of elements is not preserved, unless the slice is already partitioned.
///
/// Returns the number... | <T, F>(s: &mut [T], mut p: F) -> usize
where
F: FnMut(&T) -> bool,
{
// Count the length of the prefix where `p` returns true.
let mut count = match s.iter().position(|t|!p(t)) {
Some(t) => t,
None => return s.len(),
};
// Swap remaining `true` elements into place.
//
// Thi... | partition_slice | identifier_name |
partition_slice.rs | //! Rearrange the elements in a slice according to a predicate.
/// Rearrange the elements of the mutable slice `s` such that elements where `p(t)` is true precede
/// the elements where `p(t)` is false.
///
/// The order of elements is not preserved, unless the slice is already partitioned.
///
/// Returns the number... | // shuffled.
for i in count + 1..s.len() {
if p(&s[i]) {
s.swap(count, i);
count += 1;
}
}
count
}
#[cfg(test)]
mod tests {
use super::partition_slice;
use std::vec::Vec;
fn check(x: &[u32], want: &[u32]) {
assert_eq!(x.len(), want.len());
... | // This actually preserves the order of the `true` elements, but the `false` elements get | random_line_split |
continued_fraction_from_rational.rs | // http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
struct | {
n1: i64,
n2: i64,
}
// This iterator generates the continued fraction representation from the
// specified rational number.
impl Iterator for R2cf {
type Item = i64;
fn next(&mut self) -> Option<i64> {
if self.n2 == 0 {
None
} else {
let t1 = self.n1 / self.n... | R2cf | identifier_name |
continued_fraction_from_rational.rs | // http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
struct R2cf {
n1: i64,
n2: i64,
}
// This iterator generates the continued fraction representation from the
// specified rational number.
impl Iterator for R2cf {
type Item = i64;
fn next(&mut self) -> Option<... | }
fn r2cf(n1: i64, n2: i64) -> R2cf {
R2cf { n1: n1, n2: n2 }
}
macro_rules! printcf {
($x:expr, $y:expr) => (println!("{:?}", r2cf($x, $y).collect::<Vec<_>>()));
}
fn main() {
printcf!(1, 2);
printcf!(3, 1);
printcf!(23, 8);
printcf!(13, 11);
printcf!(22, 7);
printcf!(-152, 77);
... | self.n2 = self.n1 - t1 * t2;
self.n1 = t2;
Some(t1)
}
} | random_line_split |
continued_fraction_from_rational.rs | // http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
struct R2cf {
n1: i64,
n2: i64,
}
// This iterator generates the continued fraction representation from the
// specified rational number.
impl Iterator for R2cf {
type Item = i64;
fn next(&mut self) -> Option<... |
macro_rules! printcf {
($x:expr, $y:expr) => (println!("{:?}", r2cf($x, $y).collect::<Vec<_>>()));
}
fn main() {
printcf!(1, 2);
printcf!(3, 1);
printcf!(23, 8);
printcf!(13, 11);
printcf!(22, 7);
printcf!(-152, 77);
printcf!(14_142, 10_000);
printcf!(141_421, 100_000);
print... | {
R2cf { n1: n1, n2: n2 }
} | identifier_body |
continued_fraction_from_rational.rs | // http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
struct R2cf {
n1: i64,
n2: i64,
}
// This iterator generates the continued fraction representation from the
// specified rational number.
impl Iterator for R2cf {
type Item = i64;
fn next(&mut self) -> Option<... | else {
let t1 = self.n1 / self.n2;
let t2 = self.n2;
self.n2 = self.n1 - t1 * t2;
self.n1 = t2;
Some(t1)
}
}
}
fn r2cf(n1: i64, n2: i64) -> R2cf {
R2cf { n1: n1, n2: n2 }
}
macro_rules! printcf {
($x:expr, $y:expr) => (println!("{:?}", r... | {
None
} | conditional_block |
near_parabolic.rs | /*
Copyright (c) 2015, 2016 Saurav Sachidanand
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, merge, publish, di... | {
let (tru_anom, rad_vec) = orbit::near_parabolic::true_anom_and_rad_vec (
138.4783, 0.0, 1.0, 0.921326, 0.0000001
).unwrap();
assert_eq!(util::round_upto_digits(tru_anom.to_degrees(), 5), 102.74426);
assert_eq!(util::round_upto_digits(rad_vec, 6), 2.364192);
} | identifier_body | |
near_parabolic.rs | /*
Copyright (c) 2015, 2016 Saurav Sachidanand
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, merge, publish, di... | () {
let (tru_anom, rad_vec) = orbit::near_parabolic::true_anom_and_rad_vec (
138.4783, 0.0, 1.0, 0.921326, 0.0000001
).unwrap();
assert_eq!(util::round_upto_digits(tru_anom.to_degrees(), 5), 102.74426);
assert_eq!(util::round_upto_digits(rad_vec, 6), 2.364192);
}
| true_anom_and_rad_vec | identifier_name |
near_parabolic.rs | /*
Copyright (c) 2015, 2016 Saurav Sachidanand
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, merge, publish, di... | } | random_line_split | |
inherited_stability.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn stable() {}
}
#[unstable(feature = "unstable_test_feature", issue = "0")]
pub mod unstable_mod {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated() {}
... | unstable | identifier_name |
inherited_stability.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 ... |
}
pub enum Unstable {
UnstableVariant,
#[stable(feature = "rust1", since = "1.0.0")]
StableVariant
}
| {} | identifier_body |
inherited_stability.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 | #![crate_type = "lib"]
#![unstable(feature = "unstable_test_feature", issue = "0")]
#![feature(staged_api)]
pub fn unstable() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn stable() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub mod stable_mod {
#[unstable(feature = "unstable_test_feature", issue ... | // 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.
#![crate_name="inherited_stability"] | random_line_split |
klog.rs | use fs::{KScheme, Resource, Url};
use fs::resource::ResourceSeek;
use collections::string::String;
use alloc::boxed::Box;
use system::error::Result;
use logging::LogLevel;
/// The kernel log scheme.
pub struct KlogScheme;
impl KScheme for KlogScheme {
/// Returns the name of the scheme: "klog"
fn scheme(&self... | LogLevel::Critical => "CRIT ",
};
string.push_str(prefix);
string.push_str(message);
string.push('\n');
}
string
}
}
impl Resource for KlogResource {
fn dup(&self) -> Result<Box<Resource>> {
Ok(Box::new(KlogResource {
... | LogLevel::Error => "ERROR ", | random_line_split |
klog.rs | use fs::{KScheme, Resource, Url};
use fs::resource::ResourceSeek;
use collections::string::String;
use alloc::boxed::Box;
use system::error::Result;
use logging::LogLevel;
/// The kernel log scheme.
pub struct | ;
impl KScheme for KlogScheme {
/// Returns the name of the scheme: "klog"
fn scheme(&self) -> &str {
"klog"
}
/// Returns a resource. The `url` and `flags` arguments are currently unused.
fn open(&mut self, _: Url, _: usize) -> Result<Box<Resource>> {
Ok(Box::new(KlogResource {
... | KlogScheme | identifier_name |
klog.rs | use fs::{KScheme, Resource, Url};
use fs::resource::ResourceSeek;
use collections::string::String;
use alloc::boxed::Box;
use system::error::Result;
use logging::LogLevel;
/// The kernel log scheme.
pub struct KlogScheme;
impl KScheme for KlogScheme {
/// Returns the name of the scheme: "klog"
fn scheme(&self... |
/// Returns a resource. The `url` and `flags` arguments are currently unused.
fn open(&mut self, _: Url, _: usize) -> Result<Box<Resource>> {
Ok(Box::new(KlogResource {
pos: 0,
}))
}
/// Clears the logs.
fn unlink(&mut self, _: Url) -> Result<()> {
let mut logs... | {
"klog"
} | identifier_body |
mocking_utils.rs | /// Converts non-mutable reference to a mutable one
///
/// Allows creating multiple mutable references to a single item breaking Rust's safety policy.
/// # Safety
/// Use with extreme caution, may cause all sorts of mutability related undefined behaviors!
///
/// One safe use case is when mocking function, which gets... | <T>(t_ref: &T) -> &mut T {
&mut *(t_ref as *const T as *mut T)
}
| as_mut | identifier_name |
mocking_utils.rs | /// Converts non-mutable reference to a mutable one
///
/// Allows creating multiple mutable references to a single item breaking Rust's safety policy.
/// # Safety
/// Use with extreme caution, may cause all sorts of mutability related undefined behaviors!
///
/// One safe use case is when mocking function, which gets... | } | pub unsafe fn as_mut<T>(t_ref: &T) -> &mut T {
&mut *(t_ref as *const T as *mut T) | random_line_split |
mocking_utils.rs | /// Converts non-mutable reference to a mutable one
///
/// Allows creating multiple mutable references to a single item breaking Rust's safety policy.
/// # Safety
/// Use with extreme caution, may cause all sorts of mutability related undefined behaviors!
///
/// One safe use case is when mocking function, which gets... | {
&mut *(t_ref as *const T as *mut T)
} | identifier_body | |
variable_renaming.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr 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 ver... | }
}
fn rename_quantifier(id: i64,
p: Formula,
ri: &mut RenamingInfo,
universal_quantifier: bool)
-> Formula {
let new_id = ri.create_new_variable_id();
let renamed_p = rename(rename_variable(p, id, new_id), ri);
if uni... | _ => f, | random_line_split |
variable_renaming.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr 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 ver... | (f: Formula, ri: &mut RenamingInfo) -> Formula {
match f {
Formula::Not(p) => Formula::Not(Box::new(rename(*p, ri))),
Formula::And(l) => Formula::And(l.into_iter().map(|x| rename(x, ri)).collect()),
Formula::Or(l) => Formula::Or(l.into_iter().map(|x| rename(x, ri)).collect()),
Formul... | rename | identifier_name |
variable_renaming.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr 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 ver... | else {
Formula::Exists(new_id, Box::new(renamed_p))
}
}
/// Renames all occurrences of a single variable in a formula to another variable.
fn rename_variable(f: Formula, from: i64, to: i64) -> Formula {
match f {
Formula::Predicate(id, terms) => {
Formula::Predicate(id,
... | {
Formula::Forall(new_id, Box::new(renamed_p))
} | conditional_block |
variable_renaming.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr 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 ver... |
#[cfg(test)]
mod test {}
| {
match t {
Term::Variable(id) => {
if from == id {
Term::Variable(to)
} else {
Term::Variable(id)
}
}
Term::Function(id, args) => {
Term::Function(id,
args.into_iter()
... | identifier_body |
service.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... |
/// Handles block commit event.
///
/// This handler is a callback which is invoked by the blockchain
/// after each block commit. For example, a service can broadcast one or more transactions
/// if a specific condition has occurred.
///
/// The default implementation does nothing.
//... | {
Ok(())
} | identifier_body |
service.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... | // limitations under the License.
use exonum::{
blockchain::{config::InstanceInitParams, ApiSender, SendError},
crypto::{Hash, KeyPair, PublicKey},
helpers::{Height, ValidatorId},
merkledb::{access::Prefixed, BinaryValue, ObjectHash, Snapshot},
runtime::{
ArtifactId, BlockchainData, Dispatc... | // See the License for the specific language governing permissions and | random_line_split |
service.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... | else {
None
}
}
/// Returns a transaction broadcaster regardless of the node status (validator or auditor)
/// and the service status (active or not).
///
/// # Safety
///
/// Transactions for non-active services will not be broadcast successfully; they will be
/// ... | {
Some(self.broadcaster.clone())
} | conditional_block |
service.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... | (&self, _context: ExecutionContext<'_>) -> Result<(), ExecutionError> {
Ok(())
}
/// Handles block commit event.
///
/// This handler is a callback which is invoked by the blockchain
/// after each block commit. For example, a service can broadcast one or more transactions
/// if a spec... | after_transactions | identifier_name |
test.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 ... | * This fixes issue #7772.
*/
use libc;
type rlim_t = libc::uint64_t;
struct rlimit {
rlim_cur: rlim_t,
rlim_max: rlim_t
}
extern {
// name probably doesn't need to be mut, but the C function doesn't specify const
fn sysctl(name: *mut libc::c_int, namelen: l... | * rlimit maxfiles to 256/unlimited. The default soft limit of 256 ends up being far too low
* for our multithreaded scheduler testing, depending on the number of cores available.
* | random_line_split |
test.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 ... | else {
Path::new(r"\\.\pipe\" + string)
}
}
/// Get a unique IPv4 localhost:port pair starting at 9600
pub fn next_test_ip4() -> SocketAddr {
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: next_test_port() }
}
/// Get a unique IPv6 localhost:port pair starting at 9600
pub fn next_test_ip6() -> Socket... | {
os::tmpdir().join(string)
} | conditional_block |
test.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 ... | () -> u16 {
static mut next_offset: AtomicUint = INIT_ATOMIC_UINT;
unsafe {
base_port() + next_offset.fetch_add(1, Relaxed) as u16
}
}
/// Get a temporary path which could be the location of a unix socket
pub fn next_test_unix() -> Path {
static mut COUNT: AtomicUint = INIT_ATOMIC_UINT;
// ... | next_test_port | identifier_name |
foreign-call-no-runtime.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 ... | (data: libc::uintptr_t) {
unsafe {
let data: *int = cast::transmute(data);
assert_eq!(*data, 100);
}
}
| callback | identifier_name |
foreign-call-no-runtime.rs | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate lib... | // 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. | random_line_split | |
foreign-call-no-runtime.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
unsafe {
let data: *int = cast::transmute(data);
assert_eq!(*data, 100);
}
} | identifier_body | |
quote-tokens.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 ... | (cx: @ExtCtxt) {
let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, 1 + 2);
let p_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, (x, 1.. 4, *));
let a: @syntax::ast::expr = quote_expr!(cx, 1 + 2);
let _b: Option<@syntax::ast::item> = quote_item!(cx, static foo : int = $e_toks; );
le... | syntax_extension | identifier_name |
quote-tokens.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 main() {
}
| {
let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, 1 + 2);
let p_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, (x, 1 .. 4, *));
let a: @syntax::ast::expr = quote_expr!(cx, 1 + 2);
let _b: Option<@syntax::ast::item> = quote_item!(cx, static foo : int = $e_toks; );
let _c: @syntax:... | identifier_body |
quote-tokens.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, 1 + 2);
let p_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, (x, 1.. 4, *));
let a: @syntax::ast::expr = quote_expr!(cx, 1 + 2);
let _b: Option<@syntax::ast::item> = quote_item!(cx, static foo : int = $e_toks; );
let _c: @syntax::as... | fn syntax_extension(cx: @ExtCtxt) { | random_line_split |
repeater.rs | use futures::prelude::*;
use irc::client::prelude::*;
#[tokio::main]
async fn main() -> irc::error::Result<()> {
let config = Config {
nickname: Some("pickles".to_owned()),
server: Some("chat.freenode.net".to_owned()),
channels: vec!["#rust-spam".to_owned()],
burst_window_length: So... |
}
}
}
| {
let tokens: Vec<_> = msg.split(' ').collect();
if tokens.len() > 2 {
let n = tokens[0].len() + tokens[1].len() + 2;
if let Ok(count) = tokens[1].parse::<u8>() {
for _ in 0..count {
sender.send_p... | conditional_block |
repeater.rs | use futures::prelude::*;
use irc::client::prelude::*;
#[tokio::main]
async fn | () -> irc::error::Result<()> {
let config = Config {
nickname: Some("pickles".to_owned()),
server: Some("chat.freenode.net".to_owned()),
channels: vec!["#rust-spam".to_owned()],
burst_window_length: Some(4),
max_messages_in_burst: Some(4),
..Default::default()
};
... | main | identifier_name |
repeater.rs | use futures::prelude::*;
use irc::client::prelude::*;
#[tokio::main]
async fn main() -> irc::error::Result<()> | if msg.starts_with(&*client.current_nickname()) {
let tokens: Vec<_> = msg.split(' ').collect();
if tokens.len() > 2 {
let n = tokens[0].len() + tokens[1].len() + 2;
if let Ok(count) = tokens[1].parse::<u8>() {
f... | {
let config = Config {
nickname: Some("pickles".to_owned()),
server: Some("chat.freenode.net".to_owned()),
channels: vec!["#rust-spam".to_owned()],
burst_window_length: Some(4),
max_messages_in_burst: Some(4),
..Default::default()
};
let mut client = Client:... | identifier_body |
repeater.rs | use futures::prelude::*;
use irc::client::prelude::*;
#[tokio::main]
async fn main() -> irc::error::Result<()> {
let config = Config {
nickname: Some("pickles".to_owned()),
server: Some("chat.freenode.net".to_owned()),
channels: vec!["#rust-spam".to_owned()],
burst_window_length: So... | let message = stream.select_next_some().await?;
if let Command::PRIVMSG(ref target, ref msg) = message.command {
if msg.starts_with(&*client.current_nickname()) {
let tokens: Vec<_> = msg.split(' ').collect();
if tokens.len() > 2 {
let n =... | random_line_split | |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language gove... | * | random_line_split |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | () {
let mut out_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
out_dir.push("lib");
if!out_dir.is_dir() {
std::fs::create_dir(&out_dir).unwrap();
}
let obj_file = out_dir.join("test.o");
let lib_file = out_dir.join("libtest.a");
let output = Command::new(concat!(
env!("... | main | identifier_name |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | "Could not build tvm lib: {}",
String::from_utf8(output.stderr)
.unwrap()
.trim()
.split("\n")
.last()
.unwrap_or("")
);
let mut builder = Builder::new(File::create(lib_file).unwrap());
builder.append_path(obj_file).unwrap();
print... | {
let mut out_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
out_dir.push("lib");
if !out_dir.is_dir() {
std::fs::create_dir(&out_dir).unwrap();
}
let obj_file = out_dir.join("test.o");
let lib_file = out_dir.join("libtest.a");
let output = Command::new(concat!(
env!("CA... | identifier_body |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
let obj_file = out_dir.join("test.o");
let lib_file = out_dir.join("libtest.a");
let output = Command::new(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/build_test_lib.py"
))
.arg(&out_dir)
.output()
.expect("Failed to execute command");
assert!(
obj_file.exists(),
... | {
std::fs::create_dir(&out_dir).unwrap();
} | conditional_block |
filesearch.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () -> Option<String> {
os::getenv("RUST_PATH").map(|x| x.to_string())
}
/// Returns the value of RUST_PATH, as a list
/// of Paths. Includes default entries for, if they exist:
/// $HOME/.rust
/// DIR/.rust for any DIR that's the current working directory
/// or an ancestor of it
pub fn rust_path() -> Vec<Path> {
... | get_rust_path | identifier_name |
filesearch.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | fn primary_libdir_name() -> String {
"lib64".to_string()
}
#[cfg(target_word_size = "32")]
fn primary_libdir_name() -> String {
"lib32".to_string()
}
fn secondary_libdir_name() -> String {
"lib".to_string()
}
}
#[cfg(windows)]
fn find_libdir(_sysroot: &Path) -> Str... |
#[cfg(target_word_size = "64")] | random_line_split |
filesearch.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn make_rustpkg_lib_path(sysroot: &Path,
dir: &Path,
triple: &str) -> Path {
let mut p = dir.join(find_libdir(sysroot));
p.push(triple);
p
}
pub fn get_or_default_sysroot() -> Path {
// Follow symlinks. If the resolved path is relative, make it absol... | {
sysroot.join(&relative_target_lib_path(sysroot, target_triple))
} | identifier_body |
stylesheetlist.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::codegen::Bindings::StyleSheetListBinding;
use crate::dom::bindings::codegen::Bindings::S... |
// https://drafts.csswg.org/cssom/#dom-stylesheetlist-item
fn Item(&self, index: u32) -> Option<DomRoot<StyleSheet>> {
// XXXManishearth this doesn't handle the origin clean flag and is a
// cors vulnerability
self.document
.stylesheet_at(index as usize)
.map(Dom... | {
self.document.stylesheet_count() as u32
} | identifier_body |
stylesheetlist.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::codegen::Bindings::StyleSheetListBinding;
use crate::dom::bindings::codegen::Bindings::S... | use crate::dom::stylesheet::StyleSheet;
use crate::dom::window::Window;
use dom_struct::dom_struct;
#[dom_struct]
pub struct StyleSheetList {
reflector_: Reflector,
document: Dom<Document>,
}
impl StyleSheetList {
#[allow(unrooted_must_root)]
fn new_inherited(doc: Dom<Document>) -> StyleSheetList {
... | use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::document::Document; | random_line_split |
stylesheetlist.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::codegen::Bindings::StyleSheetListBinding;
use crate::dom::bindings::codegen::Bindings::S... | (doc: Dom<Document>) -> StyleSheetList {
StyleSheetList {
reflector_: Reflector::new(),
document: doc,
}
}
#[allow(unrooted_must_root)]
pub fn new(window: &Window, document: Dom<Document>) -> DomRoot<StyleSheetList> {
reflect_dom_object(
Box::new(... | new_inherited | identifier_name |
testcase_units.rs | // https://rustbyexample.com/generics/phantom/testcase_units.html
// http://rust-lang-ja.org/rust-by-example/generics/phantom/testcase_units.html
use std::ops::Add;
use std::marker::PhantomData;
/// Create void enumerations to define unit types.
#[derive(Debug, Clone, Copy)]
enum Inch {}
#[derive(Debug, Clone, Copy)]... | #[derive(Debug, Clone, Copy)]
struct Length<Unit>(f64, PhantomData<Unit>);
/// The `Add` trait defines the behaviour of the `+` operator.
impl<Unit> Add for Length<Unit> {
type Output = Length<Unit>;
// add() returns a new `Length` struct containig the sum.
fn add(self, rhs: Length<Unit>) -> Length<Unit> ... | /// `f64` already implements the `Clone` and `Copy` traits. | random_line_split |
testcase_units.rs | // https://rustbyexample.com/generics/phantom/testcase_units.html
// http://rust-lang-ja.org/rust-by-example/generics/phantom/testcase_units.html
use std::ops::Add;
use std::marker::PhantomData;
/// Create void enumerations to define unit types.
#[derive(Debug, Clone, Copy)]
enum Inch {}
#[derive(Debug, Clone, Copy)]... | // error[E0308]: mismatched types
}
| {
// Specifies `one_foot` to have phantom type parameter `Inch`.
let one_foot: Length<Inch> = Length(12.0, PhantomData);
// `one_meter` has phantom type parameter `Mm`.
let one_meter: Length<Mm> = Length(1000.0, PhantomData);
// `+` calls the `add()` method we implemented for `Length<Unit>`.
/... | identifier_body |
testcase_units.rs | // https://rustbyexample.com/generics/phantom/testcase_units.html
// http://rust-lang-ja.org/rust-by-example/generics/phantom/testcase_units.html
use std::ops::Add;
use std::marker::PhantomData;
/// Create void enumerations to define unit types.
#[derive(Debug, Clone, Copy)]
enum Inch {}
#[derive(Debug, Clone, Copy)]... | {}
/// `Length` is a type with phantom type parameter `Unit`,
/// and is not generic over the length type (that is `f64`).
///
/// `f64` already implements the `Clone` and `Copy` traits.
#[derive(Debug, Clone, Copy)]
struct Length<Unit>(f64, PhantomData<Unit>);
/// The `Add` trait defines the behaviour of the `+` op... | Mm | identifier_name |
types.rs | // Copyright 2018 Dmitry Tantsur <divius.inside@gmail.com>
//
// 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 ap... |
}
macro_rules! opaque_resource_type {
($(#[$attr:meta])* $name:ident? $service:expr) => (
$(#[$attr])*
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct $name {
pub(crate) value: String,
pub(crate) verified: bool
}
impl From<String> for $name {
... | {
Ok(self)
} | identifier_body |
types.rs | // Copyright 2018 Dmitry Tantsur <divius.inside@gmail.com>
//
// 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 ap... | opaque_resource_type!(#[doc = "An ID of a `KeyPair`"] KeyPairRef? "compute");
opaque_resource_type!(#[doc = "An ID of a `Network`"] NetworkRef? "network");
opaque_resource_type!(#[doc = "An ID of an `Object`"] ObjectRef? "object-storage");
opaque_resource_type!(#[doc = "An ID of a `Project`"] ProjectRef? "identity")... | random_line_split | |
types.rs | // Copyright 2018 Dmitry Tantsur <divius.inside@gmail.com>
//
// 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 ap... | (self, _session: &Session) -> Result<Self>
where
Self: Sized,
{
Ok(self)
}
}
macro_rules! opaque_resource_type {
($(#[$attr:meta])* $name:ident? $service:expr) => (
$(#[$attr])*
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct $name {
pub(crate) valu... | into_verified | identifier_name |
dst-struct-sole.rs | // As dst-struct.rs, but the unsized field is the only field in the struct.
struct Fat<T:?Sized> {
ptr: T
}
// x is a fat pointer
fn | (x: &Fat<[isize]>) {
let y = &x.ptr;
assert_eq!(x.ptr.len(), 3);
assert_eq!(y[0], 1);
assert_eq!(x.ptr[1], 2);
}
fn foo2<T:ToBar>(x: &Fat<[T]>) {
let y = &x.ptr;
let bar = Bar;
assert_eq!(x.ptr.len(), 3);
assert_eq!(y[0].to_bar(), bar);
assert_eq!(x.ptr[1].to_bar(), bar);
}
#[deriv... | foo | identifier_name |
dst-struct-sole.rs | // As dst-struct.rs, but the unsized field is the only field in the struct.
struct Fat<T:?Sized> {
ptr: T
}
// x is a fat pointer
fn foo(x: &Fat<[isize]>) {
let y = &x.ptr;
assert_eq!(x.ptr.len(), 3);
assert_eq!(y[0], 1);
assert_eq!(x.ptr[1], 2);
}
fn foo2<T:ToBar>(x: &Fat<[T]>) {
let y = &x... | let f2 = &f1;
foo(f2);
let f3: &Fat<[isize]> = f2;
foo(f3);
let f4: &Fat<[isize]> = &f1;
foo(f4);
let f5: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] };
foo(f5);
// With a vec of Bars.
let bar = Bar;
let f1 = Fat { ptr: [bar, bar, bar] };
foo2(&f1);
let f2 = &f1;
foo2(... | foo(&f1); | random_line_split |
profiler_unix.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::Mutex;
use callgrind::CallgrindClientRequest;
#[derive(Debug, PartialEq)]
enum Profiler {
None,
GPerfTools,
CallGrind,
}
lazy_static::lazy_static! {
#[derive(Debug)]
static ref ACTIVE_PROFILER: Mutex<Profiler> = Mu... | // TODO: Better multi-thread support.
#[inline]
pub fn start(name: impl AsRef<str>) -> bool {
let mut profiler = ACTIVE_PROFILER.lock().unwrap();
// Profiling in progress.
if *profiler!= Profiler::None {
return false;
}
if valgrind_request::running_on_valgrind()!= 0 {
*profiler = P... | /// zero cost.
///
/// When running in Callgrind, Callgrind instrumentation will be started
/// (`CALLGRIND_START_INSTRUMENTATION`). Otherwise, the CPU Profiler will be started and profile
/// will be generated to the file specified by `name`. | random_line_split |
profiler_unix.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::Mutex;
use callgrind::CallgrindClientRequest;
#[derive(Debug, PartialEq)]
enum Profiler {
None,
GPerfTools,
CallGrind,
}
lazy_static::lazy_static! {
#[derive(Debug)]
static ref ACTIVE_PROFILER: Mutex<Profiler> = Mu... |
true
}
/// Stop profiling. Returns false if failed, i.e. there is no profiling in progress.
///
/// When `profiling` feature is not enabled, this function will do nothing and there is totally
/// zero cost.
#[inline]
pub fn stop() -> bool {
let mut profiler = ACTIVE_PROFILER.lock().unwrap();
match *profi... | {
*profiler = Profiler::GPerfTools;
gperftools::PROFILER
.lock()
.unwrap()
.start(name.as_ref())
.unwrap();
} | conditional_block |
profiler_unix.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::Mutex;
use callgrind::CallgrindClientRequest;
#[derive(Debug, PartialEq)]
enum | {
None,
GPerfTools,
CallGrind,
}
lazy_static::lazy_static! {
#[derive(Debug)]
static ref ACTIVE_PROFILER: Mutex<Profiler> = Mutex::new(Profiler::None);
}
/// Start profiling. Returns false if failed, i.e. there is already a profiling in progress.
///
/// When `profiling` feature is not enabled, t... | Profiler | identifier_name |
profiler_unix.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::Mutex;
use callgrind::CallgrindClientRequest;
#[derive(Debug, PartialEq)]
enum Profiler {
None,
GPerfTools,
CallGrind,
}
lazy_static::lazy_static! {
#[derive(Debug)]
static ref ACTIVE_PROFILER: Mutex<Profiler> = Mu... | {
let mut profiler = ACTIVE_PROFILER.lock().unwrap();
match *profiler {
Profiler::None => false,
Profiler::CallGrind => {
CallgrindClientRequest::stop(None);
*profiler = Profiler::None;
true
}
Profiler::GPerfTools => {
gperftools::P... | identifier_body | |
print_table.rs |
use itertools::*;
use std::cmp::max;
use std::fmt::{self, Debug, Formatter};
pub fn debug_table<A, B, C, D, E, F, G>(name: A,
column_names: B,
column_alignments: D,
rows: E)
... |
}
| {
try!(writeln!(f, "{}:", self.name));
try!(writeln!(f, "{}", self.sep));
try!(writeln!(f, "{}", self.header));
try!(writeln!(f, "{}", self.sep));
for row in self.rows.iter() {
try!(writeln!(f, "{}", self.fmt_row(&*row)));
}
writeln!(f, "{}", self.se... | identifier_body |
print_table.rs |
use itertools::*;
use std::cmp::max;
use std::fmt::{self, Debug, Formatter};
pub fn debug_table<A, B, C, D, E, F, G>(name: A,
column_names: B,
column_alignments: D,
rows: E)
... | (&self, f: &mut Formatter) -> fmt::Result {
try!(writeln!(f, "{}:", self.name));
try!(writeln!(f, "{}", self.sep));
try!(writeln!(f, "{}", self.header));
try!(writeln!(f, "{}", self.sep));
for row in self.rows.iter() {
try!(writeln!(f, "{}", self.fmt_row(&*row)));
... | fmt | identifier_name |
print_table.rs | use itertools::*;
use std::cmp::max;
use std::fmt::{self, Debug, Formatter};
pub fn debug_table<A, B, C, D, E, F, G>(name: A,
column_names: B,
column_alignments: D,
rows: E)
... | Box::new(TablePrinter {
name: name,
header: header,
sep: sep,
col_widths: col_widths,
col_align: col_align,
rows: rows,
})
}
pub enum Alignment {
Left,
Right,
Center,
}
struct TablePrinter {
name: String,
header: String,
sep: String,
... | _ => "-",
}
})
.join("");
| random_line_split |
opcode.rs | use value::Value;
#[derive(Debug, Clone)]
pub enum OpCode {
Val(Value), // stack.push(Value)
Add, // stack.pop() + stack.pop()
Sub, // stack.pop() - stack.pop()
Mul, // stack.pop() * stack.pop()
Div, // stack.pop() / stack.pop()
EqEq, // stack.pop() == stack.pop()
NotEq, // s... | GtEq, // >=
Def, // scopes[stack.pop()] = stack.pop()
Ret,
Call, // stack.pop()(...)
JumpIfNot(i32), // if!stack.pop() -> pc += jump
JumpIf(i32), // if stack.pop() -> pc += jump
Jump(i32), // pc += jump
GetName(String), // stack.push(scopes[String])
} | Lt, // <
LtEq, // <=
Gt, // > | random_line_split |
opcode.rs | use value::Value;
#[derive(Debug, Clone)]
pub enum | {
Val(Value), // stack.push(Value)
Add, // stack.pop() + stack.pop()
Sub, // stack.pop() - stack.pop()
Mul, // stack.pop() * stack.pop()
Div, // stack.pop() / stack.pop()
EqEq, // stack.pop() == stack.pop()
NotEq, // stack.pop()!= stack.pop()
Lt, // <
LtEq, // <... | OpCode | identifier_name |
varuint.rs | use std::mem;
use varuint::{Deserializable, Serializable, Varint, VarintBaseType};
fn test_varuint<T: VarintBaseType>(v: T, size: usize)
where
Varint<T>: Serializable + Deserializable,
{
let v = Varint::<T>(v);
assert_eq!(size, v.size_hint());
let mut arr: [u8; 17] = unsafe { mem::uninitialized() };
... | test_varuint(67567u128, 3);
test_varuint(2032u128, 3);
test_varuint(67568u32, 4);
test_varuint(16777215u32, 4);
test_varuint(67568u64, 4);
test_varuint(16777215u64, 4);
test_varuint(67568u128, 4);
test_varuint(16777215u128, 4);
test_varuint(16777216u32, 5);
test_varuint(4294967... | random_line_split | |
varuint.rs | use std::mem;
use varuint::{Deserializable, Serializable, Varint, VarintBaseType};
fn test_varuint<T: VarintBaseType>(v: T, size: usize)
where
Varint<T>: Serializable + Deserializable,
{
let v = Varint::<T>(v);
assert_eq!(size, v.size_hint());
let mut arr: [u8; 17] = unsafe { mem::uninitialized() };
... | test_varuint(241u128, 2);
test_varuint(2032u16, 3);
test_varuint(67567u32, 3);
test_varuint(2032u32, 3);
test_varuint(67567u64, 3);
test_varuint(2032u64, 3);
test_varuint(67567u128, 3);
test_varuint(2032u128, 3);
test_varuint(67568u32, 4);
test_varuint(16777215u32, 4);
test... | {
test_varuint(0u8, 1);
test_varuint(240u8, 1);
test_varuint(0u16, 1);
test_varuint(240u16, 1);
test_varuint(0u32, 1);
test_varuint(240u32, 1);
test_varuint(0u64, 1);
test_varuint(240u64, 1);
test_varuint(0u128, 1);
test_varuint(240u128, 1);
test_varuint(241u8, 2);
test_... | identifier_body |
varuint.rs | use std::mem;
use varuint::{Deserializable, Serializable, Varint, VarintBaseType};
fn test_varuint<T: VarintBaseType>(v: T, size: usize)
where
Varint<T>: Serializable + Deserializable,
{
let v = Varint::<T>(v);
assert_eq!(size, v.size_hint());
let mut arr: [u8; 17] = unsafe { mem::uninitialized() };
... | () {
test_varuint(0u8, 1);
test_varuint(240u8, 1);
test_varuint(0u16, 1);
test_varuint(240u16, 1);
test_varuint(0u32, 1);
test_varuint(240u32, 1);
test_varuint(0u64, 1);
test_varuint(240u64, 1);
test_varuint(0u128, 1);
test_varuint(240u128, 1);
test_varuint(241u8, 2);
te... | test_all | identifier_name |
add_template.rs | use std::io::{self, Write};
use std::{fs, path};
use toml;
use filesystem;
use common;
use error;
pub fn add_template(config_path: &str,
file_path: &str,
new_name: Option<&str>,
templating_enabled: bool)
-> Result<(), error::DotfilerError... | {
for (i, dotfile) in dotfiles.iter().enumerate() {
let existing_template_path = common::resolve_path(&dotfile.template, Some(templates_path))?;
let existing_tar_path = common::resolve_path(&dotfile.target, Some(templates_path))?;
if existing_template_path == template_path || existing_tar_pa... | identifier_body | |
add_template.rs | use std::io::{self, Write};
use std::{fs, path};
use toml;
use filesystem;
use common;
use error;
pub fn add_template(config_path: &str,
file_path: &str,
new_name: Option<&str>,
templating_enabled: bool)
-> Result<(), error::DotfilerError... | .map(|p| fs::create_dir_all(&p));
let mut root = match filesystem::create_tree_from_path(file_path, &tar_path) {
Ok(root) => root,
Err(e) => {
let msg = format!("Can't create tree for file '{}':\n{}", file_path, e);
return Err(error::DotfilerError::Message(msg));
... | random_line_split | |
add_template.rs | use std::io::{self, Write};
use std::{fs, path};
use toml;
use filesystem;
use common;
use error;
pub fn | (config_path: &str,
file_path: &str,
new_name: Option<&str>,
templating_enabled: bool)
-> Result<(), error::DotfilerError> {
let mut config = common::load_config(config_path)?;
let templates_path = common::get_templates_path(config... | add_template | identifier_name |
mutated_accounts_tests.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::compiler::{as_module, compile_units};
use move_core_types::{
account_address::AccountAddress,
gas_schedule::{GasAlgebra, GasUnits},
identifier::Identifier,
language_storage::ModuleId,
value::{serialize_val... | sess.execute_function(
&module_id,
&get,
vec![],
serialize_values(&vec![MoveValue::Address(account1)]),
&mut cost_strategy,
&context,
)
.unwrap();
// Only the sender's account (TEST_ADDR) should have been modified.
assert_eq!(sess.num_mutated_accounts(... | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.