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
round_manager_fuzzing.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ block_storage::BlockStore, liveness::{ proposal_generator::ProposalGenerator, rotating_proposer_election::RotatingProposer, round_state::{ExponentialTimeInterval, NewRoundEvent, NewRoundReaso...
{ // generate a proposal let proposal = generate_corpus_proposal(); // successfully parse it fuzz_proposal(&proposal); }
identifier_body
round_manager_fuzzing.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ block_storage::BlockStore, liveness::{ proposal_generator::ProposalGenerator, rotating_proposer_election::RotatingProposer, round_state::{ExponentialTimeInterval, NewRoundEvent, NewRoundReaso...
}; use futures::{channel::mpsc, executor::block_on}; use network::{ peer_manager::{ConnectionRequestSender, PeerManagerRequestSender}, protocols::network::NewNetworkSender, }; use once_cell::sync::Lazy; use safety_rules::{test_utils, SafetyRules, TSafetyRules}; use std::{collections::BTreeMap, sync::Arc, time::...
ledger_info::{LedgerInfo, LedgerInfoWithSignatures}, on_chain_config::ValidatorSet, validator_info::ValidatorInfo, validator_signer::ValidatorSigner, validator_verifier::ValidatorVerifier,
random_line_split
round_manager_fuzzing.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ block_storage::BlockStore, liveness::{ proposal_generator::ProposalGenerator, rotating_proposer_election::RotatingProposer, round_state::{ExponentialTimeInterval, NewRoundEvent, NewRoundReaso...
( storage: Arc<dyn PersistentLivenessStorage>, initial_data: RecoveryData, ) -> Arc<BlockStore> { let (_commit_cb_sender, _commit_cb_receiver) = mpsc::unbounded::<LedgerInfoWithSignatures>(); Arc::new(BlockStore::new( storage, initial_data, Arc::new(EmptyStateComputer), ...
build_empty_store
identifier_name
mod.rs
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co // // This file is part of cancer. // // cancer is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (a...
pub use self::proxy::Proxy;
random_line_split
shadow.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 ...
(c: Vec<int> ) { let a: int = 5; let mut b: Vec<int> = Vec::new(); match t::none::<int> { t::some::<int>(_) => { for _i in c.iter() { println!("{}", a); let a = 17i; b.push(a); } } _ => { } } } enum t<T> {...
foo
identifier_name
shadow.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn foo(c: Vec<int> ...
random_line_split
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; use dom::bindings::codegen::Bindings:...
} } fn prepare_message(logLevel: LogLevel, message: DOMString) -> ConsoleMessage { // TODO: Sending fake values for filename, lineNumber and columnNumber in LogMessage; adjust later ConsoleMessage { message: String::from(message), logLevel: logLevel, filename: "test".to_owned(), ...
{ let message = message.unwrap_or_else(|| DOMString::from("no message")); println!("Assertion failed: {}", message); propagate_console_msg(&self, prepare_message(LogLevel::Error, message)); }
conditional_block
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; use dom::bindings::codegen::Bindings:...
{ reflector_: Reflector, global: GlobalField, } impl Console { fn new_inherited(global: GlobalRef) -> Console { Console { reflector_: Reflector::new(), global: GlobalField::from_rooted(&global), } } pub fn new(global: GlobalRef) -> Root<Console> { r...
Console
identifier_name
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; use dom::bindings::codegen::Bindings:...
println!("Assertion failed: {}", message); propagate_console_msg(&self, prepare_message(LogLevel::Error, message)); } } } fn prepare_message(logLevel: LogLevel, message: DOMString) -> ConsoleMessage { // TODO: Sending fake values for filename, lineNumber and columnNumber in LogM...
fn Assert(&self, condition: bool, message: Option<DOMString>) { if !condition { let message = message.unwrap_or_else(|| DOMString::from("no message"));
random_line_split
console.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 devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg}; use dom::bindings::codegen::Bindings:...
pub fn new(global: GlobalRef) -> Root<Console> { reflect_dom_object(box Console::new_inherited(global), global, ConsoleBinding::Wrap) } } impl ConsoleMethods for Console { // https://developer.mozilla.org/en-US/docs/Web/API/Console/log fn ...
{ Console { reflector_: Reflector::new(), global: GlobalField::from_rooted(&global), } }
identifier_body
thread.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> RawPthread { self.as_inner().id() as RawPthread } fn into_pthread_t(self) -> RawPthread { self.into_inner().into_id() as RawPthread } }
as_pthread_t
identifier_name
thread.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Unix-specific e...
// http://rust-lang.org/COPYRIGHT. //
random_line_split
thread.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
{ self.into_inner().into_id() as RawPthread }
identifier_body
lib.rs
//! A generic filesystem with disk and in-memory implementations. //! //! # Reason for existence //! //! The [`std::fs`] module provides functions to manipulate the filesytem, and these functions are //! good. However, if you have code that uses `std::fs`, it is difficult to ensure that your code //! handles errors pro...
mod errors; mod path_parts; mod ptr;
pub mod disk; pub mod mem; pub mod unix_ext;
random_line_split
sleep.rs
#[cfg(all(target_os = "polymorphos", target_arch = "x86_64"))] pub fn sleep_for_ms(count: u32) { use crate::timer::Timer; use crate::TIMER; let must_reach: Timer = x86_64::instructions::interrupts::without_interrupts(|| { let timer = TIMER.get(); let mut must_reach = timer.clone(); ...
(count: u32) { let duration = std::time::Duration::from_millis(u64::from(count)); std::thread::sleep(duration); }
sleep_for_ms
identifier_name
sleep.rs
#[cfg(all(target_os = "polymorphos", target_arch = "x86_64"))] pub fn sleep_for_ms(count: u32)
break; } x86_64::instructions::hlt(); } } #[cfg(any(test, rustdoc))] pub fn sleep_for_ms(count: u32) { let duration = std::time::Duration::from_millis(u64::from(count)); std::thread::sleep(duration); }
{ use crate::timer::Timer; use crate::TIMER; let must_reach: Timer = x86_64::instructions::interrupts::without_interrupts(|| { let timer = TIMER.get(); let mut must_reach = timer.clone(); must_reach.increment_ms(count); must_reach }); loop { let mut reached...
identifier_body
sleep.rs
#[cfg(all(target_os = "polymorphos", target_arch = "x86_64"))] pub fn sleep_for_ms(count: u32) { use crate::timer::Timer; use crate::TIMER; let must_reach: Timer = x86_64::instructions::interrupts::without_interrupts(|| { let timer = TIMER.get(); let mut must_reach = timer.clone(); ...
let mut reached = false; x86_64::instructions::interrupts::without_interrupts(|| { let current = TIMER.get(); reached = *current >= must_reach; }); if reached { break; } x86_64::instructions::hlt(); } } #[cfg(any(test, rustdoc))]...
loop {
random_line_split
sleep.rs
#[cfg(all(target_os = "polymorphos", target_arch = "x86_64"))] pub fn sleep_for_ms(count: u32) { use crate::timer::Timer; use crate::TIMER; let must_reach: Timer = x86_64::instructions::interrupts::without_interrupts(|| { let timer = TIMER.get(); let mut must_reach = timer.clone(); ...
x86_64::instructions::hlt(); } } #[cfg(any(test, rustdoc))] pub fn sleep_for_ms(count: u32) { let duration = std::time::Duration::from_millis(u64::from(count)); std::thread::sleep(duration); }
{ break; }
conditional_block
vfixupimmsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vfixupimmsd_1() { run_test(&Instruction { mnemonic: Mnemonic::VFIXUPIMMSD, operand1: Some(Direct(XMM5)), operand2: Some...
{ run_test(&Instruction { mnemonic: Mnemonic::VFIXUPIMMSD, operand1: Some(Direct(XMM21)), operand2: Some(Direct(XMM27)), operand3: Some(IndirectDisplaced(RAX, 1072326570, Some(OperandSize::Qword), None)), operand4: Some(Literal8(108)), lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false,...
identifier_body
vfixupimmsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*;
run_test(&Instruction { mnemonic: Mnemonic::VFIXUPIMMSD, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM2)), operand3: Some(IndirectScaledIndexedDisplaced(EDX, EBX, Two, 1540894690, Some(OperandSize::Qword), None)), operand4: Some(Literal8(71)), lock: false, rounding_mode: None, merge_mode: Some(MergeMode::...
fn vfixupimmsd_1() { run_test(&Instruction { mnemonic: Mnemonic::VFIXUPIMMSD, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM2)), operand3: Some(Direct(XMM7)), operand4: Some(Literal8(115)), lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: true, mask: Some(MaskReg::K2), broadcast: N...
random_line_split
vfixupimmsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vfixupimmsd_1() { run_test(&Instruction { mnemonic: Mnemonic::VFIXUPIMMSD, operand1: Some(Direct(XMM5)), operand2: Some...
() { run_test(&Instruction { mnemonic: Mnemonic::VFIXUPIMMSD, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM2)), operand3: Some(IndirectScaledIndexedDisplaced(EDX, EBX, Two, 1540894690, Some(OperandSize::Qword), None)), operand4: Some(Literal8(71)), lock: false, rounding_mode: None, merge_mode: Some(MergeM...
vfixupimmsd_2
identifier_name
workspace_folders.rs
use serde::{Deserialize, Serialize}; use url::Url; use crate::OneOf; #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFoldersServerCapabilities { /// The server has support for workspace folders #[serde(skip_serializing_if = "Option...
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFolder { /// The associated URI for this workspace folder. pub uri: Url, /// The name of the workspace folder. Defaults to the uri's basename. pub name: String, } #[derive(Debug, Eq, P...
/// side. The ID can be used to unregister for these events /// using the `client/unregisterCapability` request. #[serde(skip_serializing_if = "Option::is_none")] pub change_notifications: Option<OneOf<bool, String>>, }
random_line_split
workspace_folders.rs
use serde::{Deserialize, Serialize}; use url::Url; use crate::OneOf; #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFoldersServerCapabilities { /// The server has support for workspace folders #[serde(skip_serializing_if = "Option...
{ /// The actual workspace folder change event. pub event: WorkspaceFoldersChangeEvent, } /// The workspace folder change event. #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFoldersChangeEvent { /// The array of added worksp...
DidChangeWorkspaceFoldersParams
identifier_name
error.rs
// Copyright (c) 2016 Tibor Benke <ihrwein@gmail.com> // // 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. All files in the project carrying such notice may not...
}
{ Error::SerdeYaml(error) }
identifier_body
error.rs
// Copyright (c) 2016 Tibor Benke <ihrwein@gmail.com> // // 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. All files in the project carrying such notice may not...
fn from(error: serde_json::error::Error) -> Error { Error::SerdeJson(error) } } impl From<serde_yaml::error::Error> for Error { fn from(error: serde_yaml::error::Error) -> Error { Error::SerdeYaml(error) } }
} } impl From<serde_json::error::Error> for Error {
random_line_split
error.rs
// Copyright (c) 2016 Tibor Benke <ihrwein@gmail.com> // // 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. All files in the project carrying such notice may not...
(error: serde_json::error::Error) -> Error { Error::SerdeJson(error) } } impl From<serde_yaml::error::Error> for Error { fn from(error: serde_yaml::error::Error) -> Error { Error::SerdeYaml(error) } }
from
identifier_name
hosts.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 parse_hosts::HostsFile; use std::borrow::Cow; use std::collections::HashMap; use std::env; use std::fs::File; ...
() -> Option<HashMap<String, IpAddr>> { let path = env::var_os("HOST_FILE")?; let file = File::open(&path).ok()?; let mut reader = BufReader::new(file); let mut lines = String::new(); reader.read_to_string(&mut lines).ok()?; Some(parse_hostsfile(&lines)) } pub fn replace_host_table(table: Ha...
create_host_table
identifier_name
hosts.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 parse_hosts::HostsFile; use std::borrow::Cow; use std::collections::HashMap; use std::env; use std::fs::File; ...
pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> { HostsFile::read_buffered(hostsfile_content.as_bytes()) .pairs() .filter_map(Result::ok) .collect() } pub fn replace_host(host: &str) -> Cow<str> { HOST_TABLE.lock().unwrap().as_ref() .and_then(|table| tab...
{ *HOST_TABLE.lock().unwrap() = Some(table); }
identifier_body
hosts.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 parse_hosts::HostsFile; use std::borrow::Cow; use std::collections::HashMap; use std::env; use std::fs::File; ...
pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> { HostsFile::read_buffered(hostsfile_content.as_bytes()) .pairs() .filter_map(Result::ok) .collect() } pub fn replace_host(host: &str) -> Cow<str> { HOST_TABLE.lock().unwrap().as_ref() .and_then(|table| tabl...
pub fn replace_host_table(table: HashMap<String, IpAddr>) { *HOST_TABLE.lock().unwrap() = Some(table); }
random_line_split
mod.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ // Containers for Mercurial data, stored in the blob store. mod changeset_envelope; mod file_envelope; mod manifest_envelope; pub use sel...
(Bytes); impl From<BlobstoreBytes> for HgEnvelopeBlob { #[inline] fn from(bytes: BlobstoreBytes) -> HgEnvelopeBlob { HgEnvelopeBlob(bytes.into_bytes()) } } impl From<HgEnvelopeBlob> for BlobstoreBytes { #[inline] fn from(blob: HgEnvelopeBlob) -> BlobstoreBytes { BlobstoreBytes::fro...
HgEnvelopeBlob
identifier_name
mod.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ // Containers for Mercurial data, stored in the blob store. mod changeset_envelope; mod file_envelope; mod manifest_envelope; pub use sel...
#[inline] fn from(blob: HgEnvelopeBlob) -> BlobstoreBytes { BlobstoreBytes::from_bytes(blob.0) } } impl From<BlobstoreGetData> for HgEnvelopeBlob { #[inline] fn from(blob_val: BlobstoreGetData) -> HgEnvelopeBlob { HgEnvelopeBlob(blob_val.into_raw_bytes()) } } impl From<HgEnvelo...
impl From<HgEnvelopeBlob> for BlobstoreBytes {
random_line_split
overload-index-operator.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let foo = ~"foo"; let bar = ~"bar"; let mut list = AssociationList {pairs: ~[]}; list.push(copy foo, 22); list.push(copy bar, 44); assert!(list[foo] == 22) assert!(list[bar] == 44) assert!(list[foo] == 22) assert!(list[bar] == 44) }
identifier_body
overload-index-operator.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let foo = ~"foo"; let bar = ~"bar"; let mut list = AssociationList {pairs: ~[]}; list.push(copy foo, 22); list.push(copy bar, 44); assert!(list[foo] == 22) assert!(list[bar] == 44) assert!(list[foo] == 22) assert!(list[bar] == 44) }
random_line_split
overload-index-operator.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 ...
} fail!(fmt!("No value found for key: %?", index)); } } pub fn main() { let foo = ~"foo"; let bar = ~"bar"; let mut list = AssociationList {pairs: ~[]}; list.push(copy foo, 22); list.push(copy bar, 44); assert!(list[foo] == 22) assert!(list[bar] == 44) assert!(li...
{ return copy pair.value; }
conditional_block
overload-index-operator.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 ...
(&mut self, key: K, value: V) { self.pairs.push(AssociationPair {key: key, value: value}); } } impl<K:Eq,V:Copy> Index<K,V> for AssociationList<K,V> { fn index(&self, index: &K) -> V { for self.pairs.each |pair| { if pair.key == *index { return copy pair.value; ...
push
identifier_name
check_cfg.rs
use super::CFG; use super::{Adjacency}; use crate::common::{ function_attributes::FunctionAttribute, types::Type, tac_code::{Function, Statement}, error_reporter::{ErrorReporter, ReportKind}, }; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; pub fn check_cfg( ...
let end = cfg.basic_blocks[pos].end; insert_positions.push(end); } } } } } for pos in insert_positions.iter() { cfg.insert_statement(function, *pos, Statement::Return(None)); } }
} else {
random_line_split
check_cfg.rs
use super::CFG; use super::{Adjacency}; use crate::common::{ function_attributes::FunctionAttribute, types::Type, tac_code::{Function, Statement}, error_reporter::{ErrorReporter, ReportKind}, }; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; pub fn check_cfg( ...
) } else { let end = cfg.basic_blocks[pos].end; insert_positions.push(end); } } } } } for pos in insert_positions.iter() { cfg.insert_statement(func...
{ if function.has_attribute(FunctionAttribute::External) { return; } let mut insert_positions = vec![]; for (pos, adjacencies) in cfg.adjacency_list.iter().enumerate() { if adjacencies.contains(&Adjacency::End) { let bb = &cfg.basic_blocks[pos]; ma...
identifier_body
check_cfg.rs
use super::CFG; use super::{Adjacency}; use crate::common::{ function_attributes::FunctionAttribute, types::Type, tac_code::{Function, Statement}, error_reporter::{ErrorReporter, ReportKind}, }; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; pub fn check_cfg( ...
let mut insert_positions = vec![]; for (pos, adjacencies) in cfg.adjacency_list.iter().enumerate() { if adjacencies.contains(&Adjacency::End) { let bb = &cfg.basic_blocks[pos]; match function.statements[bb.end-1] { Statement::Return(_) => (), // OK ...
{ return; }
conditional_block
check_cfg.rs
use super::CFG; use super::{Adjacency}; use crate::common::{ function_attributes::FunctionAttribute, types::Type, tac_code::{Function, Statement}, error_reporter::{ErrorReporter, ReportKind}, }; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; pub fn check_cfg( ...
( function: &mut Function, cfg: &mut CFG, error_reporter: Rc<RefCell<dyn ErrorReporter>>) { if function.has_attribute(FunctionAttribute::External) { return; } let mut insert_positions = vec![]; for (pos, adjacencies) in cfg.adjacency_list.iter().enumerate() { ...
check_function
identifier_name
trait-bounds-on-structs-and-enums.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 ...
//~^ ERROR not implemented a: Foo<isize>, } enum Boo { //~^ ERROR not implemented Quux(Bar<usize>), } struct Badness<U> { //~^ ERROR not implemented b: Foo<U>, } enum MoreBadness<V> { //~^ ERROR not implemented EvenMoreBadness(Bar<V>), } trait PolyTrait<T> { fn whatever() {} } struct Struct; i...
//~^ ERROR the trait `Trait` is not implemented fn uhoh() {} } struct Baz {
random_line_split
trait-bounds-on-structs-and-enums.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 main() { }
whatever
identifier_name
borrowck-move-out-of-vec-tail.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 ...
} pub fn main() { let x = vec!( Foo { string: "foo".to_string() }, Foo { string: "bar".to_string() }, Foo { string: "baz".to_string() } ); let x: &[Foo] = x.as_slice(); match x { [_, tail..] => { match tail { [Foo { string: a }, //~ ERROR cann...
#[deriving(Clone)] struct Foo { string: String
random_line_split
borrowck-move-out-of-vec-tail.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 ...
{ string: String } pub fn main() { let x = vec!( Foo { string: "foo".to_string() }, Foo { string: "bar".to_string() }, Foo { string: "baz".to_string() } ); let x: &[Foo] = x.as_slice(); match x { [_, tail..] => { match tail { [Foo { strin...
Foo
identifier_name
borrowck-move-out-of-vec-tail.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 ...
println!("{:?}", z); } _ => { unreachable!(); } } }
{ let x = vec!( Foo { string: "foo".to_string() }, Foo { string: "bar".to_string() }, Foo { string: "baz".to_string() } ); let x: &[Foo] = x.as_slice(); match x { [_, tail..] => { match tail { [Foo { string: a }, //~ ERROR cannot move out of de...
identifier_body
borrowck-move-out-of-vec-tail.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 ...
_ => { unreachable!(); } } }
{ match tail { [Foo { string: a }, //~ ERROR cannot move out of dereference of `&`-pointer Foo { string: b }] => { //~^^ NOTE attempting to move value to here //~^^ NOTE and here } _ => { ...
conditional_block
mod.rs
pub type c_long = i32; pub type c_ulong = u32; pub type nlink_t = u32; s! { pub struct pthread_attr_t { __size: [u32; 9] } pub struct sigset_t { __val: [::c_ulong; 32], } pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg...
} else if #[cfg(any(target_arch = "arm"))] { mod arm; pub use self::arm::*; } else if #[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] { // For the time being asmjs and wasm32 are the same, and both // backed by identical emscripten runtimes mod asmjs; p...
random_line_split
class-method-cross-crate.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 nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); }
identifier_body
class-method-cross-crate.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 nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); }
main
identifier_name
class-method-cross-crate.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...
nyan.speak(); }
random_line_split
lib.rs
//! The runtime for writing applications for [Ice](https://github.com/losfair/IceCore), //! an efficient, reliable and asynchronous platform for building modern backend applications //! in WebAssembly. //! //! At a high level, `ia` (which stands for "Ice App") provides a few major components (based on //! the underlyin...
//! extern crate ia; //! extern crate futures_await as futures; //! //! use futures::prelude::*; //! use ia::net::{TcpListener, TcpConnection}; //! use ia::error::IoResult; //! //! #[async] //! fn handle_connection(incoming: TcpConnection) -> IoResult<()> { //! #[async] //! fn forward(from: TcpConnection, to:...
//! ```no_run //! #![feature(proc_macro, generators)] //! //! #[macro_use]
random_line_split
config.rs
use std::collections::HashMap; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::option::Option; use std::path::{Path, PathBuf}; use std::result::Result; use std::thread; use git2::Repository; use rustc_serialize::{Decodable, Decoder}; use toml; use ::Args; #[derive(RustcDecodable)] pub str...
{ basedir: Option<String>, repos: Option<HashMap<String, RepoConfig>>, } impl Config { pub fn from_args(args: &Args) -> Config { let path = Path::new(&args.flag_config); // opening file let mut file = match File::open(&path) { Ok(file) => file, Err(why) => ...
Config
identifier_name
config.rs
use std::collections::HashMap; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::option::Option; use std::path::{Path, PathBuf}; use std::result::Result; use std::thread; use git2::Repository; use rustc_serialize::{Decodable, Decoder}; use toml; use ::Args; #[derive(RustcDecodable)] pub str...
} }
Err(_) => Repository::clone(&url, &path),
random_line_split
ranges.rs
/* * This file is part of the uutils coreutils package. * * (c) Rolf Morel <rolfmorel@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use std; #[deriving(PartialEq,Eq,PartialOrd,Ord,Show)] pub struct
{ pub low: uint, pub high: uint, } impl std::str::FromStr for Range { fn from_str(s: &str) -> Option<Range> { use std::uint::MAX; let mut parts = s.splitn(1, '-'); match (parts.next(), parts.next()) { (Some(nm), None) => { from_str::<uint>(nm).and_then...
Range
identifier_name
ranges.rs
/* * This file is part of the uutils coreutils package. * * (c) Rolf Morel <rolfmorel@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use std; #[deriving(PartialEq,Eq,PartialOrd,Ord,Show)] pub struct Range { pub lo...
(Some(n), Some(m)) => { match (from_str::<uint>(n), from_str::<uint>(m)) { (Some(low), Some(high)) if low > 0 && low <= high => { Some(Range { low: low, high: high }) } _ => None } ...
{ from_str::<uint>(m).and_then(|high| if high >= 1 { Some(high) } else { None }) .map(|high| Range { low: 1, high: high }) }
conditional_block
ranges.rs
/* * This file is part of the uutils coreutils package. * * (c) Rolf Morel <rolfmorel@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use std; #[deriving(PartialEq,Eq,PartialOrd,Ord,Show)] pub struct Range { pub lo...
(Some(low), Some(high)) if low > 0 && low <= high => { Some(Range { low: low, high: high }) } _ => None } } _ => unreachable!() } } } impl Range { pub fn from_list(list: &str) ->...
{ use std::uint::MAX; let mut parts = s.splitn(1, '-'); match (parts.next(), parts.next()) { (Some(nm), None) => { from_str::<uint>(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) .map(|nm| Range { low: nm, high: nm }) ...
identifier_body
ranges.rs
/* * This file is part of the uutils coreutils package. * * (c) Rolf Morel <rolfmorel@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use std; #[deriving(PartialEq,Eq,PartialOrd,Ord,Show)] pub struct Range { pub lo...
let mut parts = s.splitn(1, '-'); match (parts.next(), parts.next()) { (Some(nm), None) => { from_str::<uint>(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) .map(|nm| Range { low: nm, high: nm }) } (Some(n)...
} impl std::str::FromStr for Range { fn from_str(s: &str) -> Option<Range> { use std::uint::MAX;
random_line_split
inits-1.rs
// General test of maybe_inits state computed by MIR dataflow. #![feature(core_intrinsics, rustc_attrs)] use std::intrinsics::rustc_peek; use std::mem::{drop, replace}; struct S(i32); #[rustc_mir(rustc_peek_maybe_init,stop_after_dataflow)] fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { let ret; // `re...
; // `z` may be initialized here. rustc_peek(&z); // `y` is definitely uninitialized here. rustc_peek(&y); //~ ERROR rustc_peek: bit not set // `x` is still (definitely) initialized (replace above is a reborrow). rustc_peek(&x); ::std::mem::drop(x); // `x` is *definitely* uninitia...
{ z = y; z }
conditional_block
inits-1.rs
// General test of maybe_inits state computed by MIR dataflow. #![feature(core_intrinsics, rustc_attrs)] use std::intrinsics::rustc_peek; use std::mem::{drop, replace}; struct S(i32); #[rustc_mir(rustc_peek_maybe_init,stop_after_dataflow)] fn
(test: bool, x: &mut S, y: S, mut z: S) -> S { let ret; // `ret` starts off uninitialized, so we get an error report here. rustc_peek(&ret); //~ ERROR rustc_peek: bit not set // All function formal parameters start off initialized. rustc_peek(&x); rustc_peek(&y); rustc_peek(&z); ret ...
foo
identifier_name
inits-1.rs
// General test of maybe_inits state computed by MIR dataflow. #![feature(core_intrinsics, rustc_attrs)] use std::intrinsics::rustc_peek; use std::mem::{drop, replace}; struct S(i32); #[rustc_mir(rustc_peek_maybe_init,stop_after_dataflow)] fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { let ret; // `re...
fn main() { foo(true, &mut S(13), S(14), S(15)); foo(false, &mut S(13), S(14), S(15)); }
random_line_split
borrowck-loan-rcvr-overloaded-op.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 a() { let mut p = Point {x: 3, y: 4}; // ok (we can loan out rcvr) p + 3; p.times(3); } fn b() { let mut p = Point {x: 3, y: 4}; // Here I create an outstanding loan and check that we get conflicts: let q = &mut p; //~ NOTE prior loan as mutable granted here p + 3; // ok for...
{ self.x * self.y * z }
identifier_body
borrowck-loan-rcvr-overloaded-op.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self, z: &int) -> int { self.x + self.y + (*z) } } pub impl Point { fn times(&self, z: int) -> int { self.x * self.y * z } } fn a() { let mut p = Point {x: 3, y: 4}; // ok (we can loan out rcvr) p + 3; p.times(3); } fn b() { let mut p = Point {x: 3, y: 4}; // H...
add
identifier_name
borrowck-loan-rcvr-overloaded-op.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 b() { let mut p = Point {x: 3, y: 4}; // Here I create an outstanding loan and check that we get conflicts: let q = &mut p; //~ NOTE prior loan as mutable granted here p + 3; // ok for pure fns p.times(3); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan q....
p.times(3); }
random_line_split
tokio_server.rs
/* This example creates a D-Bus server with the following functionality: It registers the "com.example.dbustest" name, creates a "/hello" object path, which has an "com.example.dbustest" interface. The interface has a "Hello" method (which takes no arguments and returns a string), and a "HelloHappened" sig...
//...and a method inside the interface. f.amethod("Hello", (), move |m| { // This is the callback that will be called when another peer on the bus calls our method. // the callback receives "MethodInfo" struct and can return either an error, or a list of ...
{ // Let's start by starting up a connection to the session bus and register a name. let c = Rc::new(Connection::get_private(BusType::Session).unwrap()); c.register_name("com.example.dbustest", NameFlag::ReplaceExisting as u32).unwrap(); // The choice of factory tells us what type of tree we want, ...
identifier_body
tokio_server.rs
/* This example creates a D-Bus server with the following functionality: It registers the "com.example.dbustest" name, creates a "/hello" object path, which has an "com.example.dbustest" interface. The interface has a "Hello" method (which takes no arguments and returns a string), and a "HelloHappened" sig...
() { // Let's start by starting up a connection to the session bus and register a name. let c = Rc::new(Connection::get_private(BusType::Session).unwrap()); c.register_name("com.example.dbustest", NameFlag::ReplaceExisting as u32).unwrap(); // The choice of factory tells us what type of tree we want, ...
main
identifier_name
tokio_server.rs
/* This example creates a D-Bus server with the following functionality: It registers the "com.example.dbustest" name, creates a "/hello" object path, which has an "com.example.dbustest" interface. The interface has a "Hello" method (which takes no arguments and returns a string), and a "HelloHappened" sig...
core.run(server).unwrap(); }
// Make the server run forever let server = server.for_each(|m| { println!("Unhandled message: {:?}", m); Ok(()) });
random_line_split
style.rs
// Copyright (C) 2017 Élisabeth HENRY. // // This file is part of Crowbook. // // Crowbook is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 2.1 of the License, or // (at your option) any...
let (_, width) = Term::stdout().size(); let wrapper = Wrapper::new(width as usize) .initial_indent(indent) .subsequent_indent(indent); wrapper.fill(msg) }
identifier_body
style.rs
// Copyright (C) 2017 Élisabeth HENRY. // // This file is part of Crowbook. // // Crowbook is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 2.1 of the License, or // (at your option) any...
// // You should have received a copy of the GNU Lesser General Public License // along with Crowbook. If not, see <http://www.gnu.org/licenses/>. //! Functions for setting styles on text, using console to make it look prettier. use console::{style, StyledObject, Term}; use textwrap::Wrapper; /// Displays a string ...
// Crowbook 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 Lesser General Public License for more details.
random_line_split
style.rs
// Copyright (C) 2017 Élisabeth HENRY. // // This file is part of Crowbook. // // Crowbook is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 2.1 of the License, or // (at your option) any...
msg: &str) -> StyledObject<&str> { style(msg).cyan() } pub fn value(msg: &str) -> StyledObject<&str> { style(msg).yellow() } pub fn fill(msg: &str, indent: &str) -> String { let (_, width) = Term::stdout().size(); let wrapper = Wrapper::new(width as usize) .initial_indent(indent) .subseq...
ipe(
identifier_name
tuple.rs
use std::rc::Rc; use std::any::Any; use crate::object::{Object, Exception, Interface, FnResult, downcast}; use crate::vm::{Env, op_eq}; pub struct Tuple { pub v: Vec<Object> } impl Tuple { pub fn new_object(v: Vec<Object>) -> Object { Object::Interface(Rc::new(Tuple {v})) } } impl Interface for...
} else { false } } fn eq(self: Rc<Self>, b: &Object, env: &mut Env) -> FnResult { if let Some(b) = downcast::<Tuple>(b) { let len = self.v.len(); if len == b.v.len() { for i in 0..len { let y = op_eq(env,&self.v[i],...
{ false }
conditional_block
tuple.rs
use std::rc::Rc; use std::any::Any; use crate::object::{Object, Exception, Interface, FnResult, downcast}; use crate::vm::{Env, op_eq}; pub struct Tuple { pub v: Vec<Object> } impl Tuple { pub fn new_object(v: Vec<Object>) -> Object { Object::Interface(Rc::new(Tuple {v})) } } impl Interface for ...
if self.v[i]!= b.v[i] {return false;} } true } else { false } } else { false } } fn eq(self: Rc<Self>, b: &Object, env: &mut Env) -> FnResult { if let Some(b) = downcast::<Tuple>(b) { ...
if let Some(b) = downcast::<Tuple>(b) { if self.v.len() == b.v.len() { for i in 0..self.v.len() {
random_line_split
tuple.rs
use std::rc::Rc; use std::any::Any; use crate::object::{Object, Exception, Interface, FnResult, downcast}; use crate::vm::{Env, op_eq}; pub struct
{ pub v: Vec<Object> } impl Tuple { pub fn new_object(v: Vec<Object>) -> Object { Object::Interface(Rc::new(Tuple {v})) } } impl Interface for Tuple { fn as_any(&self) -> &dyn Any {self} fn type_name(&self, _env: &mut Env) -> String { "Tuple".to_string() } fn to_string(sel...
Tuple
identifier_name
tuple.rs
use std::rc::Rc; use std::any::Any; use crate::object::{Object, Exception, Interface, FnResult, downcast}; use crate::vm::{Env, op_eq}; pub struct Tuple { pub v: Vec<Object> } impl Tuple { pub fn new_object(v: Vec<Object>) -> Object { Object::Interface(Rc::new(Tuple {v})) } } impl Interface for...
fn eq_plain(&self, b: &Object) -> bool { if let Some(b) = downcast::<Tuple>(b) { if self.v.len() == b.v.len() { for i in 0..self.v.len() { if self.v[i]!= b.v[i] {return false;} } true } else { false ...
{ match indices.len() { 1 => {}, n => return env.argc_error(n,1,1,"tuple indexing") } let i = match indices[0] { Object::Int(i) => if i<0 {0} else {i as usize}, ref i => return env.type_error1( "Type error in t[i]: i is not an integer.", ...
identifier_body
uuid.rs
//! MC Protocol UUID data type. use std::io::ErrorKind::InvalidInput; use std::io::prelude::*; use std::io; use std::str::FromStr; use packet::Protocol; use util::ReadExactly; use uuid::{ParseError, Uuid}; /// UUID read/write wrapper. impl Protocol for Uuid { type Clean = Uuid; fn proto_len(_: &Uuid) -> us...
(value: &Uuid, dst: &mut Write) -> io::Result<()> { <String as Protocol>::proto_encode(&value.to_hyphenated_string(), dst) } fn proto_decode(src: &mut Read) -> io::Result<Uuid> { // Unfortunately we can't implement `impl FromError<ParseError> for io::Error` let s = try!(<String as Proto...
proto_encode
identifier_name
uuid.rs
//! MC Protocol UUID data type. use std::io::ErrorKind::InvalidInput; use std::io::prelude::*; use std::io; use std::str::FromStr; use packet::Protocol; use util::ReadExactly; use uuid::{ParseError, Uuid}; /// UUID read/write wrapper. impl Protocol for Uuid { type Clean = Uuid; fn proto_len(_: &Uuid) -> us...
let s = try!(<String as Protocol>::proto_decode(src)); Uuid::from_str(&s).map_err(|err| match err { ParseError::InvalidLength(length) => io::Error::new(InvalidInput, &format!("Invalid length: {}", length)[..]), ParseError::InvalidCharacter(_, _) => io::Error::new(InvalidInput, "i...
fn proto_decode(src: &mut Read) -> io::Result<Uuid> { // Unfortunately we can't implement `impl FromError<ParseError> for io::Error`
random_line_split
uuid.rs
//! MC Protocol UUID data type. use std::io::ErrorKind::InvalidInput; use std::io::prelude::*; use std::io; use std::str::FromStr; use packet::Protocol; use util::ReadExactly; use uuid::{ParseError, Uuid}; /// UUID read/write wrapper. impl Protocol for Uuid { type Clean = Uuid; fn proto_len(_: &Uuid) -> us...
} pub struct UuidString; impl Protocol for UuidString { type Clean = Uuid; fn proto_len(value: &Uuid) -> usize { <String as Protocol>::proto_len(&value.to_hyphenated_string()) } fn proto_encode(value: &Uuid, dst: &mut Write) -> io::Result<()> { <String as Protocol>::proto_encode(&va...
{ let v = try!(src.read_exactly(16)); Uuid::from_bytes(&v).ok_or(io::Error::new(io::ErrorKind::InvalidInput, &format!("Invalid UUID value: {:?} can't be used to create UUID", v)[..])) }
identifier_body
lib.rs
//! Internal library for data-encoding-macro //! //! Do **not** use this library. Use [data-encoding-macro] instead. //! //! This library is for internal use by data-encoding-macro because procedural //! macros require a separate crate. //! //! [data-encoding-macro]: https://crates.io/crates/data-encoding-macro #![war...
{ let mut hash_map = parse_map(input.into_iter()); let encoding = get_encoding(&mut hash_map); check_present(&hash_map, "input"); let input = get_string(&mut hash_map, "input"); check_empty(hash_map); format!("{:?}", encoding.decode(input.as_bytes()).unwrap()).parse().unwrap() }
identifier_body
lib.rs
//! Internal library for data-encoding-macro //! //! Do **not** use this library. Use [data-encoding-macro] instead. //! //! This library is for internal use by data-encoding-macro because procedural //! macros require a separate crate. //! //! [data-encoding-macro]: https://crates.io/crates/data-encoding-macro #![war...
(input: TokenStream) -> TokenStream { let mut hash_map = parse_map(input.into_iter()); let encoding = get_encoding(&mut hash_map); check_empty(hash_map); format!("{:?}", encoding.internal_implementation()).parse().unwrap() } #[proc_macro] #[doc(hidden)] pub fn internal_decode_array(input: TokenStream) ...
internal_new_encoding
identifier_name
lib.rs
//! Internal library for data-encoding-macro //! //! Do **not** use this library. Use [data-encoding-macro] instead. //! //! This library is for internal use by data-encoding-macro because procedural //! macros require a separate crate. //! //! [data-encoding-macro]: https://crates.io/crates/data-encoding-macro #![war...
pub fn internal_new_encoding(input: TokenStream) -> TokenStream { let mut hash_map = parse_map(input.into_iter()); let encoding = get_encoding(&mut hash_map); check_empty(hash_map); format!("{:?}", encoding.internal_implementation()).parse().unwrap() } #[proc_macro] #[doc(hidden)] pub fn internal_decod...
} #[proc_macro] #[doc(hidden)]
random_line_split
simple.rs
#![feature(plugin)] #![plugin(must_assert)] extern crate must; use must::COLOR_ENV; use std::env; #[test] fn str_contains()
#[test] fn simple() { assume!("" == ""); assume!("" == "" || "" == ""); assume!("" == "" && "" == ""); } #[test] #[should_panic(expected = "Diff: foo -bar baz +bar quux")] fn str_fail_diff() { env::set_var(COLOR_ENV, "none"); assume!("foo bar baz quux" == "foo baz bar quux...
{ assume!("Banana".contains("nana")); }
identifier_body
simple.rs
#![feature(plugin)] #![plugin(must_assert)] extern crate must; use must::COLOR_ENV; use std::env; #[test] fn
() { assume!("Banana".contains("nana")); } #[test] fn simple() { assume!("" == ""); assume!("" == "" || "" == ""); assume!("" == "" && "" == ""); } #[test] #[should_panic(expected = "Diff: foo -bar baz +bar quux")] fn str_fail_diff() { env::set_var(COLOR_ENV, "none"); assume!("foo bar ...
str_contains
identifier_name
simple.rs
#![feature(plugin)] #![plugin(must_assert)] extern crate must; use must::COLOR_ENV; use std::env; #[test] fn str_contains() { assume!("Banana".contains("nana")); } #[test] fn simple() { assume!("" == ""); assume!("" == "" || "" == ""); assume!("" == "" && "" == ""); } #[test] #[should_panic(...
| 1 | "\na" | "b\n" |"#)] fn vec_failure() { env::set_var(COLOR_ENV, "none"); assume!(vec!["ABCDEFGHIZKLMNOPQRSTUVWXYZ", "\na"] == vec!["ABCDEFGHIZKLMNOPQRSTUVWXYZ", "b\n"]); }
#[test] #[should_panic(expected = r#"Diff: | Index | Got | Expected | |-------|-------|----------|
random_line_split
htmltrackelement.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::HTMLTrackElementBinding; use dom::bindings::codegen::InheritTypes::HTMLTrack...
document: &Document) -> Root<HTMLTrackElement> { let element = HTMLTrackElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLTrackElementBinding::Wrap) } }
prefix: Option<DOMString>,
random_line_split
htmltrackelement.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::HTMLTrackElementBinding; use dom::bindings::codegen::InheritTypes::HTMLTrack...
(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLTrackElement { HTMLTrackElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLTrackElement, localName, prefix, document) } } #[allow(unrooted_must_root)] pub fn new(localName: DOMStr...
new_inherited
identifier_name
boot-delay.rs
use std::fs::File; use std::io::Read; use std::mem::transmute; use std::thread::sleep; use std::env; use std::time::Duration; fn
() { let delay = match env::args().nth(1).and_then(|s| s.parse::<f32>().ok()) { Some(d) => 60.0 * d, None => { println!("Usage: boot-delay <minutes>"); return; } }; let mut buf = [0u8; 1024]; let uptime = File::open("/proc/uptime") .and_then(|ref m...
main
identifier_name
boot-delay.rs
use std::fs::File; use std::io::Read; use std::mem::transmute; use std::thread::sleep; use std::env; use std::time::Duration; fn main() { let delay = match env::args().nth(1).and_then(|s| s.parse::<f32>().ok()) { Some(d) => 60.0 * d, None => { println!("Usage: boot-delay <minutes>"); ...
}) .unwrap(); if delay > uptime { sleep(Duration::from_secs((delay - uptime) as u64)); } }
buf.iter() .position(|&c| c == 0x20) .and_then(|p| if p < sz { unsafe { transmute::<_, &str>(&buf[..p]) }.parse::<f32>().ok() } else { None }) .unwrap()
random_line_split
boot-delay.rs
use std::fs::File; use std::io::Read; use std::mem::transmute; use std::thread::sleep; use std::env; use std::time::Duration; fn main() { let delay = match env::args().nth(1).and_then(|s| s.parse::<f32>().ok()) { Some(d) => 60.0 * d, None => { println!("Usage: boot-delay <minutes>"); ...
) .unwrap() }) .unwrap(); if delay > uptime { sleep(Duration::from_secs((delay - uptime) as u64)); } }
{ None }
conditional_block
boot-delay.rs
use std::fs::File; use std::io::Read; use std::mem::transmute; use std::thread::sleep; use std::env; use std::time::Duration; fn main()
if delay > uptime { sleep(Duration::from_secs((delay - uptime) as u64)); } }
{ let delay = match env::args().nth(1).and_then(|s| s.parse::<f32>().ok()) { Some(d) => 60.0 * d, None => { println!("Usage: boot-delay <minutes>"); return; } }; let mut buf = [0u8; 1024]; let uptime = File::open("/proc/uptime") .and_then(|ref mut...
identifier_body
lifetime-elision-return-type-requires-explicit-lifetime.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 ...
(_x: &Foo) -> &isize { //~ ERROR missing lifetime specifier //~^ HELP the signature does not say which one of `_x`'s 2 elided lifetimes it is borrowed from panic!() } fn i(_x: isize) -> &isize { //~ ERROR missing lifetime specifier //~^ HELP this function's return type contains a borrowed value panic!() } fn ...
h
identifier_name
lifetime-elision-return-type-requires-explicit-lifetime.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 i(_x: isize) -> &isize { //~ ERROR missing lifetime specifier //~^ HELP this function's return type contains a borrowed value panic!() } fn main() {}
{ //~ ERROR missing lifetime specifier //~^ HELP the signature does not say which one of `_x`'s 2 elided lifetimes it is borrowed from panic!() }
identifier_body
lifetime-elision-return-type-requires-explicit-lifetime.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 ...
//~^ HELP this function's return type contains a borrowed value panic!() } fn main() {}
fn i(_x: isize) -> &isize { //~ ERROR missing lifetime specifier
random_line_split
heap.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} #[cfg(not(test))] #[lang = "exchange_free"] #[inline] unsafe fn exchange_free(ptr: *mut u8, old_size: usize, align: usize) { deallocate(ptr, old_size, align); } #[cfg(test)] mod tests { extern crate test; use self::test::Bencher; use boxed::Box; use heap; #[test] fn basic_reallocate_in...
{ let ptr = allocate(size, align); if ptr.is_null() { ::oom() } ptr }
conditional_block
heap.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} } #[bench] fn alloc_owned_small(b: &mut Bencher) { b.iter(|| { let _: Box<_> = box 10; }) } }
let ret = heap::reallocate_inplace(ptr, size, size, 8); heap::deallocate(ptr, size, 8); assert_eq!(ret, heap::usable_size(size, 8));
random_line_split
heap.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
/// Resize the allocation referenced by `ptr` to `size` bytes. /// /// On failure, return a null pointer and leave the original allocation intact. /// /// If the allocation was relocated, the memory at the passed-in pointer is /// undefined after the call. /// /// Behavior is undefined if the requested size is 0 or t...
{ check_size_and_alignment(size, align); __rust_allocate(size, align) }
identifier_body
heap.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { unsafe { let size = 4000; let ptr = heap::allocate(size, 8); if ptr.is_null() { ::oom() } let ret = heap::reallocate_inplace(ptr, size, size, 8); heap::deallocate(ptr, size, 8); assert_eq!(ret, heap::usable_...
basic_reallocate_inplace_noop
identifier_name
generic-struct.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<TKey, TValue> { key: TKey, value: TValue } fn main() { let int_int = AGenericStruct { key: 0, value: 1 }; let int_float = AGenericStruct { key: 2, value: 3.5 }; let float_int = AGenericStruct { key: 4.5, value: 5 }; let float_int_float = AGenericStruct { key: 6.5, value: AGenericStruct { key:...
AGenericStruct
identifier_name
generic-struct.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn zzz() {()}
{ let int_int = AGenericStruct { key: 0, value: 1 }; let int_float = AGenericStruct { key: 2, value: 3.5 }; let float_int = AGenericStruct { key: 4.5, value: 5 }; let float_int_float = AGenericStruct { key: 6.5, value: AGenericStruct { key: 7, value: 8.5 } }; zzz(); }
identifier_body
generic-struct.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// compile-flags:-Z extra-debug-info // debugger:rbreak zzz // debugger:run // debugger:finish // debugger:print int_int // check:$1 = {key = 0, value = 1} // debugger:print int_float // check:$2 = {key = 2, value = 3.5} // debugger:print float_int // check:$3 = {key = 4.5, value = 5} // debugger:print float_int_floa...
// except according to those terms.
random_line_split
any.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...
} #[cfg(test)] mod tests { use prelude::*; use super::*; use owned::Box; use realstd::str::StrAllocating; #[deriving(Eq, Show)] struct Test; static TEST: &'static str = "Test"; #[test] fn any_referenced() { let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any); ...
{ if self.is::<T>() { unsafe { // Get the raw representation of the trait object let to: TraitObject = transmute_copy(&self); // Prevent destructor on self being run intrinsics::forget(self); // Extract the data pointe...
identifier_body
any.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...
TypeId::of::<T>() } } /////////////////////////////////////////////////////////////////////////////// // Extension methods for Any trait objects. // Implemented as three extension traits so that the methods can be generic. /////////////////////////////////////////////////////////////////////////////// ///...
impl<T: 'static> Any for T { /// Get the `TypeId` of `self` fn get_type_id(&self) -> TypeId {
random_line_split
any.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...
{ } /////////////////////////////////////////////////////////////////////////////// // Any trait /////////////////////////////////////////////////////////////////////////////// /// The `Any` trait is implemented by all types, and can be used as a trait object /// for dynamic typing pub trait Any { /// Get the `T...
Void
identifier_name