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 |
|---|---|---|---|---|
chmod.rs | #![crate_name = "uu_chmod"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alex Lyon <arcterus@mail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[cfg(unix)]
extern crate libc;
extern crate walker;
#[mac... | let negative_option = sanitize_input(&mut args);
let mut matches = opts.parse(args);
if matches.free.is_empty() {
show_error!("missing an argument");
show_error!("for help, try '{} --help'", NAME);
return 1;
} else {
let changes = matches.opt_present("changes");
... | {
let syntax = format!(
"[OPTION]... MODE[,MODE]... FILE...
{0} [OPTION]... OCTAL-MODE FILE...
{0} [OPTION]... --reference=RFILE FILE...",
NAME
);
let mut opts = new_coreopts!(&syntax, SUMMARY, LONG_HELP);
opts.optflag("c", "changes", "like verbose but report only when a change is made... | identifier_body |
chmod.rs | #![crate_name = "uu_chmod"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alex Lyon <arcterus@mail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[cfg(unix)]
extern crate libc;
extern crate walker;
#[mac... | {
changes: bool,
quiet: bool,
verbose: bool,
preserve_root: bool,
recursive: bool,
fmode: Option<u32>,
cmode: Option<String>,
}
impl Chmoder {
fn chmod(&self, files: Vec<String>) -> Result<(), i32> {
let mut r = Ok(());
for filename in &files {
let filename... | Chmoder | identifier_name |
chmod.rs | #![crate_name = "uu_chmod"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alex Lyon <arcterus@mail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[cfg(unix)]
extern crate libc;
extern crate walker;
#[mac... | match chmoder.chmod(matches.free) {
Ok(()) => {}
Err(e) => return e,
}
}
0
}
fn sanitize_input(args: &mut Vec<String>) -> Option<String> {
for i in 0..args.len() {
let first = args[i].chars().nth(0).unwrap();
if first!= '-' {
continue;
... | fmode: fmode,
cmode: cmode,
}; | random_line_split |
chmod.rs | #![crate_name = "uu_chmod"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Alex Lyon <arcterus@mail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[cfg(unix)]
extern crate libc;
extern crate walker;
#[mac... | } else {
None
};
let chmoder = Chmoder {
changes: changes,
quiet: quiet,
verbose: verbose,
preserve_root: preserve_root,
recursive: recursive,
fmode: fmode,
cmode: cmode,
};
match chmo... | {
let changes = matches.opt_present("changes");
let quiet = matches.opt_present("quiet");
let verbose = matches.opt_present("verbose");
let preserve_root = matches.opt_present("preserve-root");
let recursive = matches.opt_present("recursive");
let fmode = matches
... | conditional_block |
gdb-pretty-struct-and-enums.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... |
// gdb-command: print regular_struct
// gdb-check:$1 = RegularStruct = {the_first_field = 101, the_second_field = 102.5, the_third_field = false, the_fourth_field = "I'm so pretty, oh so pretty..."}
// gdb-command: print tuple
// gdb-check:$2 = {true, 103, "blub"}
// gdb-command: print tuple_struct
// gdb-check:$3 =... | // gdb-command: run | random_line_split |
gdb-pretty-struct-and-enums.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... | {
CStyleEnumVar1,
CStyleEnumVar2,
CStyleEnumVar3,
}
enum MixedEnum {
MixedEnumCStyleVar,
MixedEnumTupleVar(u32, u16, bool),
MixedEnumStructVar { field1: f64, field2: i32 }
}
struct NestedStruct {
regular_struct: RegularStruct,
tuple_struct: TupleStruct,
empty_struct: EmptyStruct,
... | CStyleEnum | identifier_name |
bswap16.rs | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::bswap16;
// pub fn bswap16(x: u16) -> u16;
macro_rules! bswap16_test {
($value:expr, $reverse:expr) => ({
let x: u16 = $value;
let result: u16 = unsafe { bswap16(x) };
assert_eq!(result, ... |
}
| {
bswap16_test!(0x0000, 0x0000);
bswap16_test!(0x0001, 0x0100);
bswap16_test!(0x0002, 0x0200);
bswap16_test!(0x0004, 0x0400);
bswap16_test!(0x0008, 0x0800);
bswap16_test!(0x0010, 0x1000);
bswap16_test!(0x0020, 0x2000);
bswap16_test!(0x0040, 0x4000);
bswap16_test!(0x0080, 0x8000);
bswap16_test!(0x0100, 0x0001)... | identifier_body |
bswap16.rs | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::bswap16;
// pub fn bswap16(x: u16) -> u16;
macro_rules! bswap16_test {
($value:expr, $reverse:expr) => ({
let x: u16 = $value;
let result: u16 = unsafe { bswap16(x) };
assert_eq!(result, ... | () {
bswap16_test!(0x0000, 0x0000);
bswap16_test!(0x0001, 0x0100);
bswap16_test!(0x0002, 0x0200);
bswap16_test!(0x0004, 0x0400);
bswap16_test!(0x0008, 0x0800);
bswap16_test!(0x0010, 0x1000);
bswap16_test!(0x0020, 0x2000);
bswap16_test!(0x0040, 0x4000);
bswap16_test!(0x0080, 0x8000);
bswap16_test!(0x0100, 0x00... | bswap16_test1 | identifier_name |
bswap16.rs | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::bswap16;
// pub fn bswap16(x: u16) -> u16;
macro_rules! bswap16_test {
($value:expr, $reverse:expr) => ({
let x: u16 = $value;
let result: u16 = unsafe { bswap16(x) };
assert_eq!(result, ... | } | } | random_line_split |
main.rs | use std::fs::File; // File::open(&str)
use std::io::prelude::*; // std::fs::File.read_to_string(&mut str)
static VOWELS: [char; 6] = ['a', 'e', 'i', 'o', 'u', 'y'];
fn get_input() -> String {
let mut file = match File::open("input.txt") {
Ok(input) => input,
Err(err) => panic!("Error: {}", err),
... | }
println!("");
} | println!("");
for ans in counters {
print!("{} ", ans); | random_line_split |
main.rs | use std::fs::File; // File::open(&str)
use std::io::prelude::*; // std::fs::File.read_to_string(&mut str)
static VOWELS: [char; 6] = ['a', 'e', 'i', 'o', 'u', 'y'];
fn | () -> String {
let mut file = match File::open("input.txt") {
Ok(input) => input,
Err(err) => panic!("Error: {}", err),
};
let mut input = String::new();
match file.read_to_string(&mut input) {
Ok(input) => input,
Err(err) => panic!("Error: {}", err),
};
input
}... | get_input | identifier_name |
main.rs | use std::fs::File; // File::open(&str)
use std::io::prelude::*; // std::fs::File.read_to_string(&mut str)
static VOWELS: [char; 6] = ['a', 'e', 'i', 'o', 'u', 'y'];
fn get_input() -> String |
fn main() {
let input = get_input()
.to_lowercase();
let data: Vec<&str> = input
.trim()
.lines()
.collect();
let mut counters: Vec<isize> = Vec::new();
for (i, string) in data[1..].iter().enumerate() {
counters.push(0);
for ch in string.chars() {
... | {
let mut file = match File::open("input.txt") {
Ok(input) => input,
Err(err) => panic!("Error: {}", err),
};
let mut input = String::new();
match file.read_to_string(&mut input) {
Ok(input) => input,
Err(err) => panic!("Error: {}", err),
};
input
} | identifier_body |
attr.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 ... | /**
* From a list of crate attributes get only the meta_items that affect crate
* linkage
*/
pub fn find_linkage_metas(attrs: &[Attribute]) -> Vec<@MetaItem> {
let mut result = Vec::new();
for attr in attrs.iter().filter(|at| at.name().equiv(&("link"))) {
match attr.meta().node {
MetaList... | }).collect()
}
| random_line_split |
attr.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 ... | <AM: AttrMetaMethods>(metas: &[AM], name: &str) -> bool {
debug!("attr::contains_name (name={})", name);
metas.iter().any(|item| {
debug!(" testing: {}", item.name());
item.name().equiv(&name)
})
}
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str)
... | contains_name | identifier_name |
attr.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 ... | }
}).collect()
}
/**
* From a list of crate attributes get only the meta_items that affect crate
* linkage
*/
pub fn find_linkage_metas(attrs: &[Attribute]) -> Vec<@MetaItem> {
let mut result = Vec::new();
for attr in attrs.iter().filter(|at| at.name().equiv(&("link"))) {
match attr.met... | {
// This is sort of stupid here, but we need to sort by
// human-readable strings.
let mut v = items.iter()
.map(|&mi| (mi.name(), mi))
.collect::<Vec<(InternedString, @MetaItem)> >();
v.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b));
// There doesn't seem to be a more optimal way t... | identifier_body |
str_concat.rs | //
// 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 gov... | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at | random_line_split | |
str_concat.rs | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless r... |
}
| {
let mut handlebars = Handlebars::new();
handlebars.register_helper("strConcat", Box::new(STR_CONCAT));
let expected = "foobarbaz";
assert_eq!(
expected,
handlebars
.template_render("{{strConcat \"foo\" \"bar\" \"baz\"}}", &json!({}))
... | identifier_body |
str_concat.rs | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless r... | (&self, h: &Helper, _: &Handlebars, rc: &mut RenderContext) -> RenderResult<()> {
let list: Vec<String> = h.params()
.iter()
.map(|v| v.value())
.filter(|v|!v.is_object())
.map(|v| v.to_string().replace("\"", ""))
.collect();
rc.writer.write(list.c... | call | identifier_name |
comments.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... |
#[test] fn test_block_doc_comment_2() {
let comment = "/**\n * Test\n * Test\n*/";
let stripped = strip_doc_comment_decoration(comment);
assert_eq!(stripped, " Test\n Test".to_string());
}
#[test] fn test_block_doc_comment_3() {
let comment = "/**\n let a: *int;\n *a = 5... | {
let comment = "/**\n * Test \n ** Test\n * Test\n*/";
let stripped = strip_doc_comment_decoration(comment);
assert_eq!(stripped, " Test \n* Test\n Test".to_string());
} | identifier_body |
comments.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... |
if c == '*' {
if first {
i = j;
first = false;
} else if i!= j {
can_trim = false;
}
break;
}
}
if i > line.len... | {
can_trim = false;
break;
} | conditional_block |
comments.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... | {
/// No code on either side of each line of the comment
Isolated,
/// Code exists to the left of the comment
Trailing,
/// Code before /* foo */ and after the comment
Mixed,
/// Just a manual blank line "\n\n", for layout
BlankLine,
}
#[deriving(Clone)]
pub struct Comment {
pub st... | CommentStyle | identifier_name |
comments.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... | curr_line.push('/');
level -= 1;
} else { rdr.bump(); }
}
}
}
if curr_line.len()!= 0 {
trim_whitespace_prefix_and_push_line(&mut lines,
curr_line,
... | rdr.bump();
rdr.bump(); | random_line_split |
overload.rs | // https://rustbyexample.com/macros/overload.html
// http://rust-lang-ja.org/rust-by-example/macros/overload.html
// `test!` will compare `$left` and `$right`
// in different ways depending on how you invoke it:
macro_rules! test {
// Arguments don't need to be separated by a comma.
// Any template can be used... | () {
test!(1i32 + 1 == 2i32; and 2i32 * 2 == 4i32);
test!(true; or false);
}
| main | identifier_name |
overload.rs | // https://rustbyexample.com/macros/overload.html
// http://rust-lang-ja.org/rust-by-example/macros/overload.html
// `test!` will compare `$left` and `$right`
// in different ways depending on how you invoke it:
macro_rules! test {
// Arguments don't need to be separated by a comma.
// Any template can be used... | {
test!(1i32 + 1 == 2i32; and 2i32 * 2 == 4i32);
test!(true; or false);
} | identifier_body | |
overload.rs | // https://rustbyexample.com/macros/overload.html
// http://rust-lang-ja.org/rust-by-example/macros/overload.html
// `test!` will compare `$left` and `$right`
// in different ways depending on how you invoke it:
macro_rules! test {
// Arguments don't need to be separated by a comma.
// Any template can be used... | );
// ^ each arm must end with a semicolon.
($left:expr; or $right:expr) => (
println!("{:?} or {:?} is {:?}",
stringify!($left),
stringify!($right),
$left || $right)
);
}
fn main() {
test!(1i32 + 1 == 2i32; and 2i32 * 2 == 4i32);
te... | ($left:expr; and $right:expr) => (
println!("{:?} and {:?} is {:?}",
stringify!($left),
stringify!($right),
$left && $right) | random_line_split |
weird-exprs.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 ... | () {
strange();
funny();
what();
zombiejesus();
notsure();
canttouchthis();
angrydome();
evil_lincoln();
}
| main | identifier_name |
weird-exprs.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 ... |
pub fn main() {
strange();
funny();
what();
zombiejesus();
notsure();
canttouchthis();
angrydome();
evil_lincoln();
}
| { let evil = debug!("lincoln"); } | identifier_body |
weird-exprs.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 _a = (assert!((true)) == (assert!(p())));
let _c = (assert!((p())) == ());
let _b: bool = (debug!("%d", 0) == (return 0u));
}
fn angrydome() {
loop { if break { } }
let mut i = 0;
loop { i += 1; if i == 1 { match (loop) { 1 => { }, _ => fail!("wat") } }
break; }
}
fn evil_lincoln() {... | let _b = util::swap(&mut _y, &mut _z) == util::swap(&mut _y, &mut _z);
}
fn canttouchthis() -> uint {
fn p() -> bool { true } | random_line_split |
weird-exprs.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 ... |
};
} else if (return) {
return;
}
}
if (return) { break; }
}
}
fn notsure() {
let mut _x;
let mut _y = (_x = 0) == (_x = 0);
let mut _z = (_x = 0) < (_x = 0);
let _a = (_x += 0) == (_x = 0);
let _b = util::swap(&mut _y, &m... | { return } | conditional_block |
scalar.rs | use std::usize;
use test::{black_box, Bencher};
use tipb::ScalarFuncSig;
fn get_scalar_args_with_match(sig: ScalarFuncSig) -> (usize, usize) {
// Only select some functions to benchmark
let (min_args, max_args) = match sig {
ScalarFuncSig::LtInt => (2, 2),
ScalarFuncSig::CastIntAsInt => (1, 1),... | use collections::HashMap; | random_line_split | |
scalar.rs | use collections::HashMap;
use std::usize;
use test::{black_box, Bencher};
use tipb::ScalarFuncSig;
fn get_scalar_args_with_match(sig: ScalarFuncSig) -> (usize, usize) {
// Only select some functions to benchmark
let (min_args, max_args) = match sig {
ScalarFuncSig::LtInt => (2, 2),
ScalarFuncSi... |
#[bench]
fn bench_get_scalar_args_with_map(b: &mut Bencher) {
let m = init_scalar_args_map();
b.iter(|| {
for _ in 0..1000 {
black_box(get_scalar_args_with_map(
black_box(&m),
black_box(ScalarFuncSig::AbsInt),
));
}
})
}
| {
b.iter(|| {
for _ in 0..1000 {
black_box(get_scalar_args_with_match(black_box(ScalarFuncSig::AbsInt)));
}
})
} | identifier_body |
scalar.rs | use collections::HashMap;
use std::usize;
use test::{black_box, Bencher};
use tipb::ScalarFuncSig;
fn get_scalar_args_with_match(sig: ScalarFuncSig) -> (usize, usize) {
// Only select some functions to benchmark
let (min_args, max_args) = match sig {
ScalarFuncSig::LtInt => (2, 2),
ScalarFuncSi... | () -> HashMap<ScalarFuncSig, (usize, usize)> {
let mut m: HashMap<ScalarFuncSig, (usize, usize)> = HashMap::default();
let tbls = vec![
(ScalarFuncSig::LtInt, (2, 2)),
(ScalarFuncSig::CastIntAsInt, (1, 1)),
(ScalarFuncSig::IfInt, (3, 3)),
(ScalarFuncSig::JsonArraySig, (0, usize:... | init_scalar_args_map | identifier_name |
issue-38293.rs | // Copyright 2016 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 ... |
}
use foo::f::{self}; //~ ERROR unresolved import `foo::f`
mod bar {
pub fn baz() {}
pub mod baz {}
}
use bar::baz::{self};
fn main() {
baz(); //~ ERROR expected function, found module `baz`
}
| { } | identifier_body |
issue-38293.rs | // Copyright 2016 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 ... | () { }
}
use foo::f::{self}; //~ ERROR unresolved import `foo::f`
mod bar {
pub fn baz() {}
pub mod baz {}
}
use bar::baz::{self};
fn main() {
baz(); //~ ERROR expected function, found module `baz`
}
| f | identifier_name |
issue-38293.rs | // Copyright 2016 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 ... | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that `fn foo::bar::{self}` only imports `bar` in the type namespace.
mod foo {
pub fn f() { }
}
use foo::f::{self}; //~ ERROR unresolved import `foo::f`
mod bar {
pub fn baz() {}
pub mod baz {}
}
... | random_line_split | |
xsdt.rs | //! Extended System Description Table
use core::mem; | pub struct Xsdt(&'static Sdt);
impl Xsdt {
/// Cast SDT to XSDT if signature matches.
pub fn new(sdt: &'static Sdt) -> Option<Self> {
if &sdt.signature == b"XSDT" {
Some(Xsdt(sdt))
} else {
None
}
}
/// Get a iterator for the table entries.
pub fn it... |
use super::sdt::Sdt;
/// XSDT structure
#[derive(Debug)] | random_line_split |
xsdt.rs | //! Extended System Description Table
use core::mem;
use super::sdt::Sdt;
/// XSDT structure
#[derive(Debug)]
pub struct Xsdt(&'static Sdt);
impl Xsdt {
/// Cast SDT to XSDT if signature matches.
pub fn new(sdt: &'static Sdt) -> Option<Self> {
if &sdt.signature == b"XSDT" {
Some(Xsdt(sdt... |
// When there is no more elements return a None value
None
}
}
| {
// get the item
let item = unsafe { *(self.sdt.data_address() as *const u64).offset(self.index as isize) };
// increment the index
self.index += 1;
// return the found entry
return Some(item as usize);
} | conditional_block |
xsdt.rs | //! Extended System Description Table
use core::mem;
use super::sdt::Sdt;
/// XSDT structure
#[derive(Debug)]
pub struct Xsdt(&'static Sdt);
impl Xsdt {
/// Cast SDT to XSDT if signature matches.
pub fn new(sdt: &'static Sdt) -> Option<Self> {
if &sdt.signature == b"XSDT" {
Some(Xsdt(sdt... | (&self) -> XsdtIter {
XsdtIter {
sdt: self.0,
index: 0
}
}
}
/// XSDT as an array of 64-bit physical addresses that point to other DESCRIPTION_HEADERs. So we use
/// an iterator to walk through it.
pub struct XsdtIter {
sdt: &'static Sdt,
index: usize
}
impl Iterato... | iter | identifier_name |
emulation.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 actor::{Actor, ActorMessageStatus, ActorRegistry};
use serde_json::{Map, Value};
use std::net::TcpStream;
pub... | (name: String) -> EmulationActor {
EmulationActor { name: name }
}
}
| new | identifier_name |
emulation.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 actor::{Actor, ActorMessageStatus, ActorRegistry};
use serde_json::{Map, Value};
use std::net::TcpStream;
pub... |
}
impl EmulationActor {
pub fn new(name: String) -> EmulationActor {
EmulationActor { name: name }
}
}
| {
Ok(match msg_type {
_ => ActorMessageStatus::Ignored,
})
} | identifier_body |
emulation.rs |
use actor::{Actor, ActorMessageStatus, ActorRegistry};
use serde_json::{Map, Value};
use std::net::TcpStream;
pub struct EmulationActor {
pub name: String,
}
impl Actor for EmulationActor {
fn name(&self) -> String {
self.name.clone()
}
fn handle_message(
&self,
_registry: &A... | /* 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/. */ | random_line_split | |
theme.rs | use crate::color::{LinSrgba, Srgba};
use std::collections::HashMap;
/// A set of styling defaults used for coloring texturing geometric primitives that have no entry
/// within the **Draw**'s inner **ColorMap**.
#[derive(Clone, Debug)]
pub struct Theme {
/// Fill color defaults.
pub fill_color: Color,
/// ... | .get(prim)
.map(|&c| c)
.unwrap_or(self.fill_color.default)
}
/// Retrieve the linaer sRGBA fill color representation for the given primitive.
pub fn fill_lin_srgba(&self, prim: &Primitive) -> LinSrgba {
self.fill_srgba(prim).into_linear()
}
/// Retrieve th... | .primitive | random_line_split |
theme.rs | use crate::color::{LinSrgba, Srgba};
use std::collections::HashMap;
/// A set of styling defaults used for coloring texturing geometric primitives that have no entry
/// within the **Draw**'s inner **ColorMap**.
#[derive(Clone, Debug)]
pub struct Theme {
/// Fill color defaults.
pub fill_color: Color,
/// ... |
/// Retrieve the linaer sRGBA stroke color representation for the given primitive.
pub fn stroke_lin_srgba(&self, prim: &Primitive) -> LinSrgba {
self.stroke_srgba(prim).into_linear()
}
}
impl Default for Theme {
fn default() -> Self {
// TODO: This should be pub const.
let de... | {
self.stroke_color
.primitive
.get(prim)
.map(|&c| c)
.unwrap_or(self.stroke_color.default)
} | identifier_body |
theme.rs | use crate::color::{LinSrgba, Srgba};
use std::collections::HashMap;
/// A set of styling defaults used for coloring texturing geometric primitives that have no entry
/// within the **Draw**'s inner **ColorMap**.
#[derive(Clone, Debug)]
pub struct Theme {
/// Fill color defaults.
pub fill_color: Color,
/// ... | (&self, prim: &Primitive) -> Srgba {
self.stroke_color
.primitive
.get(prim)
.map(|&c| c)
.unwrap_or(self.stroke_color.default)
}
/// Retrieve the linaer sRGBA stroke color representation for the given primitive.
pub fn stroke_lin_srgba(&self, prim: &Prim... | stroke_srgba | identifier_name |
errors.rs | // ------------------------------------------------------------------------- //
// Imports //
// ------------------------------------------------------------------------- //
// Standard libraries imports
use std::process;
use std::result::Result as StdR... |
// ------------------------------------------------------------------------- //
// Traits //
// ------------------------------------------------------------------------- //
/// A fallible unwrap
pub trait Fallible<T> {
/// Return the value from Ok... | random_line_split | |
errors.rs | // ------------------------------------------------------------------------- //
// Imports //
// ------------------------------------------------------------------------- //
// Standard libraries imports
use std::process;
use std::result::Result as StdR... | (&self) {
let mut msg = self.message.clone();
match self.error {
None => (),
Some(_) => msg.push(':'),
}
stderr(&Red.paint(msg).to_string());
match self.error.clone() {
None => (),
Some(error) => stderr(&boxify(error, Red)),
... | print | identifier_name |
uievent.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/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... |
// https://w3c.github.io/uievents/#widl-UIEvent-detail
fn Detail(&self) -> i32 {
self.detail.get()
}
// https://w3c.github.io/uievents/#widl-UIEvent-initUIEvent
fn InitUIEvent(
&self,
type_: DOMString,
can_bubble: bool,
cancelable: bool,
view: Optio... | {
self.view.get()
} | identifier_body |
uievent.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/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... |
event.init_event(Atom::from(type_), can_bubble, cancelable);
self.view.set(view);
self.detail.set(detail);
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.event.IsTrusted()
}
}
| {
return;
} | conditional_block |
uievent.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/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | type_: DOMString,
can_bubble: bool,
cancelable: bool,
view: Option<&Window>,
detail: i32,
) {
let event = self.upcast::<Event>();
if event.dispatching() {
return;
}
event.init_event(Atom::from(type_), can_bubble, cancelable);
... | fn InitUIEvent(
&self, | random_line_split |
uievent.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/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | (
&self,
type_: DOMString,
can_bubble: bool,
cancelable: bool,
view: Option<&Window>,
detail: i32,
) {
let event = self.upcast::<Event>();
if event.dispatching() {
return;
}
event.init_event(Atom::from(type_), can_bubble, c... | InitUIEvent | identifier_name |
main.rs | // Crypto challenge Set1 / Challenge 1
// Convert hex to base64
extern crate codec;
#[cfg(not(test))]
fn main() |
#[test]
fn challenge1() {
let input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
let output = codec::to_base64( codec::from_hex(input).ok().unwrap().as_slice() );
assert_eq!(output, String::from_str("SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub... | {
let args = std::os::args();
if args.len() != 2 {
println!("USAGE: challenge1 HEX_ENCODED_STRING");
} else {
let input = args[1].as_slice();
match codec::from_hex(input) {
Err(msg) => println!("Invalid hex string: {}", msg),
Ok(binary) => println!("{}", ... | identifier_body |
main.rs | // Crypto challenge Set1 / Challenge 1
// Convert hex to base64
extern crate codec;
#[cfg(not(test))]
fn main() {
let args = std::os::args();
if args.len()!= 2 {
println!("USAGE: challenge1 HEX_ENCODED_STRING");
} else {
let input = args[1].as_slice();
match codec::from_hex(in... | #[test]
fn challenge1() {
let input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
let output = codec::to_base64( codec::from_hex(input).ok().unwrap().as_slice() );
assert_eq!(output, String::from_str("SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3V... | }
}
}
| random_line_split |
main.rs | // Crypto challenge Set1 / Challenge 1
// Convert hex to base64
extern crate codec;
#[cfg(not(test))]
fn main() {
let args = std::os::args();
if args.len()!= 2 {
println!("USAGE: challenge1 HEX_ENCODED_STRING");
} else {
let input = args[1].as_slice();
match codec::from_hex(in... | () {
let input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
let output = codec::to_base64( codec::from_hex(input).ok().unwrap().as_slice() );
assert_eq!(output, String::from_str("SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"));
}
| challenge1 | identifier_name |
mkfifo.rs | #![crate_name = "mkfifo"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;
#[macro_use]
extern... | () {
std::process::exit(uumain(std::env::args().collect()));
}
| main | identifier_name |
mkfifo.rs | #![crate_name = "mkfifo"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;
#[macro_use]
extern... | opts.optflag("V", "version", "output version information and exit");
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(err) => panic!("{}", err),
};
if matches.opt_present("version") {
println!("{} {}", NAME, VERSION);
return 0;
}
if matches.opt_pres... | pub fn uumain(args: Vec<String>) -> i32 {
let mut opts = getopts::Options::new();
opts.optopt("m", "mode", "file permissions for the fifo", "(default 0666)");
opts.optflag("h", "help", "display this help and exit"); | random_line_split |
mkfifo.rs | #![crate_name = "mkfifo"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;
#[macro_use]
extern... |
return 0;
}
let mode = match matches.opt_str("m") {
Some(m) => match usize::from_str_radix(&m, 8) {
Ok(m) => m,
Err(e)=> {
show_error!("invalid mode: {}", e);
return 1;
}
},
None => 0o666,
};
let mut e... | {
return 1;
} | conditional_block |
mkfifo.rs | #![crate_name = "mkfifo"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;
#[macro_use]
extern... | {
std::process::exit(uumain(std::env::args().collect()));
} | identifier_body | |
extendablemessageevent.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::ExtendableMessageEventBinding;
use crate::dom::bindings::codegen::Bin... | (
worker: &ServiceWorkerGlobalScope,
type_: DOMString,
init: RootedTraceableBox<ExtendableMessageEventBinding::ExtendableMessageEventInit>,
) -> Fallible<DomRoot<ExtendableMessageEvent>> {
let global = worker.upcast::<GlobalScope>();
let ev = ExtendableMessageEvent::new(
... | Constructor | identifier_name |
extendablemessageevent.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::ExtendableMessageEventBinding;
use crate::dom::bindings::codegen::Bin... | message,
DOMString::new(),
DOMString::new(),
);
Extendablemessageevent.upcast::<Event>().fire(target);
}
}
impl ExtendableMessageEventMethods for ExtendableMessageEvent {
#[allow(unsafe_code)]
// https://w3c.github.io/ServiceWorker/#extendablemessage-even... | let Extendablemessageevent = ExtendableMessageEvent::new(
scope,
atom!("message"),
false,
false, | random_line_split |
extendablemessageevent.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::ExtendableMessageEventBinding;
use crate::dom::bindings::codegen::Bin... |
}
| {
self.event.IsTrusted()
} | identifier_body |
inline.rs | // Copyright 2012-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-MI... | (cx: &DocContext, tcx: &ty::ctxt,
def: def::Def) -> Option<Vec<clean::Item>> {
let mut ret = Vec::new();
let did = def.def_id();
let inner = match def {
def::DefTrait(did) => {
record_extern_fqn(cx, did, clean::TypeTrait);
clean::TraitItem(build_external_tra... | try_inline_def | identifier_name |
inline.rs | // Copyright 2012-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-MI... |
fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
did: ast::DefId) -> Vec<clean::Item> {
ty::populate_implementations_for_type_if_necessary(tcx, did);
let mut impls = Vec::new();
match tcx.inherent_impls.borrow().find(&did) {
None => {}
Some(i) => {
impls.extend(i... | {
let t = ty::lookup_item_type(tcx, did);
match ty::get(t.ty).sty {
ty::ty_enum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
return clean::EnumItem(clean::Enum {
generics: (&t.generics, subst::TypeSpace).clean(cx),
variants_stripped: false,
... | identifier_body |
inline.rs | // Copyright 2012-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-MI... |
_ => fail!("not a tymethod"),
};
Some(item)
}
ty::TypeTraitItem(_) => {
// FIXME(pcwalton): Implement.
None
}
}
}).collect();
return Some(clean::Item {
inner: clean::ImplItem(... | {
clean::MethodItem(clean::Method {
fn_style: fn_style,
decl: decl,
self_: self_,
generics: generics,
})
} | conditional_block |
inline.rs | // Copyright 2012-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-MI... | ty::TypeTraitItem(_) => {
// FIXME(pcwalton): Implement.
None
}
}
}).collect();
return Some(clean::Item {
inner: clean::ImplItem(clean::Impl {
derived: clean::detect_derived(attrs.as_slice()),
trait_: associated_trai... | };
Some(item)
} | random_line_split |
misc.rs | /// Module for miscellaneous instructions
use jeebie::core::cpu::CPU;
use jeebie::core::registers::Register8::*;
use jeebie::core::registers::Register16::*;
// 'NOP' 00 4
pub fn nop(cpu: &mut CPU) -> i32 { 4 }
// 'SWAP A' CB 37 8
pub fn SWAP_a(cpu: &mut CPU) -> i32 {
cpu.compute_swap(A);
8
}
// 'SWAP B' CB 3... | // 'SWAP C' CB 31 8
pub fn SWAP_c(cpu: &mut CPU) -> i32 {
cpu.compute_swap(C);
8
}
// 'SWAP D' CB 32 8
pub fn SWAP_d(cpu: &mut CPU) -> i32 {
cpu.compute_swap(D);
8
}
// 'SWAP E' CB 33 8
pub fn SWAP_e(cpu: &mut CPU) -> i32 {
cpu.compute_swap(E);
8
}
// 'SWAP H' CB 34 8
pub fn SWAP_h(cpu: &mut ... | cpu.compute_swap(B);
8
}
| random_line_split |
misc.rs | /// Module for miscellaneous instructions
use jeebie::core::cpu::CPU;
use jeebie::core::registers::Register8::*;
use jeebie::core::registers::Register16::*;
// 'NOP' 00 4
pub fn nop(cpu: &mut CPU) -> i32 { 4 }
// 'SWAP A' CB 37 8
pub fn SWAP_a(cpu: &mut CPU) -> i32 {
cpu.compute_swap(A);
8
}
// 'SWAP B' CB 3... | (cpu: &mut CPU) -> i32 {
cpu.compute_swap(RegisterAddress(HL));
16
}
// 'EI' FB 4
pub fn EI(cpu: &mut CPU) -> i32 {
cpu.interrupts_enabled = true;
4
}
// 'DI' F3 4
pub fn DI(cpu: &mut CPU) -> i32 {
cpu.interrupts_enabled = false;
4
} | SWAP_hl | identifier_name |
misc.rs | /// Module for miscellaneous instructions
use jeebie::core::cpu::CPU;
use jeebie::core::registers::Register8::*;
use jeebie::core::registers::Register16::*;
// 'NOP' 00 4
pub fn nop(cpu: &mut CPU) -> i32 { 4 }
// 'SWAP A' CB 37 8
pub fn SWAP_a(cpu: &mut CPU) -> i32 {
cpu.compute_swap(A);
8
}
// 'SWAP B' CB 3... |
// 'SWAP (HL)' CB 36 16
pub fn SWAP_hl(cpu: &mut CPU) -> i32 {
cpu.compute_swap(RegisterAddress(HL));
16
}
// 'EI' FB 4
pub fn EI(cpu: &mut CPU) -> i32 {
cpu.interrupts_enabled = true;
4
}
// 'DI' F3 4
pub fn DI(cpu: &mut CPU) -> i32 {
cpu.interrupts_enabled = false;
4
} | {
cpu.compute_swap(L);
8
} | identifier_body |
vec.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 ... |
// -*- rust -*-
pub fn main() {
let v: ~[int] = ~[10, 20];
assert!((v[0] == 10));
assert!((v[1] == 20));
let mut x: int = 0;
assert!((v[x] == 10));
assert!((v[x + 1] == 20));
x = x + 1;
assert!((v[x] == 20));
assert!((v[x - 1] == 10));
} | // option. This file may not be copied, modified, or distributed
// except according to those terms.
| random_line_split |
vec.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 v: ~[int] = ~[10, 20];
assert!((v[0] == 10));
assert!((v[1] == 20));
let mut x: int = 0;
assert!((v[x] == 10));
assert!((v[x + 1] == 20));
x = x + 1;
assert!((v[x] == 20));
assert!((v[x - 1] == 10));
} | identifier_body | |
vec.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 v: ~[int] = ~[10, 20];
assert!((v[0] == 10));
assert!((v[1] == 20));
let mut x: int = 0;
assert!((v[x] == 10));
assert!((v[x + 1] == 20));
x = x + 1;
assert!((v[x] == 20));
assert!((v[x - 1] == 10));
}
| main | identifier_name |
usage.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | let config = match (fs::File::open(&config_file), raw_args.flag_config.is_some()) {
// Load config file
(Ok(mut file), _) => {
println_stderr!("Loading config file from {}", &config_file);
let mut config = String::new();
file.read_to_string(&mut config).map_err(|e| ArgsError::Config(conf... | let config_file = raw_args.flag_config.clone().unwrap_or_else(|| raw_args.clone().into_args(Config::default()).flag_config);
let config_file = replace_home(&::dir::default_data_path(), &config_file); | random_line_split |
lib.rs | //! # RACC -- Rust Another Compiler-Compiler
//!
//! This is a port of Barkeley YACC to Rust. It runs as a procedural macro, and so allows you to
//! define grammars directly in Rust source code, rather than calling an external tool or writing
//! a `build.rs` script.
//!
//! # How to write a grammar
//!
//! Here is a... | //! it were an option).
//!
//! RACC provides a safe means to access such data. Rules may access an "app context".
//! When the app calls `push_token` or `finish`, the app also passes a `&mut` reference
//! to an "app context" value. The type of this value can be anything defined by the
//! application. (It is neces... | //! state, when executing rule actions. In C parsers, this is usually done with global
//! variables. However, this is not an option in Rust (and would be undesirable, even if | random_line_split |
lib.rs | //! # RACC -- Rust Another Compiler-Compiler
//!
//! This is a port of Barkeley YACC to Rust. It runs as a procedural macro, and so allows you to
//! define grammars directly in Rust source code, rather than calling an external tool or writing
//! a `build.rs` script.
//!
//! # How to write a grammar
//!
//! Here is a... | (i16);
impl SymbolOrRule {
pub fn rule(rule: Rule) -> SymbolOrRule {
assert!(rule.0 > 0);
Self(-rule.0)
}
pub fn symbol(symbol: Symbol) -> SymbolOrRule {
assert!(symbol.0 >= 0);
Self(symbol.0)
}
pub fn is_symbol(self) -> bool {
self.0 >= 0
}
pub fn is... | SymbolOrRule | identifier_name |
lib.rs | //! # RACC -- Rust Another Compiler-Compiler
//!
//! This is a port of Barkeley YACC to Rust. It runs as a procedural macro, and so allows you to
//! define grammars directly in Rust source code, rather than calling an external tool or writing
//! a `build.rs` script.
//!
//! # How to write a grammar
//!
//! Here is a... | else {
write!(fmt, "Rule({})", self.as_rule().index())
}
}
}
type StateOrRule = i16;
use reader::GrammarDef;
fn racc_grammar2(tokens: proc_macro2::TokenStream) -> syn::Result<proc_macro2::TokenStream> {
let grammar_def: GrammarDef = syn::parse2::<GrammarDef>(tokens)?;
let context_par... | {
write!(fmt, "Symbol({})", self.as_symbol().index())
} | conditional_block |
lib.rs | //! # RACC -- Rust Another Compiler-Compiler
//!
//! This is a port of Barkeley YACC to Rust. It runs as a procedural macro, and so allows you to
//! define grammars directly in Rust source code, rather than calling an external tool or writing
//! a `build.rs` script.
//!
//! # How to write a grammar
//!
//! Here is a... |
pub fn as_rule(self) -> Rule {
assert!(self.is_rule());
Rule(-self.0)
}
}
use core::fmt::{Debug, Formatter};
impl Debug for SymbolOrRule {
fn fmt(&self, fmt: &mut Formatter<'_>) -> core::fmt::Result {
if self.is_symbol() {
write!(fmt, "Symbol({})", self.as_symbol().inde... | {
assert!(self.is_symbol());
Symbol(self.0)
} | identifier_body |
iterable.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![allow(unsafe_code)]
//! Implementation of `iterable<...>` and `iterable<...,...>` WebIDL declarations.
use c... | (
cx: *mut JSContext,
mut result: MutableHandleObject,
done: bool,
value: HandleValue,
) -> Fallible<()> {
let mut dict = IterableKeyOrValueResult::empty();
dict.done = done;
dict.value.set(value.get());
rooted!(in(cx) let mut dict_value = UndefinedValue());
unsafe {
dict.to_... | dict_return | identifier_name |
iterable.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![allow(unsafe_code)]
//! Implementation of `iterable<...>` and `iterable<...,...>` WebIDL declarations.
use c... | ,
}
};
self.index.set(index + 1);
result.map(|_| NonNull::new(rval.get()).expect("got a null pointer"))
}
}
fn dict_return(
cx: *mut JSContext,
mut result: MutableHandleObject,
done: bool,
value: HandleValue,
) -> Fallible<()> {
let mut dict = IterableKeyOrVa... | {
rooted!(in(cx) let mut key = UndefinedValue());
unsafe {
self.iterable
.get_key_at_index(index)
.to_jsval(cx, key.handle_mut());
self.iterable
.ge... | conditional_block |
iterable.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![allow(unsafe_code)]
//! Implementation of `iterable<...>` and `iterable<...,...>` WebIDL declarations.
use c... | type_: IteratorType,
index: Cell<u32>,
}
impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
/// Create a new iterator instance for the provided iterable DOM interface.
pub fn new(
iterable: &T,
type_: IteratorType,
wrap: unsafe fn(*mut JSContext, &GlobalScope, Box... | reflector: Reflector,
iterable: Dom<T>, | random_line_split |
session.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
}
enum ErrorType {
NotFound,
Forbidden,
}
fn error(error: ErrorType, title: &str, message: &str, details: Option<&str>) -> ws::Response {
let content = format!(
include_str!("./error_tpl.html"),
title=title,
meta="",
message=message,
details=details.unwrap_or(""),
version=version(),
);
let res = mat... | {
Session {
out: sender,
handler: self.handler.clone(),
skip_origin_validation: self.skip_origin_validation,
self_origin: self.self_origin.clone(),
authcodes_path: self.authcodes_path.clone(),
file_handler: self.file_handler.clone(),
}
} | identifier_body |
session.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | {
pub content: &'static [u8],
pub content_type: &'static str,
}
#[derive(Default)]
pub struct Handler;
impl Handler {
pub fn handle(&self, _req: &str) -> Option<&File> {
None
}
}
}
const HOME_DOMAIN: &'static str = "home.parity";
fn origin_is_allowed(self_origin: &str, header: Option<&[u8]>) -> boo... | File | identifier_name |
session.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | }
}
enum ErrorType {
NotFound,
Forbidden,
}
fn error(error: ErrorType, title: &str, message: &str, details: Option<&str>) -> ws::Response {
let content = format!(
include_str!("./error_tpl.html"),
title=title,
meta="",
message=message,
details=details.unwrap_or(""),
version=version(),
);
let res = m... | file_handler: self.file_handler.clone(),
} | random_line_split |
session.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
res
})
.unwrap_or(false)
} else {
false
}
})
},
_ => false
}
}
fn add_headers(mut response: ws::Response, mime: &str) -> ws::Response {
let content_len = format!("{}", response.len());
{
let mut headers = response.headers_mut();
headers.push(("X-Frame-Options".into(), b"S... | {
warn!(target: "signer", "Couldn't save authorization codes to file.");
} | conditional_block |
queue.rs | use std::cmp::Ordering;
use base::command::CommandType;
use base::party::Party;
use base::runner::BattleFlagsType;
#[derive(Debug)]
struct PartyCommand
{
party: bool,
commands: Vec<Option<CommandType>>,
ready: usize,
total: usize,
}
impl PartyCommand
{
fn | (members: usize) -> Self
{
let mut commands = Vec::with_capacity(members);
for _ in 0..members
{
commands.push(None);
}
PartyCommand
{
party: false,
commands: commands,
ready: 0,
total: members,
}
}
fn command_count(&self) -> usize
{
self.commands.len()
}
fn command_get(&self, index... | new | identifier_name |
queue.rs | use std::cmp::Ordering;
use base::command::CommandType;
use base::party::Party;
use base::runner::BattleFlagsType;
#[derive(Debug)]
struct PartyCommand
{
party: bool,
commands: Vec<Option<CommandType>>,
ready: usize,
total: usize,
}
impl PartyCommand
{
fn new(members: usize) -> Self
{
let mut commands = Vec:... |
else if!self.commands[member].is_some()
{
change = 1;
self.ready += 1;
}
self.commands[member] = Some(command);
change
}
fn command_add_party(&mut self, command: CommandType) -> usize
{
let change = self.total - self.ready;
if self.party
{
for i in 1..self.total
{
self.commands[i] = ... | {
// All members are now waiting for their individual commands.
change = - (self.total as isize) + 1;
self.party = false;
for i in 0..self.total
{
self.commands[i] = None;
}
self.ready = 1;
} | conditional_block |
queue.rs | use std::cmp::Ordering;
use base::command::CommandType;
use base::party::Party;
use base::runner::BattleFlagsType;
#[derive(Debug)]
struct PartyCommand
{
party: bool,
commands: Vec<Option<CommandType>>,
ready: usize,
total: usize,
}
impl PartyCommand
{
fn new(members: usize) -> Self
{
let mut commands = Vec:... | }
BattleQueue
{
waiting: total,
total: total,
queue: queue,
}
}
/// Returns true if the queue was populated or is in the process of being consumed.
pub fn ready(&self) -> bool
{
self.waiting == 0
}
/// Returns the command for the indicated party member.
pub fn command_get(&self, party: usize... | for party in parties
{
total += party.active_count();
queue.push(PartyCommand::new(party.active_count())); | random_line_split |
queue.rs | use std::cmp::Ordering;
use base::command::CommandType;
use base::party::Party;
use base::runner::BattleFlagsType;
#[derive(Debug)]
struct PartyCommand
{
party: bool,
commands: Vec<Option<CommandType>>,
ready: usize,
total: usize,
}
impl PartyCommand
{
fn new(members: usize) -> Self
{
let mut commands = Vec:... |
/// Adds the given command to the queue for the indicated members of the given party.
///
/// This will override any commands already given to this party member. If the given party
/// already has an attached command, then all members of that party will be invalidated.
///
pub fn command_add(&mut self, command:... | {
self.queue[party].command_get(member)
} | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// For simd (currently x86_64/aarch64)
#![cfg_attr(any(target_os = "linux", target_os = "android", target_os = "wi... | // Private painting modules
mod paint_context;
#[deny(unsafe_code)]
pub mod display_list;
// Fonts
#[macro_use] pub mod font;
pub mod font_cache_thread;
pub mod font_context;
pub mod font_template;
pub mod paint_thread;
// Platform-specific implementations.
#[allow(unsafe_code)]
mod platform;
// Text
pub mod text; | random_line_split | |
mod.rs | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
| /// `UNSPECIFIED_FSP` is the unspecified fractional seconds part.
pub const UNSPECIFIED_FSP: i8 = -1;
/// `MAX_FSP` is the maximum digit of fractional seconds part.
pub const MAX_FSP: i8 = 6;
/// `MIN_FSP` is the minimum digit of fractional seconds part.
pub const MIN_FSP: i8 = 0;
/// `DEFAULT_FSP` is the default digit... | use super::Result;
| random_line_split |
mod.rs | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
use super::Result;
/// `UNSPECIFIED_FSP` is the unspecified fractional seconds part.
pub const UNSPECIFIED_FSP: i8 = -1;
/// `MAX_FSP` is the maximum digit of fractional seconds part.
pub const MAX_FSP: i8 = 6;
/// `MIN_FSP` is the minimum digit of fr... | (fsp: i8) -> Result<u8> {
if fsp == UNSPECIFIED_FSP {
return Ok(DEFAULT_FSP as u8);
}
if!(MIN_FSP..=MAX_FSP).contains(&fsp) {
return Err(invalid_type!("Invalid fsp {}", fsp));
}
Ok(fsp as u8)
}
pub mod binary_literal;
pub mod charset;
pub mod decimal;
pub mod duration;
pub mod enums... | check_fsp | identifier_name |
mod.rs | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
use super::Result;
/// `UNSPECIFIED_FSP` is the unspecified fractional seconds part.
pub const UNSPECIFIED_FSP: i8 = -1;
/// `MAX_FSP` is the maximum digit of fractional seconds part.
pub const MAX_FSP: i8 = 6;
/// `MIN_FSP` is the minimum digit of fr... |
pub mod binary_literal;
pub mod charset;
pub mod decimal;
pub mod duration;
pub mod enums;
pub mod json;
pub mod set;
pub mod time;
pub use self::decimal::{dec_encoded_len, Decimal, DecimalDecoder, DecimalEncoder, Res, RoundMode};
pub use self::duration::{Duration, DurationDecoder, DurationEncoder};
pub use self::en... | {
if fsp == UNSPECIFIED_FSP {
return Ok(DEFAULT_FSP as u8);
}
if !(MIN_FSP..=MAX_FSP).contains(&fsp) {
return Err(invalid_type!("Invalid fsp {}", fsp));
}
Ok(fsp as u8)
} | identifier_body |
mod.rs | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
use super::Result;
/// `UNSPECIFIED_FSP` is the unspecified fractional seconds part.
pub const UNSPECIFIED_FSP: i8 = -1;
/// `MAX_FSP` is the maximum digit of fractional seconds part.
pub const MAX_FSP: i8 = 6;
/// `MIN_FSP` is the minimum digit of fr... |
Ok(fsp as u8)
}
pub mod binary_literal;
pub mod charset;
pub mod decimal;
pub mod duration;
pub mod enums;
pub mod json;
pub mod set;
pub mod time;
pub use self::decimal::{dec_encoded_len, Decimal, DecimalDecoder, DecimalEncoder, Res, RoundMode};
pub use self::duration::{Duration, DurationDecoder, DurationEncode... | {
return Err(invalid_type!("Invalid fsp {}", fsp));
} | conditional_block |
maybe_uninit_nodrop.rs | use super::nodrop::NoDrop;
use array::Array;
use std::mem;
use std::ops::{Deref, DerefMut};
/// A combination of NoDrop and “maybe uninitialized”;
/// this wraps a value that can be wholly or partially uninitialized.
///
/// NOTE: This is known to not be a good solution, but it's the one we have kept
/// working on st... | NoDrop<T>);
// why don't we use ManuallyDrop here: It doesn't inhibit
// enum layout optimizations that depend on T, and we support older Rust.
impl<T> MaybeUninit<T> {
/// Create a new MaybeUninit with uninitialized interior
pub unsafe fn uninitialized() -> Self {
MaybeUninit(NoDrop::new(mem::uninitia... | eUninit<T>( | identifier_name |
maybe_uninit_nodrop.rs | use super::nodrop::NoDrop;
use array::Array;
use std::mem;
use std::ops::{Deref, DerefMut};
/// A combination of NoDrop and “maybe uninitialized”;
/// this wraps a value that can be wholly or partially uninitialized.
///
/// NOTE: This is known to not be a good solution, but it's the one we have kept
/// working on st... | impl<A: Array> Deref for MaybeUninit<A> {
type Target = A;
#[inline(always)]
fn deref(&self) -> &A {
&self.0
}
}
impl<A: Array> DerefMut for MaybeUninit<A> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut A {
&mut self.0
}
}
| MaybeUninit(NoDrop::new(mem::uninitialized()))
}
}
| identifier_body |
maybe_uninit_nodrop.rs | use super::nodrop::NoDrop;
use array::Array;
use std::mem;
use std::ops::{Deref, DerefMut};
/// A combination of NoDrop and “maybe uninitialized”;
/// this wraps a value that can be wholly or partially uninitialized.
///
/// NOTE: This is known to not be a good solution, but it's the one we have kept
/// working on st... | &self.0
}
}
impl<A: Array> DerefMut for MaybeUninit<A> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut A {
&mut self.0
}
} | random_line_split | |
fat-ptr-cast.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait Trait {}
// ... | random_line_split | |
fat-ptr-cast.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 a: &[i32] = &[1, 2, 3];
let b: Box<[i32]> = Box::new([1, 2, 3]);
let p = a as *const [i32];
let q = a.as_ptr();
a as usize; //~ ERROR casting
b as usize; //~ ERROR non-scalar cast
p as usize;
//~^ ERROR casting
//~^^ HELP cast through a raw pointer
// #22955
q as *... | main | identifier_name |
fat-ptr-cast.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 a: &[i32] = &[1, 2, 3];
let b: Box<[i32]> = Box::new([1, 2, 3]);
let p = a as *const [i32];
let q = a.as_ptr();
a as usize; //~ ERROR casting
b as usize; //~ ERROR non-scalar cast
p as usize;
//~^ ERROR casting
//~^^ HELP cast through a raw pointer
// #22955
q as *con... | identifier_body | |
utils.rs | // Copyright 2018 Mozilla
//
// 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 in writing, software... |
#[cfg(all(target_os="ios", not(test)))]
pub fn d(message: &str) {
eprintln!("{}", message);
}
#[cfg(all(target_os="android", not(test)))]
pub fn d(message: &str) {
let message = CString::new(message).unwrap();
let message = message.as_ptr();
let tag = CString::new(... | {} | identifier_body |
utils.rs | // Copyright 2018 Mozilla
//
// 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 in writing, software... | (message: &str) {
eprintln!("{}", message);
}
#[cfg(all(target_os="android", not(test)))]
pub fn d(message: &str) {
let message = CString::new(message).unwrap();
let message = message.as_ptr();
let tag = CString::new("Mentat").unwrap();
let tag = tag.as_ptr();
... | d | identifier_name |
utils.rs | // Copyright 2018 Mozilla
//
// 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 in writing, software... | /// `error` to a state indicating that no error occurred (`message` is null).
/// - If `result` is `Err(e)`, returns a null pointer and stores a string representing the error
/// message (which was allocated on the heap and should eventually be freed) into
/// `error.message`
pub unsafe fn tra... | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.