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
util.rs
use std::io::{Read, Seek, SeekFrom}; use std::str; use error::Result; pub static APE_PREAMBLE: &'static [u8] = b"APETAGEX"; static ID3V1_HEADER: &'static [u8] = b"TAG"; static LYRICS3V2_HEADER: &'static [u8] = b"LYRICS200"; /// Position of ID3v1 tag pub const ID3V1_OFFSET: i64 = -128; /// Number of bytes, which are...
/// Returns the size of the Lyrics3 v2.00 tag or -1 if the tag does not exists. /// See http://id3.org/Lyrics3v2 for more details. pub fn probe_lyrics3v2<R: Read + Seek>(reader: &mut R) -> Result<i64> { let capacity = LYRICS3V2_HEADER.len(); let mut header = Vec::<u8>::with_capacity(capacity); reader.seek...
{ let capacity = ID3V1_HEADER.len(); let mut header = Vec::<u8>::with_capacity(capacity); reader.seek(SeekFrom::End(ID3V1_OFFSET))?; reader.take(capacity as u64).read_to_end(&mut header)?; Ok(header == ID3V1_HEADER) }
identifier_body
util.rs
use std::io::{Read, Seek, SeekFrom}; use std::str; use error::Result; pub static APE_PREAMBLE: &'static [u8] = b"APETAGEX"; static ID3V1_HEADER: &'static [u8] = b"TAG"; static LYRICS3V2_HEADER: &'static [u8] = b"LYRICS200"; /// Position of ID3v1 tag pub const ID3V1_OFFSET: i64 = -128; /// Number of bytes, which are...
Ok(int_size + LYRICS3V2_SIZE + capacity as i64) } else { Ok(-1) } }
reader.take(LYRICS3V2_SIZE as u64).read_to_end(&mut buf)?; let raw_size = str::from_utf8(&buf)?; let int_size = raw_size.parse::<i64>()?;
random_line_split
util.rs
use std::io::{Read, Seek, SeekFrom}; use std::str; use error::Result; pub static APE_PREAMBLE: &'static [u8] = b"APETAGEX"; static ID3V1_HEADER: &'static [u8] = b"TAG"; static LYRICS3V2_HEADER: &'static [u8] = b"LYRICS200"; /// Position of ID3v1 tag pub const ID3V1_OFFSET: i64 = -128; /// Number of bytes, which are...
<R: Read + Seek>(reader: &mut R, pos: SeekFrom) -> Result<bool> { let capacity = APE_PREAMBLE.len(); let mut preamble = Vec::<u8>::with_capacity(capacity); reader.seek(pos)?; reader.take(capacity as u64).read_to_end(&mut preamble)?; Ok(preamble == APE_PREAMBLE) } /// Whether ID3v1 tag exists pub fn...
probe_ape
identifier_name
util.rs
use std::io::{Read, Seek, SeekFrom}; use std::str; use error::Result; pub static APE_PREAMBLE: &'static [u8] = b"APETAGEX"; static ID3V1_HEADER: &'static [u8] = b"TAG"; static LYRICS3V2_HEADER: &'static [u8] = b"LYRICS200"; /// Position of ID3v1 tag pub const ID3V1_OFFSET: i64 = -128; /// Number of bytes, which are...
else { Ok(-1) } }
{ let mut buf = Vec::<u8>::with_capacity(LYRICS3V2_SIZE as usize); reader.seek(SeekFrom::Current(-LYRICS3V2_SIZE))?; reader.take(LYRICS3V2_SIZE as u64).read_to_end(&mut buf)?; let raw_size = str::from_utf8(&buf)?; let int_size = raw_size.parse::<i64>()?; Ok(int_size + LYR...
conditional_block
lexical-scope-in-match.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let shadowed = 231; let not_shadowed = 232; zzz(); sentinel(); match (233, 234) { (shadowed, local_to_arm) => { zzz(); sentinel(); } } match (235, 236) { // with literal (235, shadowed) => { zzz(); sen...
main
identifier_name
lexical-scope-in-match.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// gdb-command:finish // gdb-command:print shadowed // gdb-check:$17 = 231 // gdb-command:print not_shadowed // gdb-check:$18 = 232 // gdb-command:continue struct Struct { x: int, y: int } fn main() { let shadowed = 231; let not_shadowed = 232; zzz(); sentinel(); match (233, 234) { ...
random_line_split
lexical-scope-in-match.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn sentinel() {()}
{()}
identifier_body
mut-in-ident-patterns.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let (a, mut b) = (23i, 4i); assert_eq!(a, 23); assert_eq!(b, 4); b = a + b; assert_eq!(b, 27); assert_eq!(X.foo(2), 76); enum Bar { Foo(int), Baz(f32, u8) } let (x, mut y) = (32i, Bar::Foo(21)); match x { mut z @ 32 => { assert_eq!(z, 3...
main
identifier_name
mut-in-ident-patterns.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 ...
impl Foo for X {} pub fn main() { let (a, mut b) = (23i, 4i); assert_eq!(a, 23); assert_eq!(b, 4); b = a + b; assert_eq!(b, 27); assert_eq!(X.foo(2), 76); enum Bar { Foo(int), Baz(f32, u8) } let (x, mut y) = (32i, Bar::Foo(21)); match x { mut z @ 32 =>...
val + x } } struct X;
random_line_split
mut-in-ident-patterns.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 ...
_ => {} } check_bar(&y); y = Bar::Baz(10.0, 3); check_bar(&y); fn check_bar(y: &Bar) { match y { &Bar::Foo(a) => { assert_eq!(a, 21); } &Bar::Baz(a, b) => { assert_eq!(a, 10.0); assert_eq!(b, 3); ...
{ assert_eq!(z, 32); z = 34; assert_eq!(z, 34); }
conditional_block
fxrstor.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*;
fn fxrstor_2() { run_test(&Instruction { mnemonic: Mnemonic::FXRSTOR, operand1: Some(IndirectScaledIndexedDisplaced(EDI, EDX, Two, 1303234622, Some(OperandSize::Unsized), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: N...
fn fxrstor_1() { run_test(&Instruction { mnemonic: Mnemonic::FXRSTOR, operand1: Some(Indirect(DI, Some(OperandSize::Unsized), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 174, 13], OperandSize::Word) }
random_line_split
fxrstor.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn
() { run_test(&Instruction { mnemonic: Mnemonic::FXRSTOR, operand1: Some(Indirect(DI, Some(OperandSize::Unsized), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 174, 13], OperandSize::Word) } fn fxrstor_2(...
fxrstor_1
identifier_name
fxrstor.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn fxrstor_1() { run_test(&Instruction { mnemonic: Mnemonic::FXRSTOR, operand1: Some(Indirect(DI, Some(OperandSize::Unsize...
{ run_test(&Instruction { mnemonic: Mnemonic::FXRSTOR, operand1: Some(IndirectScaledIndexedDisplaced(RBX, RDI, Eight, 468169493, Some(OperandSize::Unsized), None)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 17...
identifier_body
axis.rs
// Copyright 2016 bluss and ndarray developers. // // 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 // ex...
ze); impl Axis { /// Return the index of the axis. #[inline(always)] pub fn index(&self) -> usize { self.0 } #[deprecated(note = "Renamed to.index()")] #[inline(always)] pub fn axis(&self) -> usize { self.0 } } copy_and_clone!{Axis} macro_rules! derive_cmp { ($traitname:ident for $typenam...
usi
identifier_name
axis.rs
// Copyright 2016 bluss and ndarray developers. // // 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 // ex...
/// correctly and easier to understand. #[derive(Eq, Ord, Hash, Debug)] pub struct Axis(pub usize); impl Axis { /// Return the index of the axis. #[inline(always)] pub fn index(&self) -> usize { self.0 } #[deprecated(note = "Renamed to.index()")] #[inline(always)] pub fn axis(&self) -> usize { ...
/// Axis *0* is the array’s outermost axis and *n*-1 is the innermost. /// /// All array axis arguments use this type to make the code easier to write
random_line_split
dpar-print-transitions.rs
use std::env::args; use std::io::{BufRead, BufWriter, Write}; use std::process; use colored::*; use conllx::{DisplaySentence, HeadProjectivizer, Projectivize, ReadSentence}; use dpar::guide::Guide; use dpar::system::{sentence_to_dependencies, ParserState, Transition, TransitionSystem}; use dpar::systems::{ ArcEage...
while!S::is_terminal(&state) { let next_transition = oracle.best_transition(&state); next_transition.apply(&mut state); // Print transition and state. writeln!(writer, "{}", format!("{:?}", next_transition).purple())?; print_tokens(&mut writer, &state...
print_tokens(&mut writer, &state, Source::Buffer)?;
random_line_split
dpar-print-transitions.rs
use std::env::args; use std::io::{BufRead, BufWriter, Write}; use std::process; use colored::*; use conllx::{DisplaySentence, HeadProjectivizer, Projectivize, ReadSentence}; use dpar::guide::Guide; use dpar::system::{sentence_to_dependencies, ParserState, Transition, TransitionSystem}; use dpar::systems::{ ArcEage...
<W>(writer: &mut W, state: &ParserState<'_>, source: Source) -> Result<(), Error> where W: Write, { let prefix = match source { Source::Buffer => "Buffer", Source::Stack => "Stack", }; let indices = match source { Source::Buffer => state.buffer(), Source::Stack => state....
print_tokens
identifier_name
dpar-print-transitions.rs
use std::env::args; use std::io::{BufRead, BufWriter, Write}; use std::process; use colored::*; use conllx::{DisplaySentence, HeadProjectivizer, Projectivize, ReadSentence}; use dpar::guide::Guide; use dpar::system::{sentence_to_dependencies, ParserState, Transition, TransitionSystem}; use dpar::systems::{ ArcEage...
let input = Input::from(matches.free.get(1)); let reader = conllx::Reader::new(input.buf_read().or_exit("Cannot open treebank", 1)); let output = Output::from(matches.free.get(2)); let writer = BufWriter::new(output.write().or_exit("Cannot create transition output", 1)); parse(&matches.free[0], ...
{ print_usage(&program, opts); return; }
conditional_block
dpar-print-transitions.rs
use std::env::args; use std::io::{BufRead, BufWriter, Write}; use std::process; use colored::*; use conllx::{DisplaySentence, HeadProjectivizer, Projectivize, ReadSentence}; use dpar::guide::Guide; use dpar::system::{sentence_to_dependencies, ParserState, Transition, TransitionSystem}; use dpar::systems::{ ArcEage...
fn parse_with_system<R, W, S>( reader: conllx::Reader<R>, mut writer: BufWriter<W>, ) -> Result<(), Error> where R: BufRead, W: Write, S: TransitionSystem, { let projectivizer = HeadProjectivizer::new(); for sentence in reader.sentences() { let sentence = projectivizer.projectiviz...
{ match system { "arceager" => parse_with_system::<R, W, ArcEagerSystem>(reader, writer), "archybrid" => parse_with_system::<R, W, ArcHybridSystem>(reader, writer), "arcstandard" => parse_with_system::<R, W, ArcStandardSystem>(reader, writer), "stackproj" => parse_with_system::<R, W,...
identifier_body
player.rs
use crate::{ entity::{Character, Entity, EntityId, EntityPersistence, EntityRef, EntityType, StatsItem}, entity_copy_prop, entity_string_prop, sessions::SignUpData, }; use pbkdf2::{pbkdf2_check, pbkdf2_simple}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(ren...
pub fn matches_password(&self, password: &str) -> bool { matches!(pbkdf2_check(password, &self.password), Ok(())) } pub fn new(id: EntityId, sign_up_data: &SignUpData) -> Self { let character = Character::from_sign_up_data(sign_up_data); Self { id, characte...
{ let mut player = serde_json::from_str::<Player>(json) .map_err(|error| format!("parse error: {}", error))?; player.id = id; Ok(Box::new(player)) }
identifier_body
player.rs
use crate::{ entity::{Character, Entity, EntityId, EntityPersistence, EntityRef, EntityType, StatsItem}, entity_copy_prop, entity_string_prop, sessions::SignUpData, }; use pbkdf2::{pbkdf2_check, pbkdf2_simple}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(ren...
(&mut self, password: &str) { match pbkdf2_simple(password, 10) { Ok(password) => { self.password = password; self.set_needs_sync(true); } Err(error) => panic!("Cannot create password hash: {:?}", error), } } } impl Entity for Play...
set_password
identifier_name
player.rs
use crate::{ entity::{Character, Entity, EntityId, EntityPersistence, EntityRef, EntityType, StatsItem}, entity_copy_prop, entity_string_prop, sessions::SignUpData, }; use pbkdf2::{pbkdf2_check, pbkdf2_simple}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(ren...
} } impl Entity for Player { entity_string_prop!(name, set_name); entity_string_prop!(description, set_description); fn as_character(&self) -> Option<&Character> { Some(&self.character) } fn as_character_mut(&mut self) -> Option<&mut Character> { Some(&mut self.character) ...
self.set_needs_sync(true); } Err(error) => panic!("Cannot create password hash: {:?}", error), }
random_line_split
tls_publish.rs
extern crate cloudpubsub; extern crate pretty_env_logger; extern crate rand; use std::thread; use std::time::Duration; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use rand::{thread_rng, Rng}; use cloudpubsub::{MqttOptions, MqttClient, MqttCallback}; fn main()
for i in 0..100 { let len: usize = thread_rng().gen_range(0, 100_000); let mut v = vec![0; len]; thread_rng().fill_bytes(&mut v); client.publish("hello/world", v); } // verifies pingreqs and responses thread::sleep(Duration::from_secs(30)); // disconnections becaus...
{ pretty_env_logger::init().unwrap(); let options = MqttOptions::new().set_client_id("tls-publisher-1") .set_clean_session(false) .set_ca("/userdata/certs/dev/ca-chain.cert.pem") .set_client_certs("/user...
identifier_body
tls_publish.rs
extern crate cloudpubsub; extern crate pretty_env_logger; extern crate rand; use std::thread; use std::time::Duration; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use rand::{thread_rng, Rng}; use cloudpubsub::{MqttOptions, MqttClient, MqttCallback}; fn main() { pretty_env_logger::init()....
for i in 0..100 { let len: usize = thread_rng().gen_range(0, 100_000); let mut v = vec![0; len]; thread_rng().fill_bytes(&mut v); client.publish("hello/world", v); } // verifies pingreqs and responses thread::sleep(Duration::from_secs(30)); // disconnections becau...
}; let on_publish = MqttCallback::new().on_publish(counter_cb); let mut client = MqttClient::start(options, Some(on_publish)).expect("Start Error");
random_line_split
tls_publish.rs
extern crate cloudpubsub; extern crate pretty_env_logger; extern crate rand; use std::thread; use std::time::Duration; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use rand::{thread_rng, Rng}; use cloudpubsub::{MqttOptions, MqttClient, MqttCallback}; fn
() { pretty_env_logger::init().unwrap(); let options = MqttOptions::new().set_client_id("tls-publisher-1") .set_clean_session(false) .set_ca("/userdata/certs/dev/ca-chain.cert.pem") .set_client_certs("/user...
main
identifier_name
f64.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.
// 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. //! This module provides constants which are specific to the implementation //! of the `...
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
f64.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...
t turns out the safety issues with sNaN were overblown! Hooray! unsafe { mem::transmute(v) } } }
identifier_body
f64.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...
) * 1.0 } /// Returns the minimum of the two numbers. /// /// ``` /// let x = 1.0_f64; /// let y = 2.0_f64; /// /// assert_eq!(x.min(y), x); /// ``` /// /// If one of the arguments is NaN, then the other argument is returned. #[stable(feature = "rust1", since = "1.0.0")]...
{ self }
conditional_block
f64.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 value: f64 = consts::PI; self * (value / 180.0) } /// Returns the maximum of the two numbers. /// /// ``` /// let x = 1.0_f64; /// let y = 2.0_f64; /// /// assert_eq!(x.max(y), y); /// ``` /// /// If one of the arguments is NaN, then the other argument ...
f) -> f64
identifier_name
xul.mako.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 https://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import Method %> // Non-standard properties t...
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-box-ordinal-group)", )}
engines="gecko", parse_method="parse_non_negative", alias="-webkit-box-ordinal-group", gecko_ffi_name="mBoxOrdinal", animation_value_type="discrete",
random_line_split
list_item.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/. */ //! Layout for elements with a CSS `display` property of `list-item`. These elements consist of a //! block and an...
#![deny(unsafe_code)] use block::BlockFlow; use context::LayoutContext; use display_list_builder::ListItemFlowDisplayListBuilding; use floats::FloatKind; use flow::{Flow, FlowClass, OpaqueFlow}; use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo}; use generated_content; use incr...
random_line_split
list_item.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/. */ //! Layout for elements with a CSS `display` property of `list-item`. These elements consist of a //! block and an...
self, iterator: &mut FragmentBorderBoxIterator, stacking_context_position: &Point2D<Au>) { self.block_flow.iterate_through_fragment_border_boxes(iterator, stacking_context_position); if let Some(ref marker) = self...
erate_through_fragment_border_boxes(&
identifier_name
list_item.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/. */ //! Layout for elements with a CSS `display` property of `list-item`. These elements consist of a //! block and an...
fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { self.block_flow.assign_inline_sizes(layout_context); if let Some(ref mut marker) = self.marker { let containing_block_inline_size = self.block_flow.base.block_container_inline_size; marker.assign_replaced_in...
{ // The marker contributes no intrinsic inline-size, so… self.block_flow.bubble_inline_sizes() }
identifier_body
f64.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...
unsafe { intrinsics::logf64(self) } } /// Returns the logarithm of the number with respect to an arbitrary base. #[inline] fn log(self, base: f64) -> f64 { self.ln() / base.ln() } /// Returns the base 2 logarithm of the number. #[inline] fn log2(self) -> f64 { unsafe { intr...
fn ln(self) -> f64 {
random_line_split
f64.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...
(self) -> f64 { 1.0 / self } #[inline] fn powf(self, n: f64) -> f64 { unsafe { intrinsics::powf64(self, n) } } #[inline] fn powi(self, n: i32) -> f64 { unsafe { intrinsics::powif64(self, n) } } #[inline] fn sqrt(self) -> f64 { if self < 0.0 { NAN ...
recip
identifier_name
f64.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...
else { unsafe { intrinsics::copysignf64(1.0, self) } } } /// Returns `true` if `self` is positive, including `+0.0` and /// `Float::infinity()`. #[inline] fn is_positive(self) -> bool { self > 0.0 || (1.0 / self) == Float::infinity() } /// Returns `true` if `se...
{ Float::nan() }
conditional_block
f64.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...
from_str_radix_float_impl! { f64 } /// Returns `true` if the number is NaN. #[inline] fn is_nan(self) -> bool { self!= self } /// Returns `true` if the number is infinite. #[inline] fn is_infinite(self) -> bool { self == Float::infinity() || self == Float::neg_infinity() } ...
{ 1.0 }
identifier_body
method-self-arg-aux1.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 x = Foo; // Test external call. Foo::bar(&x); Foo::baz(x); Foo::qux(box x); x.foo(&x); assert!(method_self_arg1::get_count() == 2u64*3*3*3*5*5*5*7*7*7); }
identifier_body
method-self-arg-aux1.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 x = Foo; // Test external call. Foo::bar(&x); Foo::baz(x); Foo::qux(box x); x.foo(&x); assert!(method_self_arg1::get_count() == 2u64*3*3*3*5*5*5*7*7*7); }
main
identifier_name
method-self-arg-aux1.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 ...
// aux-build:method_self_arg1.rs extern crate method_self_arg1; use method_self_arg1::Foo; fn main() { let x = Foo; // Test external call. Foo::bar(&x); Foo::baz(x); Foo::qux(box x); x.foo(&x); assert!(method_self_arg1::get_count() == 2u64*3*3*3*5*5*5*7*7*7); }
random_line_split
wiggle.rs
//! Dataflow node that generates/propagates/mutates a wiggle. use util::{modulo_one, almost_eq, angle_almost_eq}; use network::{Network, NodeIndex, GenerationId, NodeId, OutputId, Inputs, Outputs}; use console_server::reactor::Messages; use wiggles_value::{Data, Unipolar, Datatype}; use wiggles_value::knob::{Knobs, Res...
(NodeIndex, GenerationId); impl fmt::Display for WiggleId { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "wiggle {}, generation {}", self.0, self.1) } } impl NodeId for WiggleId { fn new(idx: NodeIndex, gen_id: GenerationId) -> Self { WiggleId(idx, gen_id) } fn ...
WiggleId
identifier_name
wiggle.rs
//! Dataflow node that generates/propagates/mutates a wiggle. use util::{modulo_one, almost_eq, angle_almost_eq}; use network::{Network, NodeIndex, GenerationId, NodeId, OutputId, Inputs, Outputs}; use console_server::reactor::Messages; use wiggles_value::{Data, Unipolar, Datatype}; use wiggles_value::knob::{Knobs, Res...
(**self).try_pop_output(node_id) } } // TODO: consider generalizing Update and/or Render as traits. /// Wrapper trait for a wiggle network. pub trait WiggleCollection { fn update(&mut self, dt: Duration) -> Messages<KnobResponse<WiggleKnobAddr>>; } impl WiggleCollection for WiggleNetwork { fn upda...
&mut self, node_id: WiggleId) -> Result<Messages<KnobResponse<WiggleKnobAddr>>, ()> {
random_line_split
wiggle.rs
//! Dataflow node that generates/propagates/mutates a wiggle. use util::{modulo_one, almost_eq, angle_almost_eq}; use network::{Network, NodeIndex, GenerationId, NodeId, OutputId, Inputs, Outputs}; use console_server::reactor::Messages; use wiggles_value::{Data, Unipolar, Datatype}; use wiggles_value::knob::{Knobs, Res...
} impl NodeId for WiggleId { fn new(idx: NodeIndex, gen_id: GenerationId) -> Self { WiggleId(idx, gen_id) } fn index(&self) -> NodeIndex { self.0 } fn gen_id(&self) -> GenerationId { self.1 } } /// Type alias for a network of wiggles. pub type WiggleNetwork = Network<B...
{ write!(f, "wiggle {}, generation {}", self.0, self.1) }
identifier_body
wiggle.rs
//! Dataflow node that generates/propagates/mutates a wiggle. use util::{modulo_one, almost_eq, angle_almost_eq}; use network::{Network, NodeIndex, GenerationId, NodeId, OutputId, Inputs, Outputs}; use console_server::reactor::Messages; use wiggles_value::{Data, Unipolar, Datatype}; use wiggles_value::knob::{Knobs, Res...
} } } pub trait CompleteWiggle: Wiggle + Inputs<KnobResponse<WiggleKnobAddr>, WiggleId> + Outputs<KnobResponse<WiggleKnobAddr>, WiggleId> + Knobs<KnobAddr> + fmt::Debug { fn eq(&self, other: &CompleteWiggle) -> bool; fn as_any(&self) -> &Any; } impl<T> CompleteWiggle for T ...
{ node.inner().render(phase_offset, type_hint, node.inputs(), output_id, self, clocks) }
conditional_block
create_mock.rs
use std::path::Path; use clap::ArgMatches; use itertools::Itertools; use log::*; use serde_json::Value; use pact_models::pact::{Pact, ReadWritePact}; use pact_models::sync_pact::RequestResponsePact; use crate::handle_error; pub async fn create_mock_server(host: &str, port: u16, matches: &ArgMatches<'_>) -> Result<(...
} if matches.is_present("tls") { info!("Setting mock server to use TLS"); args.push("tls=true"); } let url = if args.is_empty() { format!("http://{}:{}/", host, port) } else { format!("http://{}:{}/?{}", host, port, args.iter().join("&")) }; let ...
Ok(ref pact) => { let mut args = vec![]; if matches.is_present("cors") { info!("Setting mock server to handle CORS pre-flight requests"); args.push("cors=true");
random_line_split
create_mock.rs
use std::path::Path; use clap::ArgMatches; use itertools::Itertools; use log::*; use serde_json::Value; use pact_models::pact::{Pact, ReadWritePact}; use pact_models::sync_pact::RequestResponsePact; use crate::handle_error; pub async fn create_mock_server(host: &str, port: u16, matches: &ArgMatches<'_>) -> Result<(...
let client = reqwest::Client::new(); let json = match pact.to_json(pact.specification_version()) { Ok(json) => json, Err(err) => { crate::display_error(format!("Failed to send pact as JSON '{}': {}", file, err), matches); } }; let resp = client.post(url.as_str()...
{ let file = matches.value_of("file").unwrap(); log::info!("Creating mock server from file {}", file); match RequestResponsePact::read_pact(Path::new(file)) { Ok(ref pact) => { let mut args = vec![]; if matches.is_present("cors") { info!("Setting mock server to handle CORS pre-flight requ...
identifier_body
create_mock.rs
use std::path::Path; use clap::ArgMatches; use itertools::Itertools; use log::*; use serde_json::Value; use pact_models::pact::{Pact, ReadWritePact}; use pact_models::sync_pact::RequestResponsePact; use crate::handle_error; pub async fn create_mock_server(host: &str, port: u16, matches: &ArgMatches<'_>) -> Result<(...
} }
{ crate::display_error(format!("Failed to load pact file '{}': {}", file, err), matches); }
conditional_block
create_mock.rs
use std::path::Path; use clap::ArgMatches; use itertools::Itertools; use log::*; use serde_json::Value; use pact_models::pact::{Pact, ReadWritePact}; use pact_models::sync_pact::RequestResponsePact; use crate::handle_error; pub async fn
(host: &str, port: u16, matches: &ArgMatches<'_>) -> Result<(), i32> { let file = matches.value_of("file").unwrap(); log::info!("Creating mock server from file {}", file); match RequestResponsePact::read_pact(Path::new(file)) { Ok(ref pact) => { let mut args = vec![]; if matches.is_present("cors"...
create_mock_server
identifier_name
borrowck-vec-pattern-nesting.rs
fn a() { let mut vec = ~[~1, ~2, ~3]; match vec { [~ref _a] => { vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed } _ => fail!("foo") } } fn b() { let mut vec = ~[~1, ~2, ~3]; match vec { [.._b] => { vec[0] = ~4; //~ E...
_ => {} } let a = vec[0]; //~ ERROR use of partially moved value: `vec` } fn d() { let mut vec = ~[~1, ~2, ~3]; match vec { [.._a, _b] => { //~^ ERROR cannot move out } _ => {} } let a = vec[0]; //~ ERROR use of partially moved value: `vec` } fn e() ...
}
random_line_split
borrowck-vec-pattern-nesting.rs
fn a() { let mut vec = ~[~1, ~2, ~3]; match vec { [~ref _a] => { vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed } _ => fail!("foo") } } fn b() { let mut vec = ~[~1, ~2, ~3]; match vec { [.._b] => { vec[0] = ~4; //~ E...
{}
identifier_body
borrowck-vec-pattern-nesting.rs
fn a() { let mut vec = ~[~1, ~2, ~3]; match vec { [~ref _a] => { vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed } _ => fail!("foo") } } fn
() { let mut vec = ~[~1, ~2, ~3]; match vec { [.._b] => { vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed } } } fn c() { let mut vec = ~[~1, ~2, ~3]; match vec { [_a,.._b] => { //~^ ERROR cannot move out // Note:...
b
identifier_name
borrowck-vec-pattern-nesting.rs
fn a() { let mut vec = ~[~1, ~2, ~3]; match vec { [~ref _a] => { vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed } _ => fail!("foo") } } fn b() { let mut vec = ~[~1, ~2, ~3]; match vec { [.._b] => { vec[0] = ~4; //~ E...
_ => {} } let a = vec[0]; //~ ERROR use of partially moved value: `vec` } fn main() {}
{}
conditional_block
flate.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 ...
(&mut self, _buf: &[u8]) { fail2!() } fn flush(&mut self) { fail2!() } } impl<W: Writer> Decorator<W> for DeflateWriter<W> { fn inner(self) -> W { match self { DeflateWriter { inner_writer: w } => w } } fn inner_ref<'a>(&'a self) -> &'a W { match *self { ...
write
identifier_name
flate.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 ...
InflateReader { inner_reader: ref r } => r } } fn inner_mut_ref<'a>(&'a mut self) -> &'a mut R { match *self { InflateReader { inner_reader: ref mut r } => r } } } #[cfg(test)] mod test { use prelude::*; use super::*; use super::super::mem::*; ...
random_line_split
flate.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 ...
fn inner_ref<'a>(&'a self) -> &'a R { match *self { InflateReader { inner_reader: ref r } => r } } fn inner_mut_ref<'a>(&'a mut self) -> &'a mut R { match *self { InflateReader { inner_reader: ref mut r } => r } } } #[cfg(test)] mod test { ...
{ match self { InflateReader { inner_reader: r } => r } }
identifier_body
work_mode.rs
use std::str::FromStr; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum WorkMode { Normal, // generate widgets etc. Sys, // generate -sys with FFI Doc, // generate documentation file DisplayNotBound, // Show not bound types } impl WorkMode { pub fn is_normal(s...
"sys" => Ok(WorkMode::Sys), "doc" => Ok(WorkMode::Doc), "not_bound" => Ok(WorkMode::DisplayNotBound), _ => Err(format!("Wrong work mode '{}'", s)), } } }
"normal" => Ok(WorkMode::Normal),
random_line_split
work_mode.rs
use std::str::FromStr; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum WorkMode { Normal, // generate widgets etc. Sys, // generate -sys with FFI Doc, // generate documentation file DisplayNotBound, // Show not bound types } impl WorkMode { pub fn is_normal(s...
}
{ match s { "normal" => Ok(WorkMode::Normal), "sys" => Ok(WorkMode::Sys), "doc" => Ok(WorkMode::Doc), "not_bound" => Ok(WorkMode::DisplayNotBound), _ => Err(format!("Wrong work mode '{}'", s)), } }
identifier_body
work_mode.rs
use std::str::FromStr; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum WorkMode { Normal, // generate widgets etc. Sys, // generate -sys with FFI Doc, // generate documentation file DisplayNotBound, // Show not bound types } impl WorkMode { pub fn is_normal(s...
(s: &str) -> Result<Self, Self::Err> { match s { "normal" => Ok(WorkMode::Normal), "sys" => Ok(WorkMode::Sys), "doc" => Ok(WorkMode::Doc), "not_bound" => Ok(WorkMode::DisplayNotBound), _ => Err(format!("Wrong work mode '{}'", s)), } } }
from_str
identifier_name
stars.rs
use futures::prelude::*; use hubcaps::{Credentials, Github}; use std::env; use std::error::Error; #[tokio::main] async fn
() -> Result<(), Box<dyn Error>> { pretty_env_logger::init(); let token = env::var("GITHUB_TOKEN")?; let github = Github::new( concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")), Credentials::Token(token), )?; let stars = github.activity().stars(); let f = futures::f...
main
identifier_name
stars.rs
use futures::prelude::*; use hubcaps::{Credentials, Github}; use std::env; use std::error::Error; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>>
println!("{:?}", s.html_url); Ok(()) }) .await?; Ok(()) }
{ pretty_env_logger::init(); let token = env::var("GITHUB_TOKEN")?; let github = Github::new( concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")), Credentials::Token(token), )?; let stars = github.activity().stars(); let f = futures::future::try_join( stars.st...
identifier_body
stars.rs
use futures::prelude::*; use hubcaps::{Credentials, Github}; use std::env; use std::error::Error; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { pretty_env_logger::init(); let token = env::var("GITHUB_TOKEN")?; let github = Github::new( concat!(env!("CARGO_PKG_NAME"), "/", env!("CAR...
.try_for_each(|s| async move { println!("{:?}", s.html_url); Ok(()) }) .await?; Ok(()) }
stars .iter("softprops")
random_line_split
auto-encode.rs
// xfail-fast // 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 // <...
(&self, other: &CLike) -> bool { (*self) as int == *other as int } fn ne(&self, other: &CLike) -> bool {!self.eq(other) } } #[auto_encode] #[auto_decode] #[deriving(Eq)] struct Spanned<T> { lo: uint, hi: uint, node: T, } #[auto_encode] #[auto_decode] struct SomeStruct { v: ~[uint] } #[aut...
eq
identifier_name
auto-encode.rs
// xfail-fast // 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 // <...
lo: uint, hi: uint, node: T, } #[auto_encode] #[auto_decode] struct SomeStruct { v: ~[uint] } #[auto_encode] #[auto_decode] struct Point {x: uint, y: uint} #[auto_encode] #[auto_decode] enum Quark<T> { Top(T), Bottom(T) } #[auto_encode] #[auto_decode] enum CLike { A, B, C } pub fn main() { ...
struct Spanned<T> {
random_line_split
serving.rs
// Copyright (c) 2016-2018 The http-serve developers // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE.txt or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT.txt or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or dist...
.header(header::ALLOW, HeaderValue::from_static("get, head")) .body(static_body::<D, E>("This resource only supports GET and HEAD.").into()) .unwrap(), ); } let last_modified = ent.last_modified(); let etag = ent.etag(); let (precondition_failed, no...
random_line_split
serving.rs
// Copyright (c) 2016-2018 The http-serve developers // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE.txt or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT.txt or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or dist...
/// An instruction from `serve_inner` to `serve` on how to respond. enum ServeInner<B> { Simple(Response<B>), Multipart { res: http::response::Builder, part_headers: Vec<Vec<u8>>, ranges: SmallVec<[Range<u64>; 1]>, }, } /// Runs trait object-based inner logic for `serve`. fn serve...
{ // serve takes entity itself for ownership, as needed for the multipart case. But to avoid // monomorphization code bloat when there are many implementations of Entity<Data, Error>, // delegate as much as possible to functions which take a reference to a trait object. match serve_inner(&entity, req) {...
identifier_body
serving.rs
// Copyright (c) 2016-2018 The http-serve developers // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE.txt or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT.txt or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or dist...
<D, E>( state: usize, ent: &dyn Entity<Data = D, Error = E>, ranges: &[Range<u64>], part_headers: &mut [Vec<u8>], ) -> impl Future<Output = Option<(InnerBody<D, E>, usize)>> where D:'static + Send + Sync + Buf + From<Vec<u8>> + From<&'static [u8]>, E:'static + Send + Sync, { let i = state >>...
next_multipart_body_chunk
identifier_name
example.rs
use report::ExampleResult; use header::ExampleHeader; /// Test examples are the smallest unit of a testing framework, wrapping one or more assertions. pub struct Example<T> { pub(crate) header: ExampleHeader, pub(crate) function: Box<Fn(&T) -> ExampleResult>, } impl<T> Example<T> { pub(crate) fn new<F>(he...
() -> Self { Example::new(ExampleHeader::default(), |_| ExampleResult::Failure(None)) } } unsafe impl<T> Send for Example<T> where T: Send, { } unsafe impl<T> Sync for Example<T> where T: Sync, { }
fixture_failed
identifier_name
example.rs
use report::ExampleResult; use header::ExampleHeader; /// Test examples are the smallest unit of a testing framework, wrapping one or more assertions. pub struct Example<T> { pub(crate) header: ExampleHeader, pub(crate) function: Box<Fn(&T) -> ExampleResult>, }
pub(crate) fn new<F>(header: ExampleHeader, assertion: F) -> Self where F:'static + Fn(&T) -> ExampleResult, { Example { header: header, function: Box::new(assertion), } } /// Used for testing purpose #[cfg(test)] pub fn fixture_success() -> S...
impl<T> Example<T> {
random_line_split
main.rs
//! Amethyst CLI binary crate. //! use std::process::exit; use amethyst_cli as cli; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; fn
() { eprintln!( "WARNING! amethyst_tools has been deprecated and will stop working in future versions." ); eprintln!("For more details please see https://community.amethyst.rs/t/end-of-life-for-amethyst-tools-the-cli/1656"); let matches = App::new("Amethyst CLI") .author("Created by Ameth...
main
identifier_name
main.rs
//! Amethyst CLI binary crate. //! use std::process::exit; use amethyst_cli as cli; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; fn main() { eprintln!( "WARNING! amethyst_tools has been deprecated and will stop working in future versions." ); eprintln!("For more details please see h...
.value_name("AMETHYST_VERSION") .takes_value(true) .help("The requested version of Amethyst"), ) .arg( Arg::with_name("no_defaults") .short("n") .long("no...
Arg::with_name("amethyst_version") .short("a") .long("amethyst")
random_line_split
main.rs
//! Amethyst CLI binary crate. //! use std::process::exit; use amethyst_cli as cli; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; fn main() { eprintln!( "WARNING! amethyst_tools has been deprecated and will stop working in future versions." ); eprintln!("For more details please see h...
fn handle_error(e: &cli::error::Error) { use ansi_term::Color; eprintln!("{}: {}", Color::Red.paint("error"), e); e.iter() .skip(1) .for_each(|e| eprintln!("{}: {}", Color::Red.paint("caused by"), e)); // Only shown if `RUST_BACKTRACE=1`. if let Some(backtrace) = e.backtrace() { ...
{ use ansi_term::Color; use cli::get_latest_version; let local_version = semver::Version::parse(env!("CARGO_PKG_VERSION"))?; let remote_version_str = get_latest_version()?; let remote_version = semver::Version::parse(&remote_version_str)?; if local_version < remote_version { eprintln!(...
identifier_body
feature-gate.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 ...
#[rustc_error] fn main() { //[with_gate]~ ERROR compilation successful let y = Foo { x: 1 }; match y { FOO => { } _ => { } } }
x: u32 } const FOO: Foo = Foo { x: 0 };
random_line_split
feature-gate.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 ...
() { //[with_gate]~ ERROR compilation successful let y = Foo { x: 1 }; match y { FOO => { } _ => { } } }
main
identifier_name
memory.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 https://mozilla.org/MPL/2.0/. */ use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::StreamId; use serde_json::{Map, Value}; ...
}
{ //TODO: TimelineMemoryReply { jsObjectSize: 1, jsStringSize: 1, jsOtherSize: 1, domSize: 1, styleSize: 1, otherSize: 1, totalSize: 1, jsMilliseconds: 1.1, nonJSMilliseconds: 1.1, } }
identifier_body
memory.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 https://mozilla.org/MPL/2.0/. */ use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::StreamId; use serde_json::{Map, Value}; ...
} pub fn measure(&self) -> TimelineMemoryReply { //TODO: TimelineMemoryReply { jsObjectSize: 1, jsStringSize: 1, jsOtherSize: 1, domSize: 1, styleSize: 1, otherSize: 1, totalSize: 1, jsMilliseconds: ...
registry.register_later(Box::new(actor)); actor_name
random_line_split
memory.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 https://mozilla.org/MPL/2.0/. */ use crate::actor::{Actor, ActorMessageStatus, ActorRegistry}; use crate::StreamId; use serde_json::{Map, Value}; ...
(registry: &ActorRegistry) -> String { let actor_name = registry.new_name("memory"); let actor = MemoryActor { name: actor_name.clone(), }; registry.register_later(Box::new(actor)); actor_name } pub fn measure(&self) -> TimelineMemoryReply { //TODO: ...
create
identifier_name
mod.rs
/* Copyright 2018 Mozilla Foundation * * 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...
pub use self::name_section::FunctionName; pub use self::name_section::LocalName; pub use self::name_section::ModuleName; pub use self::name_section::Name; pub use self::name_section::NameSectionReader; pub use self::name_section::NamingReader; pub use self::producers_section::ProducersField; pub use self::producers_s...
random_line_split
from_raw_arc.rs
//! A "Manual Arc" which allows manually frobbing the reference count //! //! This module contains a copy of the `Arc` found in the standard library, //! stripped down to the bare bones of what we actually need. The reason this is //! done is for the ability to concretely know the memory layout of the `Inner` //! struc...
<T> { data: T, cnt: AtomicUsize, } impl<T> FromRawArc<T> { pub fn new(data: T) -> FromRawArc<T> { let x = Box::new(Inner { data: data, cnt: AtomicUsize::new(1), }); FromRawArc { _inner: unsafe { mem::transmute(x) }, } } pub unsafe...
Inner
identifier_name
from_raw_arc.rs
//! A "Manual Arc" which allows manually frobbing the reference count //! //! This module contains a copy of the `Arc` found in the standard library, //! stripped down to the bare bones of what we actually need. The reason this is //! done is for the ability to concretely know the memory layout of the `Inner` //! struc...
FromRawArc { _inner: unsafe { mem::transmute(x) }, } } pub unsafe fn from_raw(ptr: *mut T) -> FromRawArc<T> { // Note that if we could use `mem::transmute` here to get a libstd Arc // (guaranteed) then we could just use std::sync::Arc, but this is the // cruc...
let x = Box::new(Inner { data: data, cnt: AtomicUsize::new(1), });
random_line_split
from_raw_arc.rs
//! A "Manual Arc" which allows manually frobbing the reference count //! //! This module contains a copy of the `Arc` found in the standard library, //! stripped down to the bare bones of what we actually need. The reason this is //! done is for the ability to concretely know the memory layout of the `Inner` //! struc...
atomic::fence(Ordering::Acquire); drop(mem::transmute::<_, Box<T>>(self._inner)); } } } #[cfg(test)] mod tests { use super::FromRawArc; #[test] fn smoke() { let a = FromRawArc::new(1); assert_eq!(*a, 1); assert_eq!(*a.clone(), 1); } #[t...
{ return; }
conditional_block
api_str.rs
// These tests don't really make sense with the bytes API, so we only test them // on the Unicode API. #[test] fn empty_match_unicode_find_iter() { // Tests that we still yield byte ranges at valid UTF-8 sequence boundaries // even when we're susceptible to empty width matches. let re = regex!(r".*?"); ...
let re = regex!(r"fo+"); let caps = re.captures("barfoobar").unwrap(); assert_eq!(caps.get(0).map(|m| m.as_str()), Some("foo")); assert_eq!(caps.get(0).map(From::from), Some("foo")); assert_eq!(caps.get(0).map(Into::into), Some("foo")); }
assert_eq!(vec![(0, 0), (3, 3), (4, 4), (7, 7), (8, 8)], ms); } #[test] fn match_as_str() {
random_line_split
api_str.rs
// These tests don't really make sense with the bytes API, so we only test them // on the Unicode API. #[test] fn empty_match_unicode_find_iter() { // Tests that we still yield byte ranges at valid UTF-8 sequence boundaries // even when we're susceptible to empty width matches. let re = regex!(r".*?"); ...
// Same as empty_match_unicode_find_iter, but tests capture iteration. let re = regex!(r".*?"); let ms: Vec<_> = re .captures_iter(text!("Ⅰ1Ⅱ2")) .map(|c| c.get(0).unwrap()) .map(|m| (m.start(), m.end())) .collect(); assert_eq!(vec![(0, 0), (3, 3), (4, 4), (7, 7), (8, 8)], m...
y_match_unicode_captures_iter() {
identifier_name
api_str.rs
// These tests don't really make sense with the bytes API, so we only test them // on the Unicode API. #[test] fn empty_match_unicode_find_iter() { // Tests that we still yield byte ranges at valid UTF-8 sequence boundaries // even when we're susceptible to empty width matches. let re = regex!(r".*?"); ...
t re = regex!(r"fo+"); let caps = re.captures("barfoobar").unwrap(); assert_eq!(caps.get(0).map(|m| m.as_str()), Some("foo")); assert_eq!(caps.get(0).map(From::from), Some("foo")); assert_eq!(caps.get(0).map(Into::into), Some("foo")); }
identifier_body
font_template.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 font::FontHandleMethods; use platform::font_context::FontContextHandle; use platform::font::FontHandle; use pl...
let actual_desc = FontTemplateDescriptor::new(handle.boldness(), handle.stretchiness(), handle.is_italic()); let desc_match = actual...
{ // The font template data can be unloaded when nothing is referencing // it (via the Weak reference to the Arc above). However, if we have // already loaded a font, store the style information about it separately, // so that we can do font matching against it again in the future ...
identifier_body
font_template.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 font::FontHandleMethods; use platform::font_context::FontContextHandle; use platform::font::FontHandle; use pl...
, None if self.is_valid => { let data = self.get_data(); let handle: Result<FontHandle, ()> = FontHandleMethods::new_from_template(fctx, data.clone(), None); match handle { Ok(handle) => { let act...
{ if *requested_desc == actual_desc { Some(self.get_data()) } else { None } }
conditional_block
font_template.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 font::FontHandleMethods; use platform::font_context::FontContextHandle; use platform::font::FontHandle; use pl...
(&mut self, fctx: &FontContextHandle, requested_desc: &FontTemplateDescriptor) -> Option<Arc<FontTemplateData>> { // The font template data can be unloaded when nothing is referencing // it (via the Weak reference to the Arc a...
get_if_matches
identifier_name
font_template.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 font::FontHandleMethods; use platform::font_context::FontContextHandle; use platform::font::FontHandle; use pl...
return data } assert!(self.strong_ref.is_none()); let template_data = Arc::new(FontTemplateData::new(self.identifier.clone(), None)); self.weak_ref = Some(template_data.downgrade()); template_data } }
None => None, }; if let Some(data) = maybe_data {
random_line_split
walker.rs
use std::cell::RefCell; use std::io; use std::path::{Path, PathBuf}; use walkdir::{DirEntry, WalkDir, WalkDirIterator}; use pulldown_cmark::{Event, Parser, Tag}; use file_utils; /// Wrapper of a list of Markdown files. With end goal to be able to convey the
/// hierarchy. pub struct MarkdownFileList { // Considering maintaining directory structure by Map<Vec<>> files: Vec<MarkdownFile>, } impl MarkdownFileList { pub fn new(files: Vec<MarkdownFile>) -> MarkdownFileList { let mut sorted_files = files; sorted_files.sort_by(|a, b| a.get_file_name(...
random_line_split
walker.rs
use std::cell::RefCell; use std::io; use std::path::{Path, PathBuf}; use walkdir::{DirEntry, WalkDir, WalkDirIterator}; use pulldown_cmark::{Event, Parser, Tag}; use file_utils; /// Wrapper of a list of Markdown files. With end goal to be able to convey the /// hierarchy. pub struct MarkdownFileList { // Consider...
} Ok(files) } #[cfg(test)] mod tests { use std::path::PathBuf; use std::cell::RefCell; #[test] fn test_get_file_name() { let file = super::MarkdownFile { path: PathBuf::from("resources/tester.md"), heading: RefCell::new(String::new()), }; asser...
{ debug!("Adding file {:?}", path); files.push(MarkdownFile::from(path)); }
conditional_block
walker.rs
use std::cell::RefCell; use std::io; use std::path::{Path, PathBuf}; use walkdir::{DirEntry, WalkDir, WalkDirIterator}; use pulldown_cmark::{Event, Parser, Tag}; use file_utils; /// Wrapper of a list of Markdown files. With end goal to be able to convey the /// hierarchy. pub struct MarkdownFileList { // Consider...
/// Determines if the provided entry should be excluded from the files to check. /// The check just determines if the file or directory begins with an /// underscore. fn is_excluded(entry: &DirEntry) -> bool { entry .file_name() .to_str() .map(|s| s.starts_with('_')) .unwrap_or(false) ...
{ const FILE_EXT: &str = "md"; if let Some(extension) = path.extension().and_then(|x| x.to_str()) { if extension.to_lowercase().eq(FILE_EXT) { return true; } } false }
identifier_body
walker.rs
use std::cell::RefCell; use std::io; use std::path::{Path, PathBuf}; use walkdir::{DirEntry, WalkDir, WalkDirIterator}; use pulldown_cmark::{Event, Parser, Tag}; use file_utils; /// Wrapper of a list of Markdown files. With end goal to be able to convey the /// hierarchy. pub struct MarkdownFileList { // Consider...
(path: &Path) -> MarkdownFile { MarkdownFile { path: path.to_path_buf(), heading: RefCell::new(String::new()), } } /// Return the path of the Markdown file pub fn get_path(&self) -> &PathBuf { &self.path } /// Return the name of the Markdown file ...
from
identifier_name
transitionevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::Transition...
// https://dom.spec.whatwg.org/#dom-event-istrusted fn IsTrusted(&self) -> bool { self.upcast::<Event>().IsTrusted() } }
{ self.pseudo_element.clone() }
identifier_body
transitionevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::Transition...
(&self) -> DOMString { DOMString::from(&*self.property_name) } // https://drafts.csswg.org/css-transitions/#Events-TransitionEvent-elapsedTime fn ElapsedTime(&self) -> Finite<f32> { self.elapsed_time.clone() } // https://drafts.csswg.org/css-transitions/#Events-TransitionEvent-pseu...
PropertyName
identifier_name
transitionevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::Transition...
} ev } pub fn Constructor(window: &Window, type_: DOMString, init: &TransitionEventInit) -> Fallible<Root<TransitionEvent>> { let global = window.upcast::<GlobalScope>(); Ok(TransitionEvent::new(global, Atom::from(type_), init)) ...
random_line_split
video.rs
use sdl2; pub fn main()
sdl2::event::QuitEvent(_) => break'main, sdl2::event::KeyDownEvent(_, _, key, _, _) => { if key == sdl2::keycode::EscapeKey { break'main } }, sdl2::event::NoEvent => break 'event, ...
{ sdl2::init(sdl2::InitVideo); let window = match sdl2::video::Window::new("rust-sdl2 demo: Video", sdl2::video::PosCentered, sdl2::video::PosCentered, 800, 600, sdl2::video::OpenGL) { Ok(window) => window, Err(err) => fail!(format!("failed to create window: {}", err)) }; let renderer ...
identifier_body
video.rs
use sdl2; pub fn main() { sdl2::init(sdl2::InitVideo); let window = match sdl2::video::Window::new("rust-sdl2 demo: Video", sdl2::video::PosCentered, sdl2::video::PosCentered, 800, 600, sdl2::video::OpenGL) { Ok(window) => window, Err(err) => fail!(format!("failed to create window: {}", err)) ...
}, sdl2::event::NoEvent => break 'event, _ => {} } } } sdl2::quit(); }
{ break 'main }
conditional_block
video.rs
use sdl2; pub fn
() { sdl2::init(sdl2::InitVideo); let window = match sdl2::video::Window::new("rust-sdl2 demo: Video", sdl2::video::PosCentered, sdl2::video::PosCentered, 800, 600, sdl2::video::OpenGL) { Ok(window) => window, Err(err) => fail!(format!("failed to create window: {}", err)) }; let render...
main
identifier_name
video.rs
use sdl2; pub fn main() { sdl2::init(sdl2::InitVideo); let window = match sdl2::video::Window::new("rust-sdl2 demo: Video", sdl2::video::PosCentered, sdl2::video::PosCentered, 800, 600, sdl2::video::OpenGL) { Ok(window) => window, Err(err) => fail!(format!("failed to create window: {}", err)) ...
Err(err) => fail!(format!("failed to create renderer: {}", err)) }; let _ = renderer.set_draw_color(sdl2::pixels::RGB(255, 0, 0)); let _ = renderer.clear(); renderer.present(); 'main : loop { 'event : loop { match sdl2::event::poll_event() { sdl2::event::...
Ok(renderer) => renderer,
random_line_split
simdty.rs
// Copyright 2016 chacha20-poly1305-aead Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://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 exce...
(e0: T, e1: T, e2: T, e3: T) -> Simd4<T> { Simd4(e0, e1, e2, e3) } } unsafe impl<T: Safe> Safe for Simd4<T> {} unsafe impl<T: Safe> Safe for Simd8<T> {} unsafe impl<T: Safe> Safe for Simd16<T> {}
new
identifier_name
simdty.rs
// Copyright 2016 chacha20-poly1305-aead Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://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 exce...
pub T, pub T, pub T, pub T, pub T, pub T, pub T, pub T, pub T, pub T, pub T, pub T); } pub type u32x4 = Simd4<u32>; pub type u16x8 = Simd8<u16>; pub type u8x16 = Simd16<u8>; #[cfg_attr(feature = "clippy", allow(inline_always))] impl<T> Simd4<T...
pub T, pub T, pub T, pub T); pub struct Simd16<T>(pub T, pub T, pub T, pub T,
random_line_split