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 |
|---|---|---|---|---|
solutions.rs | use num::integer;
use num::Integer;
use rayon::prelude::*;
use std;
pub fn | (x: usize, digits: &Vec<u64>) -> Option<u64> {
(0..digits.len() - x)
.into_par_iter()
.map(|i| (&digits[i..i + x]).iter().product())
.max()
}
pub fn special_pythagorean_triplet(sum: u32) -> Option<u32> {
// WLOG assume a = min(a, b). (sum - 2a)^2 > c^2 > a^2 => sum > 3a
(1..sum / 3 + 1... | largest_product_in_a_series | identifier_name |
primitive.rs | use super::rbtree::RedBlackBST;
use rand::distributions::{Distribution, Standard};
use rand::Rng;
use std::borrow::Borrow;
use std::f64;
use std::fmt;
use std::vec::IntoIter;
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
pub struct Point2D {
pub x: f64,
pub y: f64,
}
impl Point2D {
pub fn new(x: f6... |
dx.powi(2) + dy.powi(2)
}
}
impl fmt::Display for RectHV {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[{}, {}] x [{}, {}]", self.xmin, self.xmax, self.ymin, self.ymax)
}
}
#[test]
fn test_rect() {
let r1 = RectHV::new(0.0, 0.0, 1.1, 1.1);
let r2 = RectHV::ne... | {
dy = p.y - self.ymax;
} | conditional_block |
primitive.rs | use super::rbtree::RedBlackBST;
use rand::distributions::{Distribution, Standard};
use rand::Rng;
use std::borrow::Borrow;
use std::f64;
use std::fmt;
use std::vec::IntoIter;
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
pub struct Point2D {
pub x: f64,
pub y: f64,
}
impl Point2D {
pub fn new(x: f6... | <R: Rng +?Sized>(&self, rng: &mut R) -> Point2D {
Point2D {
x: rng.gen(),
y: rng.gen(),
}
}
}
#[test]
fn test_point2d() {
let p1 = Point2D::new(0.0, 0.0);
let p2 = Point2D::new(1.0, 1.0);
// maybe bad :(
assert_eq!(p1.distance_to(p2), (2.0f64).sqrt());
}
#[... | sample | identifier_name |
primitive.rs | use super::rbtree::RedBlackBST;
use rand::distributions::{Distribution, Standard};
use rand::Rng;
use std::borrow::Borrow;
use std::f64;
use std::fmt;
use std::vec::IntoIter;
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
pub struct Point2D {
pub x: f64,
pub y: f64,
}
impl Point2D {
pub fn new(x: f6... |
pub fn insert(&mut self, p: Point2D) {
if!self.pset.contains(&p) {
self.pset.put(p, ())
}
}
pub fn contains<T: Borrow<Point2D>>(&self, p: T) -> bool {
self.pset.contains(p.borrow())
}
pub fn range_search<T: Borrow<RectHV>>(&self, rect: T) -> IntoIter<&Point2D>... | {
self.pset.size()
} | identifier_body |
primitive.rs | use super::rbtree::RedBlackBST;
use rand::distributions::{Distribution, Standard};
use rand::Rng;
use std::borrow::Borrow;
use std::f64;
use std::fmt;
use std::vec::IntoIter;
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
pub struct Point2D {
pub x: f64,
pub y: f64,
}
impl Point2D {
pub fn new(x: f6... | y: rng.gen(),
}
}
}
#[test]
fn test_point2d() {
let p1 = Point2D::new(0.0, 0.0);
let p2 = Point2D::new(1.0, 1.0);
// maybe bad :(
assert_eq!(p1.distance_to(p2), (2.0f64).sqrt());
}
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
/// Implementation of 2D axis-aligned recta... | fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Point2D {
Point2D {
x: rng.gen(), | random_line_split |
datastructures.rs | // This file is part of the uutils coreutils package.
//
// (c) Tyler Steele <tyler.steele@protonmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore ctable, outfile
use std::error::Error;
use uucore::error:... | Self::InvalidConvBlockUnblockCase => {
write!(f, "Invalid Conversion, Block, or Unblock data")
}
}
}
}
impl Error for InternalError {}
impl UError for InternalError {}
pub mod options {
pub const INFILE: &str = "if";
pub const OUTFILE: &str = "of";
pub c... | random_line_split | |
datastructures.rs | // This file is part of the uutils coreutils package.
//
// (c) Tyler Steele <tyler.steele@protonmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore ctable, outfile
use std::error::Error;
use uucore::error:... | {
pub sparse: bool,
pub excl: bool,
pub nocreat: bool,
pub notrunc: bool,
pub fdatasync: bool,
pub fsync: bool,
}
/// Stores all Flags that apply to the input
#[derive(Debug, Default, PartialEq)]
pub struct IFlags {
pub cio: bool,
pub direct: bool,
pub directory: bool,
pub dsyn... | OConvFlags | identifier_name |
datastructures.rs | // This file is part of the uutils coreutils package.
//
// (c) Tyler Steele <tyler.steele@protonmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore ctable, outfile
use std::error::Error;
use uucore::error:... |
Self::InvalidConvBlockUnblockCase => {
write!(f, "Invalid Conversion, Block, or Unblock data")
}
}
}
}
impl Error for InternalError {}
impl UError for InternalError {}
pub mod options {
pub const INFILE: &str = "if";
pub const OUTFILE: &str = "of";
pub ... | {
write!(f, "Internal dd error: Wrong Input/Output data type")
} | conditional_block |
regions-ret-borrowed.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 ... | <'a>() -> &'a int {
with(|o| o)
//~^ ERROR cannot infer
}
fn main() {
let x = return_it();
println!("foo={}", *x);
}
| return_it | identifier_name |
regions-ret-borrowed.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. | // <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.
// Ensure that you cannot use generic types to return a region outside
// of its bound. Here, in the `return_it()` fn, we call with() but
// with R bound... | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | random_line_split |
regions-ret-borrowed.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let x = return_it();
println!("foo={}", *x);
} | identifier_body | |
p009.rs | //! [Problem 9](https://projecteuler.net/problem=9) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use integer::Integer;
use std::{cmp, iter};
fn compute(sum: u32) -> u32 {
(2..sum - 1)
.flat_map(|c| {
... |
common::problem!("31875000", solve);
| {
compute(1000).to_string()
} | identifier_body |
p009.rs | //! [Problem 9](https://projecteuler.net/problem=9) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use integer::Integer;
use std::{cmp, iter}; |
fn compute(sum: u32) -> u32 {
(2..sum - 1)
.flat_map(|c| {
let a_max = cmp::min((sum - c) / 2, (c * c / 2).sqrt());
(1..a_max).zip(iter::repeat(c))
})
.map(|(a, c)| (a, sum - c - a, c))
.find(|&(a, b, c)| a * a + b * b == c * c)
.map(|(a, b, c)| a * b * c... | random_line_split | |
p009.rs | //! [Problem 9](https://projecteuler.net/problem=9) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use integer::Integer;
use std::{cmp, iter};
fn | (sum: u32) -> u32 {
(2..sum - 1)
.flat_map(|c| {
let a_max = cmp::min((sum - c) / 2, (c * c / 2).sqrt());
(1..a_max).zip(iter::repeat(c))
})
.map(|(a, c)| (a, sum - c - a, c))
.find(|&(a, b, c)| a * a + b * b == c * c)
.map(|(a, b, c)| a * b * c)
.u... | compute | identifier_name |
printer.rs | use types::MalVal;
pub fn escape_str(s: &str) -> String {
let mut escaped = String::new();
escaped.push('"');
for c in s.chars() {
let _ = match c {
'"' => escaped.push_str("\\\""),
'\\' => escaped.push_str("\\\\"),
'\x08' => escaped.push_str("\\b"),
'\x0c' =... |
pub fn pr_list(lst: &Vec<MalVal>, pr: bool,
start: &str, end: &str, join: &str) -> String {
let mut first = true;
let mut res = String::new();
res.push_str(start);
for mv in lst.iter() {
if first {
first = false;
} else {
res.push_str(join);
... | {
let re1 = regex!(r#"\\""#);
let re2 = regex!(r#"\\n"#);
let re3 = regex!(r#"\\\\"#);
re3.replace_all(&re2.replace_all(&re1.replace_all(&s, "\""), "\n"), "\\")
} | identifier_body |
printer.rs | use types::MalVal;
pub fn escape_str(s: &str) -> String {
let mut escaped = String::new();
escaped.push('"');
for c in s.chars() {
let _ = match c {
'"' => escaped.push_str("\\\""),
'\\' => escaped.push_str("\\\\"),
'\x08' => escaped.push_str("\\b"),
'\x0c' =... | (s: &str) -> String {
let re1 = regex!(r#"\\""#);
let re2 = regex!(r#"\\n"#);
let re3 = regex!(r#"\\\\"#);
re3.replace_all(&re2.replace_all(&re1.replace_all(&s, "\""), "\n"), "\\")
}
pub fn pr_list(lst: &Vec<MalVal>, pr: bool,
start: &str, end: &str, join: &str) -> String {
let mut f... | unescape_str | identifier_name |
printer.rs | use types::MalVal;
pub fn escape_str(s: &str) -> String {
let mut escaped = String::new();
escaped.push('"');
for c in s.chars() {
let _ = match c {
'"' => escaped.push_str("\\\""),
'\\' => escaped.push_str("\\\\"),
'\x08' => escaped.push_str("\\b"),
'\x0c' =... | } | res.push_str(end);
res | random_line_split |
tests.rs | extern crate edit_distance;
#[test]
fn simple() {
assert_eq!(edit_distance::edit_distance("kitten", "sitting"), 3);
assert_eq!(edit_distance::edit_distance("Tier", "Tor"), 2);
}
#[test]
fn same() {
assert_eq!(edit_distance::edit_distance("kitten", "kitten"), 0);
}
#[test]
fn empty_a() {
assert_eq!(ed... | equality_property() {
fn triangle_inequality(a: String, b: String, c: String) -> bool {
edit_distance::edit_distance(&a, &b)
<= edit_distance::edit_distance(&a, &c) + edit_distance::edit_distance(&b, &c)
}
quickcheck(triangle_inequality as fn(a: String, b: String, c: String) -> bool);
}... | ls_b(a: String, b: String) -> bool {
let d = edit_distance::edit_distance(&a, &b);
if a == b {
d == 0
} else {
d > 0
}
}
quickcheck(zero_iff_a_equals_b as fn(a: String, b: String) -> bool);
}
#[test]
fn triangle_in | identifier_body |
tests.rs | extern crate edit_distance;
#[test]
fn simple() {
assert_eq!(edit_distance::edit_distance("kitten", "sitting"), 3);
assert_eq!(edit_distance::edit_distance("Tier", "Tor"), 2);
}
#[test]
fn same() {
assert_eq!(edit_distance::edit_distance("kitten", "kitten"), 0);
}
#[test]
fn empty_a() {
assert_eq!(ed... | :edit_distance(&a, &b) >= diff
}
quickcheck(at_least_size_difference as fn(a: String, b: String) -> bool);
}
#[test]
fn at_most_length_of_longer_property() {
fn at_most_size_of_longer(a: String, b: String) -> bool {
let upper_bound = *[a.chars().count(), b.chars().count()].iter().max().unwrap();
... | ize_a
};
edit_distance: | conditional_block |
tests.rs | extern crate edit_distance;
#[test]
fn simple() {
assert_eq!(edit_distance::edit_distance("kitten", "sitting"), 3);
assert_eq!(edit_distance::edit_distance("Tier", "Tor"), 2);
}
#[test]
fn same() {
assert_eq!(edit_distance::edit_distance("kitten", "kitten"), 0);
}
#[test]
fn empty_a() {
assert_eq!(ed... | quals_b(a: String, b: String) -> bool {
let d = edit_distance::edit_distance(&a, &b);
if a == b {
d == 0
} else {
d > 0
}
}
quickcheck(zero_iff_a_equals_b as fn(a: String, b: String) -> bool);
}
#[test]
fn triangle_inequality_property() {
fn triangl... | erty() {
fn zero_iff_a_e | identifier_name |
tests.rs |
#[test]
fn simple() {
assert_eq!(edit_distance::edit_distance("kitten", "sitting"), 3);
assert_eq!(edit_distance::edit_distance("Tier", "Tor"), 2);
}
#[test]
fn same() {
assert_eq!(edit_distance::edit_distance("kitten", "kitten"), 0);
}
#[test]
fn empty_a() {
assert_eq!(edit_distance::edit_distance("... | extern crate edit_distance; | random_line_split | |
method-on-generic-struct.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
let stack = Struct { x: (8888_u32, -8888_i32) };
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = box Struct { x: 1234.5f64 };
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
}
fn zzz() {()}
| main | identifier_name |
method-on-generic-struct.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn self_by_val(self, arg1: int, arg2: int) -> int {
zzz(); // #break
arg1 + arg2
}
fn self_owned(self: Box<Struct<T>>, arg1: int, arg2: int) -> int {
zzz(); // #break
arg1 + arg2
}
}
fn main() {
let stack = Struct { x: (8888_u32, -8888_i32) };
let _ = stack.se... | {
zzz(); // #break
arg1 + arg2
} | identifier_body |
method-on-generic-struct.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | // lldb-command:continue
// OWNED MOVED
// lldb-command:print *self
// lldb-check:[...]$12 = Struct<f64> { x: 1234.5 }
// lldb-command:print arg1
// lldb-check:[...]$13 = -9
// lldb-command:print arg2
// lldb-check:[...]$14 = -10
// lldb-command:continue
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#... | // lldb-check:[...]$11 = -8 | random_line_split |
ui.mako.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import Method %>
// CSS Basic User Interface M... | products="gecko",
gecko_ffi_name="mWindowShadow",
gecko_constant_prefix="NS_STYLE_WINDOW_SHADOW",
animation_value_type="discrete",
enabled_in="chrome",
spec="None (Nonstandard internal property)",
)}
${helpers.predefined_type(
"-moz-window-opacity",
"Opacity",
"1.0",
products="g... | "none default menu tooltip sheet", | random_line_split |
lib.rs | #![crate_name = "bindgen"]
#![crate_type = "dylib"]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate clang_sys;
extern crate syntex_syntax as syntax;
extern crate libc;
#[macro_use] extern crate log;
use std::collections::HashSet;
use std::default::Defau... |
pub fn match_pat<T: Into<String>>(&mut self, arg: T) -> &mut Self {
self.options.match_pat.push(arg.into());
self
}
pub fn clang_arg<T: Into<String>>(&mut self, arg: T) -> &mut Self {
self.options.clang_args.push(arg.into());
self
}
pub fn link<T: Into<String>>(&m... | {
self.clang_arg(header)
} | identifier_body |
lib.rs | #![crate_name = "bindgen"]
#![crate_type = "dylib"]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate clang_sys;
extern crate syntex_syntax as syntax;
extern crate libc;
#[macro_use] extern crate log;
use std::collections::HashSet;
use std::default::Defau... | () -> Builder<'a> {
Builder {
logger: None,
options: Default::default()
}
}
}
#[derive(Clone)]
/// Deprecated - use a `Builder` instead
pub struct BindgenOptions {
pub match_pat: Vec<String>,
pub builtins: bool,
pub rust_enums: bool,
pub links: Vec<(String, L... | default | identifier_name |
lib.rs | #![crate_name = "bindgen"]
#![crate_type = "dylib"]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate clang_sys;
extern crate syntex_syntax as syntax;
extern crate libc;
#[macro_use] extern crate log;
use std::collections::HashSet;
use std::default::Defau... | options: Default::default()
}
}
}
#[derive(Clone)]
/// Deprecated - use a `Builder` instead
pub struct BindgenOptions {
pub match_pat: Vec<String>,
pub builtins: bool,
pub rust_enums: bool,
pub links: Vec<(String, LinkType)>,
pub emit_ast: bool,
pub fail_on_unknown_type:... |
impl<'a> Default for Builder<'a> {
fn default() -> Builder<'a> {
Builder {
logger: None, | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... |
extern crate app_units;
extern crate atomic_refcell;
extern crate canvas_traits;
extern crate cssparser;
extern crate euclid;
extern crate gfx_traits;
#[macro_use] extern crate html5ever;
extern crate ipc_channel;
extern crate libc;
#[macro_use]
extern crate log;
extern crate malloc_size_of;
#[macro_use] extern crate ... |
#![deny(unsafe_code)]
#![feature(associated_type_defaults)] | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
/// The number of children remaining to process during bottom-up traversal.
pub children_to_process: AtomicIsize,
}
impl DomParallelInfo {
pub fn new() -> DomParallelInfo {
DomParallelInfo {
children_to_process: AtomicIsize::new(0),
}
}
}
#[derive(Clone, Copy, Debug, Eq... | DomParallelInfo | identifier_name |
check-pass.rs | // Tests the new rules added by RFC 2396, including:
// - applying `#[target_feature]` to safe functions is allowed
// - calling functions with `#[target_feature]` is allowed in
// functions which have (at least) the same features
// - calling functions with `#[target_feature]` is allowed in
// unsafe contexts
// -... | {
if cfg!(target_feature = "sse2") {
unsafe {
sse2();
Foo.sse2();
}
}
let sse2_ptr: unsafe fn() = sse2;
} | identifier_body | |
check-pass.rs | // Tests the new rules added by RFC 2396, including:
// - applying `#[target_feature]` to safe functions is allowed
// - calling functions with `#[target_feature]` is allowed in
// functions which have (at least) the same features
// - calling functions with `#[target_feature]` is allowed in
// unsafe contexts
// -... |
let sse2_ptr: unsafe fn() = sse2;
}
| {
unsafe {
sse2();
Foo.sse2();
}
} | conditional_block |
check-pass.rs | // Tests the new rules added by RFC 2396, including:
// - applying `#[target_feature]` to safe functions is allowed
// - calling functions with `#[target_feature]` is allowed in
// functions which have (at least) the same features
// - calling functions with `#[target_feature]` is allowed in
// unsafe contexts
// -... | ;
impl Foo {
#[target_feature(enable = "sse2")]
fn sse2(&self) {
sse2();
}
}
fn main() {
if cfg!(target_feature = "sse2") {
unsafe {
sse2();
Foo.sse2();
}
}
let sse2_ptr: unsafe fn() = sse2;
}
| Foo | identifier_name |
check-pass.rs | // Tests the new rules added by RFC 2396, including:
// - applying `#[target_feature]` to safe functions is allowed
// - calling functions with `#[target_feature]` is allowed in
// functions which have (at least) the same features
// - calling functions with `#[target_feature]` is allowed in
// unsafe contexts
// -... | // revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![feature(target_feature_11)]
#[target_feature(enable = "sse2")]
const fn sse2() {}
#[cfg(target_feature = "sse2")]
const SSE2_ONLY: () = unsafe {
sse2();
};
#[target_feature(enable = "sse2")]
fn also_sse2() {
sse2();
}
#[target_feature(enabl... |
// check-pass
// only-x86_64 | random_line_split |
number.rs | use front::stdlib::value::{Value, ResultValue, VNumber, VInteger, to_value, from_value};
use front::stdlib::function::Function;
use std::f64::{NAN, MAX_VALUE, MIN_VALUE, INFINITY, NEG_INFINITY, EPSILON};
/// Parse a float into a value
pub fn parse_float(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue {
l... |
/// Check if a value when converted to a number is equal to NaN
pub fn is_nan(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue {
Ok(to_value(if args.len() == 0 {
false
} else {
from_value::<f64>(args[0]).unwrap().is_nan()
}))
}
/// Check if a number is equal to NaN
pub fn strict_i... | {
Ok(to_value(if args.len() == 0 {
false
} else {
match *args[0] {
VNumber(v) => v.is_finite(),
VInteger(_) => true, // integers can't be infinite
_ => false
}
}))
} | identifier_body |
number.rs | use front::stdlib::value::{Value, ResultValue, VNumber, VInteger, to_value, from_value};
use front::stdlib::function::Function;
use std::f64::{NAN, MAX_VALUE, MIN_VALUE, INFINITY, NEG_INFINITY, EPSILON};
/// Parse a float into a value
pub fn parse_float(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue {
l... | (args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue {
let parsed = from_str::<i32>(from_value::<String>(args[0]).unwrap().as_slice());
return Ok(match parsed {
Some(v) => to_value(v),
None => to_value(NAN)
});
}
/// Check if a value when converted to a number is finite
pub fn is_fini... | parse_int | identifier_name |
number.rs | use front::stdlib::value::{Value, ResultValue, VNumber, VInteger, to_value, from_value};
use front::stdlib::function::Function;
use std::f64::{NAN, MAX_VALUE, MIN_VALUE, INFINITY, NEG_INFINITY, EPSILON};
/// Parse a float into a value
pub fn parse_float(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue {
l... | } else {
from_value::<f64>(args[0]).unwrap().is_nan()
}))
}
/// Check if a number is equal to NaN
pub fn strict_is_nan(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue {
Ok(to_value(if args.len() == 0 {
false
} else {
match *args[0] {
VNumber(v) => v.is_nan(... | pub fn is_nan(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue {
Ok(to_value(if args.len() == 0 {
false | random_line_split |
path_filter.rs |
use std::path::{PathBuf, Path, Component};
use ignore::gitignore::GitignoreBuilder;
use errors;
pub(crate) fn new(base_path: &Path, stash_path: &Path) -> errors::Result<PathFilter> {
let base_path = PathBuf::from(base_path).canonicalize()?;
let stash_path = PathBuf::from(stash_path).canonicalize()?;
Ok(Pa... | (&self, path: &Path) -> errors::Result<bool> {
if!self.is_in_scope(&path) {
debug!("ignoring {:?} because not in scope", path);
return Ok(false);
}
if self.is_stash_path(&path) {
debug!("ignoring {:?} because within the stash", path);
return Ok(fa... | allow | identifier_name |
path_filter.rs | use std::path::{PathBuf, Path, Component};
use ignore::gitignore::GitignoreBuilder;
use errors;
pub(crate) fn new(base_path: &Path, stash_path: &Path) -> errors::Result<PathFilter> {
let base_path = PathBuf::from(base_path).canonicalize()?;
let stash_path = PathBuf::from(stash_path).canonicalize()?;
Ok(Pat... | if self.is_stash_path(&path) {
debug!("ignoring {:?} because within the stash", path);
return Ok(false);
}
if self.is_dotted(&path) {
debug!("ignoring {:?} because it's a dotted file", path);
return Ok(false);
}
if self.ignored(&p... | if !self.is_in_scope(&path) {
debug!("ignoring {:?} because not in scope", path);
return Ok(false);
}
| random_line_split |
path_filter.rs |
use std::path::{PathBuf, Path, Component};
use ignore::gitignore::GitignoreBuilder;
use errors;
pub(crate) fn new(base_path: &Path, stash_path: &Path) -> errors::Result<PathFilter> {
let base_path = PathBuf::from(base_path).canonicalize()?;
let stash_path = PathBuf::from(stash_path).canonicalize()?;
Ok(Pa... |
fn ignored(&self, path: &Path) -> errors::Result<bool> {
let rel_path = if path.is_absolute() {
path.strip_prefix(&self.base_path)?
} else {
path
};
let mut builder = GitignoreBuilder::new(&self.base_path);
builder.add(".gitignore");
let mu... | {
(!path.is_absolute()) || path.starts_with(&self.base_path)
} | identifier_body |
issue-16602-2.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 ... | {
let mut a = A { x: 1, y: 1 };
a = A { x: a.y * 2, y: a.x * 2 };
assert_eq!(a.x, 2);
assert_eq!(a.y, 2);
} | identifier_body | |
issue-16602-2.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.
// | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// run-pass
struct A {
pub x: u32,
pub y: u32,
}
fn main() {
let mut a = A { x: 1, y: 1 };
a = A { x: a.y * 2, y: a.x * 2 };
assert_eq!(a.x, 2);
assert_eq!(a.y, 2);
} | // 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 | random_line_split |
issue-16602-2.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 ... | {
pub x: u32,
pub y: u32,
}
fn main() {
let mut a = A { x: 1, y: 1 };
a = A { x: a.y * 2, y: a.x * 2 };
assert_eq!(a.x, 2);
assert_eq!(a.y, 2);
}
| A | identifier_name |
datum.rs | is the actual value (*only used for immediates* like ints, ptrs)
ByValue,
}
pub fn immediate_rvalue<'tcx>(val: ValueRef, ty: Ty<'tcx>) -> Datum<'tcx, Rvalue> {
return Datum::new(val, ty, Rvalue::new(ByValue));
}
pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
... | pub fn to_appropriate_datum<'blk>(self, bcx: Block<'blk, 'tcx>)
-> DatumBlock<'blk, 'tcx, Rvalue> {
match self.appropriate_rvalue_mode(bcx.ccx()) {
ByRef => {
self.to_ref_datum(bcx)
}
ByValue => {
match... | DatumBlock::new(bcx, scratch)
}
}
}
| random_line_split |
datum.rs | zero: bool,
scope: cleanup::ScopeId,
arg: A,
populate: F)
-> DatumBlock<'blk, 'tcx, Lvalue... | shallow_copy | identifier_name | |
datum.rs | the actual value (*only used for immediates* like ints, ptrs)
ByValue,
}
pub fn immediate_rvalue<'tcx>(val: ValueRef, ty: Ty<'tcx>) -> Datum<'tcx, Rvalue> {
return Datum::new(val, ty, Rvalue::new(ByValue));
}
pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
... |
}
impl KindOps for Lvalue {
/// If an lvalue is moved, we must zero out the memory in which it resides so as to cancel
/// cleanup. If an @T lvalue is copied, we must increment the reference count.
fn post_store<'blk, 'tcx>(&self,
bcx: Block<'blk, 'tcx>,
... | {
RvalueExpr(self)
} | identifier_body |
overloaded-index-in-field.rs | // run-pass
// Test using overloaded indexing when the "map" is stored in a
// field. This caused problems at some point.
use std::ops::Index;
struct Foo {
x: isize,
y: isize,
}
struct Bar {
foo: Foo
}
impl Index<isize> for Foo {
type Output = isize;
fn index(&self, z: isize) -> &isize {
... |
}
fn main() {
let f = Bar { foo: Foo {
x: 1,
y: 2,
} };
assert_eq!(f.foo[1].get(), 2);
}
| { *self += 1; } | identifier_body |
overloaded-index-in-field.rs | // run-pass
// Test using overloaded indexing when the "map" is stored in a
// field. This caused problems at some point.
use std::ops::Index;
struct Foo {
x: isize,
y: isize,
}
struct Bar {
foo: Foo
}
impl Index<isize> for Foo {
type Output = isize;
fn index(&self, z: isize) -> &isize {
... | (&self) -> isize { *self }
fn inc(&mut self) { *self += 1; }
}
fn main() {
let f = Bar { foo: Foo {
x: 1,
y: 2,
} };
assert_eq!(f.foo[1].get(), 2);
}
| get_from_ref | identifier_name |
overloaded-index-in-field.rs | // run-pass
// Test using overloaded indexing when the "map" is stored in a
// field. This caused problems at some point.
use std::ops::Index;
struct Foo {
x: isize,
y: isize,
}
struct Bar {
foo: Foo
}
impl Index<isize> for Foo {
type Output = isize;
fn index(&self, z: isize) -> &isize {
... | else {
&self.y
}
}
}
trait Int {
fn get(self) -> isize;
fn get_from_ref(&self) -> isize;
fn inc(&mut self);
}
impl Int for isize {
fn get(self) -> isize { self }
fn get_from_ref(&self) -> isize { *self }
fn inc(&mut self) { *self += 1; }
}
fn main() {
let f = Bar ... | {
&self.x
} | conditional_block |
overloaded-index-in-field.rs | // run-pass
// Test using overloaded indexing when the "map" is stored in a
// field. This caused problems at some point.
use std::ops::Index;
struct Foo {
x: isize,
y: isize,
}
struct Bar {
foo: Foo
}
impl Index<isize> for Foo {
type Output = isize;
fn index(&self, z: isize) -> &isize {
... | impl Int for isize {
fn get(self) -> isize { self }
fn get_from_ref(&self) -> isize { *self }
fn inc(&mut self) { *self += 1; }
}
fn main() {
let f = Bar { foo: Foo {
x: 1,
y: 2,
} };
assert_eq!(f.foo[1].get(), 2);
} | }
| random_line_split |
body.rs | use std::borrow::Cow;
#[cfg(feature = "unstable-stream")]
use std::error::Error as StdError;
use std::fmt;
use bytes::Bytes;
use futures_core::Stream; // for mpsc::Receiver
use futures_channel::{mpsc, oneshot};
#[cfg(feature = "unstable-stream")]
use futures_util::TryStreamExt;
use http_body::{SizeHint, Body as HttpBo... |
/// Wrap a futures `Stream` in a box inside `Body`.
///
/// # Example
///
/// ```
/// # use hyper::Body;
/// # fn main() {
/// let chunks: Vec<Result<_, ::std::io::Error>> = vec![
/// Ok("hello"),
/// Ok(" "),
/// Ok("world"),
/// ];
///
/// let stre... | {
let (tx, rx) = mpsc::channel(0);
let (abort_tx, abort_rx) = oneshot::channel();
let tx = Sender {
abort_tx: abort_tx,
tx: tx,
};
let rx = Body::new(Kind::Chan {
content_length,
abort_rx,
rx,
});
(tx, ... | identifier_body |
body.rs | use std::borrow::Cow;
#[cfg(feature = "unstable-stream")]
use std::error::Error as StdError;
use std::fmt;
use bytes::Bytes;
use futures_core::Stream; // for mpsc::Receiver
use futures_channel::{mpsc, oneshot};
#[cfg(feature = "unstable-stream")]
use futures_util::TryStreamExt;
use http_body::{SizeHint, Body as HttpBo... | self.extra_mut().delayed_eof = Some(DelayEof::Eof(delay));
Poll::Pending
},
Poll::Ready(Err(_done)) => {
Poll::Ready(None)
},
}
},
None => self.poll... | random_line_split | |
body.rs | use std::borrow::Cow;
#[cfg(feature = "unstable-stream")]
use std::error::Error as StdError;
use std::fmt;
use bytes::Bytes;
use futures_core::Stream; // for mpsc::Receiver
use futures_channel::{mpsc, oneshot};
#[cfg(feature = "unstable-stream")]
use futures_util::TryStreamExt;
use http_body::{SizeHint, Body as HttpBo... | (vec: Vec<u8>) -> Body {
Body::from(Chunk::from(vec))
}
}
impl From<&'static [u8]> for Body {
#[inline]
fn from(slice: &'static [u8]) -> Body {
Body::from(Chunk::from(slice))
}
}
impl From<Cow<'static, [u8]>> for Body {
#[inline]
fn from(cow: Cow<'static, [u8]>) -> Body {
... | from | identifier_name |
uv.rs | use libc;
use std::os::raw::c_int;
pub enum Loop {} | }
pub struct Async(*mut Inner);
unsafe impl Send for Async {}
unsafe impl Sync for Async {}
impl Async {
pub fn new<F: Fn()>(callback: F) -> Async {
unsafe {
extern "C" fn async_cb(asyn: *mut Inner) {
unsafe {
let data = (*asyn).data as *mut Box<Fn()>;
... |
#[repr(C)]
struct Inner {
data: *mut libc::c_void,
buf: [u8; 128], | random_line_split |
uv.rs | use libc;
use std::os::raw::c_int;
pub enum | {}
#[repr(C)]
struct Inner {
data: *mut libc::c_void,
buf: [u8; 128],
}
pub struct Async(*mut Inner);
unsafe impl Send for Async {}
unsafe impl Sync for Async {}
impl Async {
pub fn new<F: Fn()>(callback: F) -> Async {
unsafe {
extern "C" fn async_cb(asyn: *mut Inner) {
... | Loop | identifier_name |
uv.rs | use libc;
use std::os::raw::c_int;
pub enum Loop {}
#[repr(C)]
struct Inner {
data: *mut libc::c_void,
buf: [u8; 128],
}
pub struct Async(*mut Inner);
unsafe impl Send for Async {}
unsafe impl Sync for Async {}
impl Async {
pub fn new<F: Fn()>(callback: F) -> Async {
unsafe {
extern... |
}
extern "C" {
fn uv_async_init(
evloop: *mut Loop,
async: *mut Inner,
async_cb: extern "C" fn(*mut Inner),
) -> c_int;
fn uv_async_send(async: *const Inner) -> c_int;
fn uv_close(async: *mut Inner, close_cb: extern "C" fn(*mut Inner));
fn uv_default_loop() -> *mut Loop;
}
| {
extern "C" fn close_cb(asyn: *mut Inner) {
unsafe { Box::from_raw(asyn) };
}
unsafe { uv_close(self.0, close_cb) };
} | identifier_body |
fs.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
| {
let tmpdir = TempDir::new("rustc-fs").unwrap();
let tmpdir = realpath(tmpdir.path()).unwrap();
let a = tmpdir.join("a");
let b = a.join("b");
let c = b.join("c");
let d = a.join("d");
let e = d.join("e");
let f = a.join("f");
mkdir_recursive(&b... | identifier_body |
fs.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let tmpdir = TempDir::new("rustc-fs").unwrap();
let tmpdir = realpath(tmpdir.path()).unwrap();
let a = tmpdir.join("a");
let b = a.join("b");
let c = b.join("c");
let d = a.join("d");
let e = d.join("e");
let f = a.join("f");
mkdir_recursive... | realpath_works_tricky | identifier_name |
fs.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 ... | mkdir_recursive(&b, io::USER_RWX).unwrap();
mkdir_recursive(&d, io::USER_RWX).unwrap();
File::create(&f).unwrap();
symlink(&Path::new("../d/e"), &c).unwrap();
symlink(&Path::new("../f"), &e).unwrap();
assert!(realpath(&c).unwrap() == f);
assert!(realpath(&e).unwr... | let e = d.join("e");
let f = a.join("f");
| random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(globs, macro_rules, phase, thread_local, link_args)]
#![allow(experimental, non_camel_case_types)]
#![... | // Must come first.
pub mod macros;
pub mod browser;
pub mod browser_host;
pub mod command_line;
pub mod cookie;
pub mod core;
pub mod drag_data;
pub mod eutil;
pub mod frame;
pub mod interfaces;
pub mod print_settings;
pub mod process_message;
pub mod render_handler;
pub mod request;
pub mod request_context;
pub mod ... | random_line_split | |
engine.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 std::fmt::Debug;
use std::os::unix::io::RawFd;
use std::path::{Path, PathBuf};
use chrono::{DateTime, Utc};
use ... | /// The number of Sectors in this pool that are currently in use by the
/// pool for some purpose, be it to store metadata, to store user data,
/// or to reserve for some other purpose.
fn total_physical_used(&self) -> StratisResult<Sectors>;
/// Get all the filesystems belonging to this pool.
... | fn total_physical_size(&self) -> Sectors;
| random_line_split |
lib.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// https://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or d... | {
if context.access_info.borrow().is_empty() {
refresh_access_info(context, client)
} else {
future::ok(()).into_box()
}
} | identifier_body | |
lib.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// https://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or d... | (context: Rc<Registered>, client: &AppClient) -> Box<AppFuture<()>> {
let entry_key = fry!(access_container_enc_key(
&context.app_id,
&context.sym_enc_key,
&context.access_container_info.nonce,
));
client
.get_seq_mdata_value(
context.access_container_info.id,
... | refresh_access_info | identifier_name |
lib.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// https://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or d... | pub struct Registered {
object_cache: ObjectCache,
app_id: String,
sym_enc_key: shared_secretbox::Key,
access_container_info: AccessContInfo,
access_info: RefCell<AccessContainerEntry>,
}
impl AppContext {
fn unregistered() -> Self {
AppContext::Unregistered(Rc::new(Unregistered {
... | random_line_split | |
buttons-child-attribute.rs | /*
* Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com>
*
* 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, ... | use gtk::WindowType::Popup;
use relm::Widget;
use relm_derive::{Msg, widget};
use self::Msg::*;
pub struct Model {
counter: i32,
}
#[derive(Msg)]
pub enum Msg {
Decrement,
Increment,
Quit,
}
#[widget]
impl Widget for Win {
fn model() -> Model {
Model {
counter: 0,
}
... | };
use gtk::Orientation::Vertical; | random_line_split |
buttons-child-attribute.rs | /*
* Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com>
*
* 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, ... |
view! {
gtk::Window(Popup) {
gtk::Box {
orientation: Vertical,
#[name="label"]
gtk::Label {
text: &self.model.counter.to_string(),
},
#[name="dec_button"]
gtk::Button {
... | {
match event {
Decrement => self.model.counter -= 1,
Increment => self.model.counter += 1,
Quit => gtk::main_quit(),
}
} | identifier_body |
buttons-child-attribute.rs | /*
* Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com>
*
* 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, ... | () -> Model {
Model {
counter: 0,
}
}
fn update(&mut self, event: Msg) {
match event {
Decrement => self.model.counter -= 1,
Increment => self.model.counter += 1,
Quit => gtk::main_quit(),
}
}
view! {
gtk::Window(P... | model | identifier_name |
helpers.rs | use fuse::{ReplyAttr, ReplyEntry, Request};
use fs::constants;
use fs::GoodDataFS;
use fs::helpers::create_inode_directory_attributes;
use fs::inode;
use fs::item;
use std::path::Path;
pub fn getattr(_fs: &mut GoodDataFS, _req: &Request, ino: u64, reply: ReplyAttr) {
let attr = create_inode_directory_attributes(i... | (_fs: &mut GoodDataFS,
_req: &Request,
parent: u64,
_name: &Path,
reply: ReplyEntry,
item: &item::ProjectItem) {
let inode_parent = inode::Inode::deserialize(parent);
let inode = inode::Inode::serialize(&inode::Inode {
project: inode_... | lookup | identifier_name |
helpers.rs | use fuse::{ReplyAttr, ReplyEntry, Request};
use fs::constants;
use fs::GoodDataFS;
use fs::helpers::create_inode_directory_attributes;
use fs::inode;
use fs::item;
use std::path::Path;
pub fn getattr(_fs: &mut GoodDataFS, _req: &Request, ino: u64, reply: ReplyAttr) {
let attr = create_inode_directory_attributes(i... | pub fn lookup(_fs: &mut GoodDataFS,
_req: &Request,
parent: u64,
_name: &Path,
reply: ReplyEntry,
item: &item::ProjectItem) {
let inode_parent = inode::Inode::deserialize(parent);
let inode = inode::Inode::serialize(&inode::Inode {
pr... | random_line_split | |
helpers.rs | use fuse::{ReplyAttr, ReplyEntry, Request};
use fs::constants;
use fs::GoodDataFS;
use fs::helpers::create_inode_directory_attributes;
use fs::inode;
use fs::item;
use std::path::Path;
pub fn getattr(_fs: &mut GoodDataFS, _req: &Request, ino: u64, reply: ReplyAttr) |
pub fn lookup(_fs: &mut GoodDataFS,
_req: &Request,
parent: u64,
_name: &Path,
reply: ReplyEntry,
item: &item::ProjectItem) {
let inode_parent = inode::Inode::deserialize(parent);
let inode = inode::Inode::serialize(&inode::Inode {
... | {
let attr = create_inode_directory_attributes(ino);
reply.attr(&constants::DEFAULT_TTL, &attr);
} | identifier_body |
rule_cache.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/. */
//! A cache from rule node to computed values, in order to cache reset
//! properties.
use crate::logical_geomet... | ,
None => break,
},
None => {},
}
rule_node = node.parent();
}
rule_node
}
/// Finds a node in the properties matched cache.
///
/// This needs to receive a `StyleBuilder` with the `early` properties
/// alr... | {
let cascade_level = node.cascade_level();
let decls = decls.read_with(cascade_level.guard(guards));
if decls.contains_any_reset() {
break;
}
} | conditional_block |
rule_cache.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/. */
//! A cache from rule node to computed values, in order to cache reset
//! properties.
use crate::logical_geomet... |
true
}
} | .push((conditions.clone(), style.clone())); | random_line_split |
rule_cache.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/. */
//! A cache from rule node to computed values, in order to cache reset
//! properties.
use crate::logical_geomet... | {
uncacheable: bool,
font_size: Option<NonNegativeLength>,
writing_mode: Option<WritingMode>,
}
impl RuleCacheConditions {
/// Sets the style as depending in the font-size value.
pub fn set_font_size_dependency(&mut self, font_size: NonNegativeLength) {
debug_assert!(self.font_size.map_or(... | RuleCacheConditions | identifier_name |
match-ref-mut-stability.rs | // Check that `ref mut` variables don't change address between the match guard
// and the arm expression.
// run-pass
// Test that z always point to the same temporary.
fn referent_stability() {
let p;
match 0 {
ref mut z if { p = z as *const _; true } => assert_eq!(p, z as *const _),
_ => unr... | () {
let r;
match 0 {
ref mut z if { r = z as &_; true } => assert_eq!(*r, 0),
_ => unreachable!(),
}
}
fn main() {
referent_stability();
variable_stability();
persist_borrow();
}
| persist_borrow | identifier_name |
match-ref-mut-stability.rs | // Check that `ref mut` variables don't change address between the match guard
// and the arm expression.
// run-pass
// Test that z always point to the same temporary.
fn referent_stability() |
// Test that z is always effectively the same variable.
fn variable_stability() {
let p;
match 0 {
ref mut z if { p = &z as *const _; true } => assert_eq!(p, &z as *const _),
_ => unreachable!(),
};
}
// Test that a borrow of *z can cross from the guard to the arm.
fn persist_borrow() {
... | {
let p;
match 0 {
ref mut z if { p = z as *const _; true } => assert_eq!(p, z as *const _),
_ => unreachable!(),
};
} | identifier_body |
match-ref-mut-stability.rs | // Check that `ref mut` variables don't change address between the match guard
// and the arm expression.
// run-pass
// Test that z always point to the same temporary.
fn referent_stability() {
let p;
match 0 {
ref mut z if { p = z as *const _; true } => assert_eq!(p, z as *const _),
_ => unr... | _ => unreachable!(),
};
}
// Test that a borrow of *z can cross from the guard to the arm.
fn persist_borrow() {
let r;
match 0 {
ref mut z if { r = z as &_; true } => assert_eq!(*r, 0),
_ => unreachable!(),
}
}
fn main() {
referent_stability();
variable_stability();
... | // Test that z is always effectively the same variable.
fn variable_stability() {
let p;
match 0 {
ref mut z if { p = &z as *const _; true } => assert_eq!(p, &z as *const _), | random_line_split |
gash.rs | //
// gash.rs
//
// Starting code for PS2
// Running on Rust 0.9
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern mod extra;
use std::{io, run, os};
use std::io::buffered::BufferedReader;
use std::io::stdin;
use extra::getopts;
struct Shell {
cmd_prompt: ~str,
... | return None;
}
}
fn main() {
let opt_cmd_line = get_cmdline_from_args();
match opt_cmd_line {
Some(cmd_line) => Shell::new("").run_cmdline(cmd_line),
None => Shell::new("gash > ").run()
}
}
| {
/* Begin processing program arguments and initiate the parameters. */
let args = os::args();
let opts = ~[
getopts::optopt("c")
];
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => { m }
Err(f) => { fail!(f.to_err_msg()) }
};
if match... | identifier_body |
gash.rs | //
// gash.rs
//
// Starting code for PS2
// Running on Rust 0.9
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern mod extra;
use std::{io, run, os};
use std::io::buffered::BufferedReader;
use std::io::stdin;
use extra::getopts;
struct Shell {
cmd_prompt: ~str,
... | () -> Option<~str> {
/* Begin processing program arguments and initiate the parameters. */
let args = os::args();
let opts = ~[
getopts::optopt("c")
];
let matches = match getopts::getopts(args.tail(), opts) {
Ok(m) => { m }
Err(f) => { fail!(f.to_err_msg()) }
}... | get_cmdline_from_args | identifier_name |
gash.rs | //
// gash.rs
//
// Starting code for PS2
// Running on Rust 0.9
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern mod extra;
use std::{io, run, os};
use std::io::buffered::BufferedReader;
use std::io::stdin;
use extra::getopts;
struct Shell {
cmd_prompt: ~str,
... | println!("{}", *line);
}}
_ => { self.run_cmdline(cmd_line); }
}
}
}
fn run_cmdline(&mut self, cmd_line: &str) {
let mut argv: ~[~str] =
cmd_line.split(' ').filter_map(|x|... | "history" => { for line in self.history.iter() { | random_line_split |
glade.rs | /*
* Copyright (c) 2020 Boucher, Antoni <bouanto@zoho.com>
*
* 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,... |
fn main() {
Win::run(()).expect("Win::run failed");
}
#[cfg(test)]
mod tests {
use gtk::prelude::LabelExt;
use gtk_test::assert_text;
use relm_test::click;
use crate::Win;
#[test]
#[ignore]
fn label_change() {
let (_component, _, widgets) = relm::init_test::<Win>(()).expect(... |
fn get_widgets(&self) -> Self::Widgets {
self.widgets.clone()
}
} | random_line_split |
glade.rs | /*
* Copyright (c) 2020 Boucher, Antoni <bouanto@zoho.com>
*
* 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,... | () {
Win::run(()).expect("Win::run failed");
}
#[cfg(test)]
mod tests {
use gtk::prelude::LabelExt;
use gtk_test::assert_text;
use relm_test::click;
use crate::Win;
#[test]
#[ignore]
fn label_change() {
let (_component, _, widgets) = relm::init_test::<Win>(()).expect("init_te... | main | identifier_name |
glade.rs | /*
* Copyright (c) 2020 Boucher, Antoni <bouanto@zoho.com>
*
* 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,... | click(minus_button);
assert_text!(label, 1);
click(minus_button);
assert_text!(label, 0);
click(minus_button);
assert_text!(label, -1);
}
}
| {
let (_component, _, widgets) = relm::init_test::<Win>(()).expect("init_test failed");
let plus_button = &widgets.plus_button;
let minus_button = &widgets.minus_button;
let label = &widgets.counter_label;
assert_text!(label, 0);
click(plus_button);
assert_text!(... | identifier_body |
ri01_.rs | #[feature(struct_variant)];
mod ast;
mod bits;
mod bits1;
mod error;
mod interp;
mod interp1;
mod interp2;
mod interp3;
mod location;
mod parse1;
mod symbol;
mod token;
fn get_main(args: &[~str]) -> ~str {
assert!(args.len() > 0);
for i in range(1, args.len()-1) {
if "-" == args[i] {
retur... | (args: &[~str]) -> ~[Path] {
assert!(args.len() > 0);
for i in range(1, args.len()-1) {
if "-" == args[i] {
return args.slice_from(i+2).map(|arg| Path::new(arg.to_str()));
}
}
~[]
}
#[cfg(not(test))]
fn main() {
use std::io;
use std::os;
use ast::Ast;
use int... | get_arg_files | identifier_name |
ri01_.rs | #[feature(struct_variant)];
mod ast;
mod bits;
mod bits1;
mod error;
mod interp;
mod interp1;
mod interp2;
mod interp3;
mod location;
mod parse1;
mod symbol;
mod token;
fn get_main(args: &[~str]) -> ~str {
assert!(args.len() > 0);
for i in range(1, args.len()-1) {
if "-" == args[i] {
retur... | let main_arity = ast.lookup(main_index).arity();
let mut arg_files = get_arg_files(args);
while arg_files.len() > main_arity {
arg_files.pop();
}
assert!(arg_files.len() <= main_arity);
let mut args = arg_files.map(|path| interp.file(path));
assert!(ar... | None => error([format!("No such function `{}`", main_name)]),
Some(index) => index,
}; | random_line_split |
ri01_.rs | #[feature(struct_variant)];
mod ast;
mod bits;
mod bits1;
mod error;
mod interp;
mod interp1;
mod interp2;
mod interp3;
mod location;
mod parse1;
mod symbol;
mod token;
fn get_main(args: &[~str]) -> ~str {
assert!(args.len() > 0);
for i in range(1, args.len()-1) {
if "-" == args[i] {
retur... | }
let ast : Ast<B> = match Ast::parse(get_src_files(args), &|bits| interp.constant(bits)) {
Ok(ast) => ast,
Err(errors) => error(errors.map(|e| e.to_str())),
};
let main_name = get_main(args);
let main_index = match ast.lookup_index_by_str(main_name) {
... | {
use std::io;
use std::os;
use ast::Ast;
use interp::Interp;
use InterpImpl = interp3::Interp3;
fn error(msg: &[~str]) -> ! {
use std::libc;
for line in msg.iter() {
io::stderr().write_line(line.to_str()).ok();
}
unsafe { libc::exit(1) }
}
f... | identifier_body |
table_caption.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! CSS table formatting contexts.
#![deny(unsafe_code)]
use app_units::Au;
use block::BlockFlow;
use context::{... | {
pub block_flow: BlockFlow,
}
impl TableCaptionFlow {
pub fn from_fragment(fragment: Fragment) -> TableCaptionFlow {
TableCaptionFlow {
block_flow: BlockFlow::from_fragment(fragment),
}
}
}
impl Flow for TableCaptionFlow {
fn class(&self) -> FlowClass {
FlowClass:... | TableCaptionFlow | identifier_name |
table_caption.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! CSS table formatting contexts.
#![deny(unsafe_code)]
use app_units::Au;
use block::BlockFlow;
use context::{... | self.block_flow.collect_stacking_contexts(parent);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block... | }
fn collect_stacking_contexts(&mut self, parent: &mut StackingContext) { | random_line_split |
table_caption.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! CSS table formatting contexts.
#![deny(unsafe_code)]
use app_units::Au;
use block::BlockFlow;
use context::{... |
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
self.block_flow.generated_containing_block_size(flow)
}
fn iterate_through_fragment_border_boxes(&self,
... | {
self.block_flow.repair_style(new_style)
} | identifier_body |
main.rs | extern crate docopt;
#[macro_use]
extern crate serde_derive;
use docopt::Docopt;
#[macro_use]
extern crate log;
use log::{Level, LevelFilter, Metadata, Record};
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{BufRead, BufReader, Seek, SeekFrom};
use std::path::Path;
static MY_LOGGER: Simp... | let mut csv_reader = BufReader::new(csv_file);
let mut row_buff = String::new();
match csv_reader.read_line(&mut row_buff) {
Ok(_n) => {
if row_buff.ends_with("\n") {
row_buff.pop();
}
}
Err(e) => return Err(format!("error gettig csv row: {}",... | return Err(format!("error seeking offset: {}", e));
}
| random_line_split |
main.rs | extern crate docopt;
#[macro_use]
extern crate serde_derive;
use docopt::Docopt;
#[macro_use]
extern crate log;
use log::{Level, LevelFilter, Metadata, Record};
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{BufRead, BufReader, Seek, SeekFrom};
use std::path::Path;
static MY_LOGGER: Simp... | };
let csv_cols: Vec<String> = {
let cols_iter = csv_header.split(csv_desc.delimiter);
match csv_desc.quote {
Some(q) => cols_iter.map(|s| s.trim_matches(q).to_string()).collect(),
None => cols_iter.map(|s| s.to_string()).collect(),
}
};
Ok(csv_cols)
}
... | {
let csv_file = match File::open(csv_desc.file_path) {
Err(why) => panic!(
"couldn't open csv @ {}: {}",
csv_desc.file_path.display(),
why
),
Ok(file) => file,
};
let csv_reader = BufReader::new(csv_file);
let mut csv_line_iter = csv_reader.... | identifier_body |
main.rs | extern crate docopt;
#[macro_use]
extern crate serde_derive;
use docopt::Docopt;
#[macro_use]
extern crate log;
use log::{Level, LevelFilter, Metadata, Record};
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{BufRead, BufReader, Seek, SeekFrom};
use std::path::Path;
static MY_LOGGER: Simp... | <'a>(
path_arg: &'a String,
delimiter_arg: &'a String,
quote_arg: &'a String,
) -> Result<CsvDesc<'a>, &'static str> {
let csv_file_path = Path::new(path_arg);
let csv_delimiter = match delimiter_arg.chars().next() {
Some(result) => result,
None => return Err("incorrect delimiter"),... | parse_args | identifier_name |
main.rs | macro_rules! welcome {
// `()` indicates that the macro takes no argument
() => (
// the macro will expand into the contents of this block
println!("Welcome to the Game!");
)
}
macro_rules! mac1 {
($arg:expr) => (println!("arg is {}", $arg));
}
macro_rules! printall {
( $( $arg:exp... | // v does not contain 25 | random_line_split | |
main.rs | macro_rules! welcome {
// `()` indicates that the macro takes no argument
() => (
// the macro will expand into the contents of this block
println!("Welcome to the Game!");
)
}
macro_rules! mac1 {
($arg:expr) => (println!("arg is {}", $arg));
}
macro_rules! printall {
( $( $arg:exp... | () {
welcome!(); // Welcome to the Game!
mac1!(42); // arg is 42
printall!("hello", 42, 3.14); // hello / 42 / 3.14 /
fn1();
// massert!(1 == 42);
let v = [10, 40, 30];
massert!(v.contains(&30));
massert!(!v.contains(&50));
unless!(v.contains(&25), println!("v does not contain 25")... | main | identifier_name |
main.rs | macro_rules! welcome {
// `()` indicates that the macro takes no argument
() => (
// the macro will expand into the contents of this block
println!("Welcome to the Game!");
)
}
macro_rules! mac1 {
($arg:expr) => (println!("arg is {}", $arg));
}
macro_rules! printall {
( $( $arg:exp... |
// Welcome to the Game!
// arg is 42
// hello / 42 / 3.14 / Called the function "fn1"()
// thread '<main>' panicked at 'Assertion failed!'
// v does not contain 25 | {
welcome!(); // Welcome to the Game!
mac1!(42); // arg is 42
printall!("hello", 42, 3.14); // hello / 42 / 3.14 /
fn1();
// massert!(1 == 42);
let v = [10, 40, 30];
massert!(v.contains(&30));
massert!(!v.contains(&50));
unless!(v.contains(&25), println!("v does not contain 25"));
... | identifier_body |
worklet.rs | _type: global_type,
}
}
pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> {
debug!("Creating worklet {:?}.", global_type);
reflect_dom_object(Box::new(Worklet::new_inherited(window, global_type)), window, Wrap)
}
pub fn | (&self) -> WorkletId {
self.worklet_id
}
#[allow(dead_code)]
pub fn worklet_global_scope_type(&self) -> WorkletGlobalScopeType {
self.global_type
}
}
impl WorkletMethods for Worklet {
#[allow(unrooted_must_root)]
/// <https://drafts.css-houdini.org/worklets/#dom-worklet-addmodu... | worklet_id | identifier_name |
worklet.rs | global_type: global_type,
}
}
pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> {
debug!("Creating worklet {:?}.", global_type);
reflect_dom_object(Box::new(Worklet::new_inherited(window, global_type)), window, Wrap)
}
pub fn worklet_id(&sel... | /// threads cycling between three thread roles:
///
/// * The primary worklet thread is the one available to execute
/// worklet code.
///
/// * The hot backup thread may peform GC, but otherwise is expected
/// to take over the primary role.
///
/// * The cold backup thread may peform script loading and other... | /// which is able to responsively execute worklet code. In particular,
/// worklet execution should not be delayed by GC, or by script
/// loading.
///
/// To achieve this, we implement a three-thread pool, with the | random_line_split |
enums3.rs | // enums3.rs
// Address all the TODOs to make the tests pass!
// I AM NOT DONE
enum Message {
// TODO: implement the message variant types based on their usage below
}
struct Point {
x: u8,
y: u8
}
struct State {
color: (u8, u8, u8),
position: Point,
quit: bool
}
impl State {
fn change_... |
fn quit(&mut self) {
self.quit = true;
}
fn echo(&self, s: String) {
println!("{}", s);
}
fn move_position(&mut self, p: Point) {
self.position = p;
}
fn process(&mut self, message: Message) {
// TODO: create a match expression to process the different me... | {
self.color = color;
} | identifier_body |
enums3.rs | // enums3.rs
// Address all the TODOs to make the tests pass!
// I AM NOT DONE
enum Message {
// TODO: implement the message variant types based on their usage below
}
struct | {
x: u8,
y: u8
}
struct State {
color: (u8, u8, u8),
position: Point,
quit: bool
}
impl State {
fn change_color(&mut self, color: (u8, u8, u8)) {
self.color = color;
}
fn quit(&mut self) {
self.quit = true;
}
fn echo(&self, s: String) {
println!("{}",... | Point | identifier_name |
enums3.rs | // enums3.rs
// Address all the TODOs to make the tests pass!
// I AM NOT DONE
enum Message {
// TODO: implement the message variant types based on their usage below
}
struct Point {
x: u8,
y: u8
}
struct State {
color: (u8, u8, u8),
position: Point,
quit: bool
}
impl State {
fn change_... | }
fn echo(&self, s: String) {
println!("{}", s);
}
fn move_position(&mut self, p: Point) {
self.position = p;
}
fn process(&mut self, message: Message) {
// TODO: create a match expression to process the different message variants
}
}
#[cfg(test)]
mod tests {
... | random_line_split | |
trait-default-method-xc.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn welp<T>(i: int, _x: &T) -> int {
i.g()
}
mod stuff {
pub struct thing { pub x: int }
}
impl A for stuff::thing {
fn f(&self) -> int { 10 }
}
fn g<T, U, V: B<T>>(i: V, j: T, k: U) -> (T, U) {
i.thing(j, k)
}
fn eq<T: TestEquality>(lhs: &T, rhs: &T) -> bool {
lhs.test_eq(rhs)
}
fn neq<T: Test... | {
assert_eq!(i.g(), 10);
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.