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
lib.rs
// Copyright 2017-2019 Moritz Wanzenböck. // // Licensed under the MIT License <LICENSE or http://opensource.org/licenses/MIT>. // This file may not be copied, modified, or distributed except according to those terms. //! A library for exchanging paths //! //! This library provides a simple utility to swap files and/or...
/// Exchange the content of the object pointed to by the two paths. /// /// This can be used to swap the content of two files, but it also works with directories. /// **This operation may not be atomic**. If available, it will try to use the platform specific, /// atomic operations. If they are not implemented, this w...
platform::xch(path1, path2) }
identifier_body
lib.rs
// Copyright 2017-2019 Moritz Wanzenböck. //
// Licensed under the MIT License <LICENSE or http://opensource.org/licenses/MIT>. // This file may not be copied, modified, or distributed except according to those terms. //! A library for exchanging paths //! //! This library provides a simple utility to swap files and/or directory content of two paths. //! When pos...
random_line_split
lib.rs
// Copyright 2017-2019 Moritz Wanzenböck. // // Licensed under the MIT License <LICENSE or http://opensource.org/licenses/MIT>. // This file may not be copied, modified, or distributed except according to those terms. //! A library for exchanging paths //! //! This library provides a simple utility to swap files and/or...
A: AsRef<path::Path>, B: AsRef<path::Path>>(path1: A, path2: B) -> error::Result<()> { let res = platform::xch(&path1, &path2); if let Err(error::Error::NotImplemented) = res { non_atomic::xch(&path1, &path2) } else { res } }
ch_non_atomic<
identifier_name
lib.rs
// Copyright 2017-2019 Moritz Wanzenböck. // // Licensed under the MIT License <LICENSE or http://opensource.org/licenses/MIT>. // This file may not be copied, modified, or distributed except according to those terms. //! A library for exchanging paths //! //! This library provides a simple utility to swap files and/or...
}
res }
conditional_block
debugger.rs
use crate::common::Config; use crate::runtest::ProcRes; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub(super) struct
{ pub commands: Vec<String>, pub check_lines: Vec<String>, pub breakpoint_lines: Vec<usize>, } impl DebuggerCommands { pub(super) fn parse_from( file: &Path, config: &Config, debugger_prefixes: &[&str], ) -> Result<Self, String> { let directives = debugger_prefixes ...
DebuggerCommands
identifier_name
debugger.rs
use crate::common::Config; use crate::runtest::ProcRes; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub(super) struct DebuggerCommands { pub commands: Vec<String>, pub check_lines: Vec<String>, pub breakpoint_lines: Vec<usize>, } impl DebuggerCommands { pub(super) fn pa...
}
{ true }
conditional_block
debugger.rs
use crate::common::Config; use crate::runtest::ProcRes; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub(super) struct DebuggerCommands { pub commands: Vec<String>, pub check_lines: Vec<String>, pub breakpoint_lines: Vec<usize>, } impl DebuggerCommands { pub(super) fn pa...
(line, 0) }; for current_fragment in &check_fragments[first_fragment..] { match rest.find(current_fragment) { Some(pos) => { rest = &rest[pos + current_fragment.len()..]; } None => return false, } } if!can_end_anywhere &&!rest...
{ // Allow check lines to leave parts unspecified (e.g., uninitialized // bits in the wrong case of an enum) with the notation "[...]". let line = line.trim(); let check_line = check_line.trim(); let can_start_anywhere = check_line.starts_with("[...]"); let can_end_anywhere = check_line.ends_wi...
identifier_body
debugger.rs
use crate::common::Config; use crate::runtest::ProcRes; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub(super) struct DebuggerCommands { pub commands: Vec<String>, pub check_lines: Vec<String>, pub breakpoint_lines: Vec<usize>, } impl DebuggerCommands { pub(super) fn pa...
let can_start_anywhere = check_line.starts_with("[...]"); let can_end_anywhere = check_line.ends_with("[...]"); let check_fragments: Vec<&str> = check_line.split("[...]").filter(|frag|!frag.is_empty()).collect(); if check_fragments.is_empty() { return true; } let (mut rest, fir...
// Allow check lines to leave parts unspecified (e.g., uninitialized // bits in the wrong case of an enum) with the notation "[...]". let line = line.trim(); let check_line = check_line.trim();
random_line_split
tree.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/. */ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency //! between layout and style. use at...
fn parent_element(&self) -> Option<Self>; /// The parent of a given pseudo-element, after matching a pseudo-element /// selector. /// /// This is guaranteed to be called in a pseudo-element. fn pseudo_element_originating_element(&self) -> Option<Self> { self.parent_element() } ...
pub trait Element: Sized { type Impl: SelectorImpl;
random_line_split
tree.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/. */ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency //! between layout and style. use at...
/// Skips non-element nodes fn first_child_element(&self) -> Option<Self>; /// Skips non-element nodes fn last_child_element(&self) -> Option<Self>; /// Skips non-element nodes fn prev_sibling_element(&self) -> Option<Self>; /// Skips non-element nodes fn next_sibling_element(&self)...
{ self.parent_element() }
identifier_body
tree.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/. */ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency //! between layout and style. use at...
(&self) -> Option<Self> { self.parent_element() } /// Skips non-element nodes fn first_child_element(&self) -> Option<Self>; /// Skips non-element nodes fn last_child_element(&self) -> Option<Self>; /// Skips non-element nodes fn prev_sibling_element(&self) -> Option<Self>; /...
pseudo_element_originating_element
identifier_name
websocket.rs
use script_thread::Runnable; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::Cell; use std::ptr; use std::sync::Arc; use std::thread; use websocket::client::request::Url; use websocket::header::{Headers, WebSocketProtocol}; use websocket::ws::util::url::parse_url; #[derive(JSTraceable, PartialEq, C...
// Step 4. let protocols = match protocols { Some(StringOrStringSequence::String(string)) => vec![String::from(string)], Some(StringOrStringSequence::StringSequence(sequence)) => { sequence.into_iter().map(String::from).collect() }, _ => Ve...
if BLOCKED_PORTS_LIST.iter().any(|&p| p == port) { return Err(Error::Security); }
random_line_split
websocket.rs
script_thread::Runnable; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::Cell; use std::ptr; use std::sync::Arc; use std::thread; use websocket::client::request::Url; use websocket::header::{Headers, WebSocketProtocol}; use websocket::ws::util::url::parse_url; #[derive(JSTraceable, PartialEq, Copy,...
{ Connecting = 0, Open = 1, Closing = 2, Closed = 3, } // list of bad ports according to // https://fetch.spec.whatwg.org/#port-blocking const BLOCKED_PORTS_LIST: &'static [u16] = &[ 1, // tcpmux 7, // echo 9, // discard 11, // systat 13, // daytime 15, // netsta...
WebSocketRequestState
identifier_name
websocket.rs
script_thread::Runnable; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::Cell; use std::ptr; use std::sync::Arc; use std::thread; use websocket::client::request::Url; use websocket::header::{Headers, WebSocketProtocol}; use websocket::ws::util::url::parse_url; #[derive(JSTraceable, PartialEq, Copy,...
// https://html.spec.whatwg.org/multipage/#dom-websocket-send fn Send_(&self, blob: &Blob) -> ErrorResult { /* As per https://html.spec.whatwg.org/multipage/#websocket the buffered amount needs to be clamped to u32, even though Blob.Size() is u64 If the buffer limit is reached i...
{ let data_byte_len = data.0.as_bytes().len() as u64; let send_data = try!(self.send_impl(data_byte_len)); if send_data { let mut other_sender = self.sender.borrow_mut(); let my_sender = other_sender.as_mut().unwrap(); let _ = my_sender.send(WebSocketDomActi...
identifier_body
else-if.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 ...
() { if 1i == 2 { assert!((false)); } else if 2i == 3 { assert!((false)); } else if 3i == 4 { assert!((false)); } else { assert!((true)); } if 1i == 2 { assert!((false)); } else if 2i == 2 { assert!((true)); } if 1i == 2 { assert!((false)); } else if 2i == 2 { if ...
main
identifier_name
else-if.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 ...
{ if 1i == 2 { assert!((false)); } else if 2i == 3 { assert!((false)); } else if 3i == 4 { assert!((false)); } else { assert!((true)); } if 1i == 2 { assert!((false)); } else if 2i == 2 { assert!((true)); } if 1i == 2 { assert!((false)); } else if 2i == 2 { if 1i ...
identifier_body
else-if.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 ...
else { assert!((true)); } if 1i == 2 { assert!((false)); } else if 2i == 2 { assert!((true)); } if 1i == 2 { assert!((false)); } else if 2i == 2 { if 1i == 1 { assert!((true)); } else { if 2i == 1 { assert!((false)); } else { assert!((false)); } } } if 1i == 2 { ...
{ assert!((false)); }
conditional_block
else-if.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 ...
} else { if 1i == 2 { assert!((false)); } else { assert!((true)); } } }
assert!((false));
random_line_split
time.rs
//! A module for time use system::syscall::{sys_clock_gettime, CLOCK_REALTIME, CLOCK_MONOTONIC, TimeSpec}; // 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, Ve...
else { secs = secs.checked_sub(1) .expect("overflow when subtracting durations"); self.nanos + NANOS_PER_SEC - rhs.nanos }; debug_assert!(nanos < NANOS_PER_SEC); Duration { secs: secs, nanos: nanos } } } impl Mul<u32> for Duration { type Ou...
{ self.nanos - rhs.nanos }
conditional_block
time.rs
//! A module for time use system::syscall::{sys_clock_gettime, CLOCK_REALTIME, CLOCK_MONOTONIC, TimeSpec}; // 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, Ve...
} impl Mul<u32> for Duration { type Output = Duration; fn mul(self, rhs: u32) -> Duration { // Multiply nanoseconds as u64, because it cannot overflow that way. let total_nanos = self.nanos as u64 * rhs as u64; let extra_secs = total_nanos / (NANOS_PER_SEC as u64); let nanos =...
{ let mut secs = self.secs.checked_sub(rhs.secs) .expect("overflow when subtracting durations"); let nanos = if self.nanos >= rhs.nanos { self.nanos - rhs.nanos } else { secs = secs.checked_sub(1) .expect("overflow when su...
identifier_body
time.rs
//! A module for time use system::syscall::{sys_clock_gettime, CLOCK_REALTIME, CLOCK_MONOTONIC, TimeSpec}; // 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, Ve...
/// produced synthetically. pub fn elapsed(&self) -> Duration { Instant::now().0 - self.0 } } #[derive(Copy, Clone)] pub struct SystemTime(Duration); impl SystemTime { /// Returns the system time corresponding to "now". pub fn now() -> SystemTime { let mut tp = TimeSpec { ...
/// instant, which is something that can happen if an `Instant` is
random_line_split
time.rs
//! A module for time use system::syscall::{sys_clock_gettime, CLOCK_REALTIME, CLOCK_MONOTONIC, TimeSpec}; // 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, Ve...
(self, rhs: Duration) -> Duration { let mut secs = self.secs.checked_sub(rhs.secs) .expect("overflow when subtracting durations"); let nanos = if self.nanos >= rhs.nanos { self.nanos - rhs.nanos } else { secs = secs.checked_sub(1) ...
sub
identifier_name
list-user-pools.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitoidentityprovider::{Client, Error, Region, PKG_VERSION}; use aws_smithy_types_convert::date_time::DateTimeExt; use structopt::StructO...
let shared_config = aws_config::from_env().region(region_provider).load().await; let client = Client::new(&shared_config); show_pools(&client).await }
{ println!("Cognito client version: {}", PKG_VERSION); println!( "Region: {}", region_provider.region().await.unwrap().as_ref() ); println!(); }
conditional_block
list-user-pools.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitoidentityprovider::{Client, Error, Region, PKG_VERSION}; use aws_smithy_types_convert::date_time::DateTimeExt; use structopt::StructO...
(client: &Client) -> Result<(), Error> { let response = client.list_user_pools().max_results(10).send().await?; if let Some(pools) = response.user_pools() { println!("User pools:"); for pool in pools { println!(" ID: {}", pool.id().unwrap_or_default()); prin...
show_pools
identifier_name
list-user-pools.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitoidentityprovider::{Client, Error, Region, PKG_VERSION}; use aws_smithy_types_convert::date_time::DateTimeExt; use structopt::StructO...
pool.creation_date().unwrap().to_chrono_utc() ); println!(); } } println!("Next token: {}", response.next_token().unwrap_or_default()); Ok(()) } // snippet-end:[cognitoidentityprovider.rust.list-user-pools] /// Lists your Amazon Cognito user pools in the Reg...
" Last modified: {}", pool.last_modified_date().unwrap().to_chrono_utc() ); println!( " Creation date: {:?}",
random_line_split
diagnostics.rs
// Copyright (c) 2014 Richard Diamond & contributors. // // This file is part of Rust Rocket. // // Rust Rocket 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 3 of the License, or // (...
_ => NestedEntry(None, None), } } } #[deriving(Clone)] pub struct Emittion { addr: Address, // Note to Rocket devs: if SpanOrigin, the Span offsets must be normalized // as if the offending file is the only member of the CodeMap. This is so we // don't have to share or otherwi...
{ let filemap = cm.lookup_byte_offset(sp.lo).fm; let addr = address() .clone() .with_source(Path::new(filemap.name)); unimplemented!(); let file_start = filemap.start_pos; let new_sp = mk_sp(sp.lo - f...
conditional_block
diagnostics.rs
// Copyright (c) 2014 Richard Diamond & contributors. // // This file is part of Rust Rocket. // // Rust Rocket 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 3 of the License, or // (...
.clone() .with_source(Path::new(filemap.name)); unimplemented!(); let file_start = filemap.start_pos; let new_sp = mk_sp(sp.lo - file_start, sp.hi - file_start); let nested = sp.expn_...
let filemap = cm.lookup_byte_offset(sp.lo).fm; let addr = address()
random_line_split
diagnostics.rs
// Copyright (c) 2014 Richard Diamond & contributors. // // This file is part of Rust Rocket. // // Rust Rocket 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 3 of the License, or // (...
() -> SessionIf { SessionIf { errors: Cell::new(0), queue: Arc::new(mpsc_queue::Queue::new()), } } // An expected failure. pub fn fail(&self) ->! { fail!(FatalError) } fn bump_error_count(&self) { self.errors.set(self.errors.get() + 1); } ...
new
identifier_name
mod.rs
pub mod op; use std::any::Any; use std::fmt; use std::fmt::{Display, Formatter}; use spv::Op; use spv::ExtInst; use spv::ExtInstSet; use spv::raw::MemoryBlock; use spv::raw::MemoryBlockResult; use spv::raw::ReadError; use self::op::*; #[derive(Clone, Debug, PartialEq)] pub enum Inst { Sin(Sin), Cos(Cos), } i...
Sin(ref op) => op.fmt(f), Cos(ref op) => op.fmt(f), } } } pub struct InstSet; impl ExtInstSet for InstSet { fn get_name(&self) -> &'static str { "GLSL.std.450" } fn read_instruction<'a, 'b>(&'b self, instruction: u32, ...
match *self {
random_line_split
mod.rs
pub mod op; use std::any::Any; use std::fmt; use std::fmt::{Display, Formatter}; use spv::Op; use spv::ExtInst; use spv::ExtInstSet; use spv::raw::MemoryBlock; use spv::raw::MemoryBlockResult; use spv::raw::ReadError; use self::op::*; #[derive(Clone, Debug, PartialEq)] pub enum Inst { Sin(Sin), Cos(Cos), } ...
} fn read_sin<'a>(block: MemoryBlock<'a>) -> MemoryBlockResult<'a, Inst> { let (block, x) = try!(block.read_op_id()); Ok((block, Inst::Sin(Sin { x: x }))) } fn read_cos(block: MemoryBlock) -> MemoryBlockResult<Inst> { let (block, x) = try!(block.read_op_id()); Ok((block, Inst::Cos(Cos { x: x }))) }
{ Box::new(InstSet) }
identifier_body
mod.rs
pub mod op; use std::any::Any; use std::fmt; use std::fmt::{Display, Formatter}; use spv::Op; use spv::ExtInst; use spv::ExtInstSet; use spv::raw::MemoryBlock; use spv::raw::MemoryBlockResult; use spv::raw::ReadError; use self::op::*; #[derive(Clone, Debug, PartialEq)] pub enum Inst { Sin(Sin), Cos(Cos), } ...
(&self) -> &'static str { "GLSL.std.450" } fn read_instruction<'a, 'b>(&'b self, instruction: u32, block: MemoryBlock<'a>) -> MemoryBlockResult<'a, Box<ExtInst>> { let (block, inst) = try!(match instr...
get_name
identifier_name
clock.rs
use std::time::{Duration, Instant}; use tokio_core::reactor::Handle; use error::{Error, Result}; use component::Component; use tokio_timer::Timer; use futures::Stream; use time; /// A `Clock` that automatically determines the refresh rate. /// /// This uses the default [strftime](http://man7.org/linux/man-pages/man3/s...
else { Ok(Duration::from_secs(60)) } } impl Component for Clock { type Error = Error; type Stream = Box<Stream<Item = String, Error = Error>>; fn stream(self, _: Handle) -> Self::Stream { let timer = Timer::default(); let format = self.format.clone(); timer.interval_a...
{ Ok(Duration::from_secs(1)) }
conditional_block
clock.rs
use std::time::{Duration, Instant}; use tokio_core::reactor::Handle; use error::{Error, Result}; use component::Component; use tokio_timer::Timer; use futures::Stream; use time; /// A `Clock` that automatically determines the refresh rate. /// /// This uses the default [strftime](http://man7.org/linux/man-pages/man3/s...
}
random_line_split
clock.rs
use std::time::{Duration, Instant}; use tokio_core::reactor::Handle; use error::{Error, Result}; use component::Component; use tokio_timer::Timer; use futures::Stream; use time; /// A `Clock` that automatically determines the refresh rate. /// /// This uses the default [strftime](http://man7.org/linux/man-pages/man3/s...
() -> Clock { Clock { format: "%T".into(), refresh_rate: Duration::from_secs(1), } } } impl Clock { /// Create a new `Clock` specifying the time format as argument. /// /// # Errors /// /// Returns `Err` if the specified `strftime` format could not be par...
default
identifier_name
pkt_deserializer.rs
use std::io::Read; use byteorder::{BigEndian, ReadBytesExt}; use serde::de; use serde::de::Visitor; use error::{Error, ResultE}; use super::osc_reader::OscReader; use super::msg_visitor::MsgVisitor; use super::bundle_visitor::BundleVisitor; /// Deserializes an entire OSC packet or bundle element (they are syntactical...
(reader: &'a mut R) -> Self { Self{ reader } } } impl<'de, 'a, R> de::Deserializer<'de> for &'a mut PktDeserializer<'a, R> where R: Read + 'a { type Error = Error; fn deserialize_any<V>(self, visitor: V) -> ResultE<V::Value> where V: Visitor<'de> { // First, extract the leng...
new
identifier_name
pkt_deserializer.rs
use std::io::Read; use byteorder::{BigEndian, ReadBytesExt}; use serde::de; use serde::de::Visitor; use error::{Error, ResultE}; use super::osc_reader::OscReader; use super::msg_visitor::MsgVisitor; use super::bundle_visitor::BundleVisitor; /// Deserializes an entire OSC packet or bundle element (they are syntactical...
{ pub fn new(reader: &'a mut R) -> Self { Self{ reader } } } impl<'de, 'a, R> de::Deserializer<'de> for &'a mut PktDeserializer<'a, R> where R: Read + 'a { type Error = Error; fn deserialize_any<V>(self, visitor: V) -> ResultE<V::Value> where V: Visitor<'de> { // First, ...
impl<'a, R> PktDeserializer<'a, R> where R: Read + 'a
random_line_split
pkt_deserializer.rs
use std::io::Read; use byteorder::{BigEndian, ReadBytesExt}; use serde::de; use serde::de::Visitor; use error::{Error, ResultE}; use super::osc_reader::OscReader; use super::msg_visitor::MsgVisitor; use super::bundle_visitor::BundleVisitor; /// Deserializes an entire OSC packet or bundle element (they are syntactical...
// This struct only deserializes sequences; ignore all type hints. // More info: https://github.com/serde-rs/serde/blob/b7d6c5d9f7b3085a4d40a446eeb95976d2337e07/serde/src/macros.rs#L106 forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq...
{ // First, extract the length of the packet. let length = self.reader.read_i32::<BigEndian>()?; let mut reader = self.reader.take(length as u64); // See if packet is a bundle or a message. let address = reader.parse_str()?; let result = match address.as_str() { ...
identifier_body
util.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use super::{Error, Result}; use tikv_util::codec; use tikv_util::codec::number::{self, NumberEncoder}; /// Check if key in range [`start_key`, `end_key`). #[allow(dead_code)] pub fn check_key_in_range( key: &[u8], region_id: u64, start_key...
(value_with_ttl: &[u8]) -> &[u8] { let len = value_with_ttl.len(); &value_with_ttl[..len - number::U64_SIZE] } pub fn truncate_expire_ts(value_with_ttl: &mut Vec<u8>) -> Result<()> { let len = value_with_ttl.len(); if len < number::U64_SIZE { return Err(Error::Codec(codec::Error::ValueLength));...
strip_expire_ts
identifier_name
util.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use super::{Error, Result}; use tikv_util::codec; use tikv_util::codec::number::{self, NumberEncoder}; /// Check if key in range [`start_key`, `end_key`). #[allow(dead_code)] pub fn check_key_in_range( key: &[u8], region_id: u64, start_key...
pub fn get_expire_ts(value_with_ttl: &[u8]) -> Result<u64> { let len = value_with_ttl.len(); if len < number::U64_SIZE { return Err(Error::Codec(codec::Error::ValueLength)); } let mut ts = &value_with_ttl[len - number::U64_SIZE..]; Ok(number::decode_u64(&mut ts)?) } pub fn strip_expire_ts(v...
pub fn append_expire_ts(value: &mut Vec<u8>, expire_ts: u64) { value.encode_u64(expire_ts).unwrap(); }
random_line_split
util.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use super::{Error, Result}; use tikv_util::codec; use tikv_util::codec::number::{self, NumberEncoder}; /// Check if key in range [`start_key`, `end_key`). #[allow(dead_code)] pub fn check_key_in_range( key: &[u8], region_id: u64, start_key...
else { Err(Error::NotInRange { key: key.to_vec(), region_id, start: start_key.to_vec(), end: end_key.to_vec(), }) } } pub fn append_expire_ts(value: &mut Vec<u8>, expire_ts: u64) { value.encode_u64(expire_ts).unwrap(); } pub fn get_expire_ts(val...
{ Ok(()) }
conditional_block
util.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use super::{Error, Result}; use tikv_util::codec; use tikv_util::codec::number::{self, NumberEncoder}; /// Check if key in range [`start_key`, `end_key`). #[allow(dead_code)] pub fn check_key_in_range( key: &[u8], region_id: u64, start_key...
pub fn get_expire_ts(value_with_ttl: &[u8]) -> Result<u64> { let len = value_with_ttl.len(); if len < number::U64_SIZE { return Err(Error::Codec(codec::Error::ValueLength)); } let mut ts = &value_with_ttl[len - number::U64_SIZE..]; Ok(number::decode_u64(&mut ts)?) } pub fn strip_expire_ts...
{ value.encode_u64(expire_ts).unwrap(); }
identifier_body
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
#[macro_use] mod test_common; mod transaction; mod executive; mod state; mod chain; mod homestead_state; mod homestead_chain; mod eip150_state; mod eip161_state; mod trie;
// GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Parity. If not, see <http://www.gnu.org/licenses/>.
random_line_split
ip.rs
//! Handles parsing of Internet Protocol fields (shared between ipv4 and ipv6) use nom::bits; use nom::error::Error; use nom::number; use nom::sequence; use nom::IResult; #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum IPProtocol { ...
41 => IPProtocol::IPV6, 58 => IPProtocol::ICMP6, other => IPProtocol::Other(other), } } } pub(crate) fn two_nibbles(input: &[u8]) -> IResult<&[u8], (u8, u8)> { bits::bits::<_, _, Error<_>, _, _>(sequence::pair( bits::streaming::take(4u8), bits::strea...
{ match raw { 0 => IPProtocol::HOPOPT, 1 => IPProtocol::ICMP, 2 => IPProtocol::IGMP, 3 => IPProtocol::GGP, 4 => IPProtocol::IPINIP, 5 => IPProtocol::ST, 6 => IPProtocol::TCP, 7 => IPProtocol::CBT, 8 => IP...
identifier_body
ip.rs
//! Handles parsing of Internet Protocol fields (shared between ipv4 and ipv6) use nom::bits; use nom::error::Error; use nom::number; use nom::sequence; use nom::IResult; #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum IPProtocol { ...
other => IPProtocol::Other(other), } } } pub(crate) fn two_nibbles(input: &[u8]) -> IResult<&[u8], (u8, u8)> { bits::bits::<_, _, Error<_>, _, _>(sequence::pair( bits::streaming::take(4u8), bits::streaming::take(4u8), ))(input) } pub(crate) fn protocol(input: &[u8]) -> ...
16 => IPProtocol::CHAOS, 17 => IPProtocol::UDP, 41 => IPProtocol::IPV6, 58 => IPProtocol::ICMP6,
random_line_split
ip.rs
//! Handles parsing of Internet Protocol fields (shared between ipv4 and ipv6) use nom::bits; use nom::error::Error; use nom::number; use nom::sequence; use nom::IResult; #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum
{ HOPOPT, ICMP, IGMP, GGP, IPINIP, ST, TCP, CBT, EGP, IGP, BBNRCCMON, NVPII, PUP, ARGUS, EMCON, XNET, CHAOS, UDP, IPV6, ICMP6, Other(u8), } impl From<u8> for IPProtocol { fn from(raw: u8) -> Self { match raw { ...
IPProtocol
identifier_name
glb.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 regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { debug!("{}.regions({}, {})", self.tag(), a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx)); let origin = Subtype(self.fields.trace.clone()); Ok(...
{ lattice::super_lattice_tys(self, a, b) }
identifier_body
glb.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
use super::combine::CombineFields; use super::higher_ranked::HigherRankedRelations; use super::InferCtxt; use super::lattice::{self, LatticeDir}; use super::Subtype; use middle::ty::{self, Ty}; use middle::ty_relate::{Relate, RelateResult, TypeRelation}; use util::ppaux::Repr; /// "Greatest lower bound" (common subty...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
glb.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 ...
(fields: CombineFields<'a, 'tcx>) -> Glb<'a, 'tcx> { Glb { fields: fields } } } impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> { fn tag(&self) -> &'static str { "Glb" } fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expect...
new
identifier_name
text.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/. */ //! Generic types for text properties. use app_units::Au; use cssparser::Parser; use parser::ParserContext; use p...
/// `<value>` Value(Value), } impl<Value> Spacing<Value> { /// Returns `normal`. #[inline] pub fn normal() -> Self { Spacing::Normal } /// Parses. #[inline] pub fn parse_with<'i, 't, F>( context: &ParserContext, input: &mut Parser<'i, 't>, parse: F) ...
/// `normal` Normal,
random_line_split
text.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/. */ //! Generic types for text properties. use app_units::Au; use cssparser::Parser; use parser::ParserContext; use p...
<Value> { /// `normal` Normal, /// `<value>` Value(Value), } impl<Value> Spacing<Value> { /// Returns `normal`. #[inline] pub fn normal() -> Self { Spacing::Normal } /// Parses. #[inline] pub fn parse_with<'i, 't, F>( context: &ParserContext, input: ...
Spacing
identifier_name
instr_movntdqa.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn movntdqa_1() { run_test(&Instruction { mnemonic: Mnemonic::MOVNTDQA, operand1: Some(Direc...
{ run_test(&Instruction { mnemonic: Mnemonic::MOVNTDQA, operand1: Some(Direct(XMM6)), operand2: Some(IndirectScaledIndexed(RBX, RSI, Two, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, ...
identifier_body
instr_movntdqa.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn
() { run_test(&Instruction { mnemonic: Mnemonic::MOVNTDQA, operand1: Some(Direct(XMM2)), operand2: Some(IndirectScaledIndexed(EBX, EDI, Four, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, ...
movntdqa_1
identifier_name
main.rs
extern crate term_mux; extern crate termion; extern crate chan_signal; use std::io::{Read, Write, Result}; use std::fs::File; use std::thread; use std::time::Duration; use termion::get_tty; use termion::raw::IntoRawMode; use chan_signal::{notify, Signal}; use term_mux::pty::Pty; use term_mux::tui::{get_terminal_size, ...
() { let signal = notify(&[Signal::WINCH]); let mut tty_output = get_tty().unwrap().into_raw_mode().unwrap(); let mut tty_input = tty_output.try_clone().unwrap(); let pty_resize = Pty::spawn(&get_shell(), &get_terminal_size().unwrap()).unwrap(); let mut pty_output = pty_resize.try_cl...
main
identifier_name
main.rs
extern crate term_mux; extern crate termion; extern crate chan_signal; use std::io::{Read, Write, Result}; use std::fs::File; use std::thread; use std::time::Duration; use termion::get_tty; use termion::raw::IntoRawMode; use chan_signal::{notify, Signal}; use term_mux::pty::Pty; use term_mux::tui::{get_terminal_size, ...
loop { match pipe(&mut tty_input, &mut pty_output) { Err(_) => return, _ => (), } } }); thread::spawn(move || { loop { signal.recv().unwrap(); pty_resize.resize(&get_terminal_size().unwrap()); }...
{ let signal = notify(&[Signal::WINCH]); let mut tty_output = get_tty().unwrap().into_raw_mode().unwrap(); let mut tty_input = tty_output.try_clone().unwrap(); let pty_resize = Pty::spawn(&get_shell(), &get_terminal_size().unwrap()).unwrap(); let mut pty_output = pty_resize.try_clone(...
identifier_body
main.rs
extern crate term_mux; extern crate termion; extern crate chan_signal; use std::io::{Read, Write, Result}; use std::fs::File; use std::thread; use std::time::Duration; use termion::get_tty; use termion::raw::IntoRawMode; use chan_signal::{notify, Signal}; use term_mux::pty::Pty; use term_mux::tui::{get_terminal_size, ...
fn pipe(input: &mut File, output: &mut File) -> Result<()> { let mut packet = [0; 4096]; let count = input.read(&mut packet)?; let read = &packet[..count]; output.write_all(&read)?; output.flush()?; Ok(()) }
random_line_split
instr_kshiftrd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn kshiftrd_1() { run_test(&Instruction { mnemonic: Mnemonic::KSHIFTRD, operand1: Some(Direc...
{ run_test(&Instruction { mnemonic: Mnemonic::KSHIFTRD, operand1: Some(Direct(K2)), operand2: Some(Direct(K6)), operand3: Some(Literal8(43)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 227, 121, 49, 214, 43], OperandSize::Qword) }
identifier_body
instr_kshiftrd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn kshiftrd_1() {
run_test(&Instruction { mnemonic: Mnemonic::KSHIFTRD, operand1: Some(Direct(K2)), operand2: Some(Direct(K6)), operand3: Some(Literal8(43)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 227, 121, 49, 214, 43], OperandSize::Qword) }
run_test(&Instruction { mnemonic: Mnemonic::KSHIFTRD, operand1: Some(Direct(K1)), operand2: Some(Direct(K3)), operand3: Some(Literal8(43)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 227, 121, 49, 203, 43], OperandSize::Dword) } #[test] fn ...
random_line_split
instr_kshiftrd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn kshiftrd_1() { run_test(&Instruction { mnemonic: Mnemonic::KSHIFTRD, operand1: Some(Direc...
() { run_test(&Instruction { mnemonic: Mnemonic::KSHIFTRD, operand1: Some(Direct(K2)), operand2: Some(Direct(K6)), operand3: Some(Literal8(43)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 227, 121, 49, 214, 43], OperandSize::Qword) }
kshiftrd_2
identifier_name
transit.rs
#[derive(Debug, Clone)] pub struct Transit { period: f64, base: f64, depth: f64, duration: f64, decay: f64, phase: f64, } impl Transit {
let k = (time/self.period).floor(); let t = time - k * self.period; if t < self.phase { self.base } else if t < (self.phase + self.decay) { let start = self.phase; let f = (t - start) / self.decay; self.base - f * self.depth } else...
pub fn new((period, base, depth, duration, decay, phase): (f64,f64,f64,f64,f64,f64)) -> Transit { Transit { period, base, depth, duration, decay, phase } } pub fn value(&self, time: &f64) -> f64 {
random_line_split
transit.rs
#[derive(Debug, Clone)] pub struct Transit { period: f64, base: f64, depth: f64, duration: f64, decay: f64, phase: f64, } impl Transit { pub fn new((period, base, depth, duration, decay, phase): (f64,f64,f64,f64,f64,f64)) -> Transit { Transit { period, base, depth, duration, decay, ...
}
{ let k = (time/self.period).floor(); let t = time - k * self.period; if t < self.phase { self.base } else if t < (self.phase + self.decay) { let start = self.phase; let f = (t - start) / self.decay; self.base - f * self.depth } el...
identifier_body
transit.rs
#[derive(Debug, Clone)] pub struct
{ period: f64, base: f64, depth: f64, duration: f64, decay: f64, phase: f64, } impl Transit { pub fn new((period, base, depth, duration, decay, phase): (f64,f64,f64,f64,f64,f64)) -> Transit { Transit { period, base, depth, duration, decay, phase } } pub fn value(&self, tim...
Transit
identifier_name
transit.rs
#[derive(Debug, Clone)] pub struct Transit { period: f64, base: f64, depth: f64, duration: f64, decay: f64, phase: f64, } impl Transit { pub fn new((period, base, depth, duration, decay, phase): (f64,f64,f64,f64,f64,f64)) -> Transit { Transit { period, base, depth, duration, decay, ...
else if t < (self.phase + self.decay) { let start = self.phase; let f = (t - start) / self.decay; self.base - f * self.depth } else if t < (self.phase + self.decay + self.duration) { self.base - self.depth } else if t < (self.phase + self.decay + self.dur...
{ self.base }
conditional_block
main.rs
use std::sync::{Arc, Mutex}; use std::thread; use std::sync::mpsc; fn
() { let data = Arc::new(Mutex::new(vec![1u32, 2, 3])); for i in 0..3{ let data = data.clone(); thread::spawn(move||{ let mut data = data.lock().unwrap(); data[i] += 1; }); } thread::sleep_ms(50); let handle = thread::spawn(||{ println!("This is in a thread, not main"); thread::sleep_ms(5000);...
main
identifier_name
main.rs
use std::sync::{Arc, Mutex}; use std::thread; use std::sync::mpsc; fn main()
thread::sleep_ms(5000); println!("{}",handle.join().unwrap()); thread::sleep_ms(5000); println!("Hello, world, in main thread!"); println!("-------------------------------"); let (tx, rx) = mpsc::channel(); for _ in 0..10{ let tx = tx.clone(); thread::spawn(move ||{ let answer = 42u32; tx.send(...
{ let data = Arc::new(Mutex::new(vec![1u32, 2, 3])); for i in 0..3{ let data = data.clone(); thread::spawn(move||{ let mut data = data.lock().unwrap(); data[i] += 1; }); } thread::sleep_ms(50); let handle = thread::spawn(||{ println!("This is in a thread, not main"); thread::sleep_ms(5000); ...
identifier_body
main.rs
use std::sync::{Arc, Mutex}; use std::thread; use std::sync::mpsc; fn main() { let data = Arc::new(Mutex::new(vec![1u32, 2, 3])); for i in 0..3{ let data = data.clone(); thread::spawn(move||{ let mut data = data.lock().unwrap(); data[i] += 1;
let handle = thread::spawn(||{ println!("This is in a thread, not main"); thread::sleep_ms(5000); "return from thread" }); thread::sleep_ms(5000); println!("{}",handle.join().unwrap()); thread::sleep_ms(5000); println!("Hello, world, in main thread!"); println!("-------------------------------"); l...
}); } thread::sleep_ms(50);
random_line_split
security.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fs; use std::io::Read; use std::path::PathBuf; use collections::HashSet; use encryption_export::EncryptionConfig; use grpcio::{ChannelCredentials, ChannelCredentialsBuilder}; use security::SecurityConfig; pub fn new_security_cfg(cn: Option<H...
.unwrap(); fs::File::open(format!("{}", p.join("data/key.pem").display())) .unwrap() .read_to_string(&mut key) .unwrap(); fs::File::open(format!("{}", p.join("data/ca.pem").display())) .unwrap() .read_to_string(&mut ca) .unwrap(); (ca, cert, key) }
.read_to_string(&mut cert)
random_line_split
security.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fs; use std::io::Read; use std::path::PathBuf; use collections::HashSet; use encryption_export::EncryptionConfig; use grpcio::{ChannelCredentials, ChannelCredentialsBuilder}; use security::SecurityConfig; pub fn new_security_cfg(cn: Option<H...
() -> ChannelCredentials { let (ca, cert, key) = load_certs(); ChannelCredentialsBuilder::new() .root_cert(ca.into()) .cert(cert.into(), key.into()) .build() } fn load_certs() -> (String, String, String) { let mut cert = String::new(); let mut key = String::new(); let mut ca = ...
new_channel_cred
identifier_name
security.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fs; use std::io::Read; use std::path::PathBuf; use collections::HashSet; use encryption_export::EncryptionConfig; use grpcio::{ChannelCredentials, ChannelCredentialsBuilder}; use security::SecurityConfig; pub fn new_security_cfg(cn: Option<H...
pub fn new_channel_cred() -> ChannelCredentials { let (ca, cert, key) = load_certs(); ChannelCredentialsBuilder::new() .root_cert(ca.into()) .cert(cert.into(), key.into()) .build() } fn load_certs() -> (String, String, String) { let mut cert = String::new(); let mut key = String:...
{ let p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); SecurityConfig { ca_path: format!("{}", p.join("data/ca.pem").display()), cert_path: format!("{}", p.join("data/server.pem").display()), key_path: format!("{}", p.join("data/key.pem").display()), override_ssl_target: "".to_owne...
identifier_body
echo.rs
#[macro_use] mod common; use common::util::*; static UTIL_NAME: &'static str = "echo"; #[test] fn test_default() { let (_, mut ucmd) = testing(UTIL_NAME); assert_eq!(ucmd.run().stdout, "\n"); } #[test] fn test_no_trailing_newline() { let (_, mut ucmd) = testing(UTIL_NAME); ucmd.arg("-n") .arg...
#[test] fn test_disable_escapes() { let (_, mut ucmd) = testing(UTIL_NAME); ucmd.arg("-E") .arg("\\b\\c\\e"); assert_eq!(ucmd.run().stdout, "\\b\\c\\e\n"); }
{ let (_, mut ucmd) = testing(UTIL_NAME); ucmd.arg("-e") .arg("\\\\\\t\\r"); assert_eq!(ucmd.run().stdout, "\\\t\r\n"); }
identifier_body
echo.rs
#[macro_use] mod common; use common::util::*; static UTIL_NAME: &'static str = "echo"; #[test] fn test_default() { let (_, mut ucmd) = testing(UTIL_NAME); assert_eq!(ucmd.run().stdout, "\n"); } #[test] fn test_no_trailing_newline() { let (_, mut ucmd) = testing(UTIL_NAME); ucmd.arg("-n") .arg...
() { let (_, mut ucmd) = testing(UTIL_NAME); ucmd.arg("-E") .arg("\\b\\c\\e"); assert_eq!(ucmd.run().stdout, "\\b\\c\\e\n"); }
test_disable_escapes
identifier_name
echo.rs
#[macro_use] mod common; use common::util::*; static UTIL_NAME: &'static str = "echo"; #[test] fn test_default() { let (_, mut ucmd) = testing(UTIL_NAME);
} #[test] fn test_no_trailing_newline() { let (_, mut ucmd) = testing(UTIL_NAME); ucmd.arg("-n") .arg("hello_world"); assert_eq!(ucmd.run().stdout, "hello_world"); } #[test] fn test_enable_escapes() { let (_, mut ucmd) = testing(UTIL_NAME); ucmd.arg("-e") .arg("\\\\\\t\\r"); as...
assert_eq!(ucmd.run().stdout, "\n");
random_line_split
d2.rs
fn run(program: Vec<usize>) -> usize { let mut arr = program.clone(); let mut i = 0; loop { let op = arr[i]; if op == 99 { return arr[0]; }
let to = arr[i + 3]; if op == 1 { arr[to] = arr[a] + arr[b] } else if op == 2 { arr[to] = arr[a] * arr[b] } i += 4 } } fn main() { let program: Vec<usize> = include_str!("./input.txt") .split(",") .map(|i| i.parse::<usize>().unwrap()) .collect(); // p1 let mut p1 = pro...
let a = arr[i + 1]; let b = arr[i + 2];
random_line_split
d2.rs
fn run(program: Vec<usize>) -> usize { let mut arr = program.clone(); let mut i = 0; loop { let op = arr[i]; if op == 99 { return arr[0]; } let a = arr[i + 1]; let b = arr[i + 2]; let to = arr[i + 3]; if op == 1 { arr[to] = arr[a] + arr[b] } else if op == 2 { arr[...
} } }
{ println!("{}", 100 * x + y) }
conditional_block
d2.rs
fn run(program: Vec<usize>) -> usize { let mut arr = program.clone(); let mut i = 0; loop { let op = arr[i]; if op == 99 { return arr[0]; } let a = arr[i + 1]; let b = arr[i + 2]; let to = arr[i + 3]; if op == 1 { arr[to] = arr[a] + arr[b] } else if op == 2 { arr[...
() { let program: Vec<usize> = include_str!("./input.txt") .split(",") .map(|i| i.parse::<usize>().unwrap()) .collect(); // p1 let mut p1 = program.clone(); p1[1] = 12; p1[2] = 2; println!("{}", run(p1)); // p2 for x in 0..100 { for y in 0..100 { let mut p2 = program.clone(); ...
main
identifier_name
d2.rs
fn run(program: Vec<usize>) -> usize { let mut arr = program.clone(); let mut i = 0; loop { let op = arr[i]; if op == 99 { return arr[0]; } let a = arr[i + 1]; let b = arr[i + 2]; let to = arr[i + 3]; if op == 1 { arr[to] = arr[a] + arr[b] } else if op == 2 { arr[...
} } } }
{ let program: Vec<usize> = include_str!("./input.txt") .split(",") .map(|i| i.parse::<usize>().unwrap()) .collect(); // p1 let mut p1 = program.clone(); p1[1] = 12; p1[2] = 2; println!("{}", run(p1)); // p2 for x in 0..100 { for y in 0..100 { let mut p2 = program.clone(); ...
identifier_body
returnck.rs
use dora_parser::ast::*; use dora_parser::lexer::position::Position; pub fn returns_value(s: &Stmt) -> Result<(), Position> { match *s { Stmt::Return(_) => Ok(()), Stmt::For(ref stmt) => Err(stmt.pos), Stmt::While(ref stmt) => Err(stmt.pos), Stmt::Break(ref stmt) => Err(stmt.pos), ...
(e: &ExprBlockType) -> Result<(), Position> { let mut pos = e.pos; for stmt in &e.stmts { match returns_value(stmt) { Ok(_) => return Ok(()), Err(err_pos) => pos = err_pos, } } if let Some(ref expr) = e.expr { expr_returns_value(expr) } else { ...
expr_block_returns_value
identifier_name
returnck.rs
use dora_parser::ast::*; use dora_parser::lexer::position::Position; pub fn returns_value(s: &Stmt) -> Result<(), Position> { match *s { Stmt::Return(_) => Ok(()), Stmt::For(ref stmt) => Err(stmt.pos), Stmt::While(ref stmt) => Err(stmt.pos), Stmt::Break(ref stmt) => Err(stmt.pos), ...
"fun f(): Int32 { }", pos(1, 16), SemError::ReturnType("Int32".into(), "()".into()), ); err( "fun f(): Int32 { if true { return 1; } }", pos(1, 16), SemError::ReturnType("Int32".into(), "()".into()), ); err( ...
fn returns_int() { err(
random_line_split
returnck.rs
use dora_parser::ast::*; use dora_parser::lexer::position::Position; pub fn returns_value(s: &Stmt) -> Result<(), Position> { match *s { Stmt::Return(_) => Ok(()), Stmt::For(ref stmt) => Err(stmt.pos), Stmt::While(ref stmt) => Err(stmt.pos), Stmt::Break(ref stmt) => Err(stmt.pos), ...
fn expr_if_returns_value(e: &ExprIfType) -> Result<(), Position> { expr_returns_value(&e.then_block)?; match e.else_block { Some(ref block) => expr_returns_value(block), None => Err(e.pos), } } #[cfg(test)] mod tests { use crate::language::error::msg::SemError; use crate::languag...
{ let mut pos = e.pos; for stmt in &e.stmts { match returns_value(stmt) { Ok(_) => return Ok(()), Err(err_pos) => pos = err_pos, } } if let Some(ref expr) = e.expr { expr_returns_value(expr) } else { Err(pos) } }
identifier_body
util.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 layout::box::Box; use layout::construct::{ConstructionResult, NoConstructionResult}; use layout::wrapper::Layo...
{ priv entries: ~[NodeRange], } impl ElementMapping { pub fn new() -> ElementMapping { ElementMapping { entries: ~[], } } pub fn add_mapping(&mut self, node: OpaqueNode, range: &Range) { self.entries.push(NodeRange::new(node, range)) } pub fn each(&self, c...
ElementMapping
identifier_name
util.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 layout::box::Box; use layout::construct::{ConstructionResult, NoConstructionResult}; use layout::wrapper::Layo...
} true } pub fn eachi<'a>(&'a self) -> Enumerate<VecIterator<'a, NodeRange>> { self.entries.iter().enumerate() } pub fn repair_for_box_changes(&mut self, old_boxes: &[Box], new_boxes: &[Box]) { let entries = &mut self.entries; debug!("--- Old boxes: ---"); ...
{ break }
conditional_block
util.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 layout::box::Box; use layout::construct::{ConstructionResult, NoConstructionResult}; use layout::wrapper::Layo...
old_i += 1; // possibly pop several items while repair_stack.len() > 0 && old_i == entries[repair_stack.last().entry_idx].range.end() { let item = repair_stack.pop(); debug!("repair_for_box_changes: Set range for {:u} to {}", ...
while new_j < new_boxes.len() && old_boxes[old_i].node != new_boxes[new_j].node { debug!("repair_for_box_changes: Slide through new box {:u}", new_j); new_j += 1; }
random_line_split
util.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 layout::box::Box; use layout::construct::{ConstructionResult, NoConstructionResult}; use layout::wrapper::Layo...
/// Converts a DOM node (script view) to an `OpaqueNode`. pub fn from_script_node(node: &AbstractNode) -> OpaqueNode { unsafe { OpaqueNode(cast::transmute_copy(node)) } } /// Unsafely converts an `OpaqueNode` to a DOM node (script view). Use this only if you /// absolu...
{ unsafe { OpaqueNode(cast::transmute_copy(node)) } }
identifier_body
factor_int.rs
// Implements http://rosettacode.org/wiki/Factors_of_an_integer #[cfg(not(test))] fn main()
// Compute the factors of an integer // This method uses a simple check on each value between 1 and sqrt(x) to find // pairs of factors fn factor_int(x: i32) -> Vec<i32> { let mut factors: Vec<i32> = Vec::new(); let bound: i32 = (x as f64).sqrt().floor() as i32; for i in (1i32..bound) { if x % i...
{ let target = 78i32; println!("Factors of integer {}:", target); let factors = factor_int(target); for f in factors { println!("{}", f); } }
identifier_body
factor_int.rs
// Implements http://rosettacode.org/wiki/Factors_of_an_integer #[cfg(not(test))] fn main() { let target = 78i32; println!("Factors of integer {}:", target); let factors = factor_int(target); for f in factors { println!("{}", f); } } // Compute the factors of an integer // This method use...
} factors } #[test] fn test() { let result = factor_int(78i32); assert_eq!(result, vec![1i32, 78, 2, 39, 3, 26, 6, 13]); }
{ factors.push(i); factors.push(x/i); }
conditional_block
factor_int.rs
// Implements http://rosettacode.org/wiki/Factors_of_an_integer #[cfg(not(test))] fn main() { let target = 78i32; println!("Factors of integer {}:", target); let factors = factor_int(target); for f in factors { println!("{}", f); } } // Compute the factors of an integer // This method use...
() { let result = factor_int(78i32); assert_eq!(result, vec![1i32, 78, 2, 39, 3, 26, 6, 13]); }
test
identifier_name
factor_int.rs
// Implements http://rosettacode.org/wiki/Factors_of_an_integer #[cfg(not(test))] fn main() { let target = 78i32; println!("Factors of integer {}:", target); let factors = factor_int(target); for f in factors { println!("{}", f); } } // Compute the factors of an integer // This method use...
factors.push(i); factors.push(x/i); } } factors } #[test] fn test() { let result = factor_int(78i32); assert_eq!(result, vec![1i32, 78, 2, 39, 3, 26, 6, 13]); }
for i in (1i32..bound) { if x % i == 0 {
random_line_split
topic.rs
use std::fmt; use protocol::command::CMD_TOPIC; use protocol::message::{IrcMessage, RawMessage, ParseMessageError, ParseMessageErrorKind}; #[derive(Debug, Clone, Eq, PartialEq)] pub struct TopicCommand<'a> { channel: &'a str, topic: Option<&'a str>, } impl<'a> TopicCommand<'a> { pub fn new(channel: &'a s...
(&self) -> &'a str { self.channel } pub fn topic(&self) -> Option<&'a str> { self.topic } } impl<'a> fmt::Display for TopicCommand<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, "{} {}", CMD_TOPIC, self.channel)); match self.topic { ...
channel
identifier_name
topic.rs
use std::fmt; use protocol::command::CMD_TOPIC; use protocol::message::{IrcMessage, RawMessage, ParseMessageError, ParseMessageErrorKind}; #[derive(Debug, Clone, Eq, PartialEq)]
impl<'a> TopicCommand<'a> { pub fn new(channel: &'a str, topic: Option<&'a str>) -> TopicCommand<'a> { TopicCommand { channel: channel, topic: topic, } } pub fn channel(&self) -> &'a str { self.channel } pub fn topic(&self) -> Option<&'a str> { ...
pub struct TopicCommand<'a> { channel: &'a str, topic: Option<&'a str>, }
random_line_split
regionmanip.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
ty } fn fold_region(&mut self, r: ty::Region) -> ty::Region { self.relate(r); r } } impl<'a> RegionRelator<'a> { fn relate(&mut self, r_sub: ty::Region) { for &r in self.stack.iter() { if!r.is_bound() &&!r_sub.is_...
_ => { ty_fold::super_fold_ty(self, ty); } }
random_line_split
regionmanip.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 ...
} rr.fold_ty(ty); struct RegionRelator<'a> { tcx: &'a ty::ctxt, stack: Vec<ty::Region>, relate_op: |ty::Region, ty::Region|: 'a, } // FIXME(#10151) -- Define more precisely when a region is // considered "nested". Consider taking variance into account as // well. ...
{}
conditional_block
regionmanip.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 ...
(tcx: &ty::ctxt, opt_region: Option<ty::Region>, ty: ty::t, relate_op: |ty::Region, ty::Region|) { /*! * This rather specialized function walks each region `r` that appear * in `ty` and invokes `relate_op(r_encl, r)` fo...
relate_nested_regions
identifier_name
regionmanip.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 ...
for &t in all_tys.iter() { debug!("relate_free_regions(t={})", ppaux::ty_to_str(tcx, t)); relate_nested_regions(tcx, None, t, |a, b| { match (&a, &b) { (&ty::ReFree(free_a), &ty::ReFree(free_b)) => { tcx.region_maps.relate_free_regions(free_a, free_b);...
{ /*! * This function populates the region map's `free_region_map`. * It walks over the transformed self type and argument types * for each function just before we check the body of that * function, looking for types where you have a borrowed * pointer to other borrowed data (e.g., `&'a &'b...
identifier_body
x86.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 ...
(target_triple: ~str, target_os: abi::Os) -> target_strs::t { return target_strs::t { module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(), data_layout: match target_os { abi::OsMacos => { ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16"...
get_target_strs
identifier_name
x86.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 ...
"-i32:32:32-i64:32:64" + "-f32:32:32-f64:32:64-v64:64:64" + "-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32" } abi::OsWin32 => { ~"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32" } abi::OsLinux => { ~"e-...
data_layout: match target_os { abi::OsMacos => { ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" +
random_line_split
x86.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 ...
} abi::OsAndroid => { ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" } abi::OsFreebsd => { ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" } }, target_triple: target_triple, cc_args: ~[~"-m32"], }; }
{ return target_strs::t { module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(), data_layout: match target_os { abi::OsMacos => { ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + "-i32:32:32-i64:32:64" + ...
identifier_body
x86.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 ...
abi::OsFreebsd => { ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" } }, target_triple: target_triple, cc_args: ~[~"-m32"], }; }
{ ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" }
conditional_block
deriving-eq-ord-boxed-slice.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 a = Foo(box [0, 1, 2]); let b = Foo(box [0, 1, 2]); assert!(a == b); println!("{}", a!= b); println!("{}", a < b); println!("{}", a <= b); println!("{}", a == b); println!("{}", a > b); println!("{}", a >= b); }
#[derive(PartialEq, PartialOrd, Eq, Ord)] struct Foo(Box<[u8]>); pub fn main() {
random_line_split
deriving-eq-ord-boxed-slice.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 a = Foo(box [0, 1, 2]); let b = Foo(box [0, 1, 2]); assert!(a == b); println!("{}", a != b); println!("{}", a < b); println!("{}", a <= b); println!("{}", a == b); println!("{}", a > b); println!("{}", a >= b); }
identifier_body
deriving-eq-ord-boxed-slice.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 a = Foo(box [0, 1, 2]); let b = Foo(box [0, 1, 2]); assert!(a == b); println!("{}", a!= b); println!("{}", a < b); println!("{}", a <= b); println!("{}", a == b); println!("{}", a > b); println!("{}", a >= b); }
main
identifier_name
abstractworkerglobalscope.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::dom::abstractworker::WorkerScriptMsg; use crate::dom::bindings::conversions::DerivedFrom; use crate::d...
(&self) -> Result<CommonScriptMsg, ()> { let common_msg = match self.recv() { Ok(DedicatedWorkerScriptMsg::CommonWorker(_worker, common_msg)) => common_msg, Err(_) => return Err(()), Ok(DedicatedWorkerScriptMsg::WakeUp) => panic!("unexpected worker event message!"), }...
recv
identifier_name