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 |
|---|---|---|---|---|
free.rs | #![deny(warnings)]
extern crate coreutils;
extern crate extra;
#[cfg(target_os = "redox")]
extern crate syscall;
#[cfg(target_os = "redox")]
fn free(parser: &coreutils::ArgParser) -> ::std::io::Result<()> {
use coreutils::to_human_readable_string;
use std::io::Error;
use syscall::data::StatVfs;
let m... |
println!("{:<8}{:>10}{:>10}{:>10}", "", "total", "used", "free");
free(&parser).try(&mut stderr);
}
#[cfg(not(target_os = "redox"))]
fn main() {
use std::io::{stderr, Write};
use std::process::exit;
let mut stderr = stderr();
stderr.write(b"error: unimplemented outside redox").unwrap();
... | {
stdout.write(MAN_PAGE.as_bytes()).try(&mut stderr);
stdout.flush().try(&mut stderr);
exit(0);
} | conditional_block |
float2.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 ... | } | random_line_split | |
float2.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 = 1.5e6;
let b = 1.5E6;
let c = 1e6;
let d = 1E6;
let e = 3.0f32;
let f = 5.9f64;
let g = 1e6f32;
let h = 1.0e7f64;
let i = 1.0E7f64;
let j = 3.1e+9;
let k = 3.2e-10;
assert!((a == b));
assert!((c < b));
assert!((c == d));
assert!((e < g));
asse... | main | identifier_name |
float2.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | assert!((k < a));
}
| {
let a = 1.5e6;
let b = 1.5E6;
let c = 1e6;
let d = 1E6;
let e = 3.0f32;
let f = 5.9f64;
let g = 1e6f32;
let h = 1.0e7f64;
let i = 1.0E7f64;
let j = 3.1e+9;
let k = 3.2e-10;
assert!((a == b));
assert!((c < b));
assert!((c == d));
assert!((e < g));
assert!... | identifier_body |
cleanup-shortcircuit.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
| {
// Raise a segfault.
unsafe { *(0 as *mut isize) = 0; }
} | conditional_block |
cleanup-shortcircuit.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let args: Vec<String> = env::args().collect();
// Here, the rvalue `"signal".to_string()` requires cleanup. Older versions
// of the code had a problem that the cleanup scope for this
// expression was the end of the `if`, and as the `"signal".to_string()`
// expression was never evaluated, we wo... | identifier_body | |
cleanup-shortcircuit.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let args: Vec<String> = env::args().collect();
// Here, the rvalue `"signal".to_string()` requires cleanup. Older versions
// of the code had a problem that the cleanup scope for this
// expression was the end of the `if`, and as the `"signal".to_string()`
// expression was never evaluated, we... | main | identifier_name |
cleanup-shortcircuit.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | } | } | random_line_split |
heuristics.rs | use super::{Dimension, PackInput};
use std::fmt::{Debug, Result, Formatter};
use std::cmp::{Ordering, PartialOrd, max};
pub const ALL: [&(SortHeuristic + Sync); 7] = [
&AreaSort,
&PerimeterSort,
&SideSort,
&WidthSort,
&HeightSort,
&SquarenessByAreaSort,
&SquarenessByPerimeterSort,
];
pub struct AreaSor... | else { d.h as f32 / d.w as f32 }
}
fn sqa(d: &Dimension) -> f32 { squareness(d) * (d.w * d.h) as f32 }
fn sqp(d: &Dimension) -> f32 { squareness(d) * (d.w + d.h) as f32 }
fn cmp_by_key<F, T: PartialOrd>(l: &PackInput, r: &PackInput, key: F) -> Ordering
where F: Fn(&Dimension) -> T { key(&r.dim).partial_cmp(&key(&... | { d.w as f32 / d.h as f32 } | conditional_block |
heuristics.rs | use super::{Dimension, PackInput};
use std::fmt::{Debug, Result, Formatter};
use std::cmp::{Ordering, PartialOrd, max};
pub const ALL: [&(SortHeuristic + Sync); 7] = [
&AreaSort,
&PerimeterSort,
&SideSort,
&WidthSort,
&HeightSort,
&SquarenessByAreaSort,
&SquarenessByPerimeterSort, | pub struct PerimeterSort;
pub struct SideSort;
pub struct WidthSort;
pub struct HeightSort;
pub struct SquarenessByAreaSort;
pub struct SquarenessByPerimeterSort;
pub trait SortHeuristic: Sync {
fn name(&self) -> &'static str;
fn cmp(&self, l: &PackInput, r: &PackInput) -> Ordering;
}
impl SortHeuristic for ... | ];
pub struct AreaSort;
| random_line_split |
heuristics.rs | use super::{Dimension, PackInput};
use std::fmt::{Debug, Result, Formatter};
use std::cmp::{Ordering, PartialOrd, max};
pub const ALL: [&(SortHeuristic + Sync); 7] = [
&AreaSort,
&PerimeterSort,
&SideSort,
&WidthSort,
&HeightSort,
&SquarenessByAreaSort,
&SquarenessByPerimeterSort,
];
pub struct AreaSor... | (&self, l: &PackInput, r: &PackInput) -> Ordering { cmp_by_key(l, r, |d| d.w + d.h) }
}
impl SortHeuristic for SideSort {
fn name(&self) -> &'static str { "side" }
fn cmp(&self, l: &PackInput, r: &PackInput) -> Ordering { cmp_by_key(l, r, |d| max(d.w, d.h)) }
}
impl SortHeuristic for WidthSort {
fn name(&self) ... | cmp | identifier_name |
day_3.rs | use self::Number::{One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero};
#[derive(PartialEq, Debug)]
pub enum Number {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Zero
}
impl From<char> for Number {
fn from(c: char) -> Number {
match c {
... |
pub fn output(&self) -> Option<Vec<Number>> {
match self.input {
Some(data) => Some(data.chars().map(Number::from).collect::<Vec<Number>>()),
None => Some(vec![]),
}
}
pub fn input(&mut self, data: &'static str) {
self.input = Some(data);
}
}
| {
Display {
input: None
}
} | identifier_body |
day_3.rs | use self::Number::{One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero};
#[derive(PartialEq, Debug)]
pub enum | {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Zero
}
impl From<char> for Number {
fn from(c: char) -> Number {
match c {
'1' => One,
'2' => Two,
'3' => Three,
'4' => Four,
'5' => Five,
... | Number | identifier_name |
day_3.rs | use self::Number::{One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero};
#[derive(PartialEq, Debug)]
pub enum Number {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine, | impl From<char> for Number {
fn from(c: char) -> Number {
match c {
'1' => One,
'2' => Two,
'3' => Three,
'4' => Four,
'5' => Five,
'6' => Six,
'7' => Seven,
'8' => Eight,
'9' => Nine,
'0... | Zero
}
| random_line_split |
update_json.rs | use toyunda_player::VideoMeta;
use subtitles::*;
use clap::ArgMatches;
use std::path::PathBuf;
use std::fs::File;
extern crate serde_json;
extern crate serde_yaml;
/// true on success
/// false on failure
pub fn update_json(args: &ArgMatches) -> bool {
if let Some(path) = args.value_of("JSON_FILE") {
let... | println!("file `{}` couldn't be opened : {:?}",
json_path.display(),
e);
false
}
(_, Err(e)) => {
println!("file `{}` couldn't be opened : {:?}",
... | (Err(e), _) => { | random_line_split |
update_json.rs | use toyunda_player::VideoMeta;
use subtitles::*;
use clap::ArgMatches;
use std::path::PathBuf;
use std::fs::File;
extern crate serde_json;
extern crate serde_yaml;
/// true on success
/// false on failure
pub fn update_json(args: &ArgMatches) -> bool {
if let Some(path) = args.value_of("JSON_FILE") {
let... |
} else {
println!("A file is required for the subcommand 'update'");
// clap shouldn't let this case happen but never too sure
false
}
}
| {
if json_path.is_file() {
println!("file `{}` not found", yaml_path.display());
} else {
println!("file `{}` not found", json_path.display());
};
false
} | conditional_block |
update_json.rs | use toyunda_player::VideoMeta;
use subtitles::*;
use clap::ArgMatches;
use std::path::PathBuf;
use std::fs::File;
extern crate serde_json;
extern crate serde_yaml;
/// true on success
/// false on failure
pub fn update_json(args: &ArgMatches) -> bool | false
} else {
true
}
}
(Err(err), _) => {
println!("error while parsing video_meta : {:?}", err);
... | {
if let Some(path) = args.value_of("JSON_FILE") {
let json_path = PathBuf::from(path);
let yaml_path = json_path.with_extension("yaml");
if (json_path.is_file() && yaml_path.is_file()) {
let json_file = File::open(&json_path);
let yaml_file = File::open(&yaml_path);
... | identifier_body |
update_json.rs | use toyunda_player::VideoMeta;
use subtitles::*;
use clap::ArgMatches;
use std::path::PathBuf;
use std::fs::File;
extern crate serde_json;
extern crate serde_yaml;
/// true on success
/// false on failure
pub fn | (args: &ArgMatches) -> bool {
if let Some(path) = args.value_of("JSON_FILE") {
let json_path = PathBuf::from(path);
let yaml_path = json_path.with_extension("yaml");
if (json_path.is_file() && yaml_path.is_file()) {
let json_file = File::open(&json_path);
let yaml_fil... | update_json | identifier_name |
let.rs | //
// Copyright 2015 Joshua R. Rodgers
//
// 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 agre... | () {
let multiplier = 2;
let result = query! { from x => (0..5),
let a = x * multiplier,
select a };
let expected = vec! [0, 2, 4, 6, 8];
for (i, x) in result.enumerate() {
assert_eq!(x, expected[i]);
}
} | let_clause_should_be_able_to_take_closure | identifier_name |
let.rs | //
// Copyright 2015 Joshua R. Rodgers
//
// 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 agre... |
#[allow(unused_variables)]
#[test]
fn let_clause_should_introduce_new_context() {
let result = query! { from x => (0..10).zip(0..10),
let (a, b) = x,
select a*b };
let expected = vec! [0, 1, 4, 9, 16, 25, 36, 49, 64, 81];
for (i, x) in result.enumerate... | #[macro_use]
extern crate query_rs; | random_line_split |
let.rs | //
// Copyright 2015 Joshua R. Rodgers
//
// 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 agre... |
#[allow(unused_variables)]
#[test]
fn let_clause_should_be_able_to_take_closure() {
let multiplier = 2;
let result = query! { from x => (0..5),
let a = x * multiplier,
select a };
let expected = vec! [0, 2, 4, 6, 8];
for (i, x) in result.enumerat... | {
let result = query! { from x => (0..10).zip(0..10),
let (a, b) = x,
select a*b };
let expected = vec! [0, 1, 4, 9, 16, 25, 36, 49, 64, 81];
for (i, x) in result.enumerate() {
assert_eq!(x, expected[i]);
}
} | identifier_body |
mod.rs | // OpenAOE: An open source reimplementation of Age of Empires (1997)
// Copyright (c) 2016 Kevin Fuller
//
// 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 wi... | // copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS B... | random_line_split | |
lib.rs | pub trait Summary {
fn summarize(&self) -> String;
}
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for NewsArticle {
fn summarize(&self) -> String {
format!("{}, by {} ({})", self.headline, self.author, self... |
}
// ANCHOR_END: here
| {
Tweet {
username: String::from("horse_ebooks"),
content: String::from(
"of course, as you probably already know, people",
),
reply: false,
retweet: false,
}
} | conditional_block |
lib.rs | pub trait Summary {
fn summarize(&self) -> String;
}
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for NewsArticle {
fn summarize(&self) -> String {
format!("{}, by {} ({})", self.headline, self.author, self... | // ANCHOR_END: here | random_line_split | |
lib.rs | pub trait Summary {
fn summarize(&self) -> String;
}
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for NewsArticle {
fn summarize(&self) -> String {
format!("{}, by {} ({})", self.headline, self.author, self... | {
pub username: String,
pub content: String,
pub reply: bool,
pub retweet: bool,
}
impl Summary for Tweet {
fn summarize(&self) -> String {
format!("{}: {}", self.username, self.content)
}
}
// ANCHOR: here
fn returns_summarizable(switch: bool) -> impl Summary {
if switch {
... | Tweet | identifier_name |
htmltablecellelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::RGBA;
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethod... | (&self) -> LengthOrPercentageOrAuto {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
.get_attr_for_layout(&ns!(), &local_name!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
}
}
... | get_width | identifier_name |
htmltablecellelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::RGBA;
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethod... |
fn get_colspan(&self) -> Option<u32> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
.get_attr_for_layout(&ns!(), &local_name!("colspan"))
.map(AttrValue::as_uint)
}
}
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
... | .and_then(AttrValue::as_color)
.cloned()
}
} | random_line_split |
htmltablecellelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::RGBA;
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethod... |
fn get_colspan(&self) -> Option<u32> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
.get_attr_for_layout(&ns!(), &local_name!("colspan"))
.map(AttrValue::as_uint)
}
}
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
... | {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
} | identifier_body |
enums.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
// GENERATOR-BEGIN: LegacyHandlerFlags
// ⚠️This was generated by GENERATOR!🦹♂️
pub(crate) struct LegacyHandler | d_code)]
impl LegacyHandlerFlags {
pub(crate) const HANDLER_REG: u32 = 0x0000_0001;
pub(crate) const HANDLER_MEM: u32 = 0x0000_0002;
pub(crate) const HANDLER_66_REG: u32 = 0x0000_0004;
pub(crate) const HANDLER_66_MEM: u32 = 0x0000_0008;
pub(crate) const HANDLER_F3_REG: u32 = 0x0000_0010;
pub(crate) const HANDLER_... | Flags;
#[allow(dea | identifier_name |
enums.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
// GENERATOR-BEGIN: LegacyHandlerFlags
// ⚠️This was generated by GENERATOR!🦹♂️
pub(crate) struct LegacyHandlerFlags;
#[allow(dead_code)]
impl LegacyHandlerFlags {
pub(crate) const HANDLER_REG: u32 = 0x0000_0001;
pub(cra... | }
// GENERATOR-END: LegacyHandlerFlags | pub(crate) const HANDLER_F2_REG: u32 = 0x0000_0040;
pub(crate) const HANDLER_F2_MEM: u32 = 0x0000_0080; | random_line_split |
mutate.rs | use malachite_base::rational_sequences::RationalSequence;
use malachite_base_test_util::generators::large_type_gen_var_22;
#[test]
pub fn test_mutate() {
fn test(
non_repeating: &[u8],
repeating: &[u8],
index: usize,
new_value: u8,
out: u8,
non_repeating_out: &[u8],
... |
#[test]
#[should_panic]
fn mutate_fail_2() {
RationalSequence::from_vec(vec![1, 2, 3]).mutate(3, |_| {})
}
#[test]
fn mutate_properties() {
large_type_gen_var_22::<u8>().test_properties(|(mut xs, index, y, z)| {
let xs_old = xs.clone();
let x_old = xs[index];
assert_eq!(
x... | {
RationalSequence::<u8>::from_vec(vec![]).mutate(0, |_| {});
} | identifier_body |
mutate.rs | use malachite_base::rational_sequences::RationalSequence;
use malachite_base_test_util::generators::large_type_gen_var_22;
#[test]
pub fn test_mutate() {
fn test(
non_repeating: &[u8],
repeating: &[u8],
index: usize,
new_value: u8,
out: u8,
non_repeating_out: &[u8],
... | );
test(
&[1, 2, 3],
&[4, 5, 6],
10,
100,
6,
&[1, 2, 3, 4, 5, 6, 4, 5, 6, 4, 100],
&[6, 4, 5],
);
}
#[test]
#[should_panic]
fn mutate_fail_1() {
RationalSequence::<u8>::from_vec(vec![]).mutate(0, |_| {});
}
#[test]
#[should_panic]
fn mutate_fail_... | &[1, 2, 3, 100],
&[5, 6, 4], | random_line_split |
mutate.rs | use malachite_base::rational_sequences::RationalSequence;
use malachite_base_test_util::generators::large_type_gen_var_22;
#[test]
pub fn test_mutate() {
fn test(
non_repeating: &[u8],
repeating: &[u8],
index: usize,
new_value: u8,
out: u8,
non_repeating_out: &[u8],
... | () {
RationalSequence::from_vec(vec![1, 2, 3]).mutate(3, |_| {})
}
#[test]
fn mutate_properties() {
large_type_gen_var_22::<u8>().test_properties(|(mut xs, index, y, z)| {
let xs_old = xs.clone();
let x_old = xs[index];
assert_eq!(
xs.mutate(index, |x| {
*x =... | mutate_fail_2 | identifier_name |
util.rs | extern crate time;
use std::env;
use std::fs;
use std::path;
use std::time::{SystemTime, UNIX_EPOCH};
use core::io::BinaryComponent;
use core::sig;
pub fn load_user_keypair() -> Option<sig::Keypair> |
}
pub fn timestamp() -> i64 {
let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
((dur.as_secs() * 1000) + ((dur.subsec_nanos() / 1000000) as u64)) as i64
}
| {
let kpp = match env::home_dir() {
Some(mut p) => {
p.push(".jiyunet");
p.push("keypair.bin");
p
},
None => path::PathBuf::from(".")
};
let mut f = match fs::File::open(kpp) {
Ok(o) => o,
Err(_) => return None
};
match s... | identifier_body |
util.rs | extern crate time;
use std::env;
use std::fs;
use std::path;
use std::time::{SystemTime, UNIX_EPOCH};
use core::io::BinaryComponent;
use core::sig;
pub fn load_user_keypair() -> Option<sig::Keypair> {
let kpp = match env::home_dir() {
Some(mut p) => {
p.push(".jiyunet");
p.push("... | };
let mut f = match fs::File::open(kpp) {
Ok(o) => o,
Err(_) => return None
};
match sig::Keypair::from_reader(&mut f) {
Ok(kp) => Some(kp),
Err(_) => None
}
}
pub fn timestamp() -> i64 {
let dur = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
((... | None => path::PathBuf::from(".") | random_line_split |
util.rs | extern crate time;
use std::env;
use std::fs;
use std::path;
use std::time::{SystemTime, UNIX_EPOCH};
use core::io::BinaryComponent;
use core::sig;
pub fn | () -> Option<sig::Keypair> {
let kpp = match env::home_dir() {
Some(mut p) => {
p.push(".jiyunet");
p.push("keypair.bin");
p
},
None => path::PathBuf::from(".")
};
let mut f = match fs::File::open(kpp) {
Ok(o) => o,
Err(_) => retu... | load_user_keypair | identifier_name |
error.rs | //! Error types for corepack.
//
// 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 std::fmt::Display;
#[cfg(feature = "alloc")]
use alloc::string::String;... | Error::Utf8Error(cause)
}
}
#[cfg(feature = "std")]
impl ::std::error::Error for Error {
fn description(&self) -> &str {
Error::description(self)
}
fn cause(&self) -> Option<&::std::error::Error> {
match self {
&Error::Utf8Error(ref cause) => Some(cause)... | }
impl From<Utf8Error> for Error {
fn from(cause: Utf8Error) -> Error {
| random_line_split |
error.rs | //! Error types for corepack.
//
// 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 std::fmt::Display;
#[cfg(feature = "alloc")]
use alloc::string::String;... |
}
impl Error {
fn description(&self) -> &str {
match self {
&Error::TooBig => "Overflowing value",
&Error::EndOfStream => "End of stream",
&Error::BadType => "Invalid type",
&Error::BadLength => "Invalid length",
&Error::Utf8Error(_) =>... | {
fmt.write_str(self.description())
} | identifier_body |
error.rs | //! Error types for corepack.
//
// 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 std::fmt::Display;
#[cfg(feature = "alloc")]
use alloc::string::String;... | (&self) -> &str {
match self {
&Error::TooBig => "Overflowing value",
&Error::EndOfStream => "End of stream",
&Error::BadType => "Invalid type",
&Error::BadLength => "Invalid length",
&Error::Utf8Error(_) => "UTF8 Error",
&Error::Oth... | description | identifier_name |
lang_items.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 ... | }
visit::walk_item(self, item);
}
}
impl<'a> LanguageItemCollector<'a> {
pub fn new(session: &'a Session) -> LanguageItemCollector<'a> {
let mut item_refs = FnvHashMap();
$( item_refs.insert($name, $variant as usize); )*
LanguageItemCollector {
session: se... | let item_index = self.item_refs.get(&value[..]).cloned();
if let Some(item_index) = item_index {
self.collect_item(item_index, local_def(item.id), item.span)
} | random_line_split |
js.rs | use crate::{CharEncoder, Named};
pub struct Js;
impl CharEncoder for Js {
fn encode(iter: &mut dyn Iterator<Item = char>) -> Option<String> {
iter.next().map(|ch| {
let i = ch as u32;
if i <= 0xFFFF {
format!("\\u{:01$X}", i, 4)
} else |
})
}
fn wrap_in_quotes() -> bool {
true
}
}
impl Named for Js {
fn name() -> &'static str {
"javascript"
}
}
#[cfg(test)]
mod tests {
use super::Js;
use crate::{CharEncoder, Named};
use std::iter::{empty, once};
#[test]
fn empty_iterator() {
a... | {
format!("\\u{{{:X}}}", i)
} | conditional_block |
js.rs | use crate::{CharEncoder, Named};
pub struct Js;
impl CharEncoder for Js {
fn | (iter: &mut dyn Iterator<Item = char>) -> Option<String> {
iter.next().map(|ch| {
let i = ch as u32;
if i <= 0xFFFF {
format!("\\u{:01$X}", i, 4)
} else {
format!("\\u{{{:X}}}", i)
}
})
}
fn wrap_in_quotes() -> boo... | encode | identifier_name |
js.rs | use crate::{CharEncoder, Named};
pub struct Js;
impl CharEncoder for Js {
fn encode(iter: &mut dyn Iterator<Item = char>) -> Option<String> {
iter.next().map(|ch| {
let i = ch as u32;
if i <= 0xFFFF {
format!("\\u{:01$X}", i, 4)
} else {
... | assert_eq!(Js::name(), "javascript");
}
}
| identifier_body | |
js.rs | use crate::{CharEncoder, Named};
pub struct Js;
impl CharEncoder for Js {
fn encode(iter: &mut dyn Iterator<Item = char>) -> Option<String> {
iter.next().map(|ch| {
let i = ch as u32;
if i <= 0xFFFF {
format!("\\u{:01$X}", i, 4)
} else {
... | assert!(Js::wrap_in_quotes());
}
#[test]
fn name() {
assert_eq!(Js::name(), "javascript");
}
} | }
#[test]
fn quotes() { | random_line_split |
macro-only-syntax.rs | // force-host
// no-prefer-dynamic
// These are tests for syntax that is accepted by the Rust parser but
// unconditionally rejected semantically after macro expansion. Attribute macros
// are permitted to accept such syntax as long as they replace it with something
// that makes sense to Rust.
//
// We also inspect s... |
fn expect_brace(tokens: &mut token_stream::IntoIter) -> token_stream::IntoIter {
match tokens.next() {
Some(TokenTree::Group(group)) if group.delimiter() == Delimiter::Brace => {
group.stream().into_iter()
}
wrong => panic!("unexpected token: {:?}, expected `{{`", wrong),
}... | {
match tokens.next() {
Some(token) if token.to_string() == expected => token,
wrong => panic!("unexpected token: {:?}, expected `{}`", wrong, expected),
}
} | identifier_body |
macro-only-syntax.rs | // force-host
// no-prefer-dynamic
// These are tests for syntax that is accepted by the Rust parser but
// unconditionally rejected semantically after macro expansion. Attribute macros
// are permitted to accept such syntax as long as they replace it with something
// that makes sense to Rust.
//
// We also inspect s... | (_attrs: TokenStream, input: TokenStream) -> TokenStream {
let tokens = &mut input.into_iter();
expect(tokens, "unsafe");
expect(tokens, "mod");
expect(tokens, "m");
let tokens = &mut expect_brace(tokens);
expect(tokens, "pub");
expect(tokens, "unsafe");
expect(tokens, "mod");
let id... | expect_unsafe_mod | identifier_name |
macro-only-syntax.rs | // force-host
// no-prefer-dynamic
// These are tests for syntax that is accepted by the Rust parser but
// unconditionally rejected semantically after macro expansion. Attribute macros
// are permitted to accept such syntax as long as they replace it with something
// that makes sense to Rust.
//
// We also inspect s... | #![crate_type = "proc-macro"]
#![feature(proc_macro_span)]
extern crate proc_macro;
use proc_macro::{token_stream, Delimiter, TokenStream, TokenTree};
use std::path::Component;
// unsafe mod m {
// pub unsafe mod inner;
// }
#[proc_macro_attribute]
pub fn expect_unsafe_mod(_attrs: TokenStream, input: TokenStream)... | random_line_split | |
android.rs | use regex::Regex;
use crate::file::{get_path, get_content, set_content};
use crate::git::list_changes_main;
use crate::version::Version;
| fn path_error_logs() -> String { get_path(vec!["..", "android", "ErrorLogs", "build.gradle"]) }
pub fn update_android(version: &Version) {
let changes = list_changes_main();
let changed_general = general_changed(&changes);
let updated_main = update_main(version);
if!updated_main { return }
if changed_general |... | fn path_main() -> String { get_path(vec!["..", "android", "build.gradle"]) }
fn path_app() -> String { get_path(vec!["..", "android", "App", "build.gradle"]) } | random_line_split |
android.rs | use regex::Regex;
use crate::file::{get_path, get_content, set_content};
use crate::git::list_changes_main;
use crate::version::Version;
fn path_main() -> String { get_path(vec!["..", "android", "build.gradle"]) }
fn path_app() -> String { get_path(vec!["..", "android", "App", "build.gradle"]) }
fn path_error_logs() ... | (version: &str) -> String {
format!(r#"ext.dfm_version = "{}""#, version)
}
fn change_code(path: String, pattern: &str) {
let mut content = get_content(path.clone());
let pattern = version_code(&pattern);
let regex = Regex::new(&pattern).unwrap();
let old_number = regex
.captures(&content)
.unwrap()
.get(... | version_name | identifier_name |
android.rs | use regex::Regex;
use crate::file::{get_path, get_content, set_content};
use crate::git::list_changes_main;
use crate::version::Version;
fn path_main() -> String { get_path(vec!["..", "android", "build.gradle"]) }
fn path_app() -> String { get_path(vec!["..", "android", "App", "build.gradle"]) }
fn path_error_logs() ... |
}
return false;
}
fn update_main(version: &Version) -> bool {
let mut content = get_content(path_main());
if!content.contains(&version.prev) {
return false;
}
let old_name = version_name(&version.prev);
let new_name = version_name(&version.code);
content = content.replace(&old_name, &new_name);
set_co... | {
return true;
} | conditional_block |
android.rs | use regex::Regex;
use crate::file::{get_path, get_content, set_content};
use crate::git::list_changes_main;
use crate::version::Version;
fn path_main() -> String { get_path(vec!["..", "android", "build.gradle"]) }
fn path_app() -> String { get_path(vec!["..", "android", "App", "build.gradle"]) }
fn path_error_logs() ... |
fn general_changed(list: &Vec<String>) -> bool {
let checks = vec![
"Lib",
"TestUtils",
"build.gradle",
"gradle.properties",
"settings.gradle"
];
for check in checks {
if changed(check, list) {
return true;
}
}
return false;
}
fn changed(name: &str, list: &Vec<String>) -> bool {
let path = f... | {
let changes = list_changes_main();
let changed_general = general_changed(&changes);
let updated_main = update_main(version);
if !updated_main { return }
if changed_general || changed("App", &changes) {
change_code(path_app(), "(2011\\d{6})");
}
if changed_general || changed("ErrorLogs", &changes) {
cha... | identifier_body |
arc.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
struct MutexArcBox<T> {
mutex: Mutex,
value: T,
no_freeze: marker::NoFreeze
}
pub struct MutexArc<T> {
ptr: Arc<MutexArcBox<T>>
}
impl<T: Send> MutexArc<T> {
pub fn new(value: T) -> MutexArc<T> {
let b = MutexArcBox { mutex: Mutex::new(), value: value, no_freeze: marker::NoFreeze };
... | { *self.borrow() >= *other.borrow() } | identifier_body |
arc.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 ... | }
} | random_line_split | |
arc.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 ... |
}
}
impl<T> Clone for Arc<T> {
fn clone(&self) -> Arc<T> {
unsafe {
atomic_xadd_relaxed(&mut (*self.ptr).count, 1);
Arc { ptr: self.ptr }
}
}
}
impl<T: DeepClone> DeepClone for Arc<T> {
fn deep_clone(&self) -> Arc<T> {
unsafe { Arc::new_unchecked(self.b... | {
unsafe {
if atomic_xsub_rel(&mut (*self.ptr).count, 1) == 1 {
atomic_fence_acq();
let _: ~ArcBox<T> = transmute(self.ptr);
}
}
} | conditional_block |
arc.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 ... | (&self, other: &Arc<T>) -> bool { *self.borrow() < *other.borrow() }
#[inline(always)]
fn le(&self, other: &Arc<T>) -> bool { *self.borrow() <= *other.borrow() }
#[inline(always)]
fn gt(&self, other: &Arc<T>) -> bool { *self.borrow() > *other.borrow() }
#[inline(always)]
fn ge(&self, other: &... | lt | identifier_name |
p104.rs | //! [Problem 104](https://projecteuler.net/problem=104) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use num_integer::Integer;
fn is_pandigit(n: u64) -> bool {
let mut hist = [false; 10];
let mut cnt = 0;
... | let next = match self.cnt {
0 => 1,
1 => 1,
2 => 2,
3 => 3,
4 => 5,
_ => {
let mut f = ((self.curr as f64) * self.phi + 0.5) as u64;
while f > self.base * self.base {
f /= 10;
... | random_line_split | |
p104.rs | //! [Problem 104](https://projecteuler.net/problem=104) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use num_integer::Integer;
fn is_pandigit(n: u64) -> bool {
let mut hist = [false; 10];
let mut cnt = 0;
... | else {
assert_eq!(bus[..len].parse::<u64>().unwrap(), fst);
assert_eq!(bus[bus.len() - len..].parse::<u64>().unwrap(), lst);
}
}
}
}
| {
assert_eq!(bus, fst.to_string());
assert_eq!(bus, lst.to_string());
} | conditional_block |
p104.rs | //! [Problem 104](https://projecteuler.net/problem=104) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use num_integer::Integer;
fn is_pandigit(n: u64) -> bool {
let mut hist = [false; 10];
let mut cnt = 0;
... | {
base: u64,
phi: f64,
curr: u64,
cnt: usize,
}
impl FibFirst {
fn new(len: u32) -> FibFirst {
assert!(len > 0);
FibFirst {
base: 10u64.pow(len),
phi: (1.0 + (5.0f64).sqrt()) / 2.0,
curr: 1,
cnt: 1,
}
}
}
impl Iterator fo... | FibFirst | identifier_name |
p104.rs | //! [Problem 104](https://projecteuler.net/problem=104) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use num_integer::Integer;
fn is_pandigit(n: u64) -> bool {
let mut hist = [false; 10];
let mut cnt = 0;
... |
}
impl Iterator for FibFirst {
type Item = u64;
fn next(&mut self) -> Option<u64> {
let next = match self.cnt {
0 => 1,
1 => 1,
2 => 2,
3 => 3,
4 => 5,
_ => {
let mut f = ((self.curr as f64) * self.phi + 0.5) as u... | {
assert!(len > 0);
FibFirst {
base: 10u64.pow(len),
phi: (1.0 + (5.0f64).sqrt()) / 2.0,
curr: 1,
cnt: 1,
}
} | identifier_body |
imports_granularity_crate.rs | // rustfmt-imports_granularity: Crate
use a::{c,d,b};
use a::{d, e, b, a, f};
use a::{f, g, c};
#[doc(hidden)] | use a::d;
use a::{c, d, e};
#[doc(hidden)]
use a::b;
use a::d;
pub use foo::bar;
use foo::{a, b, c};
pub use foo::foobar;
use a::{b::{c::*}};
use a::{b::{c::{}}};
use a::{b::{c::d}};
use a::{b::{c::{xxx, yyy, zzz}}};
// https://github.com/rust-lang/rustfmt/issues/3808
use d::{self};
use e::{self as foo};
use f::{se... | use a::b;
use a::c; | random_line_split |
protocol.rs | pub enum Token
{
Symbol(String),
Ident(String),
Lifetime(String),
String(String),
ByteString(Vec<u8>),
Char(char),
Unsigned(u128, u8),
Signed(i128, u8),
Float(f64, u8),
}
pub struct Reader<R>
{
inner: R,
}
impl<R: ::std::io::Read> Reader<R> {
pub fn new(r: R) -> Reader<R> {
... | }
impl<T: ::std::io::Write> Writer<T>
{
pub fn new(w: T) -> Writer<T> {
Writer {
inner: w,
}
}
pub fn write_ent(&mut self, t: Token)
{
match t
{
Token::Symbol(v) => { self.putb(0); self.put_bytes(v.as_bytes()); },
Token::Ident(v) ... | }
pub struct Writer<T>
{
inner: T, | random_line_split |
protocol.rs |
pub enum Token
{
Symbol(String),
Ident(String),
Lifetime(String),
String(String),
ByteString(Vec<u8>),
Char(char),
Unsigned(u128, u8),
Signed(i128, u8),
Float(f64, u8),
}
pub struct Reader<R>
{
inner: R,
}
impl<R: ::std::io::Read> Reader<R> {
pub fn new(r: R) -> Reader<R> {... | (&mut self, mut v: u128) {
while v >= 128 {
self.putb( (v & 0x7F) as u8 | 0x80 );
v >>= 7;
}
self.putb( (v & 0x7F) as u8 );
}
fn put_i128v(&mut self, v: i128) {
if v < 0 {
self.put_u128v( (((v + 1) as u128) << 1) | 1 );
}
else {... | put_u128v | identifier_name |
protocol.rs |
pub enum Token
{
Symbol(String),
Ident(String),
Lifetime(String),
String(String),
ByteString(Vec<u8>),
Char(char),
Unsigned(u128, u8),
Signed(i128, u8),
Float(f64, u8),
}
pub struct Reader<R>
{
inner: R,
}
impl<R: ::std::io::Read> Reader<R> {
pub fn new(r: R) -> Reader<R> {... |
fn put_u128v(&mut self, mut v: u128) {
while v >= 128 {
self.putb( (v & 0x7F) as u8 | 0x80 );
v >>= 7;
}
self.putb( (v & 0x7F) as u8 );
}
fn put_i128v(&mut self, v: i128) {
if v < 0 {
self.put_u128v( (((v + 1) as u128) << 1) | 1 );
... | {
let buf = [v];
self.inner.write(&buf).expect("");
} | identifier_body |
protocol.rs |
pub enum Token
{
Symbol(String),
Ident(String),
Lifetime(String),
String(String),
ByteString(Vec<u8>),
Char(char),
Unsigned(u128, u8),
Signed(i128, u8),
Float(f64, u8),
}
pub struct Reader<R>
{
inner: R,
}
impl<R: ::std::io::Read> Reader<R> {
pub fn new(r: R) -> Reader<R> {... | ,
Token::String(v) => { self.putb(3); self.put_bytes(v.as_bytes()); },
Token::ByteString(v) => { self.putb(4); self.put_bytes(&v[..]); },
Token::Char(v) => { self.putb(5); self.put_u128v(v as u32 as u128); },
Token::Unsigned(v, sz) => { self.putb(6); self.putb(sz); self.p... | { self.putb(2); self.put_bytes(v.as_bytes()); } | conditional_block |
sprite.rs | // Copyright 2013-2014 Jeffery Olson
//
// Licensed under the 3-Clause BSD License, see LICENSE.txt
// at the top-level of this repository.
// This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone, Encodable, Decodable)]
pub struct SpriteSheet {
pub path: String... | () -> SpriteTile { SpriteTile { sheet: "".to_string(), coords: (0,0), size:(0,0) } }
}
| stub | identifier_name |
sprite.rs | // Copyright 2013-2014 Jeffery Olson
//
// Licensed under the 3-Clause BSD License, see LICENSE.txt
// at the top-level of this repository.
// This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone, Encodable, Decodable)]
pub struct SpriteSheet {
pub path: String... |
}
impl SpriteTile {
pub fn stub() -> SpriteTile { SpriteTile { sheet: "".to_string(), coords: (0,0), size:(0,0) } }
}
| {
SpriteTile {
sheet: self.sheet.clone(),
coords: (self.coords),
size: (self.size)
}
} | identifier_body |
sprite.rs | // Copyright 2013-2014 Jeffery Olson
//
// Licensed under the 3-Clause BSD License, see LICENSE.txt
// at the top-level of this repository.
// This file may not be copied, modified, or distributed
// except according to those terms. | }
#[deriving(Encodable, Decodable)]
pub struct SpriteTile {
pub sheet: String,
pub coords: (uint, uint),
pub size: (uint, uint)
}
impl Clone for SpriteTile {
fn clone(&self) -> SpriteTile {
SpriteTile {
sheet: self.sheet.clone(),
coords: (self.coords),
size:... |
#[deriving(Clone, Encodable, Decodable)]
pub struct SpriteSheet {
pub path: String,
pub name: String | random_line_split |
path.rs | use std::io::fs::PathExtensions;
fn main() | }
// `stat` returns an IoResult<FileStat> === Result<FileStat, IoError>
let stat = match path.stat() {
Err(why) => fail!("{}", why.desc),
Ok(stat) => stat,
};
println!("{} size is {} bytes", display, stat.size);
// `join` merges a path with a byte container using the OS specif... | {
// Create a `Path` from an `&'static str`
let path = Path::new(".");
// The `display` method returns a `Show`able structure
let display = path.display();
// Check if the path exists
if path.exists() {
println!("{} exists", display);
}
// Check if the path is a file
if pa... | identifier_body |
path.rs | use std::io::fs::PathExtensions;
fn main() {
// Create a `Path` from an `&'static str`
let path = Path::new(".");
// The `display` method returns a `Show`able structure
let display = path.display();
// Check if the path exists
if path.exists() {
println!("{} exists", display);
}
... | }
// `stat` returns an IoResult<FileStat> === Result<FileStat, IoError>
let stat = match path.stat() {
Err(why) => fail!("{}", why.desc),
Ok(stat) => stat,
};
println!("{} size is {} bytes", display, stat.size);
// `join` merges a path with a byte container using the OS specif... | // Check if the path is a directory
if path.is_dir() {
println!("{} is a directory", display); | random_line_split |
path.rs | use std::io::fs::PathExtensions;
fn | () {
// Create a `Path` from an `&'static str`
let path = Path::new(".");
// The `display` method returns a `Show`able structure
let display = path.display();
// Check if the path exists
if path.exists() {
println!("{} exists", display);
}
// Check if the path is a file
if... | main | identifier_name |
x86_64_unknown_freebsd.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 ... |
Target {
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-freebsd".to_string(),
target_endia... | let mut base = super::freebsd_base::opts();
base.pre_link_args.push("-m64".to_string()); | random_line_split |
x86_64_unknown_freebsd.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 ... | () -> Target {
let mut base = super::freebsd_base::opts();
base.pre_link_args.push("-m64".to_string());
Target {
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
s0:64:64-f80:128:12... | target | identifier_name |
x86_64_unknown_freebsd.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 mut base = super::freebsd_base::opts();
base.pre_link_args.push("-m64".to_string());
Target {
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
s0:64:64-f80:128:128-n8:16:32:64... | identifier_body | |
vcs.rs | use std::path::Path;
use git2;
use util::{CargoResult, process};
pub struct | ;
pub struct GitRepo;
impl GitRepo {
pub fn init(path: &Path, _: &Path) -> CargoResult<GitRepo> {
git2::Repository::init(path)?;
Ok(GitRepo)
}
pub fn discover(path: &Path, _: &Path) -> Result<git2::Repository,git2::Error> {
git2::Repository::discover(path)
}
}
impl HgRepo {
... | HgRepo | identifier_name |
vcs.rs | use std::path::Path;
use git2;
use util::{CargoResult, process};
pub struct HgRepo;
pub struct GitRepo;
impl GitRepo {
pub fn init(path: &Path, _: &Path) -> CargoResult<GitRepo> {
git2::Repository::init(path)?;
Ok(GitRepo)
}
pub fn discover(path: &Path, _: &Path) -> Result<git2::Reposito... | } | }
pub fn discover(path: &Path, cwd: &Path) -> CargoResult<HgRepo> {
process("hg").cwd(cwd).arg("root").cwd(path).exec_with_output()?;
Ok(HgRepo)
} | random_line_split |
channel.rs | extern crate futures;
use std::sync::atomic::*;
use futures::{Future, Stream, Sink};
use futures::future::result;
use futures::sync::mpsc;
mod support;
use support::*;
#[test]
fn | () {
let (tx, mut rx) = mpsc::channel(1);
sassert_empty(&mut rx);
sassert_empty(&mut rx);
let amt = 20;
send(amt, tx).forget();
let mut rx = rx.wait();
for i in (1..amt + 1).rev() {
assert_eq!(rx.next(), Some(Ok(i)));
}
assert_eq!(rx.next(), None);
fn send(n: u32, send... | sequence | identifier_name |
channel.rs | extern crate futures;
use std::sync::atomic::*;
use futures::{Future, Stream, Sink};
use futures::future::result;
use futures::sync::mpsc;
mod support;
use support::*;
#[test]
fn sequence() {
let (tx, mut rx) = mpsc::channel(1);
sassert_empty(&mut rx);
sassert_empty(&mut rx);
let amt = 20;
sen... |
sender.send(n).map_err(|_| ()).and_then(move |sender| {
send(n - 1, sender)
}).boxed()
}
}
#[test]
fn drop_sender() {
let (tx, mut rx) = mpsc::channel::<u32>(1);
drop(tx);
sassert_done(&mut rx);
}
#[test]
fn drop_rx() {
let (tx, rx) = mpsc::channel::<u32>(1);
let t... | {
return result(Ok(())).boxed()
} | conditional_block |
channel.rs |
use std::sync::atomic::*;
use futures::{Future, Stream, Sink};
use futures::future::result;
use futures::sync::mpsc;
mod support;
use support::*;
#[test]
fn sequence() {
let (tx, mut rx) = mpsc::channel(1);
sassert_empty(&mut rx);
sassert_empty(&mut rx);
let amt = 20;
send(amt, tx).forget();
... | extern crate futures; | random_line_split | |
file_reading.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::domexception::DOMErrorName;
use crate::dom::filereader::{FileReader, GenerationId, ReadMetaData, ... | }
} | random_line_split | |
file_reading.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::domexception::DOMErrorName;
use crate::dom::filereader::{FileReader, GenerationId, ReadMetaData, ... | {
ProcessRead(TrustedFileReader, GenerationId),
ProcessReadData(TrustedFileReader, GenerationId),
ProcessReadError(TrustedFileReader, GenerationId, DOMErrorName),
ProcessReadEOF(TrustedFileReader, GenerationId, ReadMetaData, Vec<u8>),
}
impl FileReadingTask {
pub fn handle_task(self) {
use... | FileReadingTask | identifier_name |
file_reading.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::domexception::DOMErrorName;
use crate::dom::filereader::{FileReader, GenerationId, ReadMetaData, ... |
}
impl TaskSource for FileReadingTaskSource {
const NAME: TaskSourceName = TaskSourceName::FileReading;
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
where
T: TaskOnce +'static,
{
self.0.send(CommonScriptMsg::Task(
ScriptThreadEven... | {
FileReadingTaskSource(self.0.clone(), self.1.clone())
} | identifier_body |
main.rs | use std::ops::{Add};
fn main() {
println!();
// ARRAYS
let one = [1,2,3];
let two: [u8; 3] = [1,2,3];
let blank1 = [0; 3];
let blank2: [u8; 3] = [0; 3];
let arrays = [one, two, blank1, blank2];
for a in &arrays {
print!("{:?}: ", a);
for n in a... | T: Add<Output = T>>(i: T, j: T) -> T {
i + j
}
| dd< | identifier_name |
main.rs | use std::ops::{Add};
fn main() {
println!();
// ARRAYS
let one = [1,2,3];
let two: [u8; 3] = [1,2,3];
let blank1 = [0; 3];
let blank2: [u8; 3] = [0; 3];
let arrays = [one, two, blank1, blank2];
for a in &arrays {
print!("{:?}: ", a);
for n in a... | print!("\t(Σ{:?} = {})", a, sum);
println!();
}
println!();
// GREP-LITE
let search_term = "picture";
let quote = "Every face, every shop, bedroom window, public-house, and
dark square is a picture feverishly turned--in search of what?
It is the same with books. What do we s... | let mut sum = 0;
for i in 0..a.len() {
sum += a[i];
} | random_line_split |
main.rs | use std::ops::{Add};
fn main() {
println!();
// ARRAYS
let one = [1,2,3];
let two: [u8; 3] = [1,2,3];
let blank1 = [0; 3];
let blank2: [u8; 3] = [0; 3];
let arrays = [one, two, blank1, blank2];
for a in &arrays {
print!("{:?}: ", a);
for n in a... |
i + j
}
| identifier_body | |
test_multicast.rs | // TODO: This doesn't pass on android 64bit CI...
// Figure out why!
#![cfg(not(target_os = "android"))]
use mio::{Events, Poll, PollOpt, Ready, Token};
use mio::net::UdpSocket;
use bytes::{Buf, MutBuf, RingBuf, SliceBuf};
use std::str;
use std::net::IpAddr;
use localhost;
const LISTENER: Token = Token(0);
const SEND... |
impl UdpHandler {
fn new(tx: UdpSocket, rx: UdpSocket, msg: &'static str) -> UdpHandler {
let sock = UdpSocket::bind(&"127.0.0.1:12345".parse().unwrap()).unwrap();
UdpHandler {
tx: tx,
rx: rx,
msg: msg,
buf: SliceBuf::wrap(msg.as_bytes()),
... | buf: SliceBuf<'static>,
rx_buf: RingBuf,
localhost: IpAddr,
shutdown: bool,
} | random_line_split |
test_multicast.rs | // TODO: This doesn't pass on android 64bit CI...
// Figure out why!
#![cfg(not(target_os = "android"))]
use mio::{Events, Poll, PollOpt, Ready, Token};
use mio::net::UdpSocket;
use bytes::{Buf, MutBuf, RingBuf, SliceBuf};
use std::str;
use std::net::IpAddr;
use localhost;
const LISTENER: Token = Token(0);
const SEND... |
}
#[test]
pub fn test_multicast() {
drop(::env_logger::init());
debug!("Starting TEST_UDP_CONNECTIONLESS");
let mut poll = Poll::new().unwrap();
let addr = localhost();
let any = "0.0.0.0:0".parse().unwrap();
let tx = UdpSocket::bind(&any).unwrap();
let rx = UdpSocket::bind(&addr).unwrap... | {
match token {
SENDER => {
let addr = self.rx.local_addr().unwrap();
let cnt = self.tx.send_to(self.buf.bytes(), &addr).unwrap();
self.buf.advance(cnt);
},
_ => ()
}
} | identifier_body |
test_multicast.rs | // TODO: This doesn't pass on android 64bit CI...
// Figure out why!
#![cfg(not(target_os = "android"))]
use mio::{Events, Poll, PollOpt, Ready, Token};
use mio::net::UdpSocket;
use bytes::{Buf, MutBuf, RingBuf, SliceBuf};
use std::str;
use std::net::IpAddr;
use localhost;
const LISTENER: Token = Token(0);
const SEND... | ,
_ => ()
}
}
}
#[test]
pub fn test_multicast() {
drop(::env_logger::init());
debug!("Starting TEST_UDP_CONNECTIONLESS");
let mut poll = Poll::new().unwrap();
let addr = localhost();
let any = "0.0.0.0:0".parse().unwrap();
let tx = UdpSocket::bind(&any).unwrap();
l... | {
let addr = self.rx.local_addr().unwrap();
let cnt = self.tx.send_to(self.buf.bytes(), &addr).unwrap();
self.buf.advance(cnt);
} | conditional_block |
test_multicast.rs | // TODO: This doesn't pass on android 64bit CI...
// Figure out why!
#![cfg(not(target_os = "android"))]
use mio::{Events, Poll, PollOpt, Ready, Token};
use mio::net::UdpSocket;
use bytes::{Buf, MutBuf, RingBuf, SliceBuf};
use std::str;
use std::net::IpAddr;
use localhost;
const LISTENER: Token = Token(0);
const SEND... | (tx: UdpSocket, rx: UdpSocket, msg: &'static str) -> UdpHandler {
let sock = UdpSocket::bind(&"127.0.0.1:12345".parse().unwrap()).unwrap();
UdpHandler {
tx: tx,
rx: rx,
msg: msg,
buf: SliceBuf::wrap(msg.as_bytes()),
rx_buf: RingBuf::new(1024),
... | new | identifier_name |
attachment.rs | // notty is a new kind of terminal emulator.
// Copyright (C) 2015 without boats
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at y... |
'#' => {
self.data.push(String::new());
None
}
'\u{9c}' => Some(true),
_ => Some(false),
}... | {
self.data.last_mut().unwrap().push(ch);
None
} | conditional_block |
attachment.rs | // notty is a new kind of terminal emulator.
// Copyright (C) 2015 without boats
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at y... | {
data: Vec<String>,
}
impl Default for Attachments {
fn default() -> Attachments {
Attachments { data: vec![String::new()] }
}
}
impl Attachments {
pub fn clear(&mut self) {
self.data.truncate(1);
self.data.last_mut().unwrap().clear();
}
pub fn iter(&self) -> Attach... | Attachments | identifier_name |
attachment.rs | // notty is a new kind of terminal emulator.
// Copyright (C) 2015 without boats
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at y... | "Happy familie are all alike; every unhappy family is unhappy in its own way.",
"--A little more test data.--"
];
#[test]
fn iterates() {
let attachments = Attachments {
data: BLOCKS.iter().map(|s| base64::encode(s).unwrap()).collect()
};
for (attachm... | "#", | random_line_split |
geometry.rs | use byteorder::{ReadBytesExt, LittleEndian};
use super::{Section, Struct, Result, Error, ReadExt, Stream};
use super::{Vec3, Uv, Sphere, Rgba};
use super::{Material, MaterialList, Extension};
use std::rc::Rc;
/// Holds a list of `Geometry`s to be passed around.
#[derive(Debug)]
pub struct GeometryList(pub Vec<Rc<Geom... |
}
impl Mesh {
/// Reads a single Mesh (from a Bin Mesh PLG) off the RenderWare Stream.
pub fn read<R: ReadExt>(rws: &mut Stream<R>, matlist: &MaterialList) -> Result<Mesh> {
let nidx = try!(rws.read_u32::<LittleEndian>()) as usize;
let matid = try!(rws.read_u32::<LittleEndian>()) as usize;
... | {
let _header = try!(Self::read_header(rws));
let flags = try!(rws.read_u32::<LittleEndian>());
let num_mesh = try!(rws.read_u32::<LittleEndian>());
let total_idx = try!(rws.read_u32::<LittleEndian>());
Ok(MeshHeader {
is_tri_strip: (flags & 1) != 0, // TODO better ... | identifier_body |
geometry.rs | use byteorder::{ReadBytesExt, LittleEndian};
use super::{Section, Struct, Result, Error, ReadExt, Stream};
use super::{Vec3, Uv, Sphere, Rgba};
use super::{Material, MaterialList, Extension};
use std::rc::Rc;
/// Holds a list of `Geometry`s to be passed around.
#[derive(Debug)]
pub struct GeometryList(pub Vec<Rc<Geom... |
},
normals: {
// This geometry has vertex normals?
if (flags & 16)!= 0 {
let mut normz = Vec::with_capacity(num_verts as usize);
for _ in (0..num_verts... | {
None
} | conditional_block |
geometry.rs | use byteorder::{ReadBytesExt, LittleEndian};
use super::{Section, Struct, Result, Error, ReadExt, Stream};
use super::{Vec3, Uv, Sphere, Rgba};
use super::{Material, MaterialList, Extension};
use std::rc::Rc;
/// Holds a list of `Geometry`s to be passed around.
#[derive(Debug)]
pub struct GeometryList(pub Vec<Rc<Geom... | {
/// Render as triangle strips.
pub is_tri_strip: bool,
/// Total triangle index count in all meshes.
pub total_indices: u32,
/// List of meshes.
pub meshes: Vec<Mesh>,
}
/// Represents a triangle in a geometry.
///
/// This is specified by three indices into the geometry's vertex list togeth... | MeshHeader | identifier_name |
geometry.rs | use byteorder::{ReadBytesExt, LittleEndian};
use super::{Section, Struct, Result, Error, ReadExt, Stream};
use super::{Vec3, Uv, Sphere, Rgba};
use super::{Material, MaterialList, Extension};
use std::rc::Rc;
/// Holds a list of `Geometry`s to be passed around.
#[derive(Debug)]
pub struct GeometryList(pub Vec<Rc<Geom... | verts.push(try!(Vec3::read(rws)));
}
Some(verts)
} else {
None
}
},
normals: {
... | random_line_split | |
lossy_float_literal.rs | // run-rustfix
#![warn(clippy::lossy_float_literal)]
fn | () {
// Lossy whole-number float literals
let _: f32 = 16_777_217.0;
let _: f32 = 16_777_219.0;
let _: f32 = 16_777_219.;
let _: f32 = 16_777_219.000;
let _ = 16_777_219f32;
let _: f32 = -16_777_219.0;
let _: f64 = 9_007_199_254_740_993.0;
let _: f64 = 9_007_199_254_740_993.;
let... | main | identifier_name |
lossy_float_literal.rs | // run-rustfix
#![warn(clippy::lossy_float_literal)]
fn main() {
// Lossy whole-number float literals
let _: f32 = 16_777_217.0;
let _: f32 = 16_777_219.0;
let _: f32 = 16_777_219.;
let _: f32 = 16_777_219.000;
let _ = 16_777_219f32;
let _: f32 = -16_777_219.0;
let _: f64 = 9_007_199_25... | let _: f64 = 1E99;
let _: f32 = 0.1;
} | // Ignored whole number float literals
let _: f32 = 1e25;
let _: f32 = 1E25;
let _: f64 = 1e99; | random_line_split |
lossy_float_literal.rs | // run-rustfix
#![warn(clippy::lossy_float_literal)]
fn main() | let _: f64 = 16_777_217.0;
let _: f64 = -16_777_217.0;
let _: f64 = 9_007_199_254_740_992.0;
let _: f64 = -9_007_199_254_740_992.0;
// Ignored whole number float literals
let _: f32 = 1e25;
let _: f32 = 1E25;
let _: f64 = 1e99;
let _: f64 = 1E99;
let _: f32 = 0.1;
}
| {
// Lossy whole-number float literals
let _: f32 = 16_777_217.0;
let _: f32 = 16_777_219.0;
let _: f32 = 16_777_219.;
let _: f32 = 16_777_219.000;
let _ = 16_777_219f32;
let _: f32 = -16_777_219.0;
let _: f64 = 9_007_199_254_740_993.0;
let _: f64 = 9_007_199_254_740_993.;
let _:... | identifier_body |
syscall_tests.rs | // TODO: Write a bunch more syscall-y tests to test that each syscall for each file/directory type
// acts as we expect.
use super::mount;
use super::tests::digest_to_filepath;
use crate::tests::make_dirs;
use libc;
use std::ffi::CString;
use std::path::Path;
use store::Store;
use testutil::data::TestData;
#[test]
fn... | {
let mut buf: Vec<u8> = Vec::new();
buf.resize(size, 0);
buf
} | identifier_body | |
syscall_tests.rs | // TODO: Write a bunch more syscall-y tests to test that each syscall for each file/directory type
// acts as we expect.
use super::mount;
use super::tests::digest_to_filepath;
use crate::tests::make_dirs;
use libc;
use std::ffi::CString;
use std::path::Path;
use store::Store;
use testutil::data::TestData;
#[test]
fn... | () {
let (store_dir, mount_dir) = make_dirs();
let runtime = task_executor::Executor::new();
let store =
Store::local_only(runtime.clone(), store_dir.path()).expect("Error creating local store");
let test_bytes = TestData::roland();
runtime
.block_on(store.store_file_bytes(test_bytes.bytes(), false)... | read_file_by_digest_exact_bytes | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.