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
swap-overlapping.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub struct TestDescAndFn { desc: TestDesc, testfn: TestFn, }
}
random_line_split
swap-overlapping.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 ...
(test: &mut TestDescAndFn) { unsafe { ptr::swap(test, test); } } pub enum TestName { DynTestName(String) } pub enum TestFn { DynTestFn(proc():'static), DynBenchFn(proc(&mut int):'static) } pub struct TestDesc { name: TestName, should_fail: bool } pub struct TestDescAndFn { de...
do_swap
identifier_name
unnecessary_operation.rs
// run-rustfix #![feature(box_syntax)] #![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)] #![warn(clippy::unnecessary_operation)] struct Tuple(i32); struct
{ field: i32, } enum Enum { Tuple(i32), Struct { field: i32 }, } struct DropStruct { field: i32, } impl Drop for DropStruct { fn drop(&mut self) {} } struct DropTuple(i32); impl Drop for DropTuple { fn drop(&mut self) {} } enum DropEnum { Tuple(i32), Struct { field: i32 }, } impl Drop f...
Struct
identifier_name
unnecessary_operation.rs
// run-rustfix #![feature(box_syntax)] #![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)] #![warn(clippy::unnecessary_operation)] struct Tuple(i32); struct Struct { field: i32, } enum Enum { Tuple(i32), Struct { field: i32 }, } struct DropStruct { field: i32, } impl Drop for DropStr...
fn get_usize() -> usize { 0 } fn get_struct() -> Struct { Struct { field: 0 } } fn get_drop_struct() -> DropStruct { DropStruct { field: 0 } } fn main() { Tuple(get_number()); Struct { field: get_number() }; Struct {..get_struct() }; Enum::Tuple(get_number()); Enum::Struct { field: ge...
{ 0 }
identifier_body
unnecessary_operation.rs
// run-rustfix #![feature(box_syntax)] #![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)] #![warn(clippy::unnecessary_operation)] struct Tuple(i32); struct Struct { field: i32, } enum Enum { Tuple(i32), Struct { field: i32 }, } struct DropStruct { field: i32, } impl Drop for DropStr...
5..get_number(); [42, get_number()]; [42, 55][get_usize()]; (42, get_number()).1; [get_number(); 55]; [42; 55][get_usize()]; { get_number() }; FooString { s: String::from("blah"), }; // Do not warn DropTuple(get_number()); DropStruct { field: get_numb...
..get_number();
random_line_split
main.rs
use std::io; use std::fmt; use std::io::prelude::*; use std::str::FromStr; use std::collections::VecDeque; #[derive(Debug)] struct Display { data: VecDeque<VecDeque<bool>>, height: usize, width: usize, } #[derive(Debug)] enum Command { Rect(usize, usize), RotateRow(usize, usize), RotateCol(us...
} impl FromStr for Command { // Slice patterns would make this so much better type Err = &'static str; fn from_str(input: &str) -> Result<Command, Self::Err> { let input = input.split_whitespace().collect::<Vec<_>>(); match input[0] { "rect" => { let xy = input...
{ let pixels = self.data .iter() .map(|row| row.iter().map(|&pixel| if pixel { '#' } else { '.' }).collect::<String>()) .collect::<Vec<_>>() .join("\n"); write!(f, "{}", pixels) }
identifier_body
main.rs
use std::io; use std::fmt; use std::io::prelude::*; use std::str::FromStr; use std::collections::VecDeque; #[derive(Debug)] struct Display { data: VecDeque<VecDeque<bool>>, height: usize, width: usize, } #[derive(Debug)] enum Command { Rect(usize, usize), RotateRow(usize, usize), RotateCol(us...
fn lit_pixels(&self) -> usize { self.data.iter().flat_map(|row| row.iter().filter(|&pixel| *pixel)).count() } } impl fmt::Display for Display { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let pixels = self.data .iter() .map(|row| row.iter().map(|&pixel| if p...
}
random_line_split
main.rs
use std::io; use std::fmt; use std::io::prelude::*; use std::str::FromStr; use std::collections::VecDeque; #[derive(Debug)] struct Display { data: VecDeque<VecDeque<bool>>, height: usize, width: usize, } #[derive(Debug)] enum Command { Rect(usize, usize), RotateRow(usize, usize), RotateCol(us...
() { let mut display = Display::new(50, 6); let stdin = io::stdin(); let stdin = stdin.lock().lines(); for line in stdin { let line = line.unwrap(); display.command(&line); } println!("part1: {}", display.lit_pixels()); println!("part2:\n{}", display); }
main
identifier_name
attr.rs
//! Code generation for `#[graphql_union]` macro. use std::mem; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens as _}; use syn::{ext::IdentExt as _, parse_quote, spanned::Spanned as _}; use crate::{ common::{parse, scalar}, result::GraphQLScope, util::{path_eq_single, span_container::Sp...
#[graphql_union(on... =...)] on the trait itself", )) .emit() } if attr.ignore.is_some() { return None; } let method_span = method.sig.span(); let method_ident = &method.sig.ident; let ty = parse::downcaster::output_type(&method.sig.output) .map_err(|...
{ let method_attrs = method.attrs.clone(); // Remove repeated attributes from the method, to omit incorrect expansion. method.attrs = mem::take(&mut method.attrs) .into_iter() .filter(|attr| !path_eq_single(&attr.path, "graphql")) .collect(); let attr = VariantAttr::from_attrs(...
identifier_body
attr.rs
//! Code generation for `#[graphql_union]` macro. use std::mem; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens as _}; use syn::{ext::IdentExt as _, parse_quote, spanned::Spanned as _}; use crate::{ common::{parse, scalar}, result::GraphQLScope, util::{path_eq_single, span_container::Sp...
let mut variants: Vec<_> = ast .items .iter_mut() .filter_map(|i| match i { syn::TraitItem::Method(m) => parse_variant_from_trait_method(m, trait_ident, &attr), _ => None, }) .collect(); proc_macro_error::abort_if_dirty(); emerge_union_variants...
{ ERR.no_double_underscore( attr.name .as_ref() .map(SpanContainer::span_ident) .unwrap_or_else(|| trait_ident.span()), ); }
conditional_block
attr.rs
//! Code generation for `#[graphql_union]` macro. use std::mem; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens as _}; use syn::{ext::IdentExt as _, parse_quote, spanned::Spanned as _}; use crate::{ common::{parse, scalar}, result::GraphQLScope, util::{path_eq_single, span_container::Sp...
( attrs: Vec<syn::Attribute>, mut ast: syn::ItemTrait, ) -> syn::Result<TokenStream> { let attr = Attr::from_attrs("graphql_union", &attrs)?; let trait_span = ast.span(); let trait_ident = &ast.ident; let name = attr .name .clone() .map(SpanContainer::into_inner) .u...
expand_on_trait
identifier_name
attr.rs
//! Code generation for `#[graphql_union]` macro. use std::mem; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens as _}; use syn::{ext::IdentExt as _, parse_quote, spanned::Spanned as _}; use crate::{ common::{parse, scalar}, result::GraphQLScope, util::{path_eq_single, span_container::Sp...
let resolver_code = { if let Some(other) = trait_attr.external_resolvers.get(&ty) { ERR.custom( method_span, format!( "trait method `{}` conflicts with the external resolver \ function `{}` declared on the trait to resolve...
"async downcast to union variants is not supported", ); return None; }
random_line_split
issue-80706.rs
// check-pass // edition:2018 type BoxFuture<T> = std::pin::Pin<Box<dyn std::future::Future<Output=T>>>; fn main() { f(); } async fn f() { run("dependency").await; } struct InMemoryStorage; struct User<'dep> { dep: &'dep str, } impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> { fn execute...
} async fn run<S>(dep: &str) where S: Storage, for<'a> SaveUser<'a>: StorageRequest<S>, { User { dep }.save().await; }
{ SaveUser { name: "Joe" } .execute() .await; }
identifier_body
issue-80706.rs
// check-pass // edition:2018 type BoxFuture<T> = std::pin::Pin<Box<dyn std::future::Future<Output=T>>>; fn main() { f(); } async fn f() { run("dependency").await; } struct
; struct User<'dep> { dep: &'dep str, } impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> { fn execute(&self) -> BoxFuture<Result<(), String>> { todo!() } } trait Storage { type Error; } impl Storage for InMemoryStorage { type Error = String; } trait StorageRequestReturnType { ...
InMemoryStorage
identifier_name
issue-80706.rs
// check-pass // edition:2018 type BoxFuture<T> = std::pin::Pin<Box<dyn std::future::Future<Output=T>>>; fn main() { f(); } async fn f() { run("dependency").await; } struct InMemoryStorage; struct User<'dep> { dep: &'dep str, } impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> { fn execute...
where S: Storage, for<'a> SaveUser<'a>: StorageRequest<S>, { SaveUser { name: "Joe" } .execute() .await; } } async fn run<S>(dep: &str) where S: Storage, for<'a> SaveUser<'a>: StorageRequest<S>, { User { dep }.save().await; }
} impl<'dep> User<'dep> { async fn save<S>(self)
random_line_split
next_back.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::result::IntoIter; // #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] // #[must_use] // #[stable(feature = "rust1", since = "1.0.0")] // pub enum Result<T, E> { // /// Contains the success value ...
// } // impl<T, E> IntoIterator for Result<T, E> { // type Item = T; // type IntoIter = IntoIter<T>; // // /// Returns a consuming iterator over the possibly contained value. // /// // /// # Examples // /// // /// ``` // /// let x: Result<u32,...
// #[stable(feature = "rust1", since = "1.0.0")] // Err(E)
random_line_split
next_back.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::result::IntoIter; // #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] // #[must_use] // #[stable(feature = "rust1", since = "1.0.0")] // pub enum Result<T, E> { // /// Contains the success value ...
() { let x: Result<T, E> = Ok::<T, E>(5); let mut into_iter: IntoIter<T> = x.into_iter(); let result: Option<T> = into_iter.next_back(); match result { Some(v) => assert_eq!(v, 5), None => assert!(false) } } #[test] fn next_back_test2() { let x: Result<T, E> = Err::<T, E>("nothing!"); let...
next_back_test1
identifier_name
next_back.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::result::IntoIter; // #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] // #[must_use] // #[stable(feature = "rust1", since = "1.0.0")] // pub enum Result<T, E> { // /// Contains the success value ...
#[test] fn next_back_test2() { let x: Result<T, E> = Err::<T, E>("nothing!"); let mut into_iter: IntoIter<T> = x.into_iter(); let result: Option<T> = into_iter.next_back(); assert_eq!(result, None::<T>); } }
{ let x: Result<T, E> = Ok::<T, E>(5); let mut into_iter: IntoIter<T> = x.into_iter(); let result: Option<T> = into_iter.next_back(); match result { Some(v) => assert_eq!(v, 5), None => assert!(false) } }
identifier_body
size-and-align.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let v: Vec<clam<int>> = vec!(clam::b::<int>, clam::b::<int>, clam::a::<int>(42, 17)); uhoh::<int>(v); }
main
identifier_name
size-and-align.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 ...
clam::b::<T> => { println!("correct"); } } } pub fn main() { let v: Vec<clam<int>> = vec!(clam::b::<int>, clam::b::<int>, clam::a::<int>(42, 17)); uhoh::<int>(v); }
panic!(); }
random_line_split
size-and-align.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() { let v: Vec<clam<int>> = vec!(clam::b::<int>, clam::b::<int>, clam::a::<int>(42, 17)); uhoh::<int>(v); }
{ match v[1] { clam::a::<T>(ref _t, ref u) => { println!("incorrect"); println!("{}", u); panic!(); } clam::b::<T> => { println!("correct"); } }
identifier_body
dns_configuration.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
unwrap_result!(write_dns_configuaration_data(client.clone(), &config_vec)); // Get the Stored Configurations config_vec = unwrap_result!(get_dns_configuaration_data(client.clone())); assert_eq!(config_vec.len(), 1); assert_eq!(config_vec[0], config_0); // Modify the co...
{ let client = ::std::sync::Arc::new(::std::sync::Mutex::new(unwrap_result!(::safe_core::utility::test_utils::get_client()))); // Initialise Dns Configuration File unwrap_result!(initialise_dns_configuaration(client.clone())); // Get the Stored Configurations let mut config_vec...
identifier_body
dns_configuration.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
{ pub long_name : String, pub encryption_keypair: (::sodiumoxide::crypto::box_::PublicKey, ::sodiumoxide::crypto::box_::SecretKey), } pub fn initialise_dns_configuaration(client: ::std::sync::Arc<::std::sync::Mutex<::safe_core::client::Client>>) -> Result<(), ::errors::Dn...
DnsConfiguation
identifier_name
dns_configuration.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
} pub fn write_dns_configuaration_data(client: ::std::sync::Arc<::std::sync::Mutex<::safe_core::client::Client>>, config: &Vec<DnsConfiguation>) -> Result<(), ::errors::DnsError> { let dir_helper = ::safe_nfs::helper::directory_helper::DirectoryHelper::new(client.clone()); ...
{ Ok(vec![]) }
conditional_block
dns_configuration.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
}
// Get the Stored Configurations config_vec = unwrap_result!(get_dns_configuaration_data(client.clone())); assert_eq!(config_vec.len(), 0); }
random_line_split
io.rs
// Copyright 2020 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
pub trait Encode { fn encode(&self, w: &mut impl std::io::Write) -> std::io::Result<()>; } pub trait Decode: Sized { fn decode(r: &mut impl std::io::Read) -> Result<Self, DecodeError>; } macro_rules! encode_decode_as { ($ty:ty, { $($lhs:tt <=> $rhs:tt,)* } $(, |$other:pat| $other_handler:expr...
}
random_line_split
io.rs
// Copyright 2020 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
} impl std::fmt::Display for DecodeError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str("(root)")?; for item in self.path.iter().rev() { match *item { PathItem::Name(name) => write!(f, ".{}", name), PathItem::Index(index) ...
{ DecodeError { path: vec![], kind: err.into(), } }
identifier_body
io.rs
// Copyright 2020 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
(_err: std::num::TryFromIntError) -> Self { DecodeErrorKind::Leb128(leb128::read::Error::Overflow) } } impl From<std::convert::Infallible> for DecodeErrorKind { fn from(err: std::convert::Infallible) -> Self { match err {} } } pub trait Encode { fn encode(&self, w: &mut impl std::io::W...
from
identifier_name
domtokenlist.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::attr::{Attr, AttrHelpers}; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::...
(self) -> u32 { self.attribute().root().map(|attr| { attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0) }).unwrap_or(0) as u32 } // http://dom.spec.whatwg.org/#dom-domtokenlist-item fn Item(self, index: u32) -> Option<DOMString> { self.attribute().root().and_t...
Length
identifier_name
domtokenlist.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::attr::{Attr, AttrHelpers}; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::...
impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> { // http://dom.spec.whatwg.org/#dom-domtokenlist-length fn Length(self) -> u32 { self.attribute().root().map(|attr| { attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0) }).unwrap_or(0) as u32 } // http://do...
// http://dom.spec.whatwg.org/#domtokenlist
random_line_split
crate-method-reexport-grrrrrrr.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
let x = box(GC) (); x.cx(); let y = (); y.add("hi".to_string()); }
random_line_split
crate-method-reexport-grrrrrrr.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ use crate_method_reexport_grrrrrrr2::rust::add; use crate_method_reexport_grrrrrrr2::rust::cx; let x = box(GC) (); x.cx(); let y = (); y.add("hi".to_string()); }
identifier_body
crate-method-reexport-grrrrrrr.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { use crate_method_reexport_grrrrrrr2::rust::add; use crate_method_reexport_grrrrrrr2::rust::cx; let x = box(GC) (); x.cx(); let y = (); y.add("hi".to_string()); }
main
identifier_name
parse.rs
//! Parse byte iterators to float. #![doc(hidden)] #[cfg(feature = "compact")] use crate::bellerophon::bellerophon; use crate::extended_float::{extended_to_float, ExtendedFloat}; #[cfg(not(feature = "compact"))] use crate::lemire::lemire; use crate::num::Float; use crate::number::Number; use crate::slow::slow; /// T...
// Now try the moderate path algorithm. let mut fp = moderate_path::<F>(&num); if fp.exp < 0 { // Undo the invalid extended float biasing. fp.exp -= F::INVALID_FP; fp = slow::<F, _, _>(num, fp, integer, fraction); } // Unable to correctly round the float using the fast or ...
{ return value; }
conditional_block
parse.rs
//! Parse byte iterators to float. #![doc(hidden)] #[cfg(feature = "compact")] use crate::bellerophon::bellerophon; use crate::extended_float::{extended_to_float, ExtendedFloat}; #[cfg(not(feature = "compact"))] use crate::lemire::lemire; use crate::num::Float; use crate::number::Number; use crate::slow::slow; /// T...
let digit = c - b'0'; num.mantissa = num.mantissa * 10 + digit as u64; break; } } } for c in fraction { fraction_count += 1; count += 1; if count == 20 { num.many_digits = true; // This can't wrap...
count += 1;
random_line_split
parse.rs
//! Parse byte iterators to float. #![doc(hidden)] #[cfg(feature = "compact")] use crate::bellerophon::bellerophon; use crate::extended_float::{extended_to_float, ExtendedFloat}; #[cfg(not(feature = "compact"))] use crate::lemire::lemire; use crate::num::Float; use crate::number::Number; use crate::slow::slow; /// T...
(value: usize) -> i32 { if value > i32::max_value() as usize { i32::max_value() } else { value as i32 } } // Add digit to mantissa. #[inline] pub fn add_digit(value: u64, digit: u8) -> Option<u64> { value.checked_mul(10)?.checked_add(digit as u64) }
into_i32
identifier_name
parse.rs
//! Parse byte iterators to float. #![doc(hidden)] #[cfg(feature = "compact")] use crate::bellerophon::bellerophon; use crate::extended_float::{extended_to_float, ExtendedFloat}; #[cfg(not(feature = "compact"))] use crate::lemire::lemire; use crate::num::Float; use crate::number::Number; use crate::slow::slow; /// T...
/// Convert usize into i32 without overflow. /// /// This is needed to ensure when adjusting the exponent relative to /// the mantissa we do not overflow for comically-long exponents. #[inline] fn into_i32(value: usize) -> i32 { if value > i32::max_value() as usize { i32::max_value() } else { ...
{ #[cfg(not(feature = "compact"))] return lemire::<F>(num); #[cfg(feature = "compact")] return bellerophon::<F>(num); }
identifier_body
snippets.rs
use ast::with_error_checking_parse; use core::{Match, MatchType, Session}; use typeinf::get_function_declaration; use syntex_syntax::ast::ImplItemKind; pub fn snippet_for_match(m: &Match, session: &Session) -> String
struct MethodInfo { name: String, args: Vec<String> } impl MethodInfo { ///Parses method declaration as string and returns relevant data fn from_source_str(source: &str) -> Option<MethodInfo> { let trim: &[_] = &['\n', '\r', '{','']; let decorated = format!("{} {{}}()", source.trim_ri...
{ match m.mtype { MatchType::Function => { let method = get_function_declaration(&m, session); if let Some(m) = MethodInfo::from_source_str(&method) { m.snippet() } else { "".into() } } _ => m.matchstr.clone() ...
identifier_body
snippets.rs
use ast::with_error_checking_parse; use core::{Match, MatchType, Session}; use typeinf::get_function_declaration; use syntex_syntax::ast::ImplItemKind; pub fn snippet_for_match(m: &Match, session: &Session) -> String { match m.mtype { MatchType::Function => { let method = get_function_declarat...
struct MethodInfo { name: String, args: Vec<String> } impl MethodInfo { ///Parses method declaration as string and returns relevant data fn from_source_str(source: &str) -> Option<MethodInfo> { let trim: &[_] = &['\n', '\r', '{','']; let decorated = format!("{} {{}}()", source.trim_righ...
_ => m.matchstr.clone() } }
random_line_split
snippets.rs
use ast::with_error_checking_parse; use core::{Match, MatchType, Session}; use typeinf::get_function_declaration; use syntex_syntax::ast::ImplItemKind; pub fn snippet_for_match(m: &Match, session: &Session) -> String { match m.mtype { MatchType::Function => { let method = get_function_declarat...
else { "".into() } } _ => m.matchstr.clone() } } struct MethodInfo { name: String, args: Vec<String> } impl MethodInfo { ///Parses method declaration as string and returns relevant data fn from_source_str(source: &str) -> Option<MethodInfo> { le...
{ m.snippet() }
conditional_block
snippets.rs
use ast::with_error_checking_parse; use core::{Match, MatchType, Session}; use typeinf::get_function_declaration; use syntex_syntax::ast::ImplItemKind; pub fn
(m: &Match, session: &Session) -> String { match m.mtype { MatchType::Function => { let method = get_function_declaration(&m, session); if let Some(m) = MethodInfo::from_source_str(&method) { m.snippet() } else { "".into() } ...
snippet_for_match
identifier_name
borrowck-preserve-expl-deref.rs
// ignore-pretty // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT lice...
{ f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow((*x).f, |b_x| { assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; println!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); assert!(&(*x.f) as *int!= &(*b_x) as *int); ...
F
identifier_name
borrowck-preserve-expl-deref.rs
// ignore-pretty // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT lice...
struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow((*x).f, |b_x| { assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; println!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); assert!(&(*x.f) as *int!= &(*b_x) as ...
{ let before = *x; f(x); let after = *x; assert_eq!(before, after); }
identifier_body
borrowck-preserve-expl-deref.rs
// ignore-pretty // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT lice...
} struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow((*x).f, |b_x| { assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; println!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); assert!(&(*x.f) as *int!= &(*b_x) as...
f(x); let after = *x; assert_eq!(before, after);
random_line_split
issue-14853.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::fmt::Show; trait Something { fn yay<T: Show>(_: Option<Self>, thing: &[T])...
random_line_split
issue-14853.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 X { data: u32 } impl Something for X { fn yay<T: Str>(_:Option<X>, thing: &[T]) -> String { //~^ ERROR in method `yay`, type parameter 0 requires bound `core::str::Str`, which is not required format!("{:s}", thing[0]) } } fn main() { let arr = &["one", "two", "three"]; println!("{}"...
{ }
identifier_body
issue-14853.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T: Show>(_: Option<Self>, thing: &[T]) -> String { } } struct X { data: u32 } impl Something for X { fn yay<T: Str>(_:Option<X>, thing: &[T]) -> String { //~^ ERROR in method `yay`, type parameter 0 requires bound `core::str::Str`, which is not required format!("{:s}", thing[0]) } } fn main() { ...
yay
identifier_name
lib.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
//! # download and build parity //! git clone https://github.com/ethcore/parity //! cd parity //! multirust override beta //! cargo build --release //! ``` //! //! - OSX: //! //! ```bash //! # install rocksdb && multirust //! brew update //! brew install multirust //! //! # export rust LIBRARY_PAT...
//! export LIBRARY_PATH=/usr/local/lib //!
random_line_split
classes-simple-cross-crate.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
random_line_split
classes-simple-cross-crate.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); }
identifier_body
classes-simple-cross-crate.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); }
main
identifier_name
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/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
extern crate pdqsort; extern crate precomputed_hash; extern crate rayon; extern crate selectors; #[cfg(feature = "servo")] #[macro_use] extern crate serde; pub extern crate servo_arc; #[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms; #[cfg(feature = "servo")] extern crate servo_config; #[cfg(feature = "s...
extern crate num_integer; extern crate num_traits; extern crate ordered_float; extern crate owning_ref; extern crate parking_lot;
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/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
#[cfg(feature = "gecko")] use gecko_string_cache::WeakAtom; #[cfg(feature = "servo")] use servo_atoms::Atom as WeakAtom; /// Extension methods for selectors::attr::CaseSensitivity pub trait CaseSensitivityExt { /// Return whether two atoms compare equal according to this case sensitivity. fn eq_atom(self, a:...
{ if list.is_empty() { return Ok(()); } list[0].to_css(dest)?; for item in list.iter().skip(1) { dest.write_str(", ")?; item.to_css(dest)?; } Ok(()) }
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/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
<W, T>(dest: &mut W, list: &[T]) -> fmt::Result where W: fmt::Write, T: ToCss, { if list.is_empty() { return Ok(()); } list[0].to_css(dest)?; for item in list.iter().skip(1) { dest.wri...
serialize_comma_separated_list
identifier_name
mod.rs
//! Types and traits to build and send responses. //! //! The return type of a Rocket handler can be any type that implements the //! [Responder](trait.Responder.html) trait. Among other things, this module //! contains several such types. //! //! # Composing //! //! Many of the built-in `Responder` types _chain_ respo...
mod response; mod failure; pub mod content; pub mod status; pub use self::response::{Response, ResponseBuilder, Body, DEFAULT_CHUNK_SIZE}; pub use self::responder::Responder; pub use self::redirect::Redirect; pub use self::flash::Flash; pub use self::named_file::NamedFile; pub use self::stream::Stream; pub use self::...
mod flash; mod named_file; mod stream;
random_line_split
str-growth.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
// option. This file may not be copied, modified, or distributed // except according to those terms. pub fn main() { let mut s = ~"a"; s.push_char('b'); assert_eq!(s[0], 'a' as u8); assert_eq!(s[1], 'b' as u8); s.push_char('c'); s.push_char('d'); assert_eq!(s[0], 'a' as u8); assert_eq...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
str-growth.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut s = ~"a"; s.push_char('b'); assert_eq!(s[0], 'a' as u8); assert_eq!(s[1], 'b' as u8); s.push_char('c'); s.push_char('d'); assert_eq!(s[0], 'a' as u8); assert_eq!(s[1], 'b' as u8); assert_eq!(s[2], 'c' as u8); assert_eq!(s[3], 'd' as u8); }
main
identifier_name
str-growth.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut s = ~"a"; s.push_char('b'); assert_eq!(s[0], 'a' as u8); assert_eq!(s[1], 'b' as u8); s.push_char('c'); s.push_char('d'); assert_eq!(s[0], 'a' as u8); assert_eq!(s[1], 'b' as u8); assert_eq!(s[2], 'c' as u8); assert_eq!(s[3], 'd' as u8); }
identifier_body
review.rs
use refs; use git2::{ Oid, Repository, Note, Commit }; use super::{ Error, Result, Request, Requests, CIStatuses, Analyses, Comments, Event, Events }; pub struct Review<'r> { git: &'r Repository, id: Oid, request: Request, requests: Vec<Request>, } impl<'r> Review<'r> { pub fn for_commit(git: &'r Repositor...
else { requests.sort_by(|a, b| a.timestamp().cmp(&b.timestamp())); Ok((requests.pop().unwrap(), requests)) }) .map(|(request, requests)| Review::from_requests(git, id, request, requests)) } pub fn id(&self) -> Oid { self.id } pub fn commit(&self) -> Result<Commit> { s...
{ Err(Error::NotFound) }
conditional_block
review.rs
use refs; use git2::{ Oid, Repository, Note, Commit }; use super::{ Error, Result, Request, Requests, CIStatuses, Analyses, Comments, Event, Events }; pub struct Review<'r> { git: &'r Repository, id: Oid, request: Request, requests: Vec<Request>, } impl<'r> Review<'r> { pub fn for_commit(git: &'r Repositor...
requests: requests, } } }
random_line_split
review.rs
use refs; use git2::{ Oid, Repository, Note, Commit }; use super::{ Error, Result, Request, Requests, CIStatuses, Analyses, Comments, Event, Events }; pub struct Review<'r> { git: &'r Repository, id: Oid, request: Request, requests: Vec<Request>, } impl<'r> Review<'r> { pub fn for_commit(git: &'r Repositor...
(git: &'r Repository, id: Oid, note: Note<'r>) -> Result<Review<'r>> { Request::all_from_note(id, note) .and_then(|mut requests| if requests.is_empty() { Err(Error::NotFound) } else { requests.sort_by(|a, b| a.timestamp().cmp(&b.timestamp())); Ok((requests.pop().un...
from_note
identifier_name
review.rs
use refs; use git2::{ Oid, Repository, Note, Commit }; use super::{ Error, Result, Request, Requests, CIStatuses, Analyses, Comments, Event, Events }; pub struct Review<'r> { git: &'r Repository, id: Oid, request: Request, requests: Vec<Request>, } impl<'r> Review<'r> { pub fn for_commit(git: &'r Repositor...
fn from_requests(git: &'r Repository, id: Oid, request: Request, requests: Vec<Request>) -> Review<'r> { Review { git: git, id: id, request: request, requests: requests, } } }
{ let mut vec = Vec::new(); vec.extend(self.all_ci_statuses().map(|status| Box::new(status) as Box<Event>)); vec.extend(self.comments().map(|comment| Box::new(comment) as Box<Event>)); vec.extend(self.analyses().map(|analysis| Box::new(analysis) as Box<Event>)); vec.sort_by(|a, b| a.timestamp().cmp...
identifier_body
sha1.rs
use std::clone::Clone; use digest::{Digest, DigestError, DigestResult, DigestSuccess}; const SHA1_HASH_SIZE: usize = 20; const BLOCK_SIZE: usize = 64; // Initial hash value. const INIT_STATE: [u32; SHA1_HASH_SIZE / 4] = [ 0x67452301u32, 0xefcdab89u32, 0x98badcfeu32, 0x10325476u32, 0xc3d2e1f0u32 ]...
fn block_size(&self) -> usize { BLOCK_SIZE } } #[cfg(test)] mod tests { use super::*; #[derive(Clone)] struct Test { input: &'static str, output: Vec<u8>, output_str: &'static str, } #[test] fn test_sha1() { let tests = vec![ Test { ...
{ 160 }
identifier_body
sha1.rs
use std::clone::Clone; use digest::{Digest, DigestError, DigestResult, DigestSuccess}; const SHA1_HASH_SIZE: usize = 20; const BLOCK_SIZE: usize = 64; // Initial hash value. const INIT_STATE: [u32; SHA1_HASH_SIZE / 4] = [ 0x67452301u32, 0xefcdab89u32, 0x98badcfeu32, 0x10325476u32, 0xc3d2e1f0u32 ]...
if self.message_block_index == 64 { self.sha1_process_block(); } } } fn result(&mut self, out: &mut [u8]) { self.sha1_result(out); } fn output_bits(&self) -> usize { 160 } fn block_size(&self) -> usize { BLOCK_SIZE } } #[cfg(test)] mod te...
{ self.length_high = self.length_high.wrapping_add(1); if self.length_high == 0 { self.corrupted = Err(DigestError::InputTooLongError); } }
conditional_block
sha1.rs
use std::clone::Clone; use digest::{Digest, DigestError, DigestResult, DigestSuccess}; const SHA1_HASH_SIZE: usize = 20; const BLOCK_SIZE: usize = 64; // Initial hash value. const INIT_STATE: [u32; SHA1_HASH_SIZE / 4] = [ 0x67452301u32, 0xefcdab89u32, 0x98badcfeu32, 0x10325476u32, 0xc3d2e1f0u32 ]...
(&self) -> Self { *self } } impl Sha1 { pub fn new() -> Sha1 { let mut new_sha1 = Sha1 { intermediate_hash: [0u32; SHA1_HASH_SIZE / 4], length_low: 0, length_high: 0, message_block_index: 0, message_block: [0u8; BLOCK_SIZE], ...
clone
identifier_name
sha1.rs
use std::clone::Clone; use digest::{Digest, DigestError, DigestResult, DigestSuccess}; const SHA1_HASH_SIZE: usize = 20; const BLOCK_SIZE: usize = 64; // Initial hash value. const INIT_STATE: [u32; SHA1_HASH_SIZE / 4] = [ 0x67452301u32, 0xefcdab89u32, 0x98badcfeu32, 0x10325476u32, 0xc3d2e1f0u32 ]...
new_sha1 } /** * This function will process the next 512 bits of the message * stored in the Message_Block array. * * Many of the variable names in this code, especially the * single character names, were used because those were the * names used in the publication. *...
corrupted: Ok(DigestSuccess) }; new_sha1.reset();
random_line_split
cargo_expand.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::bindgen::config::Profile; use std::env; use std::error; use std::fmt; use std::io; use std::path::{Path...
(err: io::Error) -> Self { Error::Io(err) } } impl From<Utf8Error> for Error { fn from(err: Utf8Error) -> Self { Error::Utf8(err) } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Error::Io(ref err) => err.fmt(f), ...
from
identifier_name
cargo_expand.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::bindgen::config::Profile; use std::env; use std::error; use std::fmt; use std::io; use std::path::{Path...
cmd.env("_CBINDGEN_IS_RUNNING", "1"); cmd.arg("rustc"); cmd.arg("--lib"); // When build with the release profile we can't choose the `check` profile. if profile!= Profile::Release { cmd.arg("--profile=check"); } cmd.arg("--manifest-path"); cmd.arg(manifest_path); if let Some...
{ let cargo = env::var("CARGO").unwrap_or_else(|_| String::from("cargo")); let mut cmd = Command::new(cargo); let mut _temp_dir = None; // drop guard if use_tempdir { _temp_dir = Some(Builder::new().prefix("cbindgen-expand").tempdir()?); cmd.env("CARGO_TARGET_DIR", _temp_dir.unwrap().pa...
identifier_body
cargo_expand.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::bindgen::config::Profile; use std::env; use std::error; use std::fmt; use std::io; use std::path::{Path...
} else { Ok(src) } }
Err(Error::Compile(error))
random_line_split
proxy.rs
#![deny(warnings)] extern crate hyper; extern crate pretty_env_logger; use hyper::{Client, Server}; use hyper::service::service_fn; use hyper::rt::{self, Future}; use std::net::SocketAddr; fn
() { pretty_env_logger::init(); let in_addr = ([127, 0, 0, 1], 3001).into(); let out_addr: SocketAddr = ([127, 0, 0, 1], 3000).into(); let client_main = Client::new(); let out_addr_clone = out_addr.clone(); // new_service is run for each connection, creating a'service' // to handle reques...
main
identifier_name
proxy.rs
#![deny(warnings)] extern crate hyper; extern crate pretty_env_logger; use hyper::{Client, Server}; use hyper::service::service_fn; use hyper::rt::{self, Future}; use std::net::SocketAddr; fn main()
let uri = uri_string.parse().unwrap(); *req.uri_mut() = uri; client.request(req) }) }; let server = Server::bind(&in_addr) .serve(new_service) .map_err(|e| eprintln!("server error: {}", e)); println!("Listening on http://{}", in_addr); println!...
{ pretty_env_logger::init(); let in_addr = ([127, 0, 0, 1], 3001).into(); let out_addr: SocketAddr = ([127, 0, 0, 1], 3000).into(); let client_main = Client::new(); let out_addr_clone = out_addr.clone(); // new_service is run for each connection, creating a 'service' // to handle requests...
identifier_body
proxy.rs
#![deny(warnings)] extern crate hyper; extern crate pretty_env_logger; use hyper::{Client, Server}; use hyper::service::service_fn; use hyper::rt::{self, Future}; use std::net::SocketAddr; fn main() { pretty_env_logger::init(); let in_addr = ([127, 0, 0, 1], 3001).into(); let out_addr: SocketAddr = ([127...
*req.uri_mut() = uri; client.request(req) }) }; let server = Server::bind(&in_addr) .serve(new_service) .map_err(|e| eprintln!("server error: {}", e)); println!("Listening on http://{}", in_addr); println!("Proxying on http://{}", out_addr); rt::run(s...
out_addr_clone, req.uri().path_and_query().map(|x| x.as_str()).unwrap_or("")); let uri = uri_string.parse().unwrap();
random_line_split
allocator-override.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 ...
() { unsafe { let before = allocator_dummy::HITS; let b = Box::new(3); assert_eq!(allocator_dummy::HITS - before, 1); drop(b); assert_eq!(allocator_dummy::HITS - before, 2); } }
main
identifier_name
allocator-override.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 ...
{ unsafe { let before = allocator_dummy::HITS; let b = Box::new(3); assert_eq!(allocator_dummy::HITS - before, 1); drop(b); assert_eq!(allocator_dummy::HITS - before, 2); } }
identifier_body
type_.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 ...
(&self) -> ~[Type] { unsafe { let n_args = llvm::LLVMCountParamTypes(self.to_ref()) as uint; let args = vec::from_elem(n_args, 0 as TypeRef); llvm::LLVMGetParamTypes(self.to_ref(), args.as_ptr()); cast::transmute(args) } } pub fn float_width(&self...
func_params
identifier_name
type_.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn float_from_ty(t: ast::FloatTy) -> Type { match t { ast::TyF32 => Type::f32(), ast::TyF64 => Type::f64() } } pub fn size_t(arch: Architecture) -> Type { Type::int(arch) } pub fn func(args: &[Type], ret: &Type) -> Type { let vec : &[Ty...
{ match t { ast::TyU => ctx.int_type, ast::TyU8 => Type::i8(), ast::TyU16 => Type::i16(), ast::TyU32 => Type::i32(), ast::TyU64 => Type::i64() } }
identifier_body
type_.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn i1() -> Type { ty!(llvm::LLVMInt1TypeInContext(base::task_llcx())) } pub fn i8() -> Type { ty!(llvm::LLVMInt8TypeInContext(base::task_llcx())) } pub fn i16() -> Type { ty!(llvm::LLVMInt16TypeInContext(base::task_llcx())) } pub fn i32() -> Type { ty!...
ty!(llvm::LLVMMetadataTypeInContext(base::task_llcx())) }
random_line_split
main.rs
#![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![cfg_attr(feature="clippy", deny(clippy_pedantic))] #![cfg_attr(feature="clippy", allow(missing_docs_in_private_items))] #![deny(missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numer...
(m: &ArgMatches) -> Vec<String> { match m.values_of("ignore") { Some(i) => i.into_iter().map(|str| str.to_owned()).collect(), None => vec![], } } fn get_base_dir(base_dir: &str) -> String { helpers::resolve_path(base_dir).unwrap_or_else(|| { helpers::print_error_and_exit("failed to ...
get_ignore_strings
identifier_name
main.rs
#![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![cfg_attr(feature="clippy", deny(clippy_pedantic))] #![cfg_attr(feature="clippy", allow(missing_docs_in_private_items))] #![deny(missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numer...
.open(path_buf.as_path()); if let Ok(file) = wrapped_file { let level = if verbose_mode { slog::Level::Debug } else { slog::Level::Info }; let file_decorator = slog_term::PlainSyncDecorator::new(file); let file_drain = slog_term::FullFormat::n...
random_line_split
main.rs
#![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![cfg_attr(feature="clippy", deny(clippy_pedantic))] #![cfg_attr(feature="clippy", allow(missing_docs_in_private_items))] #![deny(missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numer...
fn run_master(m: &ArgMatches) { #[cfg_attr(feature="clippy", allow(option_unwrap_used))] // Unwrap is safe - required by clap let base_dir = get_base_dir(m.value_of("base_dir").unwrap()); #[cfg_attr(feature="clippy", allow(option_unwrap_used))] let remote_dir = m.value_of("remote_dir").unwrap(); /...
{ #[cfg_attr(feature="clippy", allow(indexing_slicing))] let yaml = load_yaml!("cli.yml"); let m = App::from_yaml(yaml).version(VERSION).get_matches(); if let Some(sub_m) = m.subcommand_matches("run") { run_master(sub_m); } else if let Some(sub_m) = m.subcommand_matches("slave") { r...
identifier_body
ord.rs
use crate::sql_types::{self, is_nullable, SqlType}; /// Marker trait for types which can be used with `MAX` and `MIN` pub trait SqlOrd: SqlType {} impl SqlOrd for sql_types::SmallInt {} impl SqlOrd for sql_types::Integer {} impl SqlOrd for sql_types::BigInt {} impl SqlOrd for sql_types::Float {} impl SqlOrd for sql_t...
impl<T> SqlOrd for sql_types::Nullable<T> where T: SqlOrd + SqlType<IsNull = is_nullable::NotNull> {} #[cfg(feature = "postgres")] impl SqlOrd for sql_types::Timestamptz {} #[cfg(feature = "postgres")] impl<T: SqlOrd> SqlOrd for sql_types::Array<T> {} #[cfg(feature = "mysql")] impl SqlOrd for sql_types::Datetime {} #...
random_line_split
project-fn-ret-invariant.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 ...
#[cfg(ok)] // two instantiations: OK fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { let a = bar(foo, x); let b = bar(foo, y); (a, b) } #[cfg(oneuse)] // one instantiation: BAD fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { let f = foo; // <-- No consistent type ca...
{ t() }
identifier_body
project-fn-ret-invariant.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. //
// except according to those terms. #![feature(unboxed_closures)] #![feature(rustc_attrs)] // Test for projection cache. We should be able to project distinct // lifetimes from `foo` as we reinstantiate it multiple times, but not // if we do it just once. In this variant, the region `'a` is used in // an invariant po...
// 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
random_line_split
project-fn-ret-invariant.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> { // Invariant data: PhantomData<fn(&'a u32) -> &'a u32> } fn foo<'a>() -> Type<'a> { loop { } } fn bar<T>(t: T, x: T::Output) -> T::Output where T: FnOnce<()> { t() } #[cfg(ok)] // two instantiations: OK fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { let a = bar(foo, x); ...
Type
identifier_name
client.rs
extern crate getopts; extern crate serde_json; extern crate udt; extern crate punchtunnel; use std::env; use std::fs::File; use std::iter::FromIterator; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs, UdpSocket}; use std::process::exit; use std::thread; use std::time::Duration; use getopts::Opt...
}
random_line_split
client.rs
extern crate getopts; extern crate serde_json; extern crate udt; extern crate punchtunnel; use std::env; use std::fs::File; use std::iter::FromIterator; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs, UdpSocket}; use std::process::exit; use std::thread; use std::time::Duration; use getopts::Opt...
() -> Result<(), String> { let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); let matches = match opts.parse(&args[1..]) { Ok(x) => x, Err(e) => { eprintln!("{}",...
run
identifier_name
trait-cast.rs
// xfail-test FIXME #5882 // Weird borrow check bug // 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/license...
let t1 = Tree(@mut TreeR{left: None, right: None, val: ~1 as ~to_str }); let t2 = Tree(@mut TreeR{left: Some(t1), right: Some(t1), val: ~2 as ~to_str }); let expected = ~"[2, some([1, none, no...
random_line_split
trait-cast.rs
// xfail-test FIXME #5882 // Weird borrow check bug // 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/license...
(&self) -> ~str { let (l, r) = (self.left, self.right); let val = &self.val; fmt!("[%s, %s, %s]", val.to_str_(), l.to_str_(), r.to_str_()) } } fn foo<T:to_str>(x: T) -> ~str { x.to_str_() } pub fn main() { let t1 = Tree(@mut TreeR{left: None, right: None, ...
to_str_
identifier_name
trait-cast.rs
// xfail-test FIXME #5882 // Weird borrow check bug // 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/license...
{ let t1 = Tree(@mut TreeR{left: None, right: None, val: ~1 as ~to_str }); let t2 = Tree(@mut TreeR{left: Some(t1), right: Some(t1), val: ~2 as ~to_str }); let expected = ~"[2, some([1, none, ...
identifier_body
structural_match.rs
use crate::infer::{InferCtxt, TyCtxtInferExt}; use crate::traits::ObligationCause; use crate::traits::{self, TraitEngine}; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFo...
(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> { debug!("Search visiting ty: {:?}", ty); let (adt_def, substs) = match *ty.kind() { ty::Adt(adt_def, substs) => (adt_def, substs), ty::Param(_) => { return ControlFlow::Break(NonStructuralMatchTy::Param); ...
visit_ty
identifier_name
structural_match.rs
use crate::infer::{InferCtxt, TyCtxtInferExt}; use crate::traits::ObligationCause; use crate::traits::{self, TraitEngine}; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFo...
_id: hir::HirId, span: Span, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ) -> Option<NonStructuralMatchTy<'tcx>> { // FIXME: we should instead pass in an `infcx` from the outside. tcx.infer_ctxt().enter(|infcx| { ty.visit_with(&mut Search { infcx, span, seen: FxHashSet::default() }).break_value() ...
/// Rust RFC 1445, rust-lang/rust#61188, and rust-lang/rust#62307. pub fn search_for_structural_match_violation<'tcx>(
random_line_split
structural_match.rs
use crate::infer::{InferCtxt, TyCtxtInferExt}; use crate::traits::ObligationCause; use crate::traits::{self, TraitEngine}; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFo...
ty::Projection(..) => { return ControlFlow::Break(NonStructuralMatchTy::Projection); } ty::Generator(..) | ty::GeneratorWitness(..) => { return ControlFlow::Break(NonStructuralMatchTy::Generator); } ty::RawPtr(..) => { ...
{ return ControlFlow::Break(NonStructuralMatchTy::Opaque); }
conditional_block
bridge.rs
extern crate serde_json; use std; use std::str; use std::io::Result as IoResult; use std::time::Duration; use std::net::IpAddr; use std::net::Ipv4Addr; use std::net::UdpSocket; use std::collections::HashSet; use hyper::Client; use serde_json::Value; use user::User; use utils; use error::Result; /// Returns a HashSe...
let joined = string_list.join("\r\n"); let socket = UdpSocket::bind("0.0.0.0:0")?; let two_second_timeout = Duration::new(2, 0); let _ = socket.set_read_timeout(Some(two_second_timeout)); socket.send_to(joined.as_bytes(), "239.255.255.250:1900")?; let mut bridges = HashSet::new(); ...
"HOST:239.255.255.250:1900", "MAN:\"ssdp:discover\"", "ST:ssdp:all", "MX:1" ];
random_line_split
bridge.rs
extern crate serde_json; use std; use std::str; use std::io::Result as IoResult; use std::time::Duration; use std::net::IpAddr; use std::net::Ipv4Addr; use std::net::UdpSocket; use std::collections::HashSet; use hyper::Client; use serde_json::Value; use user::User; use utils; use error::Result; /// Returns a HashSe...
}
{ #[derive(Debug, Serialize, Deserialize)] struct Devicetype { devicetype: String, } let url = format!("http://{}/api", self.ip); let payload = Devicetype { devicetype: name.to_owned() }; let body = serde_json::to_string(&payload)?; let response = se...
identifier_body
bridge.rs
extern crate serde_json; use std; use std::str; use std::io::Result as IoResult; use std::time::Duration; use std::net::IpAddr; use std::net::Ipv4Addr; use std::net::UdpSocket; use std::collections::HashSet; use hyper::Client; use serde_json::Value; use user::User; use utils; use error::Result; /// Returns a HashSe...
{ devicetype: String, } let url = format!("http://{}/api", self.ip); let payload = Devicetype { devicetype: name.to_owned() }; let body = serde_json::to_string(&payload)?; let response = self.client.post(&url).body(&body).send()?; let json: Value = serde_js...
Devicetype
identifier_name
derive-hash-struct-with-float-array.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] /// A struct containing an array of floats that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { pub bar: [f32;...
concat!("Offset of field: ", stringify!(foo), "::", stringify!(bar)) ); }
assert_eq!( unsafe { &(*(::std::ptr::null::<foo>())).bar as *const _ as usize }, 0usize,
random_line_split
derive-hash-struct-with-float-array.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] /// A struct containing an array of floats that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { pub bar: [f32;...
() { assert_eq!( ::std::mem::size_of::<foo>(), 12usize, concat!("Size of: ", stringify!(foo)) ); assert_eq!( ::std::mem::align_of::<foo>(), 4usize, concat!("Alignment of ", stringify!(foo)) ); assert_eq!( unsafe { &(*(::std::ptr::null::<foo>())...
bindgen_test_layout_foo
identifier_name
owned.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 ...
} impl<T: fmt::Show> fmt::Show for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } impl fmt::Show for Box<Any> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Box<Any>") } }
{ if self.is::<T>() { unsafe { // Get the raw representation of the trait object let to: TraitObject = *mem::transmute::<&Box<Any>, &TraitObject>(&self); // Prevent destructor on self being run intrinsics::forget(se...
identifier_body
owned.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 ...
} } impl<T: fmt::Show> fmt::Show for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } impl fmt::Show for Box<Any> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Box<Any>") } }
{ Err(self) }
conditional_block
owned.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 ...
(&self, other: &Box<T>) -> bool { *(*self) <= *(*other) } #[inline] fn ge(&self, other: &Box<T>) -> bool { *(*self) >= *(*other) } #[inline] fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) } } impl<T: TotalOrd> TotalOrd for Box<T> { #[inline] fn cmp(&self, other: &Box<T>) -> Ordering...
le
identifier_name