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
mod_dir_path.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...
() { assert_eq!(mod_dir_simple::syrup::foo(), 10); #[path = "auxiliary"] mod foo { mod two_macros_2; } #[path = "auxiliary"] mod bar { macro_rules! m { () => { mod two_macros_2; } } m!(); } }
main
identifier_name
mod_dir_path.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...
mod foo { mod two_macros_2; } #[path = "auxiliary"] mod bar { macro_rules! m { () => { mod two_macros_2; } } m!(); } }
pub fn main() { assert_eq!(mod_dir_simple::syrup::foo(), 10); #[path = "auxiliary"]
random_line_split
regions-close-associated-type-into-object.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 ...
<'a, T: Iter>(v: T) -> Box<X+'a> where T::Item : 'a { let item = v.into_item(); Box::new(item) // OK, T::Item : 'a is declared } fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box<X+'a> where T::Item : Clone { let item = Clone::clone(w); Box::new(item) // OK, T::Item : 'a is implied } fn ok3<'a...
ok1
identifier_name
regions-close-associated-type-into-object.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box<X+'a> where T::Item : Clone { let item = Clone::clone(w); Box::new(item) // OK, T::Item : 'a is implied } fn ok3<'a, T: Iter>(v: &'a T) -> Box<X+'a> where T::Item : Clone + 'a { let item = Clone::clone(v.as_item()); Box::new(item) // OK, T::It...
{ let item = v.into_item(); Box::new(item) // OK, T::Item : 'a is declared }
identifier_body
regions-close-associated-type-into-object.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let item = Clone::clone(w); Box::new(item) // OK, T::Item : 'a is implied } fn ok3<'a, T: Iter>(v: &'a T) -> Box<X+'a> where T::Item : Clone + 'a { let item = Clone::clone(v.as_item()); Box::new(item) // OK, T::Item : 'a was declared } fn meh1<'a, T: Iter>(v: &'a T) -> Box<X+'a> where T::Item ...
where T::Item : Clone {
random_line_split
builder.rs
use num::{Integer, NumCast, Unsigned}; use std::hash::Hash; use typenum::NonZero; use crate::buffer::{BufferError, MeshBuffer}; use crate::builder::{FacetBuilder, MeshBuilder, SurfaceBuilder}; use crate::constant::{Constant, ToType, TypeOf}; use crate::geometry::{FromGeometry, IntoGeometry}; use crate::index::{Flat, G...
} impl<P, G> FacetBuilder<P::Vertex> for BufferBuilder<P, G> where P: Grouping<Group = P> + Topological, P::Vertex: Copy + Hash + Integer + Unsigned, Vec<P>: IndexBuffer<P>, { type Facet = (); type Key = (); fn insert_facet<T, U>(&mut self, keys: T, _: U) -> Result<Self::Key, Self::Error> ...
{ let keys = keys.as_ref(); if keys.len() == N { self.indices.extend(keys.iter()); Ok(()) } else { // TODO: These numbers do not necessarily represent arity (i.e., the // number of edges of each topological structure). Use a ...
identifier_body
builder.rs
use num::{Integer, NumCast, Unsigned}; use std::hash::Hash; use typenum::NonZero; use crate::buffer::{BufferError, MeshBuffer}; use crate::builder::{FacetBuilder, MeshBuilder, SurfaceBuilder}; use crate::constant::{Constant, ToType, TypeOf}; use crate::geometry::{FromGeometry, IntoGeometry}; use crate::index::{Flat, G...
(self) -> Self::Abort {} }
abort
identifier_name
builder.rs
use num::{Integer, NumCast, Unsigned}; use std::hash::Hash; use typenum::NonZero; use crate::buffer::{BufferError, MeshBuffer}; use crate::builder::{FacetBuilder, MeshBuilder, SurfaceBuilder}; use crate::constant::{Constant, ToType, TypeOf}; use crate::geometry::{FromGeometry, IntoGeometry}; use crate::index::{Flat, G...
else { // TODO: These numbers do not necessarily represent arity (i.e., the // number of edges of each topological structure). Use a // different error variant to express this. Err(BufferError::ArityConflict { expected: N, ...
{ self.indices.extend(keys.iter()); Ok(()) }
conditional_block
builder.rs
use crate::builder::{FacetBuilder, MeshBuilder, SurfaceBuilder}; use crate::constant::{Constant, ToType, TypeOf}; use crate::geometry::{FromGeometry, IntoGeometry}; use crate::index::{Flat, Grouping, IndexBuffer}; use crate::primitive::Topological; use crate::transact::{ClosedInput, Transact}; use crate::Arity; // TOD...
use num::{Integer, NumCast, Unsigned}; use std::hash::Hash; use typenum::NonZero; use crate::buffer::{BufferError, MeshBuffer};
random_line_split
util.rs
use fastrand; use std::ffi::{OsStr, OsString}; use std::path::{Path, PathBuf}; use std::{io, iter::repeat_with}; use crate::error::IoResultExt; fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString { let mut buf = OsString::with_capacity(prefix.len() + suffix.len() + rand_len); buf.push(pref...
<F, R>( base: &Path, prefix: &OsStr, suffix: &OsStr, random_len: usize, f: F, ) -> io::Result<R> where F: Fn(PathBuf) -> io::Result<R>, { let num_retries = if random_len!= 0 { crate::NUM_RETRIES } else { 1 }; for _ in 0..num_retries { let path = base.join...
create_helper
identifier_name
util.rs
use fastrand; use std::ffi::{OsStr, OsString}; use std::path::{Path, PathBuf}; use std::{io, iter::repeat_with}; use crate::error::IoResultExt; fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString { let mut buf = OsString::with_capacity(prefix.len() + suffix.len() + rand_len); buf.push(pref...
; for _ in 0..num_retries { let path = base.join(tmpname(prefix, suffix, random_len)); return match f(path) { Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => continue, res => res, }; } Err(io::Error::new( io::ErrorKind::AlreadyExists, ...
{ 1 }
conditional_block
util.rs
use fastrand; use std::ffi::{OsStr, OsString}; use std::path::{Path, PathBuf}; use std::{io, iter::repeat_with}; use crate::error::IoResultExt; fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString { let mut buf = OsString::with_capacity(prefix.len() + suffix.len() + rand_len); buf.push(pref...
io::ErrorKind::AlreadyExists, "too many temporary files exist", )) .with_err_path(|| base) }
}; } Err(io::Error::new(
random_line_split
util.rs
use fastrand; use std::ffi::{OsStr, OsString}; use std::path::{Path, PathBuf}; use std::{io, iter::repeat_with}; use crate::error::IoResultExt; fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString { let mut buf = OsString::with_capacity(prefix.len() + suffix.len() + rand_len); buf.push(pref...
}
{ let num_retries = if random_len != 0 { crate::NUM_RETRIES } else { 1 }; for _ in 0..num_retries { let path = base.join(tmpname(prefix, suffix, random_len)); return match f(path) { Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => continue, ...
identifier_body
lib.rs
self.ic = next_ic; next_ic = self.chars.advance(); for i in range(0, clist.size) { let pc = clist.pc(i); let step_state = self.step(&mut groups, nlist, clist.groups(i), pc); ...
check_prefix
identifier_name
lib.rs
let num_cap_locs = 2 * self.prog.num_captures(); let num_insts = self.prog.insts.len(); let cap_names = self.vec_expr(self.names.as_slice().iter(), |cx, name| match *name { Some(ref name) => { let name = name.as_slice(); quote_e...
let arms = self.prog.insts.iter().enumerate().map(|(pc, inst)| { let nextpc = pc + 1; let body = match *inst { Match => { quote_expr!(self.cx, { match self.which { Exists => { ...
random_line_split
lib.rs
here: // http://research.swtch.com/sparse // The idea here is to avoid initializing threads that never // need to be initialized, particularly for larger regexs with // a lot of instructions. queue: unsafe { ::std::mem::uninit() }, ...
{ let exprs = xs.map(|x| to_expr(self.cx, x)).collect(); self.cx.expr_vec(self.sp, exprs) }
identifier_body
cleanup_sst.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fmt; use std::sync::Arc; use kvproto::import_sstpb::SstMeta; use crate::store::util::is_epoch_stale; use crate::store::{StoreMsg, StoreRouter}; use engine_traits::KvEngine; use pd_client::PdClient; use sst_importer::SSTImporter; use std::mar...
( store_id: u64, store_router: S, importer: Arc<SSTImporter>, pd_client: Arc<C>, ) -> Runner<EK, C, S> { Runner { store_id, store_router, importer, pd_client, _engine: PhantomData, } } /// Deletes SS...
new
identifier_name
cleanup_sst.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fmt; use std::sync::Arc; use kvproto::import_sstpb::SstMeta; use crate::store::util::is_epoch_stale; use crate::store::{StoreMsg, StoreRouter}; use engine_traits::KvEngine; use pd_client::PdClient; use sst_importer::SSTImporter; use std::mar...
} Err(e) => { error!(%e; "get region failed"); } } } // We need to send back the result to check for the stale // peer, which may ingest the stale SST before it is // destroyed. let msg = StoreMsg::V...
{ let store_id = self.store_id; let mut invalid_ssts = Vec::new(); for sst in ssts { match self.pd_client.get_region(sst.get_range().get_start()) { Ok(r) => { // The region id may or may not be the same as the // SST file, but i...
identifier_body
cleanup_sst.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fmt; use std::sync::Arc; use kvproto::import_sstpb::SstMeta; use crate::store::util::is_epoch_stale; use crate::store::{StoreMsg, StoreRouter}; use engine_traits::KvEngine; use pd_client::PdClient; use sst_importer::SSTImporter; use std::mar...
let mut invalid_ssts = Vec::new(); for sst in ssts { match self.pd_client.get_region(sst.get_range().get_start()) { Ok(r) => { // The region id may or may not be the same as the // SST file, but it doesn't matter, because the ...
fn handle_validate_sst(&self, ssts: Vec<SstMeta>) { let store_id = self.store_id;
random_line_split
cleanup_sst.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fmt; use std::sync::Arc; use kvproto::import_sstpb::SstMeta; use crate::store::util::is_epoch_stale; use crate::store::{StoreMsg, StoreRouter}; use engine_traits::KvEngine; use pd_client::PdClient; use sst_importer::SSTImporter; use std::mar...
} } // We need to send back the result to check for the stale // peer, which may ingest the stale SST before it is // destroyed. let msg = StoreMsg::ValidateSSTResult { invalid_ssts }; if let Err(e) = self.store_router.send(msg) { error!(%e; "sen...
{ error!(%e; "get region failed"); }
conditional_block
resources.rs
use serde::de::Deserialize; use serde_json; use std::{collections::HashMap, str}; use economy::Commodity; use entities::Faction; use entities::PlanetEconomy; /// Generic Resource trait to be implemented by all resource types which should /// be loaded at compile time. /// KEY must be unique to the specific resource (...
{ pub names: Vec<String>, pub scientific_names: Vec<String>, pub greek: Vec<String>, pub roman: Vec<String>, pub decorators: Vec<String>, } impl Resource for AstronomicalNamesResource { const KEY: &'static str = "astronomical_names"; } #[derive(Serialize, Deserialize, Debug)] /// Resource con...
AstronomicalNamesResource
identifier_name
resources.rs
use serde::de::Deserialize; use serde_json; use std::{collections::HashMap, str}; use economy::Commodity; use entities::Faction; use entities::PlanetEconomy; /// Generic Resource trait to be implemented by all resource types which should /// be loaded at compile time. /// KEY must be unique to the specific resource (...
/// if the type has no resource or if the deserialization fails. pub fn fetch_resource<T: Resource>() -> Option<T> { let res_str = RESOURCES.get(T::KEY).unwrap(); match serde_json::from_str(res_str) { Ok(res) => Some(res), Err(msg) => { error!("{}", msg); None } ...
random_line_split
previous.rs
use std::path::Path; use serde::{ Deserialize, Serialize, }; use anyhow::Result; use rnc_core::grouper; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub struct
{ pub id: usize, pub urs_id: usize, pub urs_taxid: String, upi: String, taxid: usize, databases: Option<String>, description: Option<String>, has_coordinates: Option<bool>, is_active: Option<bool>, last_release: Option<usize>, rna_type: Option<String>, short_description:...
Previous
identifier_name
previous.rs
use std::path::Path; use serde::{ Deserialize, Serialize, }; use anyhow::Result; use rnc_core::grouper; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub struct Previous { pub id: usize, pub urs_id: usize, pub urs_taxid: String, upi: String, taxid: usize, databases: Opti...
} pub fn group(path: &Path, max: usize, output: &Path) -> Result<()> { grouper::group::<Previous>(grouper::Criteria::ZeroOrOne, &path, 1, max, &output) }
{ self.id }
identifier_body
previous.rs
use std::path::Path; use serde::{ Deserialize, Serialize, }; use anyhow::Result; use rnc_core::grouper; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub struct Previous { pub id: usize, pub urs_id: usize, pub urs_taxid: String, upi: String, taxid: usize, databases: Opti...
} impl grouper::HasIndex for Previous { fn index(&self) -> usize { self.id } } pub fn group(path: &Path, max: usize, output: &Path) -> Result<()> { grouper::group::<Previous>(grouper::Criteria::ZeroOrOne, &path, 1, max, &output) }
last_release: Option<usize>, rna_type: Option<String>, short_description: Option<String>, so_rna_type: Option<String>,
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/. */ //! This module contains shared types and messages for use by devtools/script. //! The traits are here instead of ...
{ PageError(PageError), ConsoleAPI(ConsoleAPI), } #[derive(Debug, PartialEq)] pub struct HttpRequest { pub url: Url, pub method: Method, pub headers: Headers, pub body: Option<Vec<u8>>, pub pipeline_id: PipelineId, pub startedDateTime: Tm } #[derive(Debug, PartialEq)] pub struct HttpR...
CachedConsoleMessage
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/. */ //! This module contains shared types and messages for use by devtools/script. //! The traits are here instead of ...
extern crate ipc_channel; extern crate msg; extern crate serde; extern crate time; extern crate url; extern crate util; use hyper::header::Headers; use hyper::http::RawStatus; use hyper::method::Method; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use std::net::TcpStream; use time::Duration...
#[macro_use] extern crate bitflags; extern crate heapsize; extern crate hyper;
random_line_split
zero.rs
#![feature(core, zero_one)] extern crate core; #[cfg(test)] mod tests { use core::num::Zero; // pub trait Zero { // /// The "zero" (usually, additive identity) for this type. // fn zero() -> Self; // } // pub trait One { // /// The "one" (usually, multiplicative identity) for ...
() { let value: T = T::zero(); assert_eq!(value, 0x0000000000000000); } }
zero_test1
identifier_name
zero.rs
#![feature(core, zero_one)] extern crate core; #[cfg(test)] mod tests { use core::num::Zero; // pub trait Zero { // /// The "zero" (usually, additive identity) for this type. // fn zero() -> Self; // } // pub trait One { // /// The "one" (usually, multiplicative identity) for ...
// impl One for $t { // #[inline] // fn one() -> Self { 1 } // } // )*) // } // zero_one_impl! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } // macro_rules! zero_one_impl_float { // ($($t:ty)*) => ($( // impl Zero for $t { ...
// }
random_line_split
zero.rs
#![feature(core, zero_one)] extern crate core; #[cfg(test)] mod tests { use core::num::Zero; // pub trait Zero { // /// The "zero" (usually, additive identity) for this type. // fn zero() -> Self; // } // pub trait One { // /// The "one" (usually, multiplicative identity) for ...
}
{ let value: T = T::zero(); assert_eq!(value, 0x0000000000000000); }
identifier_body
meta.rs
// Copyright (C) 2015 Steven Allen // // This file is part of gazetta. // // 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 version 3 of the // License. // // This program is distributed in t...
} pub struct EntryMeta { pub author: Option<Person>, pub about: Option<Person>, } impl Meta for EntryMeta { fn from_yaml(mut meta: Hash) -> Result<EntryMeta, &'static str> { Ok(EntryMeta { author: meta .remove(&AUTHOR) .map(Person::from_yaml) ...
{ Ok(SourceMeta { nav: meta .remove(&NAV) .map(Link::many_from_yaml) .bubble_result()? .unwrap_or_else(Vec::new), author: meta .remove(&AUTHOR) .map(Person::from_yaml) .bubble_...
identifier_body
meta.rs
// Copyright (C) 2015 Steven Allen // // This file is part of gazetta. // // 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 version 3 of the // License. // // This program is distributed in t...
.remove(&AUTHOR) .map(Person::from_yaml) .bubble_result()? .ok_or("websites must have authors")?, }) } } pub struct EntryMeta { pub author: Option<Person>, pub about: Option<Person>, } impl Meta for EntryMeta { fn from_yaml(mut meta: ...
random_line_split
meta.rs
// Copyright (C) 2015 Steven Allen // // This file is part of gazetta. // // 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 version 3 of the // License. // // This program is distributed in t...
{ pub author: Option<Person>, pub about: Option<Person>, } impl Meta for EntryMeta { fn from_yaml(mut meta: Hash) -> Result<EntryMeta, &'static str> { Ok(EntryMeta { author: meta .remove(&AUTHOR) .map(Person::from_yaml) .bubble_result()?, ...
EntryMeta
identifier_name
day20.rs
extern crate clap; extern crate regex; use clap::App; fn main() { let matches = App::new("day20") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<NUM> 'Minimum present number'") .get_matches(); let num = matches.value_of("NUM").unwrap().parse::<us...
for (i, e) in v.iter().enumerate() { if *e >= presents { println!("Part 1: House {} received {} presents", i+1, e); break; } } }
} }
random_line_split
day20.rs
extern crate clap; extern crate regex; use clap::App; fn main() { let matches = App::new("day20") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<NUM> 'Minimum present number'") .get_matches(); let num = matches.value_of("NUM").unwrap().parse::<us...
break; } } } fn find_house_number(presents : usize) { let target = presents / 10; let mut v = vec![0; target]; for i in 1..target+1 { let mut j = i; while j <= target { let entry = v.get_mut(j-1).unwrap(); *entry += i*10; j +...
{ let sz = presents/10; let mut v = vec![0; sz]; for i in 1..sz+1 { let mut j = i; let mut cnt = 0; while j <= sz && cnt < 50 { let entry = v.get_mut(j-1).unwrap(); *entry += i*11; j += i; cnt += 1; } } for (i, e) ...
identifier_body
day20.rs
extern crate clap; extern crate regex; use clap::App; fn main() { let matches = App::new("day20") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<NUM> 'Minimum present number'") .get_matches(); let num = matches.value_of("NUM").unwrap().parse::<us...
(presents : usize) { let sz = presents/10; let mut v = vec![0; sz]; for i in 1..sz+1 { let mut j = i; let mut cnt = 0; while j <= sz && cnt < 50 { let entry = v.get_mut(j-1).unwrap(); *entry += i*11; j += i; cnt += 1; } ...
find_house_number_part2
identifier_name
day20.rs
extern crate clap; extern crate regex; use clap::App; fn main() { let matches = App::new("day20") .version("v1.0") .author("Andrew Rink <andrewrink@gmail.com>") .args_from_usage("<NUM> 'Minimum present number'") .get_matches(); let num = matches.value_of("NUM").unwrap().parse::<us...
} } fn find_house_number(presents : usize) { let target = presents / 10; let mut v = vec![0; target]; for i in 1..target+1 { let mut j = i; while j <= target { let entry = v.get_mut(j-1).unwrap(); *entry += i*10; j += i; } } for...
{ println!("Part 2: House {} received {} presents", i+1, e); break; }
conditional_block
parser.rs
/* Copyright (C) 2018 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
(input: &str) -> Result<u32, std::num::ParseIntError> { input.parse::<u32>() } named!(pub parse_message<String>, do_parse!( len: map_res!( map_res!(take_until!(":"), std::str::from_utf8), parse_len) >> _sep: take!(1) >> msg: take_str!(len) >> ...
parse_len
identifier_name
parser.rs
/* Copyright (C) 2018 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
} }
{ let buf = b"12:Hello World!4:Bye."; let result = parse_message(buf); match result { Ok((remainder, message)) => { // Check the first message. assert_eq!(message, "Hello World!"); // And we should have 6 bytes left. a...
identifier_body
parser.rs
/* Copyright (C) 2018 Open Information Security Foundation *
* the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public Lice...
* You can copy, redistribute or modify this Program under the terms of
random_line_split
proxyhandler.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/. */ //! Utilities for the implementation of JSAPI proxy handlers. #![deny(missing_docs)] use dom::bindings::conversi...
} /// No-op required hook. pub unsafe extern fn enumerate(_cx: *mut JSContext, _obj: *mut JSObject, _v: *mut AutoIdVector) -> bool { true }
random_line_split
proxyhandler.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/. */ //! Utilities for the implementation of JSAPI proxy handlers. #![deny(missing_docs)] use dom::bindings::conversi...
(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, bp: *mut bool) -> bool { let expando = get_expando_object(proxy); if expando.is_null() { *bp = true; return true; } return delete_property_by_id(cx, expando, id, &mut *bp); } /// Returns the stringificatio...
delete
identifier_name
proxyhandler.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/. */ //! Utilities for the implementation of JSAPI proxy handlers. #![deny(missing_docs)] use dom::bindings::conversi...
/// Set the property descriptor's object to `obj` and set it to enumerable, /// and writable if `readonly` is true. pub fn fill_property_descriptor(desc: &mut JSPropertyDescriptor, obj: *mut JSObject, readonly: bool) { desc.obj = obj; desc.attrs = if readonly { JSPROP_READONLY ...
{ unsafe { assert!(is_dom_proxy(obj)); let mut expando = get_expando_object(obj); if expando.is_null() { expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(), ptr::null_mut(), Ge...
identifier_body
proxyhandler.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/. */ //! Utilities for the implementation of JSAPI proxy handlers. #![deny(missing_docs)] use dom::bindings::conversi...
else { 0 } | JSPROP_ENUMERATE; desc.getter = None; desc.setter = None; desc.shortid = 0; } /// No-op required hook. pub unsafe extern fn get_own_property_names(_cx: *mut JSContext, _obj: *mut JSObject, _v: *mut AutoIdV...
{ JSPROP_READONLY }
conditional_block
sign.rs
// Copyright 2017-2021 int08h LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
} impl Signer { pub fn new() -> Self { let rng = rand::SystemRandom::new(); let mut seed = [0u8; 32]; rng.fill(&mut seed).unwrap(); Signer::from_seed(&seed) } pub fn from_seed(seed: &[u8]) -> Self { Signer { key_pair: Ed25519KeyPair::from_seed_unchecke...
{ Self::new() }
identifier_body
sign.rs
// Copyright 2017-2021 int08h LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
let pubkey = hex::decode( "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a", ).unwrap(); let signature = hex::decode( "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" ...
mod test { use super::*; #[test] fn verify_ed25519_sig_on_empty_message() {
random_line_split
sign.rs
// Copyright 2017-2021 int08h LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
() { let seed = hex::decode("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60") .unwrap(); let expected_sig = hex::decode( "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" )....
sign_ed25519_empty_message
identifier_name
cookie_storage.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Implementation of cookie storage as specified in //! http://tools.ietf.org/html/rfc6265 use net_traits::Cooki...
// http://tools.ietf.org/html/rfc6265#section-5.3 pub fn remove(&mut self, cookie: &Cookie, source: CookieSource) -> Result<Option<Cookie>, ()> { // Step 1 let position = self.cookies.iter().position(|c| { c.cookie.domain == cookie.cookie.domain && c.cookie.path == cookie...
random_line_split
cookie_storage.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Implementation of cookie storage as specified in //! http://tools.ietf.org/html/rfc6265 use net_traits::Cooki...
(&mut self, url: &Url, source: CookieSource) -> Option<String> { let filterer = |c: &&mut Cookie| -> bool { info!(" === SENT COOKIE : {} {} {:?} {:?}", c.cookie.name, c.cookie.value, c.cookie.domain, c.cookie.path); info!(" === SENT COOKIE RESULT {}", c.appropriate_for_...
cookies_for_url
identifier_name
cookie_storage.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Implementation of cookie storage as specified in //! http://tools.ietf.org/html/rfc6265 use net_traits::Cooki...
// Step 11 if let Some(old_cookie) = old_cookie.unwrap() { // Step 11.3 cookie.creation_time = old_cookie.creation_time; } // Step 12 self.cookies.push(cookie); } pub fn cookie_comparator(a: &Cookie, b: &Cookie) -> Ordering { let a_path...
{ return; }
conditional_block
cookie_storage.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Implementation of cookie storage as specified in //! http://tools.ietf.org/html/rfc6265 use net_traits::Cooki...
Ok(None) } } // http://tools.ietf.org/html/rfc6265#section-5.3 pub fn push(&mut self, mut cookie: Cookie, source: CookieSource) { let old_cookie = self.remove(&cookie, source); if old_cookie.is_err() { // This new cookie is not allowed to overwrite an existi...
{ // Step 1 let position = self.cookies.iter().position(|c| { c.cookie.domain == cookie.cookie.domain && c.cookie.path == cookie.cookie.path && c.cookie.name == cookie.cookie.name }); if let Some(ind) = position { let c = self.cookies.remo...
identifier_body
surface.rs
use {Scalar, TOLERANCE}; use maths::{CrossProduct, DotProduct, UnitVec3D, Vec3D}; /// Represents a `Surface` for a given set of points. #[derive(Copy, Clone)] pub struct Surface { /// The `Surface` normal pub normal: UnitVec3D, /// The node indices associated with the `Surface` pub nodes: [usize; 3], }...
return Surface { normal: normal, nodes: [index_0, index_1, index_2], }; } /// Computes the centroid of a `Surface` using the node indices in the /// `Surface` and the point cloud provided. pub fn compute_centroid(surface: &Surface, vertices: &Vec<Vec3D>) -> Vec...
{ normal = -normal; }
conditional_block
surface.rs
use {Scalar, TOLERANCE}; use maths::{CrossProduct, DotProduct, UnitVec3D, Vec3D}; /// Represents a `Surface` for a given set of points. #[derive(Copy, Clone)] pub struct Surface { /// The `Surface` normal pub normal: UnitVec3D, /// The node indices associated with the `Surface` pub nodes: [usize; 3], }...
(surface: &Surface, vertices: &Vec<Vec3D>) -> Vec3D { return surface.nodes.iter() .fold(Vec3D::zero(), |total, &index| { total + vertices[index] }) / 3.0; } }
compute_centroid
identifier_name
surface.rs
use {Scalar, TOLERANCE};
/// Represents a `Surface` for a given set of points. #[derive(Copy, Clone)] pub struct Surface { /// The `Surface` normal pub normal: UnitVec3D, /// The node indices associated with the `Surface` pub nodes: [usize; 3], } impl Surface { /// Creates a new `Surface` from the point cloud and indices p...
use maths::{CrossProduct, DotProduct, UnitVec3D, Vec3D};
random_line_split
issue-21384.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 : Clone>(arg: T) -> T { arg.clone() } #[derive(PartialEq)] struct Test(int); fn main() { // Check that ranges implement clone assert!(test(1..5) == (1..5)); assert!(test(..5) == (..5)); assert!(test(1..) == (1..)); assert!(test(FullRange) == (FullRange)); // Check that ranges can still...
test
identifier_name
issue-21384.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 ...
} #[derive(PartialEq)] struct Test(int); fn main() { // Check that ranges implement clone assert!(test(1..5) == (1..5)); assert!(test(..5) == (..5)); assert!(test(1..) == (1..)); assert!(test(FullRange) == (FullRange)); // Check that ranges can still be used with non-clone limits assert!(...
// option. This file may not be copied, modified, or distributed // except according to those terms. fn test<T : Clone>(arg: T) -> T { arg.clone()
random_line_split
issue-21384.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 ...
{ // Check that ranges implement clone assert!(test(1..5) == (1..5)); assert!(test(..5) == (..5)); assert!(test(1..) == (1..)); assert!(test(FullRange) == (FullRange)); // Check that ranges can still be used with non-clone limits assert!((Test(1)..Test(5)) == (Test(1)..Test(5))); }
identifier_body
weight.rs
use rand::distributions::{IndependentSample, Normal}; use rand::{Closed01, Rng}; /// Represents a connection weight. #[derive(Debug, Clone, Copy)] pub struct Weight(pub f64); impl Weight { pub fn inv(self) -> Self { Weight(-self.0) } } impl Into<f64> for Weight { fn into(self) -> f64 { se...
<R: Rng>(sigma: f64, rng: &mut R) -> f64 { let normal = Normal::new(0.0, sigma); normal.ind_sample(rng) } impl WeightPerturbanceMethod { pub fn perturb<R: Rng>( &self, weight: Weight, weight_range: &WeightRange, rng: &mut R, ) -> Weight { match *self { ...
gaussian
identifier_name
weight.rs
use rand::distributions::{IndependentSample, Normal}; use rand::{Closed01, Rng}; /// Represents a connection weight. #[derive(Debug, Clone, Copy)] pub struct Weight(pub f64); impl Weight { pub fn inv(self) -> Self { Weight(-self.0) } } impl Into<f64> for Weight { fn into(self) -> f64 { se...
pub fn clip_weight(&self, weight: Weight) -> Weight { let clipped = if weight.0 >= self.high { Weight(self.high) } else if weight.0 <= self.low { Weight(self.low) } else { weight }; debug_assert!(self.in_range(clipped)); clipped ...
random_line_split
weight.rs
use rand::distributions::{IndependentSample, Normal}; use rand::{Closed01, Rng}; /// Represents a connection weight. #[derive(Debug, Clone, Copy)] pub struct Weight(pub f64); impl Weight { pub fn inv(self) -> Self { Weight(-self.0) } } impl Into<f64> for Weight { fn into(self) -> f64 { se...
; debug_assert!(self.in_range(clipped)); clipped } } /// Defines a perturbance method. #[derive(Debug, Clone, Copy)] pub enum WeightPerturbanceMethod { JiggleUniform { range: WeightRange }, JiggleGaussian { sigma: f64 }, Random, } pub fn gaussian<R: Rng>(sigma: f64, rng: &mut R) -> f...
{ weight }
conditional_block
weight.rs
use rand::distributions::{IndependentSample, Normal}; use rand::{Closed01, Rng}; /// Represents a connection weight. #[derive(Debug, Clone, Copy)] pub struct Weight(pub f64); impl Weight { pub fn inv(self) -> Self { Weight(-self.0) } } impl Into<f64> for Weight { fn into(self) -> f64 { se...
pub fn bipolar(magnitude: f64) -> WeightRange { assert!(magnitude >= 0.0); WeightRange { high: magnitude, low: -magnitude, } } pub fn in_range(&self, weight: Weight) -> bool { weight.0 >= self.low && weight.0 <= self.high } pub fn random_we...
{ if magnitude >= 0.0 { WeightRange { high: magnitude, low: 0.0, } } else { WeightRange { high: 0.0, low: magnitude, } } }
identifier_body
lib.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). #![deny(warnings)] // Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to...
let res = f(permit.id).await; drop(permit); res } async fn acquire(&self) -> Permit<'_> { let permit = self.inner.sema.acquire().await.expect("semaphore closed"); let id = { let mut available_ids = self.inner.available_ids.lock(); available_ids .pop_front() .expect("Mo...
let permit = self.acquire().await;
random_line_split
lib.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). #![deny(warnings)] // Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to...
(&self) -> usize { self.inner.sema.available_permits() } /// /// Runs the given Future-creating function (and the Future it returns) under the semaphore. /// pub async fn with_acquired<F, B, O>(self, f: F) -> O where F: FnOnce(usize) -> B + Send +'static, B: Future<Output = O> + Send +'static, ...
available_permits
identifier_name
error.rs
use std::error; use std::fmt; use provider; use provider::service::inline::systemd; #[derive(Debug)] pub enum
{ DBus(systemd::dbus::Error), DBusArgTypeMismatch(systemd::dbus::arg::TypeMismatchError), } impl error::Error for Error { fn description(&self) -> &str { match *self { Error::DBus(ref err) => err.description(), Error::DBusArgTypeMismatch(ref err) => err.description(), ...
Error
identifier_name
error.rs
use std::error; use std::fmt;
pub enum Error { DBus(systemd::dbus::Error), DBusArgTypeMismatch(systemd::dbus::arg::TypeMismatchError), } impl error::Error for Error { fn description(&self) -> &str { match *self { Error::DBus(ref err) => err.description(), Error::DBusArgTypeMismatch(ref err) => err.descri...
use provider; use provider::service::inline::systemd; #[derive(Debug)]
random_line_split
error.rs
use std::error; use std::fmt; use provider; use provider::service::inline::systemd; #[derive(Debug)] pub enum Error { DBus(systemd::dbus::Error), DBusArgTypeMismatch(systemd::dbus::arg::TypeMismatchError), } impl error::Error for Error { fn description(&self) -> &str { match *self { E...
} impl From<systemd::dbus::arg::TypeMismatchError> for provider::error::Error { fn from(err: systemd::dbus::arg::TypeMismatchError) -> provider::error::Error { Error::DBusArgTypeMismatch(err).into() } }
{ Error::DBus(err).into() }
identifier_body
lib_2015.rs
// Copyright 2020 The Bazel Authors. 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 appl...
{ TokenStream::new() }
identifier_body
lib_2015.rs
// Copyright 2020 The Bazel Authors. 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 appl...
(_input: TokenStream) -> TokenStream { TokenStream::new() }
hello_world
identifier_name
lib_2015.rs
// Copyright 2020 The Bazel Authors. 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 appl...
use proc_macro::TokenStream; /// This macro is a no-op; it is exceedingly simple as a result /// of avoiding dependencies on both the syn and quote crates. #[proc_macro_derive(HelloWorld)] pub fn hello_world(_input: TokenStream) -> TokenStream { TokenStream::new() }
extern crate proc_macro;
random_line_split
noop_method_call.rs
use crate::context::LintContext; use crate::rustc_middle::ty::TypeFoldable; use crate::LateContext; use crate::LateLintPass; use rustc_hir::def::DefKind; use rustc_hir::{Expr, ExprKind}; use rustc_middle::ty; use rustc_span::symbol::sym; declare_lint! { /// The `noop_method_call` lint detects specific calls to noo...
let note = format!( "the type `{:?}` which `{}` is being called on is the same as \ the type returned from `{}`, so the method call does not do \ anything and can be removed", receiver_ty, method, method, )...
random_line_split
noop_method_call.rs
use crate::context::LintContext; use crate::rustc_middle::ty::TypeFoldable; use crate::LateContext; use crate::LateLintPass; use rustc_hir::def::DefKind; use rustc_hir::{Expr, ExprKind}; use rustc_middle::ty; use rustc_span::symbol::sym; declare_lint! { /// The `noop_method_call` lint detects specific calls to noo...
_ => return, }, _ => return, }; let substs = cx.typeck_results().node_substs(expr.hir_id); if substs.definitely_needs_subst(cx.tcx) { // We can't resolve on types that require monomorphization, so we don't handle them if // we need ...
{ // We only care about method calls. let (call, elements) = match expr.kind { ExprKind::MethodCall(call, _, elements, _) => (call, elements), _ => return, }; // We only care about method calls corresponding to the `Clone`, `Deref` and `Borrow` // traits a...
identifier_body
noop_method_call.rs
use crate::context::LintContext; use crate::rustc_middle::ty::TypeFoldable; use crate::LateContext; use crate::LateLintPass; use rustc_hir::def::DefKind; use rustc_hir::{Expr, ExprKind}; use rustc_middle::ty; use rustc_span::symbol::sym; declare_lint! { /// The `noop_method_call` lint detects specific calls to noo...
(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { // We only care about method calls. let (call, elements) = match expr.kind { ExprKind::MethodCall(call, _, elements, _) => (call, elements), _ => return, }; // We only care about method calls correspondin...
check_expr
identifier_name
issue-3743.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, other: f64) -> Vec2 { Vec2 { x: self.x * other, y: self.y * other } } } // Right-hand-side operator visitor pattern trait RhsOfVec2Mul<Result> { fn mul_vec2_by(&self, lhs: &Vec2) -> Result; } // Vec2's implementation of Mul "from the other side" using the above trait impl<Res, Rhs: RhsOfVec2Mul<Res...
vmul
identifier_name
issue-3743.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 ...
} // Right-hand-side operator visitor pattern trait RhsOfVec2Mul<Result> { fn mul_vec2_by(&self, lhs: &Vec2) -> Result; } // Vec2's implementation of Mul "from the other side" using the above trait impl<Res, Rhs: RhsOfVec2Mul<Res>> Mul<Rhs,Res> for Vec2 { fn mul(&self, rhs: &Rhs) -> Res { rhs.mul_vec2_by(self) }...
{ Vec2 { x: self.x * other, y: self.y * other } }
identifier_body
issue-3743.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 ...
// Right-hand-side operator visitor pattern trait RhsOfVec2Mul<Result> { fn mul_vec2_by(&self, lhs: &Vec2) -> Result; } // Vec2's implementation of Mul "from the other side" using the above trait impl<Res, Rhs: RhsOfVec2Mul<Res>> Mul<Rhs,Res> for Vec2 { fn mul(&self, rhs: &Rhs) -> Res { rhs.mul_vec2_by(self) } } ...
random_line_split
marker-attribute-on-non-trait.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{} #[marker] //~ ERROR attribute can only be applied to a trait impl Struct {} #[marker] //~ ERROR attribute can only be applied to a trait union Union { x: i32, } #[marker] //~ ERROR attribute can only be applied to a trait const CONST: usize = 10; #[marker] //~ ERROR attribute can only be applied to a trait ...
Struct
identifier_name
marker-attribute-on-non-trait.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
#[marker] //~ ERROR attribute can only be applied to a trait const CONST: usize = 10; #[marker] //~ ERROR attribute can only be applied to a trait fn function() {} #[marker] //~ ERROR attribute can only be applied to a trait type Type = (); fn main() {}
x: i32, }
random_line_split
tyencode.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 ...
ty::ty_vec(mt, v) => { mywrite!(w, "V"); enc_mt(w, cx, mt); enc_vstore(w, cx, v); } ty::ty_str(v) => { mywrite!(w, "v"); enc_vstore(w, cx, v); } ty::ty_unboxed_vec(mt) => { mywrite!(w, "U"); enc_mt(w, cx, mt); } ...
enc_mt(w, cx, mt); }
random_line_split
tyencode.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 ...
(w: &mut MemWriter, fmt: &fmt::Arguments) { fmt::write(&mut *w as &mut io::Writer, fmt); } pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) { match cx.abbrevs { ac_no_abbrevs => { let result_str_opt; { let short_names_cache = cx.tcx.short_names_cache.borrow(); ...
mywrite
identifier_name
tyencode.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 ...
ty::BrFresh(id) => { mywrite!(w, "f{}|", id); } } } pub fn enc_vstore(w: &mut MemWriter, cx: @ctxt, v: ty::vstore) { mywrite!(w, "/"); match v { ty::vstore_fixed(u) => mywrite!(w, "{}|", u), ty::vstore_uniq => mywrite!(w, "~"), ty::vstore_box => mywrite!...
{ mywrite!(w, "[{}|{}]", (cx.ds)(d), cx.tcx.sess.str_of(s)); }
conditional_block
tyencode.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn enc_region_substs(w: &mut MemWriter, cx: @ctxt, substs: &ty::RegionSubsts) { match *substs { ty::ErasedRegions => { mywrite!(w, "e"); } ty::NonerasedRegions(ref regions) => { mywrite!(w, "n"); for &r in regions.iter() { enc_region(w, c...
{ enc_region_substs(w, cx, &substs.regions); enc_opt(w, substs.self_ty, |w, t| enc_ty(w, cx, t)); mywrite!(w, "["); for t in substs.tps.iter() { enc_ty(w, cx, *t); } mywrite!(w, "]"); }
identifier_body
id.rs
// Copyright 2018 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...
(full_id: ClientFullId) -> Self { Self::Client(Arc::new(full_id)) } /// Creates an app full ID. pub fn app(full_id: AppFullId) -> Self { Self::App(Arc::new(full_id)) } /// Signs a given message using the App / Client full id as required. pub fn sign(&self, msg: &[u8]) -> Signat...
client
identifier_name
id.rs
// Copyright 2018 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...
} } /// Returns a corresponding public ID. pub fn public_id(&self) -> PublicId { match self { Self::App(app_full_id) => PublicId::App(app_full_id.public_id().clone()), Self::Client(client_full_id) => PublicId::Client(client_full_id.public_id().clone()), } ...
match self { Self::App(app_full_id) => app_full_id.sign(msg), Self::Client(client_full_id) => client_full_id.sign(msg),
random_line_split
id.rs
// Copyright 2018 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...
/// Creates an app full ID. pub fn app(full_id: AppFullId) -> Self { Self::App(Arc::new(full_id)) } /// Signs a given message using the App / Client full id as required. pub fn sign(&self, msg: &[u8]) -> Signature { match self { Self::App(app_full_id) => app_full_id.si...
{ Self::Client(Arc::new(full_id)) }
identifier_body
pkgid.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { flag_verbose: bool, flag_quiet: bool, flag_manifest_path: Option<String>, arg_spec: Option<String>, } pub const USAGE: &'static str...
(options: Options, config: &Config) -> CliResult<Option<()>> { try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path.clone())); let spec = options.arg_spec.as_ref().map(|s| &s[..]); let spec = t...
execute
identifier_name
pkgid.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { flag_verbose: bool, flag_quiet: bool, flag_manifest_path: Option<String>, arg_spec: Option<String>, } pub const USAGE: &'static str...
crates.io/foo | foo | * | *://crates.io/foo crates.io/foo#1.2.3 | foo | 1.2.3 | *://crates.io/foo crates.io/bar#foo:1.2.3 | foo | 1.2.3 | *://crates.io/bar http://crates.io/foo#1.2.3 | foo | 1.2.3 | http://crates.io/foo "; pub fn execu...
foo:1.2.3 | foo | 1.2.3 | *
random_line_split
question_6.rs
pub fn compress(string: &str) -> String { let mut character_count = 0; let mut previous_char = string.chars().nth(0).unwrap(); // Starts at first char let mut new_string_parts: Vec<String> = vec![]; for c in string.chars() { if previous_char == c { character_count = character_count ...
} #[test] fn example_compress() { assert_eq!(compress("aabcccccaaa"), "a2b1c5a3"); } #[test] fn compress_should_return_original_string_when_not_smaller() { assert_eq!(compress("aa"), "aa"); } #[test] fn compress_should_return_original_string_when_not_smaller_with_larger_example() { assert_eq!(compress("...
{ return new_string_parts.join(""); }
conditional_block
question_6.rs
pub fn compress(string: &str) -> String { let mut character_count = 0; let mut previous_char = string.chars().nth(0).unwrap(); // Starts at first char let mut new_string_parts: Vec<String> = vec![]; for c in string.chars() { if previous_char == c { character_count = character_count ...
() { assert_eq!(compress("aa"), "aa"); } #[test] fn compress_should_return_original_string_when_not_smaller_with_larger_example() { assert_eq!(compress("aabbccddeeffgg"), "aabbccddeeffgg"); } #[test] fn compress_should_return_original_string_when_compression_generates_larger_string() { // if compress() ha...
compress_should_return_original_string_when_not_smaller
identifier_name
question_6.rs
pub fn compress(string: &str) -> String { let mut character_count = 0; let mut previous_char = string.chars().nth(0).unwrap(); // Starts at first char let mut new_string_parts: Vec<String> = vec![]; for c in string.chars() { if previous_char == c { character_count = character_count ...
previous_char = c; } new_string_parts.push(previous_char.to_string()); new_string_parts.push(character_count.to_string()); let new_string = new_string_parts.join(""); if string.len() <= new_string.len() { return string.to_string(); } else { return new_string_parts.join(...
}
random_line_split
question_6.rs
pub fn compress(string: &str) -> String { let mut character_count = 0; let mut previous_char = string.chars().nth(0).unwrap(); // Starts at first char let mut new_string_parts: Vec<String> = vec![]; for c in string.chars() { if previous_char == c { character_count = character_count ...
#[test] fn compress_should_return_original_string_when_not_smaller() { assert_eq!(compress("aa"), "aa"); } #[test] fn compress_should_return_original_string_when_not_smaller_with_larger_example() { assert_eq!(compress("aabbccddeeffgg"), "aabbccddeeffgg"); } #[test] fn compress_should_return_original_string_...
{ assert_eq!(compress("aabcccccaaa"), "a2b1c5a3"); }
identifier_body
type_name.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::type_name; // pub fn type_name<T>() -> usize; macro_rules! type_name_test { ($T:ty, $message:expr) => ({ let message: &'static str = unsafe { type_name::<$T>() }; assert_eq!(message, $message)...
() { type_name_test!( u8, "u8" ); type_name_test!( u16, "u16" ); type_name_test!( u32, "u32" ); type_name_test!( u64, "u64" ); type_name_test!( i8, "i8" ); type_name_test!( i16, "i16" ); type_name_test!( i32, "i32" ); type_name_test!( i64, "i64" ); type_name_test!( f32, "f32" ); type_name_test!( f64, "f64" )...
type_name_test1
identifier_name
type_name.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::type_name; // pub fn type_name<T>() -> usize; macro_rules! type_name_test { ($T:ty, $message:expr) => ({ let message: &'static str = unsafe { type_name::<$T>() }; assert_eq!(message, $message)...
type_name_test!( (u8, u16), "(u8, u16)" ); type_name_test!( (u8, u16, u32), "(u8, u16, u32)" ); type_name_test!( (u8, u16, u32, u64), "(u8, u16, u32, u64)" ); } }
{ type_name_test!( u8, "u8" ); type_name_test!( u16, "u16" ); type_name_test!( u32, "u32" ); type_name_test!( u64, "u64" ); type_name_test!( i8, "i8" ); type_name_test!( i16, "i16" ); type_name_test!( i32, "i32" ); type_name_test!( i64, "i64" ); type_name_test!( f32, "f32" ); type_name_test!( f64, "f64" ); ...
identifier_body
type_name.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::type_name; // pub fn type_name<T>() -> usize; macro_rules! type_name_test { ($T:ty, $message:expr) => ({ let message: &'static str = unsafe { type_name::<$T>() }; assert_eq!(message, $message)...
type_name_test!( i8, "i8" ); type_name_test!( i16, "i16" ); type_name_test!( i32, "i32" ); type_name_test!( i64, "i64" ); type_name_test!( f32, "f32" ); type_name_test!( f64, "f64" ); type_name_test!( [u8; 0], "[u8; 0]" ); type_name_test!( [u8; 68], "[u8; 68]" ); type_name_test!( [u32; 0], "[u32; 0]" ); ty...
type_name_test!( u8, "u8" ); type_name_test!( u16, "u16" ); type_name_test!( u32, "u32" ); type_name_test!( u64, "u64" );
random_line_split
main.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
(_: libc::c_int, description: ~str) { println(fmt!("GLFW Error: %s", description)); }
error_callback
identifier_name
main.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
fn key_callback(window: &glfw::Window, key: libc::c_int, _: libc::c_int, action: libc::c_int, _: glfw::KeyMods) { if action == glfw::PRESS && key == glfw::KEY_ESCAPE { window.set_should_close(true); } } fn error_callback(_: libc::c_int, description: ~str) { println(fmt!("GLFW Error: %s", descript...
{ glfw::set_error_callback(error_callback); if glfw::init().is_err() { fail!(~"Failed to initialize GLFW"); } else { (||{ let window = glfw::Window::create(300, 300, "Hello this is window", glfw::Windowed).unwrap(); window.set_key_callback(key_callback); ...
identifier_body
main.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
} else { (||{ let window = glfw::Window::create(300, 300, "Hello this is window", glfw::Windowed).unwrap(); window.set_key_callback(key_callback); window.make_context_current(); while!window.should_close() { window.poll_events(); ...
random_line_split
main.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
else { (||{ let window = glfw::Window::create(300, 300, "Hello this is window", glfw::Windowed).unwrap(); window.set_key_callback(key_callback); window.make_context_current(); while!window.should_close() { window.poll_events(); g...
{ fail!(~"Failed to initialize GLFW"); }
conditional_block
annulus_distribution.rs
//! Implementation of a uniform distribuition of points on a two-dimensional //! annulus. use rand::distributions::Distribution; use rand::Rng; use std::f64::consts::PI; pub use Point; /// The uniform distribution of 2D points on an annulus `{x: r_1 <= |x| <= r_2}`. pub struct AnnulusDist { r1_sq: f64, r2_sq: ...
} impl Distribution<Point> for AnnulusDist { fn sample<R: Rng +?Sized>(&self, rng: &mut R) -> Point { // For points to be uniformly distributed in the annulus, the area of the disk with radius // equal to the distance of the point from the origin is distributed uniformly between r₁² // and ...
r1_sq: r1 * r1, r2_sq: r2 * r2, } }
random_line_split
annulus_distribution.rs
//! Implementation of a uniform distribuition of points on a two-dimensional //! annulus. use rand::distributions::Distribution; use rand::Rng; use std::f64::consts::PI; pub use Point; /// The uniform distribution of 2D points on an annulus `{x: r_1 <= |x| <= r_2}`. pub struct
{ r1_sq: f64, r2_sq: f64, } impl AnnulusDist { /// Construct a new `AnnulusDist` with the given inner and outer radius /// `r1`, `r2`. Panics if not `0 < r1 < r2`. pub fn new(r1: f64, r2: f64) -> AnnulusDist { assert!(0. < r1, "AnnulusDist::new called with `r1 <= 0`"); assert!(r1 <...
AnnulusDist
identifier_name
annulus_distribution.rs
//! Implementation of a uniform distribuition of points on a two-dimensional //! annulus. use rand::distributions::Distribution; use rand::Rng; use std::f64::consts::PI; pub use Point; /// The uniform distribution of 2D points on an annulus `{x: r_1 <= |x| <= r_2}`. pub struct AnnulusDist { r1_sq: f64, r2_sq: ...
} impl Distribution<Point> for AnnulusDist { fn sample<R: Rng +?Sized>(&self, rng: &mut R) -> Point { // For points to be uniformly distributed in the annulus, the area of the disk with radius // equal to the distance of the point from the origin is distributed uniformly between r₁² // and...
{ assert!(0. < r1, "AnnulusDist::new called with `r1 <= 0`"); assert!(r1 < r2, "AnnulusDist::new called with `r2 <= r1`"); AnnulusDist { r1_sq: r1 * r1, r2_sq: r2 * r2, } }
identifier_body