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 |
|---|---|---|---|---|
persistable.rs | use std::marker::PhantomData;
use expression::Expression;
use query_builder::{QueryBuilder, BuildQueryResult};
use query_source::{Table, Column};
use types::NativeSqlType;
/// Represents that a structure can be used to to insert a new row into the database.
/// Implementations can be automatically generated by
/// [`... |
}
| {
Self::name().to_string()
} | identifier_body |
persistable.rs | use std::marker::PhantomData;
use expression::Expression;
use query_builder::{QueryBuilder, BuildQueryResult};
use query_source::{Table, Column};
use types::NativeSqlType;
/// Represents that a structure can be used to to insert a new row into the database.
/// Implementations can be automatically generated by
/// [`... | T: Table,
&'a U: Insertable<T>,
{
type SqlType = <<&'a U as Insertable<T>>::Columns as InsertableColumns<T>>::SqlType;
fn to_sql(&self, out: &mut QueryBuilder) -> BuildQueryResult {
self.to_insert_sql(out)
}
fn to_insert_sql(&self, out: &mut QueryBuilder) -> BuildQueryResult {
... | _marker: PhantomData<T>,
}
impl<'a, T, U> Expression for InsertValues<'a, T, U> where | random_line_split |
persistable.rs | use std::marker::PhantomData;
use expression::Expression;
use query_builder::{QueryBuilder, BuildQueryResult};
use query_source::{Table, Column};
use types::NativeSqlType;
/// Represents that a structure can be used to to insert a new row into the database.
/// Implementations can be automatically generated by
/// [`... |
try!(record.values().to_insert_sql(out));
}
Ok(())
}
}
impl<C: Column<Table=T>, T: Table> InsertableColumns<T> for C {
type SqlType = <Self as Expression>::SqlType;
fn names(&self) -> String {
Self::name().to_string()
}
}
| {
out.push_sql(", ");
} | conditional_block |
promoted_errors.rs | // http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | random_line_split | |
promoted_errors.rs | // Copyright 2018 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 ... | {
println!("{}", 0u32 - 1);
let _x = 0u32 - 1;
//~^ WARN const_err
println!("{}", 1/(1-1));
//~^ WARN const_err
let _x = 1/(1-1);
//~^ WARN const_err
//~| WARN const_err
println!("{}", 1/(false as u32));
//~^ WARN const_err
let _x = 1/(false as u32);
//~^ WARN const_err
... | identifier_body | |
promoted_errors.rs | // Copyright 2018 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 ... | () {
println!("{}", 0u32 - 1);
let _x = 0u32 - 1;
//~^ WARN const_err
println!("{}", 1/(1-1));
//~^ WARN const_err
let _x = 1/(1-1);
//~^ WARN const_err
//~| WARN const_err
println!("{}", 1/(false as u32));
//~^ WARN const_err
let _x = 1/(false as u32);
//~^ WARN const_er... | main | identifier_name |
lib.rs | extern crate yassy;
extern crate gnuplot;
use yassy::utils;
use yassy::utils::*;
use self::gnuplot::*;
pub fn | (nt: usize, nppt: usize, nn: usize, fs: f64, fhabs: &[f64], outname: &str) {
// The axis of fhabs has nn/2+1 points, representing frequencies from 0 to fl/2,
// or i*(fl/2)/(nn/2) = i*fl/nn = i*fs*(nppt-1)/nn for i=0..nn/2. (Because
// fl=1/Tl=fs*(nppt-1)) We are only interested in
// frequencies up to... | plot_ampl_spec | identifier_name |
lib.rs | extern crate yassy;
extern crate gnuplot;
use yassy::utils;
use yassy::utils::*;
use self::gnuplot::*;
pub fn plot_ampl_spec(nt: usize, nppt: usize, nn: usize, fs: f64, fhabs: &[f64], outname: &str) | let fhabs_cut = &fhabs[..i_fi as usize];
let mut fg = gnuplot::Figure::new();
fg.set_terminal("svg", outname);
// yticks
let yticks = [0.00001f64,0.0001f64,0.001f64,0.01f64,0.1f64,1f64];
fg.axes2d()
.set_y_log(Some(10f64))
.lines(f_cut.iter(), fhabs_cut.iter(), &[Color("blue")])
.line... | {
// The axis of fhabs has nn/2+1 points, representing frequencies from 0 to fl/2,
// or i*(fl/2)/(nn/2) = i*fl/nn = i*fs*(nppt-1)/nn for i=0..nn/2. (Because
// fl=1/Tl=fs*(nppt-1)) We are only interested in
// frequencies up to around fi=60KHz, or i= 60KHz*nn/(fs*(nppt-1)).
let npptf64=nppt as f6... | identifier_body |
lib.rs | extern crate yassy;
extern crate gnuplot;
use yassy::utils;
use yassy::utils::*;
use self::gnuplot::*;
pub fn plot_ampl_spec(nt: usize, nppt: usize, nn: usize, fs: f64, fhabs: &[f64], outname: &str) {
// The axis of fhabs has nn/2+1 points, representing frequencies from 0 to fl/2,
// or i*(fl/2)/(nn/2) = i*f... | let ntf64=nt as f64;
// Find index such that the horizontal axis of the plot is fmax, i.e.
// i = fmax*nn/(fs*(nppt-1))
let fac = (nn as f64)/(fs*(npptf64-1f64));
let i_fi = (60000f64*fac).round();
println!("fac: {}", fac);
println!("i_fi: {}", i_fi);
let mut f = vec![0f64; nn/2+1];
... | // frequencies up to around fi=60KHz, or i= 60KHz*nn/(fs*(nppt-1)).
let npptf64=nppt as f64; | random_line_split |
ed25519.rs | use digest::Digest;
use sha2::{Sha512};
use curve25519::{GeP2, GeP3, ge_scalarmult_base, sc_reduce, sc_muladd, curve25519, Fe};
use util::{fixed_time_eq};
use std::ops::{Add, Sub, Mul};
pub fn keypair(seed: &[u8]) -> ([u8; 64], [u8; 32]) {
let mut secret: [u8; 64] = {
let mut hash_output: [u8; 64] = [0; 64... |
fn do_sign_verify_case(seed: [u8; 32], message: &[u8], expected_signature: [u8; 64]) {
let (secret_key, public_key) = keypair(seed.as_ref());
let mut actual_signature = signature(message, secret_key.as_ref());
assert_eq!(expected_signature.to_vec(), actual_signature.to_vec());
asser... |
assert_eq!(edx_ss.to_vec(), cv_ss.to_vec());
} | random_line_split |
ed25519.rs | use digest::Digest;
use sha2::{Sha512};
use curve25519::{GeP2, GeP3, ge_scalarmult_base, sc_reduce, sc_muladd, curve25519, Fe};
use util::{fixed_time_eq};
use std::ops::{Add, Sub, Mul};
pub fn keypair(seed: &[u8]) -> ([u8; 64], [u8; 32]) {
let mut secret: [u8; 64] = {
let mut hash_output: [u8; 64] = [0; 64... | () {
let seed = [0x26, 0x27, 0xf6, 0x85, 0x97, 0x15, 0xad, 0x1d, 0xd2, 0x94, 0xdd, 0xc4, 0x76, 0x19, 0x39, 0x31,
0xf1, 0xad, 0xb5, 0x58, 0xf0, 0x93, 0x97, 0x32, 0x19, 0x2b, 0xd1, 0xc0, 0xfd, 0x16, 0x8e, 0x4e];
let (ed_private, ed_public) = keypair(seed.as_ref());
let mut has... | keypair_matches_mont | identifier_name |
ed25519.rs | use digest::Digest;
use sha2::{Sha512};
use curve25519::{GeP2, GeP3, ge_scalarmult_base, sc_reduce, sc_muladd, curve25519, Fe};
use util::{fixed_time_eq};
use std::ops::{Add, Sub, Mul};
pub fn keypair(seed: &[u8]) -> ([u8; 64], [u8; 32]) {
let mut secret: [u8; 64] = {
let mut hash_output: [u8; 64] = [0; 64... |
#[test]
fn sign_verify_cases() {
do_sign_verify_case(
[0x2d, 0x20, 0x86, 0x83, 0x2c, 0xc2, 0xfe, 0x3f, 0xd1, 0x8c, 0xb5, 0x1d, 0x6c, 0x5e, 0x99, 0xa5,
0x75, 0x9f, 0x02, 0x21, 0x1f, 0x85, 0xe5, 0xff, 0x2f, 0x90, 0x4a, 0x78, 0x0f, 0x58, 0x00, 0x6f],
[0x89, 0x8f, 0x9c... | {
let (secret_key, public_key) = keypair(seed.as_ref());
let mut actual_signature = signature(message, secret_key.as_ref());
assert_eq!(expected_signature.to_vec(), actual_signature.to_vec());
assert!(verify(message, public_key.as_ref(), actual_signature.as_ref()));
for &(index,... | identifier_body |
magenta.rs | extern crate drm;
use std::io::Result as IoResult;
use std::thread::sleep;
use std::time::Duration;
fn main() -> IoResult<()>
{
let mut dev0 = drm::Device::first_card().unwrap();
let dev = dev0.set_master()
.map_err(|err| {
eprintln!("Failed to set master: {:?}", err);
err
... | let mut buffer = drm::mode::DumbBuf::create_with_depth(
&dev,
mode.hdisplay as u32, mode.vdisplay as u32, 32, 32)
.expect("creating buffer");
dev.set_crtc(crtc.id(), Some(buffer.fb().id()),
0, 0,
&[ connector.id() ],
Some(&mode))
... | random_line_split | |
magenta.rs |
extern crate drm;
use std::io::Result as IoResult;
use std::thread::sleep;
use std::time::Duration;
fn main() -> IoResult<()>
| let encoder = dev.get(encoder_id)
.expect("failed get encoder");
let crtc_id = encoder.crtc_id().unwrap();
let crtc = dev.get(crtc_id)
.expect("failed get crtc");
let old_fbid = crtc.fb_id().expect("Currently no fb");
let mode = crtc.mode().expect("mode")
.clone()... | {
let mut dev0 = drm::Device::first_card().unwrap();
let dev = dev0.set_master()
.map_err(|err| {
eprintln!("Failed to set master: {:?}", err);
err
})?;
let res = dev.get_resources()?;
let connector = res.connectors().iter()
.filter_map(|id| dev.get(*i... | identifier_body |
magenta.rs |
extern crate drm;
use std::io::Result as IoResult;
use std::thread::sleep;
use std::time::Duration;
fn main() -> IoResult<()>
{
let mut dev0 = drm::Device::first_card().unwrap();
let dev = dev0.set_master()
.map_err(|err| {
eprintln!("Failed to set master: {:?}", err);
err
... | <B:AsMut<[u32]>>(mut buffer_ref: B) {
let mut buffer = buffer_ref.as_mut();
for p in buffer.iter_mut() {
*p = 0xffff00ff;
}
}
| fill_buffer | identifier_name |
check_const.rs | bl: ast::Mutability) {
match self.rvalue_borrows.entry(id) {
Entry::Occupied(mut entry) => {
// Merge the two borrows, taking the most demanding
// one, mutability-wise.
if mutbl == ast::MutMutable {
entry.insert(mutbl);
... | let tcontents = ty::type_contents(self.tcx, node_ty);
let suffix = if tcontents.has_dtor() {
"destructors"
} else if tcontents.owns_owned() {
"owned pointers"
} else {
return
};
self.tcx.sess.span_err(e.span, &format!("mutable statics... | }
fn check_static_mut_type(&self, e: &ast::Expr) {
let node_ty = ty::node_id_to_type(self.tcx, e.id); | random_line_split |
check_const.rs | to immutable values", self.msg())
}
}
if!self.qualif.intersects(NON_STATIC_BORROWS) {
self.add_qualif(HAS_STATIC_BORROWS);
}
}
None => {}
}
self.tcx.const_qualif_map.borrow_mut().insert(ex.... | matched_pat | identifier_name | |
check_const.rs | : ast::Mutability) {
match self.rvalue_borrows.entry(id) {
Entry::Occupied(mut entry) => {
// Merge the two borrows, taking the most demanding
// one, mutability-wise.
if mutbl == ast::MutMutable {
entry.insert(mutbl);
... |
fn visit_pat(&mut self, p: &ast::Pat) {
match p.node {
ast::PatLit(ref lit) => {
self.global_expr(Mode::Const, &**lit);
}
ast::PatRange(ref start, ref end) => {
self.global_expr(Mode::Const, &**start);
self.global_expr(Mod... | {
assert!(self.mode == Mode::Var);
self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b));
visit::walk_fn(self, fk, fd, b, s);
} | identifier_body |
get_exact_record.rs |
use uuid::Uuid;
use rustorm::dao::{Dao, IsDao};
use rustorm::pool::ManagedPool;
use rustorm::em::EntityManager;
use rustorm::table::{Table, Column};
use rustorm::table::IsTable;
#[derive(Debug, Clone)]
pub struct Product {
pub product_id: Uuid,
pub name: String,
pub description: Option<String>,
}
impl... | extern crate rustorm;
extern crate uuid;
extern crate chrono;
extern crate rustc_serialize; | random_line_split | |
get_exact_record.rs | extern crate rustorm;
extern crate uuid;
extern crate chrono;
extern crate rustc_serialize;
use uuid::Uuid;
use rustorm::dao::{Dao, IsDao};
use rustorm::pool::ManagedPool;
use rustorm::em::EntityManager;
use rustorm::table::{Table, Column};
use rustorm::table::IsTable;
#[derive(Debug, Clone)]
pub struct Product {
... | data_type:"String".to_string(),
db_data_type:"character varying".to_string(),
is_primary:false, is_unique:false, not_null:true, is_inherited:false,
default:None,
comment:None,
foreign:None,
... | {
Table {
schema: "bazaar".to_string(),
name: "product".to_string(),
parent_table: None,
sub_table: vec![],
comment: None,
columns: vec![
Column{
name:"product_id".to_string(),
data_t... | identifier_body |
get_exact_record.rs | extern crate rustorm;
extern crate uuid;
extern crate chrono;
extern crate rustc_serialize;
use uuid::Uuid;
use rustorm::dao::{Dao, IsDao};
use rustorm::pool::ManagedPool;
use rustorm::em::EntityManager;
use rustorm::table::{Table, Column};
use rustorm::table::IsTable;
#[derive(Debug, Clone)]
pub struct Product {
... | () {
let url = "postgres://postgres:p0stgr3s@localhost/bazaar_v6";
let pool = ManagedPool::init(&url, 1).unwrap();
let db = pool.connect().unwrap();
let em = EntityManager::new(db.as_ref());
let pid = Uuid::parse_str("6db712e6-cc50-4c3a-8269-451c98ace5ad").unwrap();
let prod: Product = em.get_e... | main | identifier_name |
statics-and-consts.rs | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
//~ MONO_ITEM static statics_and_consts::STATIC1[0]
//~ MONO_ITEM fn statics_and_consts::foo[0]
//~ MONO_ITEM static statics_and_consts::foo[0]::STATIC2[0]
//~ MONO_ITEM static statics_and_consts::foo[0]::STATIC2[1]
//~ MONO_ITEM static statics_and_consts::foo[0]::STATIC2[2]
| {
foo();
let _ = STATIC1;
0
} | identifier_body |
statics-and-consts.rs | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (_: isize, _: *const *const u8) -> isize {
foo();
let _ = STATIC1;
0
}
//~ MONO_ITEM static statics_and_consts::STATIC1[0]
//~ MONO_ITEM fn statics_and_consts::foo[0]
//~ MONO_ITEM static statics_and_consts::foo[0]::STATIC2[0]
//~ MONO_ITEM static statics_and_consts::foo[0]::STATIC2[1]
//~ MONO_ITEM stat... | start | identifier_name |
statics-and-consts.rs | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
static STATIC1: i64 = {
const STATIC1_CONST1: i64 = 2;
1 + CONST1 as i64 + STATIC1_CONST1
};
const CONST1: i64 = {
const CONST1_1: i64 = {
const CONST1_1_1: i64 = 2;
CONST1_1_1 + 1
};
1 + CONST1_1 as i64
};
fn foo() {
let _ = {
const CONST2: i64 = 0;
static STA... | // ignore-tidy-linelength
// compile-flags:-Zprint-mono-items=eager
#![deny(dead_code)]
#![feature(start)] | random_line_split |
issue-23442.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <K:UnifyKey> {
values: Delegate<K>,
}
pub struct Delegate<K>(PhantomData<K>);
fn main() {}
| UnificationTable | identifier_name |
issue-23442.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-pass
... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | random_line_split |
issue-23442.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {} | identifier_body | |
robots_txt.rs | use crate::model::Path;
use crate::model::RequestRate;
use crate::model::RobotsTxt;
use crate::service::RobotsTxtService;
use std::time::Duration;
use url::Url;
impl RobotsTxtService for RobotsTxt {
fn can_fetch(&self, user_agent: &str, url: &Url) -> bool {
if url.origin()!= *self.get_origin() {
... |
fn normalize_url_ignore_origin(&self, url: &mut Url) {
if url.query().is_none() {
return;
}
let mut query_params_to_filter = Vec::new();
let path = Path::from_url(url);
for clean_params in self.get_clean_params().iter() {
if clean_params.get_path_pat... | {
if url.origin() != *self.get_origin() {
return false;
}
self.normalize_url_ignore_origin(url);
true
} | identifier_body |
robots_txt.rs | use crate::model::Path;
use crate::model::RequestRate;
use crate::model::RobotsTxt;
use crate::service::RobotsTxtService;
use std::time::Duration;
use url::Url;
impl RobotsTxtService for RobotsTxt {
fn can_fetch(&self, user_agent: &str, url: &Url) -> bool {
if url.origin()!= *self.get_origin() {
... | (&self, url: &mut Url) {
if url.query().is_none() {
return;
}
let mut query_params_to_filter = Vec::new();
let path = Path::from_url(url);
for clean_params in self.get_clean_params().iter() {
if clean_params.get_path_pattern().applies_to(&path) {
... | normalize_url_ignore_origin | identifier_name |
robots_txt.rs | use crate::model::Path;
use crate::model::RequestRate;
use crate::model::RobotsTxt;
use crate::service::RobotsTxtService;
use std::time::Duration;
use url::Url;
impl RobotsTxtService for RobotsTxt {
fn can_fetch(&self, user_agent: &str, url: &Url) -> bool {
if url.origin()!= *self.get_origin() {
... |
}
let mut pairs: Vec<(String, String)> = url
.query_pairs()
.map(|(key, value)| (key.into(), value.into()))
.collect();
{
let mut query_pairs_mut = url.query_pairs_mut();
query_pairs_mut.clear();
for (key, value) in pairs.drai... | {
query_params_to_filter.extend_from_slice(clean_params.get_params())
} | conditional_block |
robots_txt.rs | use crate::model::Path;
use crate::model::RequestRate;
use crate::model::RobotsTxt;
use crate::service::RobotsTxtService;
use std::time::Duration;
use url::Url;
impl RobotsTxtService for RobotsTxt {
fn can_fetch(&self, user_agent: &str, url: &Url) -> bool {
if url.origin()!= *self.get_origin() {
... | }
None
});
if let Some(rule_decision) = rule_decision {
return rule_decision;
}
// Empty robots.txt allows crawling. Everything that was not denied must be allowed.
true
}
fn get_crawl_delay(&self, user_agent: &str) -> Option<Duration>... | return Some(rule.get_allowance());
} | random_line_split |
hygiene_example_codegen.rs | // force-host
// no-prefer-dynamic
#![feature(proc_macro_quote)]
#![crate_type = "proc-macro"]
extern crate proc_macro as proc_macro_renamed; // This does not break `quote!`
use proc_macro_renamed::{TokenStream, quote};
#[proc_macro]
pub fn | (input: TokenStream) -> TokenStream {
quote!(hello_helper!($input))
//^ `hello_helper!` always resolves to the following proc macro,
//| no matter where `hello!` is used.
}
#[proc_macro]
pub fn hello_helper(input: TokenStream) -> TokenStream {
quote! {
extern crate hygiene_example; // This is n... | hello | identifier_name |
hygiene_example_codegen.rs | // force-host |
#![feature(proc_macro_quote)]
#![crate_type = "proc-macro"]
extern crate proc_macro as proc_macro_renamed; // This does not break `quote!`
use proc_macro_renamed::{TokenStream, quote};
#[proc_macro]
pub fn hello(input: TokenStream) -> TokenStream {
quote!(hello_helper!($input))
//^ `hello_helper!` always re... | // no-prefer-dynamic | random_line_split |
hygiene_example_codegen.rs | // force-host
// no-prefer-dynamic
#![feature(proc_macro_quote)]
#![crate_type = "proc-macro"]
extern crate proc_macro as proc_macro_renamed; // This does not break `quote!`
use proc_macro_renamed::{TokenStream, quote};
#[proc_macro]
pub fn hello(input: TokenStream) -> TokenStream {
quote!(hello_helper!($input)... | {
quote! {
extern crate hygiene_example; // This is never a conflict error
let string = format!("hello {}", $input);
//^ `format!` always resolves to the prelude macro,
//| even if a different `format!` is in scope where `hello!` is used.
hygiene_example::print(&string)
}... | identifier_body | |
req_handler_unary.rs | use crate::error;
use crate::result;
use crate::server::req_handler::ServerRequestStreamHandler;
use crate::server::req_handler::ServerRequestUnaryHandler;
use httpbis::IncreaseInWindow;
use std::marker;
pub(crate) struct RequestHandlerUnaryToStream<M, H>
where
H: ServerRequestUnaryHandler<M>,
M: Send +'static... |
}
| {
// TODO: overflow check
self.increase_in_window
.increase_window_auto_above(buffered as u32)?;
Ok(())
} | identifier_body |
req_handler_unary.rs | use crate::error;
use crate::result;
use crate::server::req_handler::ServerRequestStreamHandler;
use crate::server::req_handler::ServerRequestUnaryHandler;
use httpbis::IncreaseInWindow;
use std::marker;
pub(crate) struct RequestHandlerUnaryToStream<M, H>
where
H: ServerRequestUnaryHandler<M>,
M: Send +'static... |
self.message = Some(message);
Ok(())
}
fn end_stream(&mut self) -> result::Result<()> {
match self.message.take() {
Some(message) => self.handler.grpc_message(message),
None => Err(error::Error::Other("no message, end of stream")),
}
}
fn buffer... | {
return Err(error::Error::Other("more than one message in a stream"));
} | conditional_block |
req_handler_unary.rs | use crate::error;
use crate::result;
use crate::server::req_handler::ServerRequestStreamHandler;
use crate::server::req_handler::ServerRequestUnaryHandler;
use httpbis::IncreaseInWindow;
use std::marker;
pub(crate) struct | <M, H>
where
H: ServerRequestUnaryHandler<M>,
M: Send +'static,
{
pub(crate) increase_in_window: IncreaseInWindow,
pub(crate) handler: H,
pub(crate) message: Option<M>,
pub(crate) _marker: marker::PhantomData<M>,
}
impl<M, H> ServerRequestStreamHandler<M> for RequestHandlerUnaryToStream<M, H>
w... | RequestHandlerUnaryToStream | identifier_name |
req_handler_unary.rs | use crate::error;
use crate::result;
use crate::server::req_handler::ServerRequestStreamHandler;
use crate::server::req_handler::ServerRequestUnaryHandler;
use httpbis::IncreaseInWindow;
use std::marker;
pub(crate) struct RequestHandlerUnaryToStream<M, H>
where
H: ServerRequestUnaryHandler<M>,
M: Send +'static... | fn buffer_processed(&mut self, buffered: usize) -> result::Result<()> {
// TODO: overflow check
self.increase_in_window
.increase_window_auto_above(buffered as u32)?;
Ok(())
}
} | Some(message) => self.handler.grpc_message(message),
None => Err(error::Error::Other("no message, end of stream")),
}
}
| random_line_split |
storage.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 dom::bindings::codegen::Bindings::StorageBinding;
use dom::bindings::codegen::Bindings::StorageBinding::Storag... | new_value: Option<DOMString>) -> StorageEventRunnable {
StorageEventRunnable { element: storage, key: key, old_value: old_value, new_value: new_value }
}
}
impl MainThreadRunnable for StorageEventRunnable {
fn handler(self: Box<StorageEventRunnable>, script_task: &ScriptTask) {
let t... |
impl StorageEventRunnable {
fn new(storage: Trusted<Storage>, key: Option<DOMString>, old_value: Option<DOMString>, | random_line_split |
storage.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 dom::bindings::codegen::Bindings::StorageBinding;
use dom::bindings::codegen::Bindings::StorageBinding::Storag... |
fn Key(self, index: u32) -> Option<DOMString> {
let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), self.storage_type, index)).unwrap();
receiver.recv().unwrap()
}
fn GetItem(self, name: DOMString) -> Option<DOMString> {
... | {
let (sender, receiver) = channel();
self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url(), self.storage_type)).unwrap();
receiver.recv().unwrap() as u32
} | identifier_body |
storage.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 dom::bindings::codegen::Bindings::StorageBinding;
use dom::bindings::codegen::Bindings::StorageBinding::Storag... | (global: &GlobalRef, storage_type: StorageType) -> Temporary<Storage> {
reflect_dom_object(box Storage::new_inherited(global, storage_type), *global, StorageBinding::Wrap)
}
fn get_url(&self) -> Url {
let global_root = self.global.root();
let global_ref = global_root.r();
global... | new | identifier_name |
storage.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 dom::bindings::codegen::Bindings::StorageBinding;
use dom::bindings::codegen::Bindings::StorageBinding::Storag... |
}
}
}
| {
let target: JSRef<EventTarget> = EventTargetCast::from_ref(it_window);
event.fire(target);
} | conditional_block |
color.rs | // Copyright (c) 2015-2019 William (B.J.) Snow Orvis
//
// 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 applicab... | (pub [u8; 4]);
/// Black for use with `graphics`' functions
pub const BLACK_F32: ColorF32 = ColorF32([0.0, 0.0, 0.0, 1.0]);
/// Grey for use with `graphics`' functions
pub const GREY_F32: ColorF32 = ColorF32([0.5, 0.5, 0.5, 1.0]);
/// White for use with `graphics`' functions
pub const WHITE_F32: ColorF32 = ColorF32([1... | ColorU8 | identifier_name |
color.rs | // Copyright (c) 2015-2019 William (B.J.) Snow Orvis
//
// 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 applicab... | ///
/// ```
/// use fractal_lib::color::{ColorU8, color_range_linear};
/// use std::cmp::min;
///
/// let black = ColorU8([0,0,0,255]);
/// let white = ColorU8([255,255,255,255]);
/// let gradient_count = 128;
/// let range = color_range_linear(black, white, gradient_count);
///
/// assert_eq!(range[min(gradient_count-... | /// error: | random_line_split |
color.rs | // Copyright (c) 2015-2019 William (B.J.) Snow Orvis
//
// 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 applicab... |
let deltas = [
(f32::from(last.0[0]) - f32::from(first.0[0])) / f32::from((count as u16) - 1),
(f32::from(last.0[1]) - f32::from(first.0[1])) / f32::from((count as u16) - 1),
(f32::from(last.0[2]) - f32::from(first.0[2])) / f32::from((count as u16) - 1),
(f32::from(last.0[3]) - f32:... | {
panic!("Count must be 2 or more: {}", count);
} | conditional_block |
or-patterns-syntactic-fail.rs | // Test some cases where or-patterns may ostensibly be allowed but are in fact not.
// This is not a semantic test. We only test parsing.
fn | () {}
enum E { A, B }
use E::*;
fn no_top_level_or_patterns() {
// We do *not* allow or-patterns at the top level of lambdas...
let _ = |A | B: E| (); //~ ERROR no implementation for `E | ()`
// -------- This looks like an or-pattern but is in fact `|A| (B: E | ())`.
//...and for now neithe... | main | identifier_name |
or-patterns-syntactic-fail.rs | // Test some cases where or-patterns may ostensibly be allowed but are in fact not.
// This is not a semantic test. We only test parsing.
fn main() {}
enum E { A, B }
use E::*;
fn no_top_level_or_patterns() {
// We do *not* allow or-patterns at the top level of lambdas...
let _ = |A | B: E| (); //~ ERROR no ... |
//~^ ERROR top-level or-patterns are not allowed
fn fun2(| A | B: E) {}
//~^ ERROR top-level or-patterns are not allowed
// We don't allow top-level or-patterns before type annotation in let-statements because we
// want to reserve this syntactic space for possible future type ascription.
let... | {} | identifier_body |
or-patterns-syntactic-fail.rs | // Test some cases where or-patterns may ostensibly be allowed but are in fact not.
// This is not a semantic test. We only test parsing.
fn main() {}
enum E { A, B } | // We do *not* allow or-patterns at the top level of lambdas...
let _ = |A | B: E| (); //~ ERROR no implementation for `E | ()`
// -------- This looks like an or-pattern but is in fact `|A| (B: E | ())`.
//...and for now neither do we allow or-patterns at the top level of functions.
fn fu... | use E::*;
fn no_top_level_or_patterns() { | random_line_split |
array_slice.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | )
.collect();
Arc::new(array)
}
fn array_slice_benchmark(c: &mut Criterion) {
let array = create_array_with_nulls(4096);
c.bench_function("array_slice 128", |b| {
b.iter(|| create_array_slice(&array, 128))
});
c.bench_function("array_slice 512", |b| {
b.iter(|| create_array_s... | { None } | conditional_block |
array_slice.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | });
c.bench_function("array_slice 2048", |b| {
b.iter(|| create_array_slice(&array, 2048))
});
}
criterion_group!(benches, array_slice_benchmark);
criterion_main!(benches); | b.iter(|| create_array_slice(&array, 512)) | random_line_split |
array_slice.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... |
fn create_array_with_nulls(size: usize) -> ArrayRef {
let array: Float64Array = (0..size)
.map(|i| if i % 2 == 0 { Some(1.0) } else { None })
.collect();
Arc::new(array)
}
fn array_slice_benchmark(c: &mut Criterion) {
let array = create_array_with_nulls(4096);
c.bench_function("array_sl... | {
array.slice(0, length)
} | identifier_body |
array_slice.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | (c: &mut Criterion) {
let array = create_array_with_nulls(4096);
c.bench_function("array_slice 128", |b| {
b.iter(|| create_array_slice(&array, 128))
});
c.bench_function("array_slice 512", |b| {
b.iter(|| create_array_slice(&array, 512))
});
c.bench_function("array_slice 2048", ... | array_slice_benchmark | identifier_name |
sha256_bench.rs | #![cfg_attr(all(feature = "nightly", test), feature(test))]
#![cfg(all(feature = "nightly", test))]
extern crate test;
extern crate cxema;
#[cfg(test)]
use cxema::sha2::{Sha256};
use cxema::digest::Digest;
use test::Bencher;
#[bench]
pub fn sha256_10(bh: &mut Bencher) {
let mut sh = Sha256::new();
let bytes... | (bh: &mut Bencher) {
let mut sh = Sha256::new();
let bytes = [1u8; 1024];
bh.iter(|| {
sh.input(&bytes);
});
bh.bytes = bytes.len() as u64;
}
#[bench]
pub fn sha256_64k(bh: &mut Bencher) {
let mut sh = Sha256::new();
let bytes = [1u8; 65536];
bh.iter(|| {
sh.input(&byt... | sha256_1k | identifier_name |
sha256_bench.rs | #![cfg_attr(all(feature = "nightly", test), feature(test))]
#![cfg(all(feature = "nightly", test))]
extern crate test;
extern crate cxema;
#[cfg(test)]
use cxema::sha2::{Sha256};
use cxema::digest::Digest;
use test::Bencher;
#[bench]
pub fn sha256_10(bh: &mut Bencher) {
let mut sh = Sha256::new(); |
bh.iter(|| {
sh.input(&bytes);
});
bh.bytes = bytes.len() as u64;
}
#[bench]
pub fn sha256_1k(bh: &mut Bencher) {
let mut sh = Sha256::new();
let bytes = [1u8; 1024];
bh.iter(|| {
sh.input(&bytes);
});
bh.bytes = bytes.len() as u64;
}
#[bench]
pub fn sha256_64k(bh: &m... | let bytes = [1u8; 10]; | random_line_split |
sha256_bench.rs | #![cfg_attr(all(feature = "nightly", test), feature(test))]
#![cfg(all(feature = "nightly", test))]
extern crate test;
extern crate cxema;
#[cfg(test)]
use cxema::sha2::{Sha256};
use cxema::digest::Digest;
use test::Bencher;
#[bench]
pub fn sha256_10(bh: &mut Bencher) {
let mut sh = Sha256::new();
let bytes... | {
let mut sh = Sha256::new();
let bytes = [1u8; 65536];
bh.iter(|| {
sh.input(&bytes);
});
bh.bytes = bytes.len() as u64;
} | identifier_body | |
lib.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@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.o... | (cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
match it.node {
ast::ItemKind::Fn(ref decl, style, constness, abi, _, ref block) => {
let istr = it.ident.name.as_str();
let fn_name = &*istr;
let ty_params = platformtree::builder::meta_args::get_ty_params_for_task(cx, fn_name);
let ... | macro_zinc_task_item | identifier_name |
lib.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@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.o... | fn macro_zinc_task(cx: &mut ExtCtxt, _: Span, _: &ast::MetaItem,
ann: Annotatable) -> Annotatable {
match ann {
Annotatable::Item(it) => {Annotatable::Item(macro_zinc_task_item(cx, it))}
other => {other}
}
}
fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
match it.no... | }
macro_platformtree(cx, sp, tts)
}
| random_line_split |
lib.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@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.o... | ["pt".to_string(), fn_name.to_string() + "_args"].iter().map(|t| cx.ident_of(t.as_str())).collect(),
vec!(),
ty_params.iter().map(|ty| {
cx.ty_path(cx.path_ident(DUMMY_SP, cx.ident_of(ty.to_tyhash().as_str())))
}).collect(),
... | {
let istr = it.ident.name.as_str();
let fn_name = &*istr;
let ty_params = platformtree::builder::meta_args::get_ty_params_for_task(cx, fn_name);
let params = ty_params.iter().map(|ty| {
cx.typaram(
DUMMY_SP,
cx.ident_of(ty.to_tyhash().as_str()),
P::f... | conditional_block |
main.rs | //! Module with the entry point of the binary.
extern crate case;
extern crate clap;
extern crate conv;
#[macro_use]
extern crate log;
extern crate rush;
mod args;
mod logging;
mod rcfile;
use std::error::Error; // for.cause() method
use std::io::{self, Write};
use std::iter::repeat;
use std::process::exit;
use... |
Ok(())
}
/// Apply the expressions to the standard input with given mode.
/// This forms the bulk of the input processing.
#[inline]
fn apply_multi_ctx(mode: InputMode,
context: &mut Context, exprs: &[&str], mut output: &mut Write) -> io::Result<()> {
let func: fn(_, _, _, _) -> _ = match ... | {
let result = try!(rush::eval(after, &mut context));
let result_string = try!(String::try_from(result)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)));
// Make it so that the output always ends with a newline,
// regardless whether it consists of a single value... | conditional_block |
main.rs | //! Module with the entry point of the binary.
extern crate case;
extern crate clap;
extern crate conv;
#[macro_use]
extern crate log;
extern crate rush;
mod args;
mod logging;
mod rcfile;
use std::error::Error; // for.cause() method
use std::io::{self, Write};
use std::iter::repeat;
use std::process::exit;
use... | // Do the processing.
//
// If there is an "after" expression provided, it is that expression that should produce
// the only output of the program. So we'll just consume whatever results would normally
// be printed otherwise.
if after.is_some() {
// HACK: Because the intermediate resul... | if let Some(before) = before {
try!(rush::exec(before, &mut context));
}
| random_line_split |
main.rs | //! Module with the entry point of the binary.
extern crate case;
extern crate clap;
extern crate conv;
#[macro_use]
extern crate log;
extern crate rush;
mod args;
mod logging;
mod rcfile;
use std::error::Error; // for.cause() method
use std::io::{self, Write};
use std::iter::repeat;
use std::process::exit;
use... | (mode: InputMode,
before: Option<&str>, exprs: &[&str], after: Option<&str>) -> io::Result<()> {
// Prepare a Context for the processing.
// This includes evaluating any "before" expression within it.
let mut context = Context::new();
try!(rcfile::load_into(&mut context)
.map_err... | process_input | identifier_name |
main.rs | //! Module with the entry point of the binary.
extern crate case;
extern crate clap;
extern crate conv;
#[macro_use]
extern crate log;
extern crate rush;
mod args;
mod logging;
mod rcfile;
use std::error::Error; // for.cause() method
use std::io::{self, Write};
use std::iter::repeat;
use std::process::exit;
use... |
/// Handle an error that occurred while processing the input.
fn handle_error(error: io::Error) {
writeln!(&mut io::stderr(), "error: {}", error).unwrap();
// Print the error causes as an indented "tree".
let mut cause = error.cause();
let mut indent = 0;
while let Some(error) = cause {
w... | {
let func: fn(_, _, _, _) -> _ = match mode {
InputMode::String => rush::apply_string_multi_ctx,
InputMode::Lines => rush::map_lines_multi_ctx,
InputMode::Words => rush::map_words_multi_ctx,
InputMode::Chars => rush::map_chars_multi_ctx,
InputMode::Bytes => rush::map_bytes_m... | identifier_body |
config.rs | // In heavy WIP
use std::fs::{ self, File };
use std::io::Read;
use std::path::Path;
use toml;
use error::PackageError;
use repository::RepositoryUrls;
/// Represents the config file.
#[derive(Debug, Deserialize)]
pub struct Config {
pub buffer_size: Option<u64>,
// pub config_path: Option<String>,
pub do... |
// Wait for RFC-2086 to be implemented first.
/*
[allow(irrefutable_let_pattern)]
if let Config { $key: mut x,.. } = $dest {
if let None = x { x = $value }
}
*/
... | {
// Destructuring the default configs into individual variables.
let Self {
buffer_size: buf_size,
download_path: dl_path,
unpack_path: unpk_path,
repository: repo,
} = Self::default();
/// Internal macro, to ease the implementation of `f... | identifier_body |
config.rs | // In heavy WIP
use std::fs::{ self, File };
use std::io::Read;
use std::path::Path;
use toml;
use error::PackageError;
use repository::RepositoryUrls;
/// Represents the config file.
#[derive(Debug, Deserialize)]
pub struct Config {
pub buffer_size: Option<u64>,
// pub config_path: Option<String>,
pub do... | <P: AsRef<Path>>(path: P) -> Result<Self, PackageError> {
let mut content = String::new();
// Check whether there are tons of configs in the path
if path.as_ref().is_dir() {
// Read every config files and put them into a string, if it is
for entry in fs::read_dir(path)? ... | read_from | identifier_name |
config.rs | // In heavy WIP
use std::fs::{ self, File };
use std::io::Read;
use std::path::Path;
use toml;
use error::PackageError;
use repository::RepositoryUrls;
/// Represents the config file.
#[derive(Debug, Deserialize)]
pub struct Config {
pub buffer_size: Option<u64>,
// pub config_path: Option<String>,
pub do... | else {
// Read the config file into a string, if it isn't
let mut config = File::open(path)?;
config.read_to_string(&mut content)?;
}
// Try to parse the string, and convert it into a `Config`.
let config = content.parse::<toml::Value>()?;
let config... | {
// Read every config files and put them into a string, if it is
for entry in fs::read_dir(path)? {
let entry = entry?;
let mut config = File::open(entry.path())?;
config.read_to_string(&mut content)?;
}
} | conditional_block |
config.rs | // In heavy WIP
use std::fs::{ self, File };
use std::io::Read;
use std::path::Path;
use toml;
use error::PackageError;
use repository::RepositoryUrls;
/// Represents the config file.
#[derive(Debug, Deserialize)]
pub struct Config {
pub buffer_size: Option<u64>,
// pub config_path: Option<String>,
pub do... | match $dest {
Self { $key: ref mut x,.. } => {
match x {
&mut Some(_) => {},
&mut None => *x = $value,
}
}
}
//... | macro_rules! set_on_none {
($dest:ident, $key:ident, $value:expr) => ( | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(macro_rules, plugin_registrar, quote, phase)]
#![deny(unused_imports, unused_variable)]
//! Exports m... |
impl LintPass for UnrootedPass {
fn get_lints(&self) -> LintArray {
lint_array!(UNROOTED_MUST_ROOT)
}
fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident, _gen: &ast::Generics, id: ast::NodeId) {
if cx.tcx.map.expect_item(id).attrs.iter().all(|a|!a.check_name... | {
match ty.node {
ast::TyBox(ref t) | ast::TyUniq(ref t) |
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
ast::TyPath(_, _, id) => {
ma... | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(macro_rules, plugin_registrar, quote, phase)]
#![deny(unused_imports, unused_variable)]
//! Exports m... |
fn check_variant(&mut self, cx: &Context, var: &ast::Variant, _gen: &ast::Generics) {
let ref map = cx.tcx.map;
if map.expect_item(map.get_parent(var.node.id)).attrs.iter().all(|a|!a.check_name("must_root")) {
match var.node.kind {
ast::TupleVariantKind(ref vec) => {
... | "Type must be rooted, use #[must_root] on the struct definition to propagate");
}
}
} | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(macro_rules, plugin_registrar, quote, phase)]
#![deny(unused_imports, unused_variable)]
//! Exports m... | (reg: &mut Registry) {
reg.register_lint_pass(box TransmutePass as LintPassObject);
reg.register_lint_pass(box UnrootedPass as LintPassObject);
}
#[macro_export]
macro_rules! bitfield(
($bitfieldname:ident, $getter:ident, $setter:ident, $value:expr) => (
impl $bitfieldname {
#[inline]
... | plugin_registrar | identifier_name |
mod.rs | pub mod counts;
mod hashing;
pub mod mash;
pub mod scaled;
use needletail::parser::SequenceRecord;
use serde::{Deserialize, Serialize};
use crate::bail;
use crate::errors::FinchResult;
use crate::filtering::FilterParams;
use crate::serialization::Sketch;
pub use hashing::ItemHash;
#[derive(Clone, Debug, Deserialize,... | Ok(first_params)
}
/// Return any sketch parameter difference that would make comparisons
/// between sketches generated by these parameter sets not work.
///
/// Note this doesn't actually check the enum variants themselves, but it
/// should still break if there are different variants... | // TODO: harminize sketch sizes?
// TODO: do something with no_strict and final_size
}
| random_line_split |
mod.rs | pub mod counts;
mod hashing;
pub mod mash;
pub mod scaled;
use needletail::parser::SequenceRecord;
use serde::{Deserialize, Serialize};
use crate::bail;
use crate::errors::FinchResult;
use crate::filtering::FilterParams;
use crate::serialization::Sketch;
pub use hashing::ItemHash;
#[derive(Clone, Debug, Deserialize,... | (&self) -> (&str, u16, u64, Option<f64>) {
match self {
SketchParams::Mash { hash_seed,.. } => ("MurmurHash3_x64_128", 64, *hash_seed, None),
SketchParams::Scaled {
hash_seed, scale,..
} => ("MurmurHash3_x64_128", 64, *hash_seed, Some(*scale)),
Ske... | hash_info | identifier_name |
mod.rs | pub mod counts;
mod hashing;
pub mod mash;
pub mod scaled;
use needletail::parser::SequenceRecord;
use serde::{Deserialize, Serialize};
use crate::bail;
use crate::errors::FinchResult;
use crate::filtering::FilterParams;
use crate::serialization::Sketch;
pub use hashing::ItemHash;
#[derive(Clone, Debug, Deserialize,... | *kmer_length,
*hash_seed,
)),
SketchParams::AllCounts { kmer_length } => {
Box::new(counts::AllCountsSketcher::new(*kmer_length))
}
}
}
pub fn process_post_filter(&self, kmers: &mut Vec<KmerCount>, name: &str) -> Finch... | {
match self {
SketchParams::Mash {
kmers_to_sketch,
kmer_length,
hash_seed,
..
} => Box::new(mash::MashSketcher::new(
*kmers_to_sketch,
*kmer_length,
*hash_seed,
)... | identifier_body |
htmltablecaptionelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding;
use crate::dom::bindings::root::DomRo... | document: &Document,
) -> HTMLTableCaptionElement {
HTMLTableCaptionElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
pub fn new(
local_name: LocalName,
prefix: Option<Prefix>,
do... |
impl HTMLTableCaptionElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>, | random_line_split |
htmltablecaptionelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding;
use crate::dom::bindings::root::DomRo... | (
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> DomRoot<HTMLTableCaptionElement> {
Node::reflect_node(
Box::new(HTMLTableCaptionElement::new_inherited(
local_name, prefix, document,
)),
document,
... | new | identifier_name |
main.rs | #![feature(async_await)]
use futures_util::stream::StreamExt;
use std::env;
use std::io::*;
use std::process::Stdio;
use tokio::codec::{FramedRead, LinesCodec};
use tokio::prelude::*;
use tokio::process::{Child, Command};
const USAGE: &str = "args: config_file";
struct Qemu {
pub process: Child,
}
impl Qemu {
... | (mut self) {
{
self.process
.stdin()
.as_mut()
.unwrap()
.write_all(b"q\n")
.unwrap();
}
let ecode = self.process.wait().expect("failed to wait on child");
assert!(ecode.success());
}
}
struct Gdb... | terminate | identifier_name |
main.rs | #![feature(async_await)]
use futures_util::stream::StreamExt;
use std::env;
use std::io::*;
use std::process::Stdio;
use tokio::codec::{FramedRead, LinesCodec};
use tokio::prelude::*;
use tokio::process::{Child, Command};
const USAGE: &str = "args: config_file";
struct Qemu {
pub process: Child,
}
impl Qemu {
... |
fn read(&mut self) -> Vec<u8> {
let mut result = Vec::new();
self.process
.stdout
.as_mut()
.unwrap()
.read_to_end(&mut result)
.unwrap();
result
}
fn write(&mut self, bytes: &[u8]) {
self.process
.stdin
... | {
let process = Command::new("gdb")
.stdin(Stdio::piped())
.stdout(Stdio::null())
// .stderr(Stdio::null())
.spawn()
.expect("Unable to start gdb");
let stdout = process.stdout().take().unwrap();
Self {
process,
... | identifier_body |
main.rs | #![feature(async_await)]
use futures_util::stream::StreamExt;
use std::env;
use std::io::*;
use std::process::Stdio;
use tokio::codec::{FramedRead, LinesCodec};
use tokio::prelude::*;
use tokio::process::{Child, Command};
const USAGE: &str = "args: config_file";
struct Qemu {
pub process: Child,
}
impl Qemu {
... | let ecode = self.process.wait().expect("failed to wait on child");
assert!(ecode.success());
}
}
#[tokio::main]
async fn main() {
let _args: Vec<_> = env::args().skip(1).collect();
let mut qemu = Qemu::new("build/test_disk.img");
let mut gdb = Gdb::new();
gdb.start();
std::th... | self.write(b"q\n"); | random_line_split |
devlinks.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::collections::HashSet;
use std::io::ErrorKind;
use std::os::unix::fs::symlink;
use std::path::{Path, PathBuf}... | (pool_name: &str, fs_name: &str, devnode: &Path) {
let p = filesystem_mount_path(pool_name, fs_name);
// Remove existing and recreate to ensure it points to the correct devnode
let _ = fs::remove_file(&p);
if let Err(e) = symlink(devnode, &p) {
warn!(
"unable to create symlink for {... | filesystem_added | identifier_name |
devlinks.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::collections::HashSet;
use std::io::ErrorKind;
use std::os::unix::fs::symlink;
use std::path::{Path, PathBuf}... | if err.kind()!= ErrorKind::AlreadyExists {
return Err(From::from(err));
}
}
Ok(())
}
/// Setup the pool directory and the symlinks in /stratis for the specified pool and filesystems
/// it contains.
// Don't just remove and recreate everything in case there are processes
// (e.g. u... | pub fn setup_dev_path() -> StratisResult<()> {
if let Err(err) = fs::create_dir(DEV_PATH) { | random_line_split |
devlinks.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::collections::HashSet;
use std::io::ErrorKind;
use std::os::unix::fs::symlink;
use std::path::{Path, PathBuf}... |
}
/// Create a directory when a pool is added.
pub fn pool_added(pool: &str) {
let p = pool_directory(pool);
if let Err(e) = fs::create_dir(&p) {
warn!("unable to create pool directory {:?}, reason {:?}", p, e);
}
}
/// Remove the directory and its contents when the pool is removed.
pub fn pool_r... | {
warn!("cleanup_devlinks failed, reason {:?}", err);
} | conditional_block |
devlinks.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::collections::HashSet;
use std::io::ErrorKind;
use std::os::unix::fs::symlink;
use std::path::{Path, PathBuf}... |
/// Remove the directory and its contents when the pool is removed.
pub fn pool_removed(pool: &str) {
let p = pool_directory(pool);
if let Err(e) = fs::remove_dir_all(&p) {
warn!("unable to remove pool directory {:?}, reason {:?}", p, e);
}
}
/// Rename the directory to match the pool's new name.... | {
let p = pool_directory(pool);
if let Err(e) = fs::create_dir(&p) {
warn!("unable to create pool directory {:?}, reason {:?}", p, e);
}
} | identifier_body |
fence_rmw.rs | //! This mod provides orderings to use with RMW operations
//! that optimally handle the case when all loads and stores
//! after an RMW operation must be ordered after the operation.
//! # Example:
//! ```
//! use std::sync::atomic::{AtomicUsize, fence, Ordering};
//! use atomic_utilities::fence_rmw::{RMWOrder, fence_... |
}
/// The ordering to be used for RMW operations in this fencing scheme
#[allow(non_upper_case_globals)]
pub const RMWOrder: Ordering = internal_ordering::RMW_O;
/// The fence to be used after the RMW
#[inline(always)]
pub fn fence_rmw() {
internal_ordering::the_fence()
}
| {
fence(Ordering::SeqCst)
} | identifier_body |
fence_rmw.rs | //! This mod provides orderings to use with RMW operations
//! that optimally handle the case when all loads and stores
//! after an RMW operation must be ordered after the operation.
//! # Example:
//! ```
//! use std::sync::atomic::{AtomicUsize, fence, Ordering};
//! use atomic_utilities::fence_rmw::{RMWOrder, fence_... | mod internal_ordering {
use std::sync::atomic::{Ordering, fence};
pub const RMW_O: Ordering = Ordering::Relaxed;
pub fn the_fence() {
fence(Ordering::SeqCst)
}
}
/// The ordering to be used for RMW operations in this fencing scheme
#[allow(non_upper_case_globals)]
pub const RMWOrder: Ordering =... | random_line_split | |
fence_rmw.rs | //! This mod provides orderings to use with RMW operations
//! that optimally handle the case when all loads and stores
//! after an RMW operation must be ordered after the operation.
//! # Example:
//! ```
//! use std::sync::atomic::{AtomicUsize, fence, Ordering};
//! use atomic_utilities::fence_rmw::{RMWOrder, fence_... | () {
internal_ordering::the_fence()
}
| fence_rmw | identifier_name |
mock_executor.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use tipb::FieldType;
use crate::interface::*;
use tidb_query_common::storage::IntervalRange;
use tidb_query_datatype::codec::batch::LazyBatchColumnVec;
use tidb_query_datatype::codec::data_type::VectorValue;
use tidb_query_datatype::expr::EvalWarnings... | (&mut self, _dest: &mut Self::StorageStats) {
// Do nothing
}
fn take_scanned_range(&mut self) -> IntervalRange {
// Do nothing
unreachable!()
}
fn can_be_cached(&self) -> bool {
false
}
}
| collect_storage_stats | identifier_name |
mock_executor.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use tipb::FieldType;
use crate::interface::*;
use tidb_query_common::storage::IntervalRange;
use tidb_query_datatype::codec::batch::LazyBatchColumnVec;
use tidb_query_datatype::codec::data_type::VectorValue;
use tidb_query_datatype::expr::EvalWarnings... |
fn can_be_cached(&self) -> bool {
false
}
}
pub struct MockScanExecutor {
pub rows: Vec<i64>,
pub pos: usize,
schema: Vec<FieldType>,
}
impl MockScanExecutor {
pub fn new(rows: Vec<i64>, schema: Vec<FieldType>) -> Self {
MockScanExecutor {
rows,
pos: 0,... | unreachable!()
} | random_line_split |
group.rs | extern crate kiss3d;
extern crate nalgebra as na;
use na::Vec3;
use kiss3d::window::Window;
use kiss3d::light::Light;
fn main() | while window.render() {
g1.prepend_to_local_rotation(&Vec3::new(0.0f32, 0.014, 0.0));
g2.prepend_to_local_rotation(&Vec3::new(0.014f32, 0.0, 0.0));
}
}
| {
let mut window = Window::new("Kiss3d: cube");
let mut g1 = window.add_group();
let mut g2 = window.add_group();
g1.append_translation(&Vec3::new(2.0f32, 0.0, 0.0));
g2.append_translation(&Vec3::new(-2.0f32, 0.0, 0.0));
g1.add_cube(1.0, 5.0, 1.0);
g1.add_cube(5.0, 1.0, 1.0);
g2.add_... | identifier_body |
group.rs | use kiss3d::window::Window;
use kiss3d::light::Light;
fn main() {
let mut window = Window::new("Kiss3d: cube");
let mut g1 = window.add_group();
let mut g2 = window.add_group();
g1.append_translation(&Vec3::new(2.0f32, 0.0, 0.0));
g2.append_translation(&Vec3::new(-2.0f32, 0.0, 0.0));
g1.add_... | extern crate kiss3d;
extern crate nalgebra as na;
use na::Vec3; | random_line_split | |
group.rs | extern crate kiss3d;
extern crate nalgebra as na;
use na::Vec3;
use kiss3d::window::Window;
use kiss3d::light::Light;
fn | () {
let mut window = Window::new("Kiss3d: cube");
let mut g1 = window.add_group();
let mut g2 = window.add_group();
g1.append_translation(&Vec3::new(2.0f32, 0.0, 0.0));
g2.append_translation(&Vec3::new(-2.0f32, 0.0, 0.0));
g1.add_cube(1.0, 5.0, 1.0);
g1.add_cube(5.0, 1.0, 1.0);
g2.a... | main | identifier_name |
record_backend.rs | extern crate chrono;
extern crate mysql;
use self::chrono::UTC;
use self::chrono::offset::TimeZone;
use self::mysql::conn::MyOpts;
use self::mysql::conn::pool::MyPool;
use self::mysql::error::MyResult;
use self::mysql::value::from_row;
use self::mysql::value::Value;
use std::clone::Clone;
use std::default::Default;
us... | finished_at: finished_at
}
}
}
#[derive(Clone, Debug)]
pub struct MysqlOptimizedUuid {
uuid: String
}
impl MysqlOptimizedUuid {
pub fn from_uuid (uuid: String) -> MysqlOptimizedUuid {
// the optimized way https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
let mut ordered_uuid... | started_at: started_at, | random_line_split |
record_backend.rs | extern crate chrono;
extern crate mysql;
use self::chrono::UTC;
use self::chrono::offset::TimeZone;
use self::mysql::conn::MyOpts;
use self::mysql::conn::pool::MyPool;
use self::mysql::error::MyResult;
use self::mysql::value::from_row;
use self::mysql::value::Value;
use std::clone::Clone;
use std::default::Default;
us... | {
CannotStoreRecord,
CannotFetchRecord,
CannotDenormalizeRecord,
RecordNotFound
}
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
pub struct MysqlConfig {
address: String,
username: String,
password: String,
database: String
}
impl MysqlConfig {
pub fn to_connection (&self) -> MysqlReposit... | RecordRepositoryError | identifier_name |
record_backend.rs | extern crate chrono;
extern crate mysql;
use self::chrono::UTC;
use self::chrono::offset::TimeZone;
use self::mysql::conn::MyOpts;
use self::mysql::conn::pool::MyPool;
use self::mysql::error::MyResult;
use self::mysql::value::from_row;
use self::mysql::value::Value;
use std::clone::Clone;
use std::default::Default;
us... |
};
results
}
fn fetch_record (&self, id: String) -> Result<(Record), RecordRepositoryError> {
let uuid_optimized = MysqlOptimizedUuid::from_uuid(id.clone());
let query = r"SELECT HEX(id) AS id, command, cwd, status, stderr, stdout, CAST(started_at AS char) AS started_at, CAST(finished_at AS char)... | {
error!("error fetching from mysql {:?}", err);
return Err(RecordRepositoryError::CannotDenormalizeRecord)
} | conditional_block |
mozmap.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 `MozMap` (open-ended dictionary) type.
use dom::bindings::conversions::jsid_to_string;
use dom::bindings:... | ConversionResult::Failure(message) => return Ok(ConversionResult::Failure(message)),
};
let key = jsid_to_string(cx, id.handle()).unwrap();
map.insert(key, property);
}
Ok(ConversionResult::Success(MozMap {
map: map,
}))
}
}
... | {
if !value.is_object() {
return Ok(ConversionResult::Failure("MozMap value was not an object".into()));
}
rooted!(in(cx) let object = value.to_object());
let ids = IdVector::new(cx);
assert!(GetPropertyKeys(cx, object.handle(), JSITER_OWNONLY, ids.get()));
... | identifier_body |
mozmap.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 `MozMap` (open-ended dictionary) type.
use dom::bindings::conversions::jsid_to_string;
use dom::bindings:... | where T: FromJSValConvertible<Config=C>,
C: Clone,
{
type Config = C;
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, config: C)
-> Result<ConversionResult<Self>, ()> {
if!value.is_object() {
return Ok(ConversionResult::Failure("MozMap valu... |
impl<T, C> FromJSValConvertible for MozMap<T> | random_line_split |
mozmap.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 `MozMap` (open-ended dictionary) type.
use dom::bindings::conversions::jsid_to_string;
use dom::bindings:... | () -> Self {
MozMap {
map: HashMap::new(),
}
}
}
impl<T> Deref for MozMap<T> {
type Target = HashMap<DOMString, T>;
fn deref(&self) -> &HashMap<DOMString, T> {
&self.map
}
}
impl<T, C> FromJSValConvertible for MozMap<T>
where T: FromJSValConvertible<Config=C>,
... | new | identifier_name |
lib.rs | // Copyright 2013-2015, The Rust-GNOME Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
/*!
Bindings and wrappers for __GTK__
To implement __GTK+__ inheritance in rust, we imp... | ProgressBar,
Arrow,
Calendar,
Alignment,
Expander,
Paned,
InfoBar,
Toolbar,
ToolItem,
SeparatorToolItem,
ToolButton,
ToggleToolButton,
MenuToolButton,
Dialog,
AboutDialog,
ColorChooserDialog,
FontChooserDialog,
MessageDialog,
NoteBook,
Over... | Range,
Scale,
SpinButton,
Spinner,
Image, | random_line_split |
privacy-struct-variant.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 foo = Bar { baz: 42 };
let Bar { baz: _ } = foo;
match foo { Bar { baz: _ } => {} }
}
}
fn main() {
let foo = a::Bar { baz: 42 };
//~^ ERROR: field `baz` of variant `Bar` of enum `a::Foo` is private
let a::Bar { baz: _ } = foo;
//~^ ERROR: field `baz` of variant `... | test | identifier_name |
privacy-struct-variant.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 ... | extern crate "privacy-struct-variant" as other;
mod a {
pub enum Foo {
Bar {
baz: int
}
}
fn test() {
let foo = Bar { baz: 42 };
let Bar { baz: _ } = foo;
match foo { Bar { baz: _ } => {} }
}
}
fn main() {
let foo = a::Bar { baz: 42 };
//~^... | random_line_split | |
privacy-struct-variant.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 foo = a::Bar { baz: 42 };
//~^ ERROR: field `baz` of variant `Bar` of enum `a::Foo` is private
let a::Bar { baz: _ } = foo;
//~^ ERROR: field `baz` of variant `Bar` of enum `a::Foo` is private
match foo { a::Bar { baz: _ } => {} }
//~^ ERROR: field `baz` of variant `Bar` of enum `a::Foo` ... | identifier_body | |
chip8.rs | extern crate sdl2;
use std::fs::File;
use std::io::prelude::*;
use std::time::{Duration, Instant};
#[cfg(feature="debugger")]
use std::process::Command;
use chip8::MEMORY_SIZE;
use chip8::ROM_START_ADDRESS;
use chip8::keyboard::Keyboard;
use chip8::display::Display;
#[cfg(feature="interpreter")]
use chip8::interpre... | chip8.memory[0x03] = 0x90;
chip8.memory[0x04] = 0xF0;
chip8.memory[0x05] = 0x20;
chip8.memory[0x06] = 0x60;
chip8.memory[0x07] = 0x20;
chip8.memory[0x08] = 0x20;
chip8.memory[0x09] = 0x70;
chip8.memory[0x0A] = 0xF0;
chip8.memory[0x0B] = 0x10;
chip8.memory[0x0C] = 0xF0;
chip8.memory[0x0D] = 0x80;... | {
let sdl_context = sdl2::init().unwrap();
let mut chip8 = Chip8 {
memory: [0; MEMORY_SIZE],
stack: [0; STACK_SIZE],
register_v: [0; V_REGISTERS_COUNT],
register_i: 0,
register_dt: 0,
register_st: 0,
register_pc: ROM_START_ADDRESS,
register_sp: 0xFF,
keyboard: Keyboard::new(&sdl_contex... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.