file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
init.rs | use std::sync::{atomic, mpsc};
use std::{io, process, thread};
use ctrlc;
use crate::control::acio;
use crate::{args, control, disk, log, rpc, throttle, tracker};
use crate::{CONFIG, SHUTDOWN, THROT_TOKS};
pub fn init(args: args::Args) -> Result<(), ()> {
if let Some(level) = args.level {
log::log_init(l... |
if let Err(e) = init_signals() {
error!("Failed to initialize signal handlers: {}", e);
return Err(());
}
Ok(())
}
pub fn run() -> Result<(), ()> {
match init_threads() {
Ok(threads) => {
for thread in threads {
if thread.join().is_err() {
... | info!("Initializing");
// Since the config is lazy loaded, dereference now to check it.
CONFIG.port; | random_line_split |
init.rs | use std::sync::{atomic, mpsc};
use std::{io, process, thread};
use ctrlc;
use crate::control::acio;
use crate::{args, control, disk, log, rpc, throttle, tracker};
use crate::{CONFIG, SHUTDOWN, THROT_TOKS};
pub fn | (args: args::Args) -> Result<(), ()> {
if let Some(level) = args.level {
log::log_init(level);
} else if cfg!(debug_assertions) {
log::log_init(log::LogLevel::Debug);
} else {
log::log_init(log::LogLevel::Info);
}
info!("Initializing");
// Since the config is lazy loade... | init | identifier_name |
text.rs | extern crate graphics;
use piston_window::{Transformed};
use widget::{Widget, State};
use appearance;
use layout;
use renderer::{self, geometry};
use graphics::character::CharacterCache;
#[derive(Default, Clone, Debug)]
pub struct Text{
pub text: &'static str,
}
impl Widget for Text{
fn layout(&self, cartogra... |
// TODO - Font's don't render very nicely, seems partly related to sub-pixel positioning
graphics::text(color,
size as u32,
self.text,
renderer.glyphs,
renderer.context.transform.trans(geometry.position.x, geometry.position.y + (size - (size / 4.11315283... | {
size = font.size;
color = font.color;
} | conditional_block |
text.rs | extern crate graphics;
use piston_window::{Transformed};
use widget::{Widget, State};
use appearance;
use layout;
use renderer::{self, geometry};
use graphics::character::CharacterCache;
#[derive(Default, Clone, Debug)]
pub struct Text{
pub text: &'static str,
}
impl Widget for Text{
fn layout(&self, cartogra... | <'a>(&self, renderer: &mut renderer::Renderer, appearance: &appearance::Appearance, geometry: &geometry::Geometry, _state: &'a State) {
// Determine font y-position related to size...
// Unsure if magic numbers, specific to a font, or related to font system in rust.
// 400:(-94..<97.249>..-100.4... | render | identifier_name |
text.rs | extern crate graphics;
use piston_window::{Transformed};
use widget::{Widget, State};
use appearance;
use layout;
use renderer::{self, geometry};
use graphics::character::CharacterCache;
#[derive(Default, Clone, Debug)]
pub struct Text{
pub text: &'static str, | impl Widget for Text{
fn layout(&self, cartographer: &mut layout::Cartographer, appearance: &appearance::Appearance) -> geometry::Xy {
let mut size = 20.0;
if let Some(ref font) = appearance.font {
size = font.size;
}
geometry::Xy{
x: cartographer.glyphs.wid... | }
| random_line_split |
text.rs | extern crate graphics;
use piston_window::{Transformed};
use widget::{Widget, State};
use appearance;
use layout;
use renderer::{self, geometry};
use graphics::character::CharacterCache;
#[derive(Default, Clone, Debug)]
pub struct Text{
pub text: &'static str,
}
impl Widget for Text{
fn layout(&self, cartogra... |
fn render<'a>(&self, renderer: &mut renderer::Renderer, appearance: &appearance::Appearance, geometry: &geometry::Geometry, _state: &'a State) {
// Determine font y-position related to size...
// Unsure if magic numbers, specific to a font, or related to font system in rust.
// 400:(-94..<... | {
let mut size = 20.0;
if let Some(ref font) = appearance.font {
size = font.size;
}
geometry::Xy{
x: cartographer.glyphs.width(size as u32, self.text),
y: size
}
} | identifier_body |
issue-13853.rs | trait Node {
fn zomg();
}
trait Graph<N: Node> {
fn nodes<'a, I: Iterator<Item=&'a N>>(&'a self) -> I
where N: 'a;
}
impl<N: Node> Graph<N> for Vec<N> {
fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
where N: 'a
{
self.iter() //~ ERROR mismatched types
}
}
struct Stuff;... | <N: Node, G: Graph<N>>(graph: &G) {
for node in graph.iter() { //~ ERROR no method named `iter` found
node.zomg();
}
}
pub fn main() {
let graph = Vec::new();
graph.push(Stuff);
iterate(graph); //~ ERROR mismatched types
}
| iterate | identifier_name |
issue-13853.rs | trait Node {
fn zomg();
}
trait Graph<N: Node> {
fn nodes<'a, I: Iterator<Item=&'a N>>(&'a self) -> I
where N: 'a; |
impl<N: Node> Graph<N> for Vec<N> {
fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
where N: 'a
{
self.iter() //~ ERROR mismatched types
}
}
struct Stuff;
impl Node for Stuff {
fn zomg() {
println!("zomg");
}
}
fn iterate<N: Node, G: Graph<N>>(graph: &G) {
for node ... | } | random_line_split |
issue-13853.rs | trait Node {
fn zomg();
}
trait Graph<N: Node> {
fn nodes<'a, I: Iterator<Item=&'a N>>(&'a self) -> I
where N: 'a;
}
impl<N: Node> Graph<N> for Vec<N> {
fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
where N: 'a
{
self.iter() //~ ERROR mismatched types
}
}
struct Stuff;... |
}
fn iterate<N: Node, G: Graph<N>>(graph: &G) {
for node in graph.iter() { //~ ERROR no method named `iter` found
node.zomg();
}
}
pub fn main() {
let graph = Vec::new();
graph.push(Stuff);
iterate(graph); //~ ERROR mismatched types
}
| {
println!("zomg");
} | identifier_body |
pat.rs | extern crate std;
#[derive(Debug)]
pub struct ProgramAssociationTable {
pub table_id: u8,
pub transport_stream_id: u16,
pub version_number: u8,
pub current_next_indicator: bool,
pub section_number: u8,
pub last_section_number: u8,
pub program_map: std::collections::HashMap<u16, u16>,
pu... | table_id: table_id,
transport_stream_id: transport_stream_id,
version_number: version_number,
current_next_indicator: current_next_indicator,
section_number: section_number,
last_section_number: last_section_number,
program_map: program... | (payload[index + 2] as u32) << 8 |
payload[index + 3] as u32;
Ok(ProgramAssociationTable { | random_line_split |
pat.rs | extern crate std;
#[derive(Debug)]
pub struct ProgramAssociationTable {
pub table_id: u8,
pub transport_stream_id: u16,
pub version_number: u8,
pub current_next_indicator: bool,
pub section_number: u8,
pub last_section_number: u8,
pub program_map: std::collections::HashMap<u16, u16>,
pu... | }
let section_length = ((payload[1] & 0b00001111) as usize) << 8 | payload[2] as usize;
let transport_stream_id = ((payload[3] as u16) << 8) | payload[4] as u16;
let version_number = (payload[5] & 0b00111110) >> 1;
let current_next_indicator = (payload[5] & 0b00000001)!= 0;
... | {
// ISO/IEC 13818-1 2.4.4.1 Table 2-29
// ISO/IEC 13818-1 2.4.4.2
let pointer_field = payload[0] as usize;
let payload = &payload[(1 + pointer_field)..];
// ISO/IEC 13818-1 2.4.4.3 Table 2-30
// ISO/IEC 13818-1 2.4.4.4
let table_id = payload[0];
if table... | identifier_body |
pat.rs | extern crate std;
#[derive(Debug)]
pub struct | {
pub table_id: u8,
pub transport_stream_id: u16,
pub version_number: u8,
pub current_next_indicator: bool,
pub section_number: u8,
pub last_section_number: u8,
pub program_map: std::collections::HashMap<u16, u16>,
pub crc32: u32,
}
impl ProgramAssociationTable {
pub fn parse(paylo... | ProgramAssociationTable | identifier_name |
pat.rs | extern crate std;
#[derive(Debug)]
pub struct ProgramAssociationTable {
pub table_id: u8,
pub transport_stream_id: u16,
pub version_number: u8,
pub current_next_indicator: bool,
pub section_number: u8,
pub last_section_number: u8,
pub program_map: std::collections::HashMap<u16, u16>,
pu... | else {
program_map.insert(pid, program_number);
}
}
let index = 8 + n * 4;
let crc32 = (payload[index] as u32) << 24 | (payload[index + 1] as u32) << 16 |
(payload[index + 2] as u32) << 8 |
payload[index + 3] as u32;
O... | {
// Network_PID
} | conditional_block |
lib.rs | #![feature(custom_derive, plugin)]
#![plugin(serde_macros)]
#![cfg_attr(test, plugin(stainless))]
extern crate chrono;
extern crate metrics_controller;
extern crate serde_json;
extern crate timer;
extern crate uuid;
extern crate time;
extern crate hyper;
#[allow(unused_imports)]
use std::env;
#[allow(unused_imports)]... | () -> String {
let mut cid = String::new();
let mut cfg = Config::new();
if cfg.init("cid.dat") {
let val: Option<Value> = cfg.get(KEY_CID);
match val {
Some(_) => cid.push_str(&cfg.get_string(KEY_CID).to_string()),
None => panic!("Error: no cid written")
}
... | read_client_id | identifier_name |
lib.rs | #![feature(custom_derive, plugin)]
#![plugin(serde_macros)]
#![cfg_attr(test, plugin(stainless))]
extern crate chrono;
extern crate metrics_controller;
extern crate serde_json;
extern crate timer;
extern crate uuid;
extern crate time;
extern crate hyper;
#[allow(unused_imports)]
use std::env;
#[allow(unused_imports)]... |
// Read the environment variable for the Google Access Token... Obtain
// this from Query Explorer. It is good for an hour.
let access_token:String;
let key = "GOOGLE_ACCESS_TOKEN";
match env::var_os(key) {
Some(val) => {
access_token = val.to_str().unwrap().to_string();
... | {
let event_category = "test";
let event_action = "integration";
let event_label = &Uuid::new_v4().to_simple_string().to_string();
let event_value = 5;
let ei = get_event_info();
create_config("metricsconfig.json");
let mut metrics_controller = MetricsController::new... | identifier_body |
lib.rs | #![feature(custom_derive, plugin)]
#![plugin(serde_macros)]
#![cfg_attr(test, plugin(stainless))]
extern crate chrono;
extern crate metrics_controller;
extern crate serde_json;
extern crate timer;
extern crate uuid;
extern crate time;
extern crate hyper;
#[allow(unused_imports)]
use std::env;
#[allow(unused_imports)]... | pub app_name: &'a str,
pub app_version: &'a str,
pub app_update_channel: &'a str,
pub app_build_id: &'a str,
pub app_platform: &'a str,
pub locale: &'a str,
pub device: &'a str,
pub arch: &'a str,
pub os: &'a str,
pub os_version: &'a str
}
#[cfg(feature = "integration")]
fn get_... |
#[cfg(feature = "integration")]
struct MockEventInfo<'a> { | random_line_split |
hex.rs | #![allow(deprecated)]
use std::hash::{Hasher, Hash, SipHasher};
use rustc_serialize::hex::ToHex;
pub fn to_hex(num: u64) -> String { | (num >> 32) as u8,
(num >> 40) as u8,
(num >> 48) as u8,
(num >> 56) as u8,
].to_hex()
}
pub fn hash_u64<H: Hash>(hashable: &H) -> u64 {
let mut hasher = SipHasher::new_with_keys(0, 0);
hashable.hash(&mut hasher);
hasher.finish()
}
pub fn short_hash<H: Hash>(hashable: &... | [
(num >> 0) as u8,
(num >> 8) as u8,
(num >> 16) as u8,
(num >> 24) as u8, | random_line_split |
hex.rs | #![allow(deprecated)]
use std::hash::{Hasher, Hash, SipHasher};
use rustc_serialize::hex::ToHex;
pub fn to_hex(num: u64) -> String {
[
(num >> 0) as u8,
(num >> 8) as u8,
(num >> 16) as u8,
(num >> 24) as u8,
(num >> 32) as u8,
(num >> 40) as u8,
(num >> ... | <H: Hash>(hashable: &H) -> String {
to_hex(hash_u64(hashable))
}
| short_hash | identifier_name |
hex.rs | #![allow(deprecated)]
use std::hash::{Hasher, Hash, SipHasher};
use rustc_serialize::hex::ToHex;
pub fn to_hex(num: u64) -> String |
pub fn hash_u64<H: Hash>(hashable: &H) -> u64 {
let mut hasher = SipHasher::new_with_keys(0, 0);
hashable.hash(&mut hasher);
hasher.finish()
}
pub fn short_hash<H: Hash>(hashable: &H) -> String {
to_hex(hash_u64(hashable))
}
| {
[
(num >> 0) as u8,
(num >> 8) as u8,
(num >> 16) as u8,
(num >> 24) as u8,
(num >> 32) as u8,
(num >> 40) as u8,
(num >> 48) as u8,
(num >> 56) as u8,
].to_hex()
} | identifier_body |
stackvec.rs | use minimal_lexical::bigint;
#[cfg(feature = "alloc")]
pub use minimal_lexical::heapvec::HeapVec as VecType;
#[cfg(not(feature = "alloc"))]
pub use minimal_lexical::stackvec::StackVec as VecType;
pub fn vec_from_u32(x: &[u32]) -> VecType {
let mut vec = VecType::new();
#[cfg(not(all(target_pointer_width = "64"... | {
for xi in x.chunks(2) {
match xi.len() {
1 => vec.try_push(xi[0] as bigint::Limb).unwrap(),
2 => {
let xi0 = xi[0] as bigint::Limb;
let xi1 = xi[1] as bigint::Limb;
vec.try_push((xi1 << 32) | xi0).unwra... | random_line_split | |
stackvec.rs | use minimal_lexical::bigint;
#[cfg(feature = "alloc")]
pub use minimal_lexical::heapvec::HeapVec as VecType;
#[cfg(not(feature = "alloc"))]
pub use minimal_lexical::stackvec::StackVec as VecType;
pub fn vec_from_u32(x: &[u32]) -> VecType | }
}
}
vec
}
| {
let mut vec = VecType::new();
#[cfg(not(all(target_pointer_width = "64", not(target_arch = "sparc"))))]
{
for &xi in x {
vec.try_push(xi as bigint::Limb).unwrap();
}
}
#[cfg(all(target_pointer_width = "64", not(target_arch = "sparc")))]
{
for xi in x.chunks... | identifier_body |
stackvec.rs | use minimal_lexical::bigint;
#[cfg(feature = "alloc")]
pub use minimal_lexical::heapvec::HeapVec as VecType;
#[cfg(not(feature = "alloc"))]
pub use minimal_lexical::stackvec::StackVec as VecType;
pub fn | (x: &[u32]) -> VecType {
let mut vec = VecType::new();
#[cfg(not(all(target_pointer_width = "64", not(target_arch = "sparc"))))]
{
for &xi in x {
vec.try_push(xi as bigint::Limb).unwrap();
}
}
#[cfg(all(target_pointer_width = "64", not(target_arch = "sparc")))]
{
... | vec_from_u32 | identifier_name |
build.rs | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | config,
&proto_files
.iter()
.map(|path| path.to_str().unwrap())
.collect::<Vec<_>>(),
&include_dirs
.iter()
.map(|p| p.to_str().unwrap())
.collect::<Vec<_>>(),
)?;
// This tells ca... | tonic_build::configure()
.build_server(true)
.compile_with_config( | random_line_split |
build.rs | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | "proto/quilkin/filters/pass/v1alpha1/pass.proto",
"proto/quilkin/filters/token_router/v1alpha1/token_router.proto",
"proto/udpa/xds/core/v3/resource_name.proto",
]
.iter()
.map(|name| std::env::current_dir().unwrap().join(name))
.collect::<Vec<_>>();
let include_dirs = vec![
... | {
let proto_files = vec![
"proto/data-plane-api/envoy/config/accesslog/v3/accesslog.proto",
"proto/data-plane-api/envoy/config/cluster/v3/cluster.proto",
"proto/data-plane-api/envoy/config/listener/v3/listener.proto",
"proto/data-plane-api/envoy/config/route/v3/route.proto",
... | identifier_body |
build.rs | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | () -> Result<(), Box<dyn std::error::Error>> {
let proto_files = vec![
"proto/data-plane-api/envoy/config/accesslog/v3/accesslog.proto",
"proto/data-plane-api/envoy/config/cluster/v3/cluster.proto",
"proto/data-plane-api/envoy/config/listener/v3/listener.proto",
"proto/data-plane-api... | main | identifier_name |
x86_64.rs | pub type c_long = i64;
pub type c_ulong = u64;
pub type time_t = i64;
pub type suseconds_t = i64;
s! {
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st... | pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_gen: ::uint32_t,
pub st_lspare: ::int32_t,
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
}
} | pub st_ctime_nsec: ::c_long,
pub st_size: ::off_t, | random_line_split |
unsized2.rs | // run-pass
#![allow(unconditional_recursion)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![feature(box_syntax)]
// Test sized-ness checking in substitution.
use std::marker;
// Unbounded.
fn f1<X:?Sized>(x: &X) {
f1::<X>(x);
}
fn f2<X>(x: &X) {
f1::<X>(x);
f2::<X>(x);
}... | trait T4<X> {
fn dummy(&self) { }
fn m1(&self, x: &dyn T4<X>, y: X);
fn m2(&self, x: &dyn T5<X>, y: X);
}
trait T5<X:?Sized> {
fn dummy(&self) { }
// not an error (for now)
fn m1(&self, x: &dyn T4<X>);
fn m2(&self, x: &dyn T5<X>);
}
trait T6<X: T> {
fn dummy(&self) { }
fn m1(&self, ... | let _: Box<X> = T3::f();
}
| random_line_split |
unsized2.rs | // run-pass
#![allow(unconditional_recursion)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![feature(box_syntax)]
// Test sized-ness checking in substitution.
use std::marker;
// Unbounded.
fn f1<X:?Sized>(x: &X) {
f1::<X>(x);
}
fn f2<X>(x: &X) {
f1::<X>(x);
f2::<X>(x);
}... | {
} | identifier_body | |
unsized2.rs | // run-pass
#![allow(unconditional_recursion)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![feature(box_syntax)]
// Test sized-ness checking in substitution.
use std::marker;
// Unbounded.
fn f1<X:?Sized>(x: &X) {
f1::<X>(x);
}
fn f2<X>(x: &X) {
f1::<X>(x);
f2::<X>(x);
}... | <X: T>(x: &X) {
f3::<X>(x);
f4::<X>(x);
}
// Self type.
trait T2 {
fn f() -> Box<Self>;
}
struct S;
impl T2 for S {
fn f() -> Box<S> {
box S
}
}
fn f5<X:?Sized+T2>(x: &X) {
let _: Box<X> = T2::f();
}
fn f6<X: T2>(x: &X) {
let _: Box<X> = T2::f();
}
trait T3 {
fn f() -> Box<Self... | f4 | identifier_name |
ord.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | layers of pointers, if the type includes pointers.
*/
let other_f = match other_fs {
[ref o_f] => o_f,
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialOrd)`")
};
let cmp = cx.expr_binary(span, op, self_f.clo... | {
let op = if less {ast::BiLt} else {ast::BiGt};
cs_fold(
false, // need foldr,
|cx, span, subexpr, self_f, other_fs| {
/*
build up a series of chain ||'s and &&'s from the inside
out (hence foldr) to get lexical ordering, i.e. for op ==
`ast::lt`
... | identifier_body |
ord.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn some_ordering_collapsed(cx: &mut ExtCtxt,
span: Span,
op: OrderingOp,
self_arg_tags: &[ast::Ident]) -> P<ast::Expr> {
let lft = cx.expr_ident(span, self_arg_tags[0]);
let rgt = cx.expr_addr_of(span, cx.expr_iden... | random_line_split | |
ord.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | else {
some_ordering_collapsed(cx, span, PartialCmpOp, tag_tuple)
}
},
cx, span, substr)
}
/// Strict inequality.
fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
span: Span, substr: &Substructure) -> P<Expr> {
let op = if less {ast::BiLt} else {ast::BiGt};
... | {
cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialOrd)`")
} | conditional_block |
ord.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
PartialCmpOp, LtOp, LeOp, GtOp, GeOp,
}
pub fn some_ordering_collapsed(cx: &mut ExtCtxt,
span: Span,
op: OrderingOp,
self_arg_tags: &[ast::Ident]) -> P<ast::Expr> {
let lft = cx.expr_ident(span, self_arg_tags[0]);
... | OrderingOp | identifier_name |
mod.rs | use std::fmt::Debug;
use provider::Output;
use provider::error::Error;
use provider::error::HandleFuncNotDefined;
pub trait InlineProvider: Debug {
fn is_installed(&self, &str, Option<&str>) -> Result<Output, Error> |
fn version(&self, &str, Option<&str>) -> Result<Output, Error> {
let e = HandleFuncNotDefined {
provider: format!("{:?}", self),
func: "version".to_string(),
};
Err(e.into())
}
fn remove(&self, &str, Option<&str>) -> Result<Output, Error> {
let e = ... | {
let e = HandleFuncNotDefined {
provider: format!("{:?}", self),
func: "is_installed".to_string(),
};
Err(e.into())
} | identifier_body |
mod.rs | use std::fmt::Debug;
use provider::Output;
use provider::error::Error;
use provider::error::HandleFuncNotDefined;
pub trait InlineProvider: Debug {
fn | (&self, &str, Option<&str>) -> Result<Output, Error> {
let e = HandleFuncNotDefined {
provider: format!("{:?}", self),
func: "is_installed".to_string(),
};
Err(e.into())
}
fn version(&self, &str, Option<&str>) -> Result<Output, Error> {
let e = HandleFunc... | is_installed | identifier_name |
mod.rs | use std::fmt::Debug;
use provider::Output; | fn is_installed(&self, &str, Option<&str>) -> Result<Output, Error> {
let e = HandleFuncNotDefined {
provider: format!("{:?}", self),
func: "is_installed".to_string(),
};
Err(e.into())
}
fn version(&self, &str, Option<&str>) -> Result<Output, Error> {
... | use provider::error::Error;
use provider::error::HandleFuncNotDefined;
pub trait InlineProvider: Debug { | random_line_split |
objects.rs | // Copyright 2019 Dmitry Tantsur <divius.inside@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... |
}
#[cfg(feature = "object-storage")]
impl IntoVerified for ObjectRef {}
| {
ObjectRef::new_verified(value.inner.name)
} | identifier_body |
objects.rs | // Copyright 2019 Dmitry Tantsur <divius.inside@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... | self.session
.get_endpoint(OBJECT_STORAGE, &[self.container_name(), self.name()])
}
}
impl Refresh for Object {
/// Refresh the object.
fn refresh(&mut self) -> Result<()> {
self.inner = api::get_object(&self.session, &self.c_name, &self.inner.name)?;
Ok(())
}
}
impl... | random_line_split | |
objects.rs | // Copyright 2019 Dmitry Tantsur <divius.inside@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... | (mut self, limit: usize) -> Self {
self.can_paginate = false;
self.query.push("limit", limit);
self
}
/// Convert this query into an iterator executing the request.
///
/// Returns a `FallibleIterator`, which is an iterator with each `next`
/// call returning a `Result`.
... | with_limit | identifier_name |
objects.rs | // Copyright 2019 Dmitry Tantsur <divius.inside@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... |
self.into_iter().one()
}
}
impl ResourceQuery for ObjectQuery {
type Item = Object;
const DEFAULT_LIMIT: usize = 100;
fn can_paginate(&self) -> Result<bool> {
Ok(self.can_paginate)
}
fn extract_marker(&self, resource: &Self::Item) -> String {
resource.name().clone()... | {
// We need only one result. We fetch maximum two to be able
// to check if the query yieled more than one result.
self.query.push("limit", 2);
} | conditional_block |
type_alias.rs | /*type 语句可以给一个已存在类型起一个新的名字。
类型必须要有 CamelCase(驼峰方式)的名称,否则 编译器会产生一个警告。
对规则为例外的是基本类型: usize,f32等等。*/
// `NanoSecond` 是 `u64` 的新名字。
type NanoSecond = u64;
type Inch = u64;
// 使用一个属性来忽略警告。
//#[allow(non_camel_case_types)]
type u64_t = u64;
// 试一试 ^ 试着删掉属性
fn main() {
// `NanoSecond` = `Inch` = `u64_t` = `u64`.
le... | tln!(
"{} nanoseconds + {} inches = {} unit?",
nanoseconds,
inches,
nanoseconds + inches
);
}
| prin | identifier_name |
type_alias.rs | /*type 语句可以给一个已存在类型起一个新的名字。
类型必须要有 CamelCase(驼峰方式)的名称,否则 编译器会产生一个警告。
对规则为例外的是基本类型: usize,f32等等。*/
// `NanoSecond` 是 `u64` 的新名字。
type NanoSecond = u64;
type Inch = u64;
// 使用一个属性来忽略警告。
//#[allow(non_camel_case_types)]
type u64_t = u64;
// 试一试 ^ 试着删掉属性
fn main() {
// `NanoSecond` = `Inch` = `u64_t` = `u64`.
le... |
// 注意类型的别名*没有*提供任何额外的类型安全,因为别名*不是*新的类型
println!(
"{} nanoseconds + {} inches = {} unit?",
nanoseconds,
inches,
nanoseconds + inches
);
} | let inches: Inch = 2 as u64_t; | random_line_split |
type_alias.rs | /*type 语句可以给一个已存在类型起一个新的名字。
类型必须要有 CamelCase(驼峰方式)的名称,否则 编译器会产生一个警告。
对规则为例外的是基本类型: usize,f32等等。*/
// `NanoSecond` 是 `u64` 的新名字。
type NanoSecond = u64;
type Inch = u64;
// 使用一个属性来忽略警告。
//#[allow(non_camel_case_types)]
type u64_t = u64;
// 试一试 ^ 试着删掉属性
fn main() {
// `NanoSecond` = `Inch` = `u64_t` = `u64`.
le... | !(
"{} nanoseconds + {} inches = {} unit?",
nanoseconds,
inches,
nanoseconds + inches
);
}
| identifier_body | |
mod.rs | #![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
#![allow(unused_variables, dead_code)]
use libc;
use api::osmesa::{OsMesaContext};
use Api;
use ContextError;
use CreationError;
use Event;
use GlAttributes;
use GlContext;
use PixelFormat;
use PixelFormatRequirem... |
#[inline]
fn get_pixel_format(&self) -> PixelFormat {
self.opengl.get_pixel_format()
}
}
impl Drop for Window {
#[inline]
fn drop(&mut self) {
unsafe {
(self.libcaca.caca_free_dither)(self.dither);
(self.libcaca.caca_free_display)(self.display);
}
... | random_line_split | |
mod.rs | #![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
#![allow(unused_variables, dead_code)]
use libc;
use api::osmesa::{OsMesaContext};
use Api;
use ContextError;
use CreationError;
use Event;
use GlAttributes;
use GlContext;
use PixelFormat;
use PixelFormatRequirem... |
#[inline]
pub fn show(&self) {
}
#[inline]
pub fn hide(&self) {
}
#[inline]
pub fn get_position(&self) -> Option<(i32, i32)> {
unimplemented!()
}
#[inline]
pub fn set_position(&self, x: i32, y: i32) {
}
#[inline]
pub fn get_inner_size(&self) -> Optio... | {
} | identifier_body |
mod.rs | #![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
#![allow(unused_variables, dead_code)]
use libc;
use api::osmesa::{OsMesaContext};
use Api;
use ContextError;
use CreationError;
use Event;
use GlAttributes;
use GlContext;
use PixelFormat;
use PixelFormatRequirem... | ;
impl WindowProxy {
#[inline]
pub fn wakeup_event_loop(&self) {
unimplemented!()
}
}
pub struct MonitorId;
#[inline]
pub fn get_available_monitors() -> VecDeque<MonitorId> {
VecDeque::new()
}
#[inline]
pub fn get_primary_monitor() -> MonitorId {
MonitorId
}
impl MonitorId {
#[inline... | WindowProxy | identifier_name |
htmltablerowelement.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::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
use do... | (&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)))
}
}
impl HTMLTableRowElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document)
... | is_htmltablerowelement | identifier_name |
htmltablerowelement.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::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
use do... | ,
}
}
}
| {} | conditional_block |
htmltablerowelement.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::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
use do... |
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
&atom!(bgcolor) => {
self.background_color.set(mutation.new_value(attr).and_then(|value| {
... | {
let htmlelement: &HTMLElement = HTMLElementCast::from_ref(self);
Some(htmlelement as &VirtualMethods)
} | identifier_body |
htmltablerowelement.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::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
use do... | *self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)))
}
}
impl HTMLTableRowElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document)
-> ... | }
impl HTMLTableRowElementDerived for EventTarget {
fn is_htmltablerowelement(&self) -> bool { | random_line_split |
lib.rs | extern crate audsp;
extern crate aunorm;
use aunorm::{Normalizer, NormalizerProvider};
use std::collections::HashMap;
pub trait DspProcessor<'a, TSample: audsp::Numeric> {
fn get_properties(& self) -> & PropStorage<'a, TSample, Self>;
fn get_mut_properties(&mut self) -> &mut PropStorage<'a, TSample, Self>;
... | <'a, TSample: audsp::Numeric, TProcessor: DspProcessor<'a, TSample>> where TSample: 'a {
id: u32,
min: TSample,
max: TSample,
default: TSample,
value: TSample,
norm_value: TSample,
caption: &'a str,
measure: &'a str,
norm: Box<Normalizer<TSample> + 'a>,
callback : Box<Fn(&mut TPr... | PropInfo | identifier_name |
lib.rs | extern crate audsp;
extern crate aunorm;
use aunorm::{Normalizer, NormalizerProvider};
use std::collections::HashMap;
pub trait DspProcessor<'a, TSample: audsp::Numeric> {
fn get_properties(& self) -> & PropStorage<'a, TSample, Self>;
fn get_mut_properties(&mut self) -> &mut PropStorage<'a, TSample, Self>;
... | properties: HashMap<u32, PropInfo<'a, TSample, TProcessor>>
}
impl<'a, TSample: audsp::Numeric, TProcessor: DspProcessor<'a, TSample>> PropInfo<'a, TSample, TProcessor> where TSample: 'a {
pub fn set_from_norm(&mut self, norm: TSample, processor: &mut TProcessor) {
self.norm_value = norm;
self.... |
#[derive(Default)]
pub struct PropStorage<'a, TSample: audsp::Numeric, TProcessor: DspProcessor<'a, TSample>> where TSample: 'a { | random_line_split |
unique-vec-res.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 i1 = &Cell::new(0);
let i2 = &Cell::new(1);
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let r1 = vec!(Box::new(r { i: i1 }));
let r2 = vec!(Box::new(r { i: i2 }));
f(clone(&r1), clone(&r2));
//~^ ERROR the trait `core::clone::Clone` is not implemented for... | main | identifier_name |
unique-vec-res.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {
let i1 = &Cell::new(0);
let i2 = &Cell::new(1);
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let r1 = vec!(Box::new(r { i: i1 }));
let r2 = vec!(Box::new(r { i: i2 }));
f(clone(&r1), clone(&r2));
//~^ ERROR the trait `core::clone::Clone` is not implem... | { t.clone() } | identifier_body |
unique-vec-res.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
fn clone<T: Clone>(t: &T) -> T { t.clone() }
fn main() {
let i1 = &Cell::new(0);
let i2 = &Cell::new(1);
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let r1 = vec!(Box::new(r { i: i1 }));
let r2 = vec!(Box::new(r { i: i2 }));
f(clone(&r1), clone(&r2));
//~^ ERR... |
fn f<T>(__isize: Vec<T> , _j: Vec<T> ) { | random_line_split |
http_body.rs | // Copyright 2020 Google LLC
//
// 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 ... | () {
proxy_wasm::set_log_level(LogLevel::Trace);
proxy_wasm::set_root_context(|_| -> Box<dyn RootContext> { Box::new(HttpBodyRoot) });
}
struct HttpBodyRoot;
impl Context for HttpBodyRoot {}
impl RootContext for HttpBodyRoot {
fn get_type(&self) -> Option<ContextType> {
Some(ContextType::HttpCont... | _start | identifier_name |
http_body.rs | // Copyright 2020 Google LLC
//
// 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 ... | Action::Continue
}
} | random_line_split | |
http_body.rs | // Copyright 2020 Google LLC
//
// 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 ... |
Action::Continue
}
}
| {
let body_str = String::from_utf8(body_bytes).unwrap();
if body_str.contains("secret") {
let new_body = format!("Original message body ({} bytes) redacted.", body_size);
self.set_http_response_body(0, body_size, &new_body.into_bytes());
}
} | conditional_block |
graphviz.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn dataflow_for_variant(&self, e: EntryOrExit, n: &Node, v: Variant) -> String {
let cfgidx = n.0;
match v {
Loans => self.dataflow_loans_for(e, cfgidx),
Moves => self.dataflow_moves_for(e, cfgidx),
Assigns => self.dataflow_assigns_for(e, cfgidx),
}
... | {
let id = n.1.data.id();
debug!("dataflow_for({:?}, id={}) {:?}", e, id, self.variants);
let mut sets = "".to_string();
let mut seen_one = false;
for &variant in &self.variants {
if seen_one { sets.push_str(" "); } else { seen_one = true; }
sets.push_str(... | identifier_body |
graphviz.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, e: EntryOrExit, n: &Node<'a>) -> String {
let id = n.1.data.id();
debug!("dataflow_for({:?}, id={}) {:?}", e, id, self.variants);
let mut sets = "".to_string();
let mut seen_one = false;
for &variant in &self.variants {
if seen_one { sets.push_str(" "); } else... | dataflow_for | identifier_name |
graphviz.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | pub enum Variant {
Loans,
Moves,
Assigns,
}
impl Variant {
pub fn short_name(&self) -> &'static str {
match *self {
Loans => "loans",
Moves => "moves",
Assigns => "assigns",
}
}
}
pub struct DataflowLabeller<'a, 'tcx: 'a> {
pub inner: cfg... | random_line_split | |
ifmt.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 ... | use std::fmt;
use std::usize;
struct A;
struct B;
struct C;
impl fmt::LowerHex for A {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("aloha")
}
}
impl fmt::UpperHex for B {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("adios")
}
}
impl fmt::Di... | #![deny(warnings)]
#![allow(unused_must_use)]
#![allow(unknown_features)]
#![feature(box_syntax)]
| random_line_split |
ifmt.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 ... | t!(format!("{:?}", 10_usize), "10");
t!(format!("{:?}", "true"), "\"true\"");
t!(format!("{:?}", "foo\nbar"), "\"foo\\nbar\"");
t!(format!("{:o}", 10_usize), "12");
t!(format!("{:x}", 10_usize), "a");
t!(format!("{:X}", 10_usize), "A");
t!(format!("{}", "foo"), "foo");
t!(format!("{}", "... | // Various edge cases without formats
t!(format!(""), "");
t!(format!("hello"), "hello");
t!(format!("hello {{"), "hello {");
// default formatters should work
t!(format!("{}", 1.0f32), "1");
t!(format!("{}", 1.0f64), "1");
t!(format!("{}", "a"), "a");
t!(format!("{}", "a".to_string... | identifier_body |
ifmt.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 ... | format!("{:p}", 0x1234 as *const isize), "0x1234");
t!(format!("{:p}", 0x1234 as *mut isize), "0x1234");
t!(format!("{:x}", A), "aloha");
t!(format!("{:X}", B), "adios");
t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃");
t!(format!("{1} {0}", 0, 1), "1 0");
t!(format!("{foo} {bar}", foo=0, ... | t!(format!("{:#p}", 0x1234 as *const isize), "0x0000000000001234");
t!(format!("{:#p}", 0x1234 as *mut isize), "0x0000000000001234");
}
t!( | conditional_block |
ifmt.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, f: &mut fmt::Formatter) -> fmt::Result {
f.pad_integral(true, "☃", "123")
}
}
macro_rules! t {
($a:expr, $b:expr) => { assert_eq!($a, $b) }
}
pub fn main() {
// Various edge cases without formats
t!(format!(""), "");
t!(format!("hello"), "hello");
t!(format!("hello {{"), "hello... | fmt | identifier_name |
generate.rs | // Copyright (c) 2016 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... |
use common::ui::UI;
use hcore::crypto::SymKey;
use error::Result;
pub fn start(ui: &mut UI, ring: &str, cache: &Path) -> Result<()> {
ui.begin(format!("Generating ring key for {}", &ring))?;
let pair = SymKey::generate_pair_for_ring(ring)?;
pair.to_pair_files(cache)?;
ui.end(format!(
"Generat... | use std::path::Path; | random_line_split |
generate.rs | // Copyright (c) 2016 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... | {
ui.begin(format!("Generating ring key for {}", &ring))?;
let pair = SymKey::generate_pair_for_ring(ring)?;
pair.to_pair_files(cache)?;
ui.end(format!(
"Generated ring key pair {}.",
&pair.name_with_rev()
))?;
Ok(())
} | identifier_body | |
generate.rs | // Copyright (c) 2016 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... | (ui: &mut UI, ring: &str, cache: &Path) -> Result<()> {
ui.begin(format!("Generating ring key for {}", &ring))?;
let pair = SymKey::generate_pair_for_ring(ring)?;
pair.to_pair_files(cache)?;
ui.end(format!(
"Generated ring key pair {}.",
&pair.name_with_rev()
))?;
Ok(())
}
| start | identifier_name |
script_runtime.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/. */
//! The script runtime contains common traits and structs commonly used by the
//! script thread, the dom, and the... |
#[allow(unsafe_code)]
#[cfg(not(feature = "debugmozjs"))]
unsafe fn set_gc_zeal_options(_: *mut JSRuntime) {}
| {
use js::jsapi::{JS_DEFAULT_ZEAL_FREQ, JS_SetGCZeal};
let level = match PREFS.get("js.mem.gc.zeal.level").as_i64() {
Some(level @ 0...14) => level as u8,
_ => return,
};
let frequency = match PREFS.get("js.mem.gc.zeal.frequency").as_i64() {
Some(frequency) if frequency >= 0 => ... | identifier_body |
script_runtime.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/. */
//! The script runtime contains common traits and structs commonly used by the
//! script thread, the dom, and the... | fn deref(&self) -> &RustRuntime {
&self.0
}
}
#[allow(unsafe_code)]
pub unsafe fn new_rt_and_cx() -> Runtime {
LiveDOMReferences::initialize();
let runtime = RustRuntime::new().unwrap();
JS_AddExtraGCRootsTracer(runtime.rt(), Some(trace_rust_roots), ptr::null_mut());
// Needed for deb... | type Target = RustRuntime; | random_line_split |
script_runtime.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/. */
//! The script runtime contains common traits and structs commonly used by the
//! script thread, the dom, and the... | (_rt: *mut JSRuntime, status: JSGCStatus, _data: *mut os::raw::c_void) {
match status {
JSGCStatus::JSGC_BEGIN => thread_state::enter(thread_state::IN_GC),
JSGCStatus::JSGC_END => thread_state::exit(thread_state::IN_GC),
}
}
thread_local!(
static THREAD_ACTIVE: Cell<bool> = Cell::new(true... | debug_gc_callback | identifier_name |
script_runtime.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/. */
//! The script runtime contains common traits and structs commonly used by the
//! script thread, the dom, and the... | ;
let mode = if val {
JSGCMode::JSGC_MODE_INCREMENTAL
} else if compartment {
JSGCMode::JSGC_MODE_COMPARTMENT
} else {
JSGCMode::JSGC_MODE_GLOBAL
};
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MODE, mode as u32);
}
if let Some(va... | {
false
} | conditional_block |
cross-borrow-trait.rs | // Copyright 2012-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
// <LICEN... | let x: Box<Trait> = box Foo;
let _y: &Trait = x; //~ ERROR mismatched types: expected `&Trait`, found `Box<Trait>`
} |
pub fn main() { | random_line_split |
cross-borrow-trait.rs | // Copyright 2012-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
// <LICEN... | () {
let x: Box<Trait> = box Foo;
let _y: &Trait = x; //~ ERROR mismatched types: expected `&Trait`, found `Box<Trait>`
}
| main | identifier_name |
cross-borrow-trait.rs | // Copyright 2012-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
// <LICEN... | {
let x: Box<Trait> = box Foo;
let _y: &Trait = x; //~ ERROR mismatched types: expected `&Trait`, found `Box<Trait>`
} | identifier_body | |
main.rs | /// serde_eg
/// Example of serializing a rust struct into various formats
///
///
extern crate bincode;
extern crate serde;
extern crate serde_cbor;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
/// struct to describe some properties of a city
#[derive(Serialize, Deserialize)]
struct City {
nam... | () {
let calabar = City {
name: String::from("Calabar"),
population: 470_000,
latitude: 4.95,
longitude: 8.33,
};
let as_json = serde_json::to_string(&calabar).unwrap();
let as_cbor = serde_cbor::to_vec(&calabar).unwrap();
let as_bincode = bincode::serialize(&calabar... | main | identifier_name |
main.rs | /// serde_eg
/// Example of serializing a rust struct into various formats
///
///
extern crate bincode;
extern crate serde;
extern crate serde_cbor;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
/// struct to describe some properties of a city
#[derive(Serialize, Deserialize)]
struct City {
nam... | }
fn main() {
let calabar = City {
name: String::from("Calabar"),
population: 470_000,
latitude: 4.95,
longitude: 8.33,
};
let as_json = serde_json::to_string(&calabar).unwrap();
let as_cbor = serde_cbor::to_vec(&calabar).unwrap();
let as_bincode = bincode::serializ... | latitude: f64,
longitude: f64, | random_line_split |
actor.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/. */
/// General actor system infrastructure.
use std::any::{Any, AnyRefExt, AnyMutRefExt};
use std::collections::Hash... | (&self, prefix: &str) -> String {
let suffix = self.next.get();
self.next.set(suffix + 1);
format!("{:s}{:u}", prefix, suffix)
}
/// Add an actor to the registry of known actors that can receive messages.
pub fn register(&mut self, actor: Box<Actor+Send+Sized>) {
self.actors... | new_name | identifier_name |
actor.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/. */
/// General actor system infrastructure.
use std::any::{Any, AnyRefExt, AnyMutRefExt};
use std::collections::Hash... |
/// Create a unique name based on a monotonically increasing suffix
pub fn new_name(&self, prefix: &str) -> String {
let suffix = self.next.get();
self.next.set(suffix + 1);
format!("{:s}{:u}", prefix, suffix)
}
/// Add an actor to the registry of known actors that can receive ... | return key.to_string();
}
}
panic!("couldn't find actor named {:s}", actor)
} | random_line_split |
instr_vextracti128.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test] | }
#[test]
fn vextracti128_2() {
run_test(&Instruction { mnemonic: Mnemonic::VEXTRACTI128, operand1: Some(IndirectScaledIndexedDisplaced(EAX, EBX, Eight, 1167941305, Some(OperandSize::Xmmword), None)), operand2: Some(Direct(YMM0)), operand3: Some(Literal8(96)), operand4: None, lock: false, rounding_mode: None, merg... | fn vextracti128_1() {
run_test(&Instruction { mnemonic: Mnemonic::VEXTRACTI128, operand1: Some(Direct(XMM5)), operand2: Some(Direct(YMM4)), operand3: Some(Literal8(67)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 227, 125, 57, 229, 67], Oper... | random_line_split |
instr_vextracti128.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn vextracti128_1() {
run_test(&Instruction { mnemonic: Mnemonic::VEXTRACTI128, operand1: So... | () {
run_test(&Instruction { mnemonic: Mnemonic::VEXTRACTI128, operand1: Some(IndirectDisplaced(RDX, 545176606, Some(OperandSize::Xmmword), None)), operand2: Some(Direct(YMM0)), operand3: Some(Literal8(81)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None ... | vextracti128_4 | identifier_name |
instr_vextracti128.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn vextracti128_1() {
run_test(&Instruction { mnemonic: Mnemonic::VEXTRACTI128, operand1: So... | {
run_test(&Instruction { mnemonic: Mnemonic::VEXTRACTI128, operand1: Some(IndirectDisplaced(RDX, 545176606, Some(OperandSize::Xmmword), None)), operand2: Some(Direct(YMM0)), operand3: Some(Literal8(81)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, ... | identifier_body | |
tag.rs | // Copyright 2016 Jeremy Letang.
// 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 ... |
pub fn list_for_user_id(db: &mut PgConnection, list_user_id: &str) -> Result<Vec<Tag>, DieselError> {
use diesel::{LoadDsl, FilterDsl, ExpressionMethods};
use db::schemas::tags::dsl::{tags, user_id};
tags.filter(user_id.eq(list_user_id)).load::<Tag>(db)
}
pub fn delete(db: &mut PgConnection, delete_id: &... | {
use diesel::LoadDsl;
use db::schemas::tags::dsl::tags;
tags.load::<Tag>(db)
} | identifier_body |
tag.rs | // Copyright 2016 Jeremy Letang.
// 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 ... | (db: &mut PgConnection, get_id: &str) -> Result<Tag, DieselError> {
use diesel::{LoadDsl, FilterDsl, ExpressionMethods};
use db::schemas::tags::dsl::{tags, id};
tags.filter(id.eq(get_id)).first::<Tag>(db)
}
pub fn get_from_name_and_user_id(db: &mut PgConnection, get_name: &str, get_user_id: &str) -> Result... | get | identifier_name |
tag.rs | // Copyright 2016 Jeremy Letang.
// 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 ... |
pub fn get_all(db: &mut PgConnection, ids: &[String]) -> Result<Vec<Tag>, DieselError> {
use diesel::{LoadDsl, FilterDsl, ExpressionMethods};
use db::schemas::tags::dsl::{tags, id};
use diesel::pg::expression::dsl::any;
tags.filter(id.eq(any(ids)))
.load::<Tag>(db)
} | random_line_split | |
main.rs | use std::io;
use std::io::Write;
use std::f64::consts::PI; // We can use std::f32::consts::PI if using float
fn | () {
let mut side_1: String = String::new();
let mut side_2: String = String::new();
let mut angle: String = String::new();
print!("Enter first side length: ");
io::stdout().flush().unwrap();
io::stdin().read_line(&mut side_1)
.expect("Failed to read");
print!("Enter second side len... | main | identifier_name |
main.rs | use std::io;
use std::io::Write;
use std::f64::consts::PI; // We can use std::f32::consts::PI if using float
fn main() {
let mut side_1: String = String::new();
let mut side_2: String = String::new();
let mut angle: String = String::new();
print!("Enter first side length: ");
io::stdout().flush().... |
print!("Enter the angle: ");
io::stdout().flush().unwrap();
io::stdin().read_line(&mut angle)
.expect("Failed to read");
let side_1: f64 = side_1.trim().parse()
.expect("Parsing error");
let side_2: f64 = side_2.trim().parse()
.expect("Parsing error");
let angle: f64 = ang... | io::stdout().flush().unwrap();
io::stdin().read_line(&mut side_2)
.expect("Failed to read"); | random_line_split |
main.rs | use std::io;
use std::io::Write;
use std::f64::consts::PI; // We can use std::f32::consts::PI if using float
fn main() | let side_1: f64 = side_1.trim().parse()
.expect("Parsing error");
let side_2: f64 = side_2.trim().parse()
.expect("Parsing error");
let angle: f64 = angle.trim().parse()
.expect("Parsing error");
// I have to calculate and write the type the pi angle first before "sin" it
let pi... | {
let mut side_1: String = String::new();
let mut side_2: String = String::new();
let mut angle: String = String::new();
print!("Enter first side length: ");
io::stdout().flush().unwrap();
io::stdin().read_line(&mut side_1)
.expect("Failed to read");
print!("Enter second side lengt... | identifier_body |
log.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | pub block_hash: H256,
#[serde(rename="blockNumber")]
pub block_number: U256,
#[serde(rename="transactionHash")]
pub transaction_hash: H256,
#[serde(rename="transactionIndex")]
pub transaction_index: U256,
#[serde(rename="logIndex")]
pub log_index: U256,
}
impl From<LocalizedLogEntry> for Log {
fn from(e: Loc... | pub struct Log {
pub address: Address,
pub topics: Vec<H256>,
pub data: Bytes,
#[serde(rename="blockHash")] | random_line_split |
log.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | (e: LocalizedLogEntry) -> Log {
Log {
address: e.entry.address,
topics: e.entry.topics,
data: Bytes::new(e.entry.data),
block_hash: e.block_hash,
block_number: From::from(e.block_number),
transaction_hash: e.transaction_hash,
transaction_index: From::from(e.transaction_index),
log_index: From:... | from | identifier_name |
element_test.rs | use rquery::Document;
fn new_document() -> Document {
Document::new_from_xml_string(r#"
<?xml version="1.0" encoding="UTF-8"?>
<main type="simple">
This is some text
</main>
"#).unwrap()
}
#[test]
fn it_knows_its_tag_name() {
let document = new_document();
let element = document.select("main").unwrap(... |
let element = document.select("main").unwrap();
assert_eq!(element.text().trim(), "This is some text");
}
#[test]
fn it_knows_its_node_indices() {
let document = new_document();
let element = document.select("main").unwrap();
assert_eq!(element.node_index(), 1);
} | let document = new_document(); | random_line_split |
element_test.rs | use rquery::Document;
fn new_document() -> Document {
Document::new_from_xml_string(r#"
<?xml version="1.0" encoding="UTF-8"?>
<main type="simple">
This is some text
</main>
"#).unwrap()
}
#[test]
fn it_knows_its_tag_name() {
let document = new_document();
let element = document.select("main").unwrap(... | () {
let document = new_document();
let element = document.select("main").unwrap();
assert_eq!(element.node_index(), 1);
} | it_knows_its_node_indices | identifier_name |
element_test.rs | use rquery::Document;
fn new_document() -> Document {
Document::new_from_xml_string(r#"
<?xml version="1.0" encoding="UTF-8"?>
<main type="simple">
This is some text
</main>
"#).unwrap()
}
#[test]
fn it_knows_its_tag_name() {
let document = new_document();
let element = document.select("main").unwrap(... |
#[test]
fn it_knows_its_inner_text_contents() {
let document = new_document();
let element = document.select("main").unwrap();
assert_eq!(element.text().trim(), "This is some text");
}
#[test]
fn it_knows_its_node_indices() {
let document = new_document();
let element = document.select("ma... | {
let document = new_document();
let element = document.select("main").unwrap();
assert_eq!(element.attr("type").unwrap(), "simple");
} | identifier_body |
catrank.rs | // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... |
}
| {
let mut good_count : i32 = 0;
let results = response.get_results()?;
for result in results.iter() {
if result.get_score() > 1001.0 {
good_count += 1;
} else {
break;
}
}
if good_count == expected_good_count {
... | identifier_body |
catrank.rs | // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... |
let suffix = rng.next_less_than(20) as usize;
for _ in 0..suffix {
snippet.push_str(WORDS[rng.next_less_than(WORDS.len() as u32) as usize]);
}
result.set_snippet(&snippet);
}
good_count
}
fn handle_request(&self, request: searc... | { snippet.push_str("dog ") } | conditional_block |
catrank.rs | // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... | (&self, request: search_result_list::Reader,
response: search_result_list::Builder) -> ::capnp::Result<()>
{
let mut scored_results: Vec<ScoredResult> = Vec::new();
let results = request.get_results()?;
for i in 0..results.len() {
let result = results.get(i... | handle_request | identifier_name |
catrank.rs | // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
use common::*;
use catrank_capnp::*;
#[derive(Clone, Copy)]
pub struct ScoredResult<'a> {
score: f64,
result: search_result::Reader<'a>
}
const URL_PREFIX: &'static str = "http://example.com";
pub struct CatRank;
... | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | random_line_split |
lib.rs | extern crate warc_parser;
extern crate nom;
mod tests {
use std::fs::File;
use std::io::prelude::*;
use nom::{Err, IResult, Needed};
fn | (sample_name: &str) -> Vec<u8> {
let full_path = "sample/".to_string() + sample_name;
let mut f = File::open(full_path).unwrap();
let mut s = Vec::new();
f.read_to_end(&mut s).unwrap();
s
}
use warc_parser;
#[test]
fn it_parses_a_plethora() {
let example... | read_sample_file | identifier_name |
lib.rs | extern crate warc_parser;
extern crate nom;
mod tests {
use std::fs::File;
use std::io::prelude::*;
use nom::{Err, IResult, Needed};
fn read_sample_file(sample_name: &str) -> Vec<u8> {
let full_path = "sample/".to_string() + sample_name;
let mut f = File::open(full_path).unwrap();
... | use warc_parser;
#[test]
fn it_parses_a_plethora() {
let examples = read_sample_file("plethora.warc");
let parsed = warc_parser::records(&examples);
assert!(parsed.is_ok());
match parsed {
Err(_) => assert!(false),
Ok((i, records)) => {
... | random_line_split | |
lib.rs | extern crate warc_parser;
extern crate nom;
mod tests {
use std::fs::File;
use std::io::prelude::*;
use nom::{Err, IResult, Needed};
fn read_sample_file(sample_name: &str) -> Vec<u8> {
let full_path = "sample/".to_string() + sample_name;
let mut f = File::open(full_path).unwrap();
... |
}
| {
let bbc = read_sample_file("bbc.warc");
let parsed = warc_parser::record(&bbc[..bbc.len() - 10]);
assert!(!parsed.is_ok());
match parsed {
Err(Err::Incomplete(needed)) => assert_eq!(Needed::Size(10), needed),
Err(_) => assert!(false),
Ok((_, _)) => a... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.