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
build.rs
extern crate rustc_version; extern crate rusoto_codegen; extern crate rayon; use std::env; use std::path::Path; use std::io::Write; use std::fs::File; use rusoto_codegen::{Service, generate}; use rayon::prelude::*; /// Parses and generates variables used to construct a User-Agent. /// /// This is used to create a Us...
["sqs", "2012-11-05"], ["ssm", "2014-11-06"], ["storagegateway", "2013-06-30"], ["sts", "2011-06-15"], ["swf", "2012-01-25"], ["waf", "2015-08-24"], ["workspaces", "2015-04-08"] }; let count: usize = services.into_par_iter().map(|service| generate(service...
["s3", "2006-03-01"], ["sdb", "2009-04-15"], ["sns", "2010-03-31"],
random_line_split
build.rs
extern crate rustc_version; extern crate rusoto_codegen; extern crate rayon; use std::env; use std::path::Path; use std::io::Write; use std::fs::File; use rusoto_codegen::{Service, generate}; use rayon::prelude::*; /// Parses and generates variables used to construct a User-Agent. /// /// This is used to create a Us...
/* gamelift/2015-10-01/service-2.json: "protocol":"json" support/2013-04-15/service-2.json: "protocol":"json" */ // expand to use cfg!() so codegen only gets run for services // in the features list macro_rules! services { ( $( [$name:expr, $date:expr] ),* ) => { { let mut services = Ve...
{ let rust_version = rustc_version::version(); let mut f = File::create(&output_path.join("user_agent_vars.rs")) .expect("Could not create user agent file"); f.write_all(format!("static RUST_VERSION: &'static str = \"{}\";", rust_version).as_bytes()) .expect("Unable to write user age...
identifier_body
build.rs
extern crate rustc_version; extern crate rusoto_codegen; extern crate rayon; use std::env; use std::path::Path; use std::io::Write; use std::fs::File; use rusoto_codegen::{Service, generate}; use rayon::prelude::*; /// Parses and generates variables used to construct a User-Agent. /// /// This is used to create a Us...
}
{ println!("cargo:rerun-if-changed=codegen"); }
conditional_block
build.rs
extern crate rustc_version; extern crate rusoto_codegen; extern crate rayon; use std::env; use std::path::Path; use std::io::Write; use std::fs::File; use rusoto_codegen::{Service, generate}; use rayon::prelude::*; /// Parses and generates variables used to construct a User-Agent. /// /// This is used to create a Us...
(output_path: &Path) { let rust_version = rustc_version::version(); let mut f = File::create(&output_path.join("user_agent_vars.rs")) .expect("Could not create user agent file"); f.write_all(format!("static RUST_VERSION: &'static str = \"{}\";", rust_version).as_bytes()) .expect("Unabl...
generate_user_agent_vars
identifier_name
p041.rs
//! [Problem 41](https://projecteuler.net/problem=41) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use iter::Permutations; use prime::PrimeSet; // 1 + 2 +... + 9 = 45 (dividable by 9 => 9-pandigi...
() -> String { compute().to_string() } common::problem!("7652413", solve);
solve
identifier_name
p041.rs
//! [Problem 41](https://projecteuler.net/problem=41) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use iter::Permutations; use prime::PrimeSet; // 1 + 2 +... + 9 = 45 (dividable by 9 => 9-pandigi...
} unreachable!() } fn solve() -> String { compute().to_string() } common::problem!("7652413", solve);
{ return n; }
conditional_block
p041.rs
//! [Problem 41](https://projecteuler.net/problem=41) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use iter::Permutations; use prime::PrimeSet; // 1 + 2 +... + 9 = 45 (dividable by 9 => 9-pandigi...
fn solve() -> String { compute().to_string() } common::problem!("7652413", solve);
{ let radix = 10; let ps = PrimeSet::new(); for (perm, _) in Permutations::new(&[7, 6, 5, 4, 3, 2, 1], 7) { let n = Integer::from_digits(perm.iter().rev().copied(), radix); if ps.contains(n) { return n; } } unreachable!() }
identifier_body
line.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program 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 ve...
impl Extend<String> for LineCollection { fn extend<T: IntoIterator<Item = String>>(&mut self, iter: T) { for item in iter { self.add(item); } self.clear_excess(); } } pub struct ParserState<'a, I> where I: DoubleEndedIterator<Item = &'a Line> { iterator: I, pa...
random_line_split
line.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program 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 ve...
{ pub content_without_ansi: String, pub components: Option<ComponentCollection>, pub width: usize, } impl Line { pub fn new(content: String) -> Line { let has_ansi = content.has_ansi_escape_sequence(); let (content_without_ansi, components) = if has_ansi { (content.strip_a...
Line
identifier_name
line.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program 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 ve...
fn clear_excess(&mut self) { while self.entries.len() > self.capacity { self.entries.pop_front(); } } pub fn len(&self) -> usize { self.entries.len() } fn add(&mut self, item: String) { self.entries.push_back(Line::new(item)); } } impl Extend<Stri...
{ LineCollection { entries: VecDeque::new(), capacity: capacity, } }
identifier_body
line.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program 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 ve...
FilterParserResult::Invalid(append) => { self.pending.clear(); if append { self.pending.push(line); } } FilterParserResult::NoMatch => {} } ...
{ match_found = true; if append { self.pending.push(line); } break; }
conditional_block
deriving-cmp-generic-struct.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 ...
// TotalEq assert_eq!(s1.equals(s2), eq); // Ord assert_eq!(*s1 < *s2, lt); assert_eq!(*s1 > *s2, gt); assert_eq!(*s1 <= *s2, le); assert_eq!(*s1 >= *s2, ge); // TotalOrd assert_eq!(s1.cmp(s2), ord); ...
{ let s1 = S {x: 1, y: 1}; let s2 = S {x: 1, y: 2}; // in order for both Ord and TotalOrd let ss = [s1, s2]; for (i, s1) in ss.iter().enumerate() { for (j, s2) in ss.iter().enumerate() { let ord = i.cmp(&j); let eq = i == j; let lt = i < j; ...
identifier_body
deriving-cmp-generic-struct.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 ...
y: T } pub fn main() { let s1 = S {x: 1, y: 1}; let s2 = S {x: 1, y: 2}; // in order for both Ord and TotalOrd let ss = [s1, s2]; for (i, s1) in ss.iter().enumerate() { for (j, s2) in ss.iter().enumerate() { let ord = i.cmp(&j); let eq = i == j; le...
#[deriving(Eq, TotalEq, Ord, TotalOrd)] struct S<T> { x: T,
random_line_split
deriving-cmp-generic-struct.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 ...
() { let s1 = S {x: 1, y: 1}; let s2 = S {x: 1, y: 2}; // in order for both Ord and TotalOrd let ss = [s1, s2]; for (i, s1) in ss.iter().enumerate() { for (j, s2) in ss.iter().enumerate() { let ord = i.cmp(&j); let eq = i == j; let lt = i < j; ...
main
identifier_name
mod.rs
//! Thrift generated Jaeger client //! //! Definitions: <https://github.com/uber/jaeger-idl/blob/master/thrift/> use std::time::{Duration, SystemTime}; use opentelemetry::trace::Event; use opentelemetry::{Key, KeyValue, Value}; pub(crate) mod agent; pub(crate) mod jaeger; pub(crate) mod zipkincore; impl From<super::...
(process: super::Process) -> jaeger::Process { jaeger::Process::new( process.service_name, Some(process.tags.into_iter().map(Into::into).collect()), ) } } impl From<Event> for jaeger::Log { fn from(event: crate::exporter::Event) -> jaeger::Log { let timestamp = e...
from
identifier_name
mod.rs
//! Thrift generated Jaeger client //! //! Definitions: <https://github.com/uber/jaeger-idl/blob/master/thrift/> use std::time::{Duration, SystemTime}; use opentelemetry::trace::Event; use opentelemetry::{Key, KeyValue, Value};
impl From<super::Process> for jaeger::Process { fn from(process: super::Process) -> jaeger::Process { jaeger::Process::new( process.service_name, Some(process.tags.into_iter().map(Into::into).collect()), ) } } impl From<Event> for jaeger::Log { fn from(event: crate:...
pub(crate) mod agent; pub(crate) mod jaeger; pub(crate) mod zipkincore;
random_line_split
mod.rs
//! Thrift generated Jaeger client //! //! Definitions: <https://github.com/uber/jaeger-idl/blob/master/thrift/> use std::time::{Duration, SystemTime}; use opentelemetry::trace::Event; use opentelemetry::{Key, KeyValue, Value}; pub(crate) mod agent; pub(crate) mod jaeger; pub(crate) mod zipkincore; impl From<super::...
} if event.dropped_attributes_count!= 0 { fields.push( Key::new("otel.event.dropped_attributes_count") .i64(i64::from(event.dropped_attributes_count)) .into(), ); } jaeger::Log::new(timestamp, fields) } ...
{ let timestamp = event .timestamp .duration_since(SystemTime::UNIX_EPOCH) .unwrap_or_else(|_| Duration::from_secs(0)) .as_micros() as i64; let mut event_set_via_attribute = false; let mut fields = event .attributes .into_it...
identifier_body
main.rs
#[cfg_attr(feature="clippy", allow(needless_range_loop))] fn counting_sort(array: &mut [i32], min: i32, max: i32) { // nothing to do for arrays shorter than 2 if array.len() < 2 { return; } // we count occurences of values let size = (max - min + 1) as usize; let mut count = vec![0; siz...
() { let numbers = &mut [4i32, 65, 2, -31, 0, 99, 2, 83, 782, 1]; check_sort(numbers, -31, 782); } #[test] fn one_element_vector() { let numbers = &mut [0i32]; check_sort(numbers, 0, 0); } #[test] fn repeat_vector() { let numbers = &mut [1i32, 1, 1, 1, 1...
rosetta_vector
identifier_name
main.rs
#[cfg_attr(feature="clippy", allow(needless_range_loop))] fn counting_sort(array: &mut [i32], min: i32, max: i32) { // nothing to do for arrays shorter than 2 if array.len() < 2 { return; } // we count occurences of values let size = (max - min + 1) as usize;
count[(*e - min) as usize] += 1; } // then we write values back, sorted let mut index = 0; for value in 0..count.len() { for _ in 0..count[value] { array[index] = value as i32; index += 1; } } } fn main() { let mut numbers = [4i32, 65, 2, -31, 0,...
let mut count = vec![0; size]; for e in array.iter() {
random_line_split
main.rs
#[cfg_attr(feature="clippy", allow(needless_range_loop))] fn counting_sort(array: &mut [i32], min: i32, max: i32) { // nothing to do for arrays shorter than 2 if array.len() < 2 { return; } // we count occurences of values let size = (max - min + 1) as usize; let mut count = vec![0; siz...
#[test] fn worst_case_vector() { let numbers = &mut [20i32, 10, 0, -1, -5]; check_sort(numbers, -5, 20); } #[test] fn already_sorted_vector() { let numbers = &mut [-1i32, 0, 3, 6, 99]; check_sort(numbers, -1, 99); } #[test] #[should_panic] fn bad_m...
{ let numbers = &mut [1i32, 1, 1, 1, 1]; check_sort(numbers, 1, 1); }
identifier_body
main.rs
#[cfg_attr(feature="clippy", allow(needless_range_loop))] fn counting_sort(array: &mut [i32], min: i32, max: i32) { // nothing to do for arrays shorter than 2 if array.len() < 2
// we count occurences of values let size = (max - min + 1) as usize; let mut count = vec![0; size]; for e in array.iter() { count[(*e - min) as usize] += 1; } // then we write values back, sorted let mut index = 0; for value in 0..count.len() { for _ in 0..count[valu...
{ return; }
conditional_block
struct-style-enum.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ Case1 { a: u64, b: u16, c: u16, d: u16, e: u16}, Case2 { a: u64, b: u32, c: u32}, Case3 { a: u64, b: u64 } } enum Univariant { TheOnlyCase { a: i64 } } fn main() { // In order to avoid endianess trouble all of the following test values consist of a single // repeated byte. This way each in...
Regular
identifier_name
struct-style-enum.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// the size of the discriminant value is machine dependent, this has be taken into account when // datatype layout should be predictable as in this case. enum Regular { Case1 { a: u64, b: u16, c: u16, d: u16, e: u16}, Case2 { a: u64, b: u32, c: u32}, Case3 { a: u64, b: u64 } } enum Univariant { TheOnly...
#![allow(unused_variable)] #![feature(struct_variant)] // The first element is to ensure proper alignment, irrespective of the machines word size. Since
random_line_split
parameters.rs
use http_types::Method; use std::borrow::Cow; #[derive(Clone, Debug)] pub enum Parameters { Query(String), Body(String), } use std::{ iter::Map, slice::Iter, }; // This newtype is currently only used internally here, but we might want to move it elsewhere where // it could be more useful because of g...
(method: &Method) -> bool { match *method { Method::GET | Method::HEAD | Method::DELETE => false, _ => true, } } pub fn path_and_query<'p>(&self, path: &'p str) -> Cow<'p, str> { self.query().map_or_else(|| Cow::Borrowed(path), |q...
method_requires_body
identifier_name
parameters.rs
use http_types::Method; use std::borrow::Cow; #[derive(Clone, Debug)] pub enum Parameters { Query(String), Body(String), } use std::{ iter::Map, slice::Iter, }; // This newtype is currently only used internally here, but we might want to move it elsewhere where // it could be more useful because of g...
}
{ let params_str = (1..10).map(|i| (format!("unakey{}", i), format!("unvalor{}", i))) .collect::<Vec<_>>(); let params = params_str.iter() .map(|(k, v)| (k.as_str().into(), v.as_str())) .collect::<Vec<(Cow<str...
identifier_body
parameters.rs
use http_types::Method; use std::borrow::Cow; #[derive(Clone, Debug)] pub enum Parameters { Query(String), Body(String), } use std::{ iter::Map, slice::Iter, }; // This newtype is currently only used internally here, but we might want to move it elsewhere where // it could be more useful because of g...
fn params_to_query<S: AsRef<str>>(params: &[(Cow<str>, S)]) -> String { Self::params_to_vec(params).join("&") } } #[cfg(all(test, feature = "nightly"))] mod benches { use super::*; use test::Bencher; #[bench] fn bench_params_to_query(b: &mut Bencher) { let params_str = (1..10)....
Self::params_to_string_collection(params).collect() }
random_line_split
total_count.rs
use collectors::{Collector, DocumentMatch}; #[derive(Debug)] pub struct TotalCountCollector { total_count: u64, } impl TotalCountCollector { pub fn new() -> TotalCountCollector { TotalCountCollector { total_count: 0, } } pub fn get_total_count(&self) -> u64 { self....
#[cfg(test)] mod tests { use collectors::{Collector, DocumentMatch}; use super::TotalCountCollector; #[test] fn test_total_count_collector_inital_state() { let collector = TotalCountCollector::new(); assert_eq!(collector.get_total_count(), 0); } #[test] fn test_total_coun...
fn collect(&mut self, _doc: DocumentMatch) { self.total_count += 1; } }
random_line_split
total_count.rs
use collectors::{Collector, DocumentMatch}; #[derive(Debug)] pub struct TotalCountCollector { total_count: u64, } impl TotalCountCollector { pub fn new() -> TotalCountCollector { TotalCountCollector { total_count: 0, } } pub fn get_total_count(&self) -> u64 { self....
() { let collector = TotalCountCollector::new(); assert_eq!(collector.needs_score(), false); } #[test] fn test_total_count_collector_collect() { let mut collector = TotalCountCollector::new(); collector.collect(DocumentMatch::new_unscored(0)); collector.collect(Doc...
test_total_count_collector_needs_score
identifier_name
destructure-trait-ref.rs
// The regression test for #15031 to make sure destructuring trait // reference work properly. #![feature(box_patterns)] #![feature(box_syntax)] trait T { fn foo(&self)
} impl T for isize {} fn main() { // For an expression of the form: // // let &...&x = &..&SomeTrait; // // Say we have n `&` at the left hand and m `&` right hand, then: // if n < m, we are golden; // if n == m, it's a derefing non-derefable type error; // if n > m, it's a type m...
{}
identifier_body
destructure-trait-ref.rs
// The regression test for #15031 to make sure destructuring trait // reference work properly. #![feature(box_patterns)] #![feature(box_syntax)] trait T { fn
(&self) {} } impl T for isize {} fn main() { // For an expression of the form: // // let &...&x = &..&SomeTrait; // // Say we have n `&` at the left hand and m `&` right hand, then: // if n < m, we are golden; // if n == m, it's a derefing non-derefable type error; // if n > m, it'...
foo
identifier_name
destructure-trait-ref.rs
// The regression test for #15031 to make sure destructuring trait // reference work properly. #![feature(box_patterns)]
trait T { fn foo(&self) {} } impl T for isize {} fn main() { // For an expression of the form: // // let &...&x = &..&SomeTrait; // // Say we have n `&` at the left hand and m `&` right hand, then: // if n < m, we are golden; // if n == m, it's a derefing non-derefable type error; ...
#![feature(box_syntax)]
random_line_split
lib.rs
// Helianto -- static website generator // Copyright © 2015-2016 Mickaël RAYBAUD-ROIG // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your...
mut self) -> Result<()> { self.check_settings()?; self.load_templates()?; let entries = WalkDir::new(&self.settings.source_dir) .min_depth(1) .max_depth(self.settings.max_depth) .follow_links(self.settings.follow_links) .into_iter(); for entr...
n(&
identifier_name
lib.rs
// Helianto -- static website generator // Copyright © 2015-2016 Mickaël RAYBAUD-ROIG // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your...
.and_then(|_| { self.documents.insert( dest.to_str().unwrap().into(), Rc::new(document.metadata.clone()), ); Ok(()) }) } fn copy_file(&mut self, path: &Path) -> Result<()> { let dest = path ...
random_line_split
lib.rs
// Helianto -- static website generator // Copyright © 2015-2016 Mickaël RAYBAUD-ROIG // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your...
pub fn add_generator<T: Generator +'static>(&mut self) { self.generators.push(Rc::new(T::new())); } fn load_templates(&mut self) -> Result<()> { self.handlebars.clear_templates(); templates::register_helpers(&mut self.handlebars); let loader = &mut templates::Loader::new(&m...
let reader = Rc::new(T::new(&self.settings)); for &extension in T::extensions() { self.readers.insert(extension.into(), reader.clone()); } }
identifier_body
orphan.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 ...
.span_label(sp, "impl doesn't use types inside crate") .note("the impl does not reference any types defined in this crate") .note("define and implement a trait or new type instead") .emit(); return; ...
struct_span_err!(self.tcx.sess, sp, E0117, "only traits defined in the current crate can be \ implemented for arbitrary types")
random_line_split
orphan.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
struct OrphanChecker<'cx, 'tcx: 'cx> { tcx: TyCtxt<'cx, 'tcx, 'tcx>, } impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { /// Checks exactly one impl for orphan rules and other such /// restrictions. In this fn, it can happen that multiple errors /// apply to a specific impl, so ...
{ let mut orphan = OrphanChecker { tcx }; tcx.hir().krate().visit_all_item_likes(&mut orphan); }
identifier_body
orphan.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 ...
<'cx, 'tcx: 'cx> { tcx: TyCtxt<'cx, 'tcx, 'tcx>, } impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { /// Checks exactly one impl for orphan rules and other such /// restrictions. In this fn, it can happen that multiple errors /// apply to a specific impl, so just return after repo...
OrphanChecker
identifier_name
cast_sign_loss.rs
use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint; use clippy_utils::{method_chain_args, sext}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::CAST_SIGN_LOSS; pub(super) fn check(cx: &LateContext...
return false; } // Don't lint for positive constants. let const_val = constant(cx, cx.typeck_results(), cast_op); if_chain! { if let Some((Constant::Int(n), _)) = const_val; if let ty::Int(ity) = *cast_from.kind(); ...
fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) -> bool { match (cast_from.is_integral(), cast_to.is_integral()) { (true, true) => { if !cast_from.is_signed() || cast_to.is_signed() {
random_line_split
cast_sign_loss.rs
use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint; use clippy_utils::{method_chain_args, sext}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::CAST_SIGN_LOSS; pub(super) fn check(cx: &LateContext...
true }, (false, true) =>!cast_to.is_signed(), (_, _) => false, } }
{ let mut method_name = path.ident.name.as_str(); let allowed_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"]; if_chain! { if method_name == "unwrap"; if let Some(arglist) = method_chain_args(cast_op, &["unwrap...
conditional_block
cast_sign_loss.rs
use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint; use clippy_utils::{method_chain_args, sext}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::CAST_SIGN_LOSS; pub(super) fn check(cx: &LateContext...
(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) -> bool { match (cast_from.is_integral(), cast_to.is_integral()) { (true, true) => { if!cast_from.is_signed() || cast_to.is_signed() { return false; } // Don't lint for positiv...
should_lint
identifier_name
cast_sign_loss.rs
use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint; use clippy_utils::{method_chain_args, sext}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::CAST_SIGN_LOSS; pub(super) fn check(cx: &LateContext...
let mut method_name = path.ident.name.as_str(); let allowed_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"]; if_chain! { if method_name == "unwrap"; if let Some(arglist) = method_chain_args(cast_op, &["unwrap"]...
{ match (cast_from.is_integral(), cast_to.is_integral()) { (true, true) => { if !cast_from.is_signed() || cast_to.is_signed() { return false; } // Don't lint for positive constants. let const_val = constant(cx, cx.typeck_results(), cast_op); ...
identifier_body
history.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::HistoryBinding; use dom::bindings::codegen::Bindings::HistoryBinding::Histor...
} impl History { fn traverse_history(&self, direction: TraversalDirection) { let pipeline = self.window.pipeline_id(); let msg = ConstellationMsg::TraverseHistory(Some(pipeline), direction); let _ = self.window.constellation_chan().send(msg); } } impl HistoryMethods for History { ...
{ reflect_dom_object(box History::new_inherited(window), GlobalRef::Window(window), HistoryBinding::Wrap) }
identifier_body
history.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::HistoryBinding; use dom::bindings::codegen::Bindings::HistoryBinding::Histor...
else { self.window.Location().Reload(); return; }; self.traverse_history(direction); } // https://html.spec.whatwg.org/multipage/#dom-history-back fn Back(&self) { self.traverse_history(TraversalDirection::Back(1)); } // https://html.spec.whatwg.or...
{ TraversalDirection::Back(-delta as usize) }
conditional_block
history.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::HistoryBinding; use dom::bindings::codegen::Bindings::HistoryBinding::Histor...
} impl HistoryMethods for History { // https://html.spec.whatwg.org/multipage/#dom-history-length fn Length(&self) -> u32 { let pipeline = self.window.pipeline_id(); let (sender, recv) = ipc::channel().expect("Failed to create channel to send jsh length."); let msg = ConstellationMsg::J...
}
random_line_split
history.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::HistoryBinding; use dom::bindings::codegen::Bindings::HistoryBinding::Histor...
{ reflector_: Reflector, window: JS<Window>, } impl History { pub fn new_inherited(window: &Window) -> History { History { reflector_: Reflector::new(), window: JS::from_ref(&window), } } pub fn new(window: &Window) -> Root<History> { reflect_dom_ob...
History
identifier_name
merkletree.rs
use services::ledger::merkletree::tree::{ Tree, LeavesIterator, LeavesIntoIterator, TreeLeafData }; use services::ledger::merkletree::proof::{ Proof, Lemma }; use utils::crypto::hash::{Hash, HASH_OUTPUT_LEN}; use errors::crypto::CryptoError; /// A Merkle tree is a binary tree, with values of type `T` at the leafs, ///...
} debug_assert!(cur.len() == 1); let root = cur.remove(0); Ok(MerkleTree { root: root, height: height, count: count, nodes_count: nodes_count }) } /// Returns the root hash of Merkle tree pub fn root_hash(&self) -> &...
cur = next;
random_line_split
merkletree.rs
use services::ledger::merkletree::tree::{ Tree, LeavesIterator, LeavesIntoIterator, TreeLeafData }; use services::ledger::merkletree::proof::{ Proof, Lemma }; use utils::crypto::hash::{Hash, HASH_OUTPUT_LEN}; use errors::crypto::CryptoError; /// A Merkle tree is a binary tree, with values of type `T` at the leafs, ///...
(self) -> Self::IntoIter { self.root.iter() } }
into_iter
identifier_name
merkletree.rs
use services::ledger::merkletree::tree::{ Tree, LeavesIterator, LeavesIntoIterator, TreeLeafData }; use services::ledger::merkletree::proof::{ Proof, Lemma }; use utils::crypto::hash::{Hash, HASH_OUTPUT_LEN}; use errors::crypto::CryptoError; /// A Merkle tree is a binary tree, with values of type `T` at the leafs, ///...
let count = values.len(); let mut nodes_count = 0; let mut height = 0; let mut cur = Vec::with_capacity(count); for v in values { let leaf = Tree::new_leaf(v)?; cur.push(leaf); } while cur.len() > 1 { let mut next = Vec::...
{ return Ok(MerkleTree { root: Tree::empty(Hash::hash_empty()?), height: 0, count: 0, nodes_count: 0 }); }
conditional_block
merkletree.rs
use services::ledger::merkletree::tree::{ Tree, LeavesIterator, LeavesIntoIterator, TreeLeafData }; use services::ledger::merkletree::proof::{ Proof, Lemma }; use utils::crypto::hash::{Hash, HASH_OUTPUT_LEN}; use errors::crypto::CryptoError; /// A Merkle tree is a binary tree, with values of type `T` at the leafs, ///...
/// Returns whether the Merkle tree is empty or not pub fn is_empty(&self) -> bool { self.count() == 0 } /// Generate an inclusion proof for the given value. /// Returns `None` if the given value is not found in the tree. pub fn gen_proof(&self, value: TreeLeafData) -> Result<Option<P...
{ self.count }
identifier_body
panic_in_result_fn_debug_assertions.rs
#![warn(clippy::panic_in_result_fn)] #![allow(clippy::unnecessary_wraps)] // debug_assert should never trigger the `panic_in_result_fn` lint struct A; impl A { fn
(x: i32) -> Result<bool, String> { debug_assert!(x == 5, "wrong argument"); Ok(true) } fn result_with_debug_assert_eq(x: i32) -> Result<bool, String> { debug_assert_eq!(x, 5); Ok(true) } fn result_with_debug_assert_ne(x: i32) -> Result<bool, String> { debug_asse...
result_with_debug_assert_with_message
identifier_name
panic_in_result_fn_debug_assertions.rs
#![warn(clippy::panic_in_result_fn)] #![allow(clippy::unnecessary_wraps)] // debug_assert should never trigger the `panic_in_result_fn` lint struct A; impl A { fn result_with_debug_assert_with_message(x: i32) -> Result<bool, String> { debug_assert!(x == 5, "wrong argument"); Ok(true) } f...
{}
identifier_body
panic_in_result_fn_debug_assertions.rs
#![warn(clippy::panic_in_result_fn)] #![allow(clippy::unnecessary_wraps)]
// debug_assert should never trigger the `panic_in_result_fn` lint struct A; impl A { fn result_with_debug_assert_with_message(x: i32) -> Result<bool, String> { debug_assert!(x == 5, "wrong argument"); Ok(true) } fn result_with_debug_assert_eq(x: i32) -> Result<bool, String> { deb...
random_line_split
htmltabledatacellelement.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::HTMLTableDataCellElementBinding; use dom::document::AbstractDocument; use dom::element...
(localName: ~str, document: AbstractDocument) -> HTMLTableDataCellElement { HTMLTableDataCellElement { htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document) } } pub fn new(localName: ~str, document: AbstractDocument) -> Abstra...
new_inherited
identifier_name
htmltabledatacellelement.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::HTMLTableDataCellElementBinding; use dom::document::AbstractDocument; use dom::element...
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { let element = HTMLTableDataCellElement::new_inherited(localName, document); Node::reflect_node(@mut element, document, HTMLTableDataCellElementBinding::Wrap) } }
{ HTMLTableDataCellElement { htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document) } }
identifier_body
htmltabledatacellelement.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::HTMLTableDataCellElementBinding; use dom::document::AbstractDocument; use dom::element...
pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLTableDataCellElement { HTMLTableDataCellElement { htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document) } } pub fn new(localName: ~str, document: Abs...
} impl HTMLTableDataCellElement {
random_line_split
_9_1_geometry_shader_houses.rs
#![allow(non_upper_case_globals)] #![allow(non_snake_case)] use std::ptr; use std::mem; use std::os::raw::c_void; extern crate glfw; use self::glfw::Context; extern crate gl; use self::gl::types::*; use cgmath::{Point3}; use common::{process_events, processInput}; use shader::Shader; use camera::Camera; // settin...
() { let mut camera = Camera { Position: Point3::new(0.0, 0.0, 3.0), ..Camera::default() }; let mut firstMouse = true; let mut lastX: f32 = SCR_WIDTH as f32 / 2.0; let mut lastY: f32 = SCR_HEIGHT as f32 / 2.0; // timing let mut deltaTime: f32; // time between current frame a...
main_4_9_1
identifier_name
_9_1_geometry_shader_houses.rs
#![allow(non_upper_case_globals)] #![allow(non_snake_case)] use std::ptr; use std::mem; use std::os::raw::c_void; extern crate glfw; use self::glfw::Context; extern crate gl; use self::gl::types::*; use cgmath::{Point3}; use common::{process_events, processInput}; use shader::Shader; use camera::Camera; // settin...
glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true)); // glfw window creation // -------------------- let (mut window, events) = glfw.create_window(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", glfw::WindowMode::Windowed) .expect("Failed to create GLFW window"); window.make_current(); ...
{ let mut camera = Camera { Position: Point3::new(0.0, 0.0, 3.0), ..Camera::default() }; let mut firstMouse = true; let mut lastX: f32 = SCR_WIDTH as f32 / 2.0; let mut lastY: f32 = SCR_HEIGHT as f32 / 2.0; // timing let mut deltaTime: f32; // time between current frame and...
identifier_body
_9_1_geometry_shader_houses.rs
#![allow(non_upper_case_globals)] #![allow(non_snake_case)] use std::ptr; use std::mem; use std::os::raw::c_void; extern crate glfw; use self::glfw::Context; extern crate gl; use self::gl::types::*; use cgmath::{Point3}; use common::{process_events, processInput}; use shader::Shader; use camera::Camera; // settin...
processInput(&mut window, deltaTime, &mut camera); // render // ------ unsafe { gl::ClearColor(0.1, 0.1, 0.1, 1.0); gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT); shader.useProgram(); gl::BindVertexArray(VAO); gl::Dra...
// input // -----
random_line_split
mod.rs
mod env; mod model; mod uploader; use async_trait::async_trait; use http::Uri; use model::endpoint::Endpoint; use opentelemetry::sdk::resource::ResourceDetector; use opentelemetry::sdk::resource::SdkProvidedResourceDetector; use opentelemetry::sdk::trace::Config; use opentelemetry::sdk::Resource; use opentelemetry::{ ...
/// Assign client implementation pub fn with_http_client<T: HttpClient +'static>(mut self, client: T) -> Self { self.client = Some(Box::new(client)); self } /// Assign the service name under which to group traces. pub fn with_service_address(mut self, addr: SocketAddr) -> Self { ...
/// Assign the service name under which to group traces. pub fn with_service_name<T: Into<String>>(mut self, name: T) -> Self { self.service_name = Some(name.into()); self }
random_line_split
mod.rs
mod env; mod model; mod uploader; use async_trait::async_trait; use http::Uri; use model::endpoint::Endpoint; use opentelemetry::sdk::resource::ResourceDetector; use opentelemetry::sdk::resource::SdkProvidedResourceDetector; use opentelemetry::sdk::trace::Config; use opentelemetry::sdk::Resource; use opentelemetry::{ ...
(local_endpoint: Endpoint, client: Box<dyn HttpClient>, collector_endpoint: Uri) -> Self { Exporter { local_endpoint, uploader: uploader::Uploader::new(client, collector_endpoint), } } } /// Create a new Zipkin exporter pipeline builder. pub fn new_pipeline() -> ZipkinPipeli...
new
identifier_name
mod.rs
mod env; mod model; mod uploader; use async_trait::async_trait; use http::Uri; use model::endpoint::Endpoint; use opentelemetry::sdk::resource::ResourceDetector; use opentelemetry::sdk::resource::SdkProvidedResourceDetector; use opentelemetry::sdk::trace::Config; use opentelemetry::sdk::Resource; use opentelemetry::{ ...
else { let service_name = SdkProvidedResourceDetector .detect(Duration::from_secs(0)) .get(semcov::resource::SERVICE_NAME) .unwrap() .to_string(); ( Config { // use a empty resource to prevent Tracer...
{ let config = if let Some(mut cfg) = self.trace_config.take() { cfg.resource = cfg.resource.map(|r| { let without_service_name = r .iter() .filter(|(k, _v)| **k != semcov::resource::SERVICE_NAME) .ma...
conditional_block
mod.rs
mod env; mod model; mod uploader; use async_trait::async_trait; use http::Uri; use model::endpoint::Endpoint; use opentelemetry::sdk::resource::ResourceDetector; use opentelemetry::sdk::resource::SdkProvidedResourceDetector; use opentelemetry::sdk::trace::Config; use opentelemetry::sdk::Resource; use opentelemetry::{ ...
} /// Create a new Zipkin exporter pipeline builder. pub fn new_pipeline() -> ZipkinPipelineBuilder { ZipkinPipelineBuilder::default() } /// Builder for `ExporterConfig` struct. #[derive(Debug)] pub struct ZipkinPipelineBuilder { service_name: Option<String>, service_addr: Option<SocketAddr>, collect...
{ Exporter { local_endpoint, uploader: uploader::Uploader::new(client, collector_endpoint), } }
identifier_body
instance_metadata.rs
//! The Credentials Provider for an AWS Resource's IAM Role. use async_trait::async_trait; use hyper::Uri; use std::time::Duration; use crate::request::HttpClient; use crate::{ parse_credentials_from_aws_service, AwsCredentials, CredentialsError, ProvideAwsCredentials, }; const AWS_CREDENTIALS_PROVIDER_IP: &str ...
(&self) -> Result<AwsCredentials, CredentialsError> { let role_name = get_role_name(&self.client, self.timeout, &self.metadata_ip_addr) .await .map_err(|err| CredentialsError { message: format!("Could not get credentials from iam: {}", err.to_string()), })?; ...
credentials
identifier_name
instance_metadata.rs
//! The Credentials Provider for an AWS Resource's IAM Role. use async_trait::async_trait; use hyper::Uri; use std::time::Duration; use crate::request::HttpClient; use crate::{ parse_credentials_from_aws_service, AwsCredentials, CredentialsError, ProvideAwsCredentials, }; const AWS_CREDENTIALS_PROVIDER_IP: &str ...
} /// Gets the role name to get credentials for using the IAM Metadata Service (169.254.169.254). async fn get_role_name( client: &HttpClient, timeout: Duration, ip_addr: &str, ) -> Result<String, CredentialsError> { let role_name_address = format!("http://{}/{}/", ip_addr, AWS_CREDENTIALS_PROVIDER_PA...
{ let role_name = get_role_name(&self.client, self.timeout, &self.metadata_ip_addr) .await .map_err(|err| CredentialsError { message: format!("Could not get credentials from iam: {}", err.to_string()), })?; let cred_str = get_credentials_from_role( ...
identifier_body
instance_metadata.rs
//! The Credentials Provider for an AWS Resource's IAM Role. use async_trait::async_trait; use hyper::Uri; use std::time::Duration; use crate::request::HttpClient; use crate::{ parse_credentials_from_aws_service, AwsCredentials, CredentialsError, ProvideAwsCredentials, }; const AWS_CREDENTIALS_PROVIDER_IP: &str ...
self.metadata_ip_addr = format!("{}:{}", ip, port); } } impl Default for InstanceMetadataProvider { fn default() -> Self { Self::new() } } #[async_trait] impl ProvideAwsCredentials for InstanceMetadataProvider { async fn credentials(&self) -> Result<AwsCredentials, CredentialsError> { ...
self.timeout = timeout; } /// Allow overriding host and port of instance metadata service. pub fn set_ip_addr_with_port(&mut self, ip: &str, port: &str) {
random_line_split
test_cargo_profiles.rs
use std::env; use std::path::MAIN_SEPARATOR as SEP; use support::{project, execs}; use support::{COMPILING, RUNNING}; use hamcrest::assert_that; fn setup()
test!(profile_overrides { let mut p = project("foo"); p = p .file("Cargo.toml", r#" [package] name = "test" version = "0.0.0" authors = [] [profile.dev] opt-level = 1 debug = false rpath = true "#)...
{ }
identifier_body
test_cargo_profiles.rs
use std::env; use std::path::MAIN_SEPARATOR as SEP; use support::{project, execs}; use support::{COMPILING, RUNNING}; use hamcrest::assert_that; fn
() { } test!(profile_overrides { let mut p = project("foo"); p = p .file("Cargo.toml", r#" [package] name = "test" version = "0.0.0" authors = [] [profile.dev] opt-level = 1 debug = false rpath = true ...
setup
identifier_name
test_cargo_profiles.rs
use std::env; use std::path::MAIN_SEPARATOR as SEP; use support::{project, execs}; use support::{COMPILING, RUNNING}; use hamcrest::assert_that; fn setup() { } test!(profile_overrides { let mut p = project("foo"); p = p .file("Cargo.toml", r#" [package] name = "test" ...
--emit=dep-info,link \ -L dependency={dir}{sep}target{sep}release \ -L dependency={dir}{sep}target{sep}release{sep}deps \ --extern foo={dir}{sep}target{sep}release{sep}deps{sep}\ {prefix}foo-[..]{suffix} \ --extern foo={dir}{sep}target{sep}release{sep}deps{se...
-g \ -C metadata=[..] \ -C extra-filename=-[..] \ --out-dir {dir}{sep}target{sep}release \
random_line_split
font.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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern crate core_foundation; extern crate core_graphics; exte...
fn au_from_pt(pt: f64) -> Au { Au::from_f64_px(pt_to_px(pt)) } impl FontTable { pub fn wrap(data: CFData) -> FontTable { FontTable { data: data } } } impl FontTableMethods for FontTable { fn buffer(&self) -> &[u8] { self.data.bytes() } } #[derive(Debug)] pub struct FontHandle { ...
{ pt / 72. * 96. }
identifier_body
font.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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern crate core_foundation; extern crate core_graphics; exte...
(&self) -> String { self.ctfont.family_name() } fn face_name(&self) -> String { self.ctfont.face_name() } fn is_italic(&self) -> bool { self.ctfont.symbolic_traits().is_italic() } fn boldness(&self) -> font_weight::T { let normalized = self.ctfont.all_traits()....
family_name
identifier_name
font.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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern crate core_foundation; extern crate core_graphics; exte...
fn family_name(&self) -> String { self.ctfont.family_name() } fn face_name(&self) -> String { self.ctfont.face_name() } fn is_italic(&self) -> bool { self.ctfont.symbolic_traits().is_italic() } fn boldness(&self) -> font_weight::T { let normalized = self.c...
fn template(&self) -> Arc<FontTemplateData> { self.font_data.clone() }
random_line_split
profile.rs
use crate::{Error, Result}; use chrono::{DateTime, Utc}; use colored::Colorize; use serde::Deserialize; use std::fs::File; use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::time::SystemTime; /// Represents a file with a provisioning profile info. #[derive(Debug, Clone)] pub struct Profile { pub p...
() { let mut profile = Info::empty(); profile.app_identifier = "12345ABCDE.com.exmaple.app".to_owned(); expect!(profile.bundle_id()).to(be_some().value("com.exmaple.app")); } #[test] fn incorrect_bundle_id() { let mut profile = Info::empty(); profile.app_identifier =...
correct_bundle_id
identifier_name
profile.rs
use crate::{Error, Result}; use chrono::{DateTime, Utc}; use colored::Colorize; use serde::Deserialize; use std::fs::File; use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::time::SystemTime; /// Represents a file with a provisioning profile info. #[derive(Debug, Clone)] pub struct Profile { pub p...
fn wildcard_bundle_id() { let mut profile = Info::empty(); profile.app_identifier = "12345ABCDE.*".to_owned(); expect!(profile.bundle_id()).to(be_some().value("*")); } }
#[test]
random_line_split
profile.rs
use crate::{Error, Result}; use chrono::{DateTime, Utc}; use colored::Colorize; use serde::Deserialize; use std::fs::File; use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::time::SystemTime; /// Represents a file with a provisioning profile info. #[derive(Debug, Clone)] pub struct Profile { pub p...
} false } /// Returns a bundle id of a profile. pub fn bundle_id(&self) -> Option<&str> { self.app_identifier .find(|ch| ch == '.') .map(|i| &self.app_identifier[(i + 1)..]) } /// Returns profile in a text form. pub fn description(&self, oneline: ...
{ return true; }
conditional_block
navigator.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::NavigatorBinding; use dom::bindings::js::{JSRef, Temporary}; use dom::bindin...
(&self) -> bool { false } fn AppName(&self) -> DOMString { "Netscape".to_string() // Like Gecko/Webkit } fn AppCodeName(&self) -> DOMString { "Mozilla".to_string() } fn Platform(&self) -> DOMString { "".to_string() } } impl Reflectable for Navigator { ...
TaintEnabled
identifier_name
navigator.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::NavigatorBinding; use dom::bindings::js::{JSRef, Temporary}; use dom::bindin...
fn Platform(&self) -> DOMString { "".to_string() } } impl Reflectable for Navigator { fn reflector<'a>(&'a self) -> &'a Reflector { &self.reflector_ } }
"Mozilla".to_string() }
random_line_split
listeners.rs
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
SectionInfoMsg::SectionInfoUpdate(update) => { let correlation_id = update.correlation_id; error!("MessageId {:?} was interrupted due to infrastructure updates. This will most likely need to be sent again. Update was : {:?}", correlation_id, update); if let S...
{ trace!("GetSectionResponse::Redirect, reboostrapping with provided peers"); // Disconnect from peer that sent us the redirect, connect to the new elders provided and // request the section info again. self.disconnect_from_peers(vec![src]).await?; ...
conditional_block
listeners.rs
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
ClientMsg::Process(msg) => self.handle_client_msg(msg, src).await, ClientMsg::ProcessingError(error) => { warn!("Processing error received. {:?}", error); // TODO: Handle lazy message errors }...
error!("Error handling network info message: {:?}", error); } } MessageType::Client { msg, .. } => { match msg {
random_line_split
listeners.rs
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
// Note that this doesn't remove the sender from here since multiple // responses corresponding to the same message ID might arrive. // Once we are satisfied with the response this is channel is discarded in // ConnectionManager::send_quer...
{ debug!( "===> ClientMsg with id {:?} received from {:?}", msg.id(), src ); let queries = self.pending_queries.clone(); let transfers = self.pending_transfers.clone(); let error_sender = self.incoming_err_sender.clone(); let _ = tokio:...
identifier_body
listeners.rs
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
(&self, msg_id: &MessageId) -> Result<(), Error> { let pending_transfers = self.pending_transfers.clone(); let mut listeners = pending_transfers.write().await; debug!("Pending transfers at this point: {:?}", listeners); let _ = listeners .remove(msg_id) .ok_or(Error...
remove_pending_transfer_sender
identifier_name
issue-2502.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
struct font<'a> { fontbuf: &'a ~[u8], } impl<'a> font<'a> { pub fn buf(&self) -> &'a ~[u8] { self.fontbuf } } fn font<'r>(fontbuf: &'r ~[u8]) -> font<'r> { font { fontbuf: fontbuf } } pub fn main() { }
// <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.
random_line_split
issue-2502.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a> { fontbuf: &'a ~[u8], } impl<'a> font<'a> { pub fn buf(&self) -> &'a ~[u8] { self.fontbuf } } fn font<'r>(fontbuf: &'r ~[u8]) -> font<'r> { font { fontbuf: fontbuf } } pub fn main() { }
font
identifier_name
issue-2502.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { }
{ font { fontbuf: fontbuf } }
identifier_body
ipdl-analyze.rs
use std::env; use std::path::Path; use std::path::PathBuf; use std::fs::File; use std::io::Write; extern crate tools; extern crate ipdl_parser; extern crate getopts; use getopts::Options; use tools::file_format::analysis::{read_analysis, read_target, WithLocation, AnalysisTarget, AnalysisKind}; use ipdl_parser::par...
() -> Options { let mut opts = Options::new(); opts.optmulti("I", "include", "Additional directory to search for included protocol specifications", "DIR"); opts.reqopt("d", "outheaders-dir", "Directory into which C++ headers analysis data is location.", ...
get_options_parser
identifier_name
ipdl-analyze.rs
use std::env; use std::path::Path; use std::path::PathBuf; use std::fs::File; use std::io::Write; extern crate tools; extern crate ipdl_parser; extern crate getopts; use getopts::Options; use tools::file_format::analysis::{read_analysis, read_target, WithLocation, AnalysisTarget, AnalysisKind}; use ipdl_parser::par...
fn mangle_nested_name(ns: &[String], protocol: &str, name: &str) -> String { format!("_ZN{}{}{}E", ns.iter().map(|id| mangle_simple(&id)).collect::<Vec<_>>().join(""), mangle_simple(protocol), mangle_simple(name)) } fn find_analysis<'a>(analysis: &'a TargetAnalysis, mangled: &...
{ format!("{}{}", s.len(), s) }
identifier_body
ipdl-analyze.rs
use std::env; use std::path::Path; use std::path::PathBuf; use std::fs::File; use std::io::Write; extern crate tools; extern crate ipdl_parser; extern crate getopts; use getopts::Options; use tools::file_format::analysis::{read_analysis, read_target, WithLocation, AnalysisTarget, AnalysisKind}; use ipdl_parser::par...
; let ctor_suffix = if is_ctor { "Constructor" } else { "" }; let mangled = mangle_nested_name(&protocol.namespaces, &format!("{}{}", protocol.name.id, send_side), &format!("{}{}{}", send_prefix, message.name.id, ctor_suffix)); if l...
{ "Recv" }
conditional_block
ipdl-analyze.rs
use std::env; use std::path::Path; use std::path::PathBuf; use std::fs::File; use std::io::Write; extern crate tools; extern crate ipdl_parser; extern crate getopts; use getopts::Options; use tools::file_format::analysis::{read_analysis, read_target, WithLocation, AnalysisTarget, AnalysisKind}; use ipdl_parser::par...
let base_path = Path::new(&base_dir); let analysis_path = Path::new(&analysis_dir); let mut file_names = Vec::new(); for f in matches.free { file_names.push(PathBuf::from(f)); } let maybe_tus = parser::parse(&include_dirs, file_names); if maybe_tus.is_none() { println!("Sp...
random_line_split
name.rs
#![macro_use] use std::{ cell::RefCell, collections::{HashMap, HashSet}, fmt, string::String, }; /// An interned, freshenable identifier. /// Generally, one creates names with `n()` (short for `Name::global()`); /// two names created this way with the same spelling will be treated as the same name. /...
// Printable versions are first-come, first-served assert_eq!(a.freshen().print(), "a"); assert_eq!(a.print(), "a🥕"); }
random_line_split
name.rs
#![macro_use] use std::{ cell::RefCell, collections::{HashMap, HashSet}, fmt, string::String, }; /// An interned, freshenable identifier. /// Generally, one creates names with `n()` (short for `Name::global()`); /// two names created this way with the same spelling will be treated as the same name. /...
*id_map_.borrow_mut().entry(unique_spelling.clone()).or_insert_with(claim_id) }; Name { id: id } }) } pub fn is(self, s: &str) -> bool { self.sp() == s } pub fn is_name(self, n: Name) -> bool { self.sp() == n.sp() } } impl From<&str> for Name { fn from(s: &str) -> ...
aim_id() // ...don't put it in the table } else {
conditional_block
name.rs
#![macro_use] use std::{ cell::RefCell, collections::{HashMap, HashSet}, fmt, string::String, }; /// An interned, freshenable identifier. /// Generally, one creates names with `n()` (short for `Name::global()`); /// two names created this way with the same spelling will be treated as the same name. /...
ame { Name::new(s, true) } pub fn freshen(self) -> Name { Name::new(&self.orig_sp(), true) } fn new(orig_spelling: &str, freshen: bool) -> Name { let fake_freshness_ = fake_freshness.with(|ff| *ff.borrow()); id_map.with(|id_map_| { let mut unique_spelling = orig_spelling.to_owned()...
) -> N
identifier_name
sparc64_unknown_linux_gnu.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); base.cpu = "v9".to_string(); base.max_atomic_width = Some(64); Ok(Target { llvm_target: "sparc64-unknown-linux-gnu".to_string(), target_endian: "big".to_string(), target_pointer_width: "64".to_string(), ...
// option. This file may not be copied, modified, or distributed // except according to those terms. use spec::{LinkerFlavor, Target, TargetResult};
random_line_split
sparc64_unknown_linux_gnu.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() -> TargetResult { let mut base = super::linux_base::opts(); base.cpu = "v9".to_string(); base.max_atomic_width = Some(64); Ok(Target { llvm_target: "sparc64-unknown-linux-gnu".to_string(), target_endian: "big".to_string(), target_pointer_width: "64".to_string(), targe...
target
identifier_name
sparc64_unknown_linux_gnu.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut base = super::linux_base::opts(); base.cpu = "v9".to_string(); base.max_atomic_width = Some(64); Ok(Target { llvm_target: "sparc64-unknown-linux-gnu".to_string(), target_endian: "big".to_string(), target_pointer_width: "64".to_string(), target_c_int_width: "32"...
identifier_body
mod.rs
// Generated with./mk_vsl_tag from Varnish headers: include/tbl/vsl_tags.h include/tbl/vsl_tags_http.h include/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/vapi/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/tbl/vsl_tags.h // https://github.com/varnishca...
(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { let tag = format!("{:?}", self.tag); if f.alternate() { write!(f, "{} {:5} {:18} {}", self.marker, self.ident, tag, MaybeStr::from_bytes(self.data)) } else { write!(f, "VSL record (marker: {} ident: {} tag: ...
fmt
identifier_name
mod.rs
// Generated with./mk_vsl_tag from Varnish headers: include/tbl/vsl_tags.h include/tbl/vsl_tags_http.h include/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/vapi/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/tbl/vsl_tags.h // https://github.com/varnishca...
else { write!(f, "VSL record (marker: {} ident: {} tag: {} data: {:?})", self.marker, self.ident, tag, MaybeStr::from_bytes(self.data)) } } }
{ write!(f, "{} {:5} {:18} {}", self.marker, self.ident, tag, MaybeStr::from_bytes(self.data)) }
conditional_block
mod.rs
// Generated with./mk_vsl_tag from Varnish headers: include/tbl/vsl_tags.h include/tbl/vsl_tags_http.h include/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/vapi/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/tbl/vsl_tags.h // https://github.com/varnishca...
pub fn is_backend(&self) -> bool { self.marker.contains(Marker::VSL_BACKENDMARKER) } } impl<'b> Debug for VslRecord<'b> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.debug_struct("VSL Record") .field("tag", &self.tag) .field("marker", &self...
}
random_line_split
mod.rs
// Generated with./mk_vsl_tag from Varnish headers: include/tbl/vsl_tags.h include/tbl/vsl_tags_http.h include/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/vapi/vsl_int.h // https://github.com/varnishcache/varnish-cache/blob/master/include/tbl/vsl_tags.h // https://github.com/varnishca...
} impl<'b> Display for VslRecord<'b> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { let tag = format!("{:?}", self.tag); if f.alternate() { write!(f, "{} {:5} {:18} {}", self.marker, self.ident, tag, MaybeStr::from_bytes(self.data)) } else { ...
{ f.debug_struct("VSL Record") .field("tag", &self.tag) .field("marker", &self.marker) .field("ident", &self.ident) .field("data", &MaybeStr::from_bytes(self.data)) .finish() }
identifier_body
network.rs
10; #[derive(Debug)] struct ErrorAction { retry_timeout: Duration, max_retries: usize, description: String, } impl ErrorAction { fn new(config: &NetworkConfiguration, description: String) -> Self { Self { retry_timeout: Duration::from_millis(config.tcp_connect_retry_timeout), ...
Ok(()) } .right_future() } async fn process_messages( pool: SharedConnectionPool, connection: Connection, mut network_tx: mpsc::Sender<NetworkEvent>, ) { let (sink, stream) = connection.socket.split(); let key = connection.key; let...
{ let handler = Self::handle_connection(connection, connect, pool, network_tx); tokio::spawn(handler); }
conditional_block
network.rs
10; #[derive(Debug)] struct ErrorAction { retry_timeout: Duration, max_retries: usize, description: String, } impl ErrorAction { fn new(config: &NetworkConfiguration, description: String) -> Self { Self { retry_timeout: Duration::from_millis(config.tcp_connect_retry_timeout), ...
( &self, key: PublicKey, handshake_params: &HandshakeParams, ) -> impl Future<Output = anyhow::Result<()>> { // Resolve peer key to an address. let maybe_address = self.connect_list.find_address_by_key(&key); let unresolved_address = if let Some(address) = maybe_addre...
connect
identifier_name
network.rs
= 10; #[derive(Debug)] struct ErrorAction { retry_timeout: Duration, max_retries: usize, description: String, } impl ErrorAction { fn new(config: &NetworkConfiguration, description: String) -> Self { Self { retry_timeout: Duration::from_millis(config.tcp_connect_retry_timeout), ...
"Ignoring outgoing connection to {:?} because the connection limit ({}) \ is reached", key, max_connections ); return Ok(()); } let conn_addr = ConnectedPeerAddr::Out(unresolved_addr...
.send(&mut socket) .await?; if pool.read().count_outgoing() >= max_connections { log::info!(
random_line_split