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 |
|---|---|---|---|---|
kqueue.rs | use std::{cmp, fmt, ptr};
#[cfg(not(target_os = "netbsd"))]
use std::os::raw::{c_int, c_short};
use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
use std::collections::HashMap;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use std::time::Duration;
use libc::{self, time_t};
use {io, Re... | unsafe {
let _ = libc::close(self.kq);
}
}
}
pub struct Events {
sys_events: KeventList,
events: Vec<Event>,
event_map: HashMap<Token, usize>,
}
struct KeventList(Vec<libc::kevent>);
unsafe impl Send for KeventList {}
unsafe impl Sync for KeventList {}
impl Events {
p... | }
impl Drop for Selector {
fn drop(&mut self) { | random_line_split |
kqueue.rs | use std::{cmp, fmt, ptr};
#[cfg(not(target_os = "netbsd"))]
use std::os::raw::{c_int, c_short};
use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
use std::collections::HashMap;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use std::time::Duration;
use libc::{self, time_t};
use {io, Re... | (Vec<libc::kevent>);
unsafe impl Send for KeventList {}
unsafe impl Sync for KeventList {}
impl Events {
pub fn with_capacity(cap: usize) -> Events {
Events {
sys_events: KeventList(Vec::with_capacity(cap)),
events: Vec::with_capacity(cap),
event_map: HashMap::with_capa... | KeventList | identifier_name |
snoop.rs | //! Snoop plugin that exposes metrics on a local socket.
use errors::*;
use plugin::*;
use metric::*;
use std::collections::HashMap;
use std::sync::{Mutex, Arc};
use std::net::SocketAddr;
use tokio_io::{io, AsyncRead};
use tokio_core::net;
use futures::{sync, Future};
use futures::stream::Stream;
use std::convert::As... | () -> Result<Box<Output>> {
Ok(Box::new(SnoopOutput {}))
}
#[derive(Clone)]
pub struct Message(Arc<Box<[u8]>>);
impl AsRef<[u8]> for Message {
fn as_ref(&self) -> &[u8] {
let &Message(ref a) = self;
&a
}
}
| output | identifier_name |
snoop.rs | //! Snoop plugin that exposes metrics on a local socket.
use errors::*;
use plugin::*;
use metric::*;
use std::collections::HashMap; | use futures::stream::Stream;
use std::convert::AsRef;
use std::fmt;
use serde_json;
#[derive(Deserialize, Debug)]
struct SnoopInputConfig {
bind: Option<SocketAddr>,
}
#[derive(Debug)]
struct SnoopOutput {}
fn report_and_discard<E: fmt::Display>(e: E) -> () {
info!("An error occured: {}", e);
}
type Sender ... | use std::sync::{Mutex, Arc};
use std::net::SocketAddr;
use tokio_io::{io, AsyncRead};
use tokio_core::net;
use futures::{sync, Future}; | random_line_split |
runtime.rs | #[cfg(windows)]
mod os
{
#[cfg(windows)]
#[link(name = "ole32")]
extern "system" {
#[doc(hidden)]
pub fn CoInitializeEx(
reserved: *const ::std::os::raw::c_void,
init: u32,
) -> crate::raw::HRESULT;
#[doc(hidden)]
pub fn CoUninitialize();
... |
}
pub fn initialize() -> crate::RawComResult<()>
{
match os::initialize() {
crate::raw::S_OK => Ok(()),
e => Err(e),
}
}
pub fn uninitialize()
{
os::uninitialize();
}
| {} | identifier_body |
runtime.rs | #[cfg(windows)]
mod os
{
#[cfg(windows)]
#[link(name = "ole32")]
extern "system" {
#[doc(hidden)]
pub fn CoInitializeEx(
reserved: *const ::std::os::raw::c_void,
init: u32,
) -> crate::raw::HRESULT;
#[doc(hidden)]
pub fn CoUninitialize();
... | () {}
}
pub fn initialize() -> crate::RawComResult<()>
{
match os::initialize() {
crate::raw::S_OK => Ok(()),
e => Err(e),
}
}
pub fn uninitialize()
{
os::uninitialize();
}
| uninitialize | identifier_name |
runtime.rs | #[cfg(windows)]
mod os
{
#[cfg(windows)]
#[link(name = "ole32")]
extern "system" {
#[doc(hidden)]
pub fn CoInitializeEx(
reserved: *const ::std::os::raw::c_void,
init: u32,
) -> crate::raw::HRESULT;
#[doc(hidden)]
pub fn CoUninitialize();
... | }
pub fn uninitialize() {}
}
pub fn initialize() -> crate::RawComResult<()>
{
match os::initialize() {
crate::raw::S_OK => Ok(()),
e => Err(e),
}
}
pub fn uninitialize()
{
os::uninitialize();
} | random_line_split | |
lib.rs | #[macro_use]
extern crate error_chain;
// We'll put our errors in an `errors` module, and other modules in
// this crate will `use errors::*;` to get access to everything
// `error_chain!` creates.
mod errors {
// Create the Error, ErrorKind, ResultExt, and Result types
error_chain!{}
}
use errors::*;
pub fn... | <T: AsRef<str>>(digits: T, length: usize) -> Result<u64> {
let digits = digits.as_ref();
if digits.len() < length {
bail!("The digits string must at least be {} characters in size but was only {}",
length,
digits.len());
}
let mut new_digits = Vec::with_capacity(digit... | lsp | identifier_name |
lib.rs | #[macro_use]
extern crate error_chain;
// We'll put our errors in an `errors` module, and other modules in
// this crate will `use errors::*;` to get access to everything
// `error_chain!` creates.
mod errors {
// Create the Error, ErrorKind, ResultExt, and Result types
error_chain!{}
}
use errors::*;
pub fn... | {
match c {
'0'...'9' => Ok(c as u8 - '0' as u8),
_ => bail!("'{}' is not a digit"),
}
} | identifier_body | |
lib.rs | #[macro_use]
extern crate error_chain;
// We'll put our errors in an `errors` module, and other modules in
// this crate will `use errors::*;` to get access to everything
// `error_chain!` creates.
mod errors {
// Create the Error, ErrorKind, ResultExt, and Result types
error_chain!{}
}
use errors::*;
pub fn... | _ => bail!("'{}' is not a digit"),
}
} | fn char_to_digit(c: char) -> Result<u8> {
match c {
'0'...'9' => Ok(c as u8 - '0' as u8), | random_line_split |
mod.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/. */
//! The implementation of the DOM.
//!
//! The DOM is comprised of interfaces (defined by specifications using
//!... | //! and check whether a given instance is of a given type.
//!
//! ```ignore
//! use dom::bindings::inheritance::Castable;
//! use dom::element::Element;
//! use dom::htmlelement::HTMLElement;
//! use dom::htmlinputelement::HTMLInputElement;
//!
//! if let Some(elem) = node.downcast::<Element> {
//! if elem.is::<HT... | //! implement the `Castable` trait, which provides three methods `is::<T>()`,
//! `downcast::<T>()` and `upcast::<T>()` to cast across the type hierarchy | random_line_split |
mod.rs | mod address;
mod entry;
mod table;
mod huge;
mod page;
use alloc::boxed::Box;
use alloc::vec::Vec;
use sys::volatile::prelude::*;
use pi::common::IO_BASE as _IO_BASE;
use core::fmt;
use aarch64;
pub use self::entry::Entry;
pub use self::table::{Table, Level, L0, L1, L2, L3};
pub use self::address::{PhysicalAddr, V... |
pub fn contains(&self, addr: VirtualAddr) -> bool {
self.start <= addr && addr < self.end
}
pub fn intersects(&self, other: Self) -> bool {
self.contains(other.start) || self.contains(other.end)
}
}
/// Set up page translation tables and enable virtual memory
pub fn initialize() {
... | {
self.start >= self.end
} | identifier_body |
mod.rs | mod address;
mod entry;
mod table;
mod huge;
mod page;
use alloc::boxed::Box;
use alloc::vec::Vec;
use sys::volatile::prelude::*;
use pi::common::IO_BASE as _IO_BASE;
use core::fmt;
use aarch64;
pub use self::entry::Entry;
pub use self::table::{Table, Level, L0, L1, L2, L3};
pub use self::address::{PhysicalAddr, V... | (&mut self, area: Area) -> Option<()> {
self.area(area.prot(Prot::RX))
}
#[must_use]
pub fn area_rw(&mut self, area: Area) -> Option<()> {
self.area(area.prot(Prot::RW))
}
#[must_use]
pub fn area_ro(&mut self, area: Area) -> Option<()> {
self.area(area.prot(Prot::RO))
... | area_rx | identifier_name |
mod.rs | mod address;
mod entry;
mod table;
mod huge;
mod page;
use alloc::boxed::Box;
use alloc::vec::Vec;
use sys::volatile::prelude::*;
use pi::common::IO_BASE as _IO_BASE;
use core::fmt;
use aarch64;
pub use self::entry::Entry;
pub use self::table::{Table, Level, L0, L1, L2, L3};
pub use self::address::{PhysicalAddr, V... | let mut r: u64;
asm!("dsb ish; isb; mrs $0, sctlr_el1" : "=r"(r) : : : "volatile");
r |= 0xC00800; // set mandatory reserved bits
r &=!((1<<25) | // clear EE, little endian translation tables
(1<<24) | // clear E0E
(1<<19) | // clear WXN
... | unsafe { | random_line_split |
mod.rs | mod address;
mod entry;
mod table;
mod huge;
mod page;
use alloc::boxed::Box;
use alloc::vec::Vec;
use sys::volatile::prelude::*;
use pi::common::IO_BASE as _IO_BASE;
use core::fmt;
use aarch64;
pub use self::entry::Entry;
pub use self::table::{Table, Level, L0, L1, L2, L3};
pub use self::address::{PhysicalAddr, V... |
Some(())
}
pub fn find_area_mut(&mut self, addr: VirtualAddr) -> Option<&mut Area> {
self.areas.iter_mut().find(|area| area.contains(addr))
}
pub fn find_area(&self, addr: VirtualAddr) -> Option<&Area> {
self.areas.iter().find(|area| area.contains(addr))
}
pub fn has... | {
let mut p = align_down(p.as_usize(), PAGESZ);
while addr < end {
let v = (addr as *mut u8).into();
let l2 = self.root.next_table_or(v, Entry::USER_BASE)?;
if addr % HUGESZ == 0 && (end - addr) >= HUGESZ {
l2[v].write(Entry::bl... | conditional_block |
parser_tests.rs | #[cfg(test)]
mod tests {
use model::{Model, TemplateParameter};
use std::fs::File;
use std::io::Write;
use clang::{Clang, Index};
use tempdir::TempDir;
use serde_json;
use std::fmt::Debug;
use response_file::ExtendWithResponseFile;
const INTERFACE: &'static str = r#"
namespace fo... |
#[test]
fn should_list_template_parameters() {
let model = create_model(TEMPLATE_INTERFACE);
assert!(model.interfaces.len() > 0);
assert_eq!(model.interfaces[0]
.clone()
.template_parameters
.unwrap(),
... | {
create_model(TEMPLATE_INTERFACE);
} | identifier_body |
parser_tests.rs | #[cfg(test)]
mod tests {
use model::{Model, TemplateParameter};
use std::fs::File;
use std::io::Write;
use clang::{Clang, Index};
use tempdir::TempDir;
use serde_json;
use std::fmt::Debug;
use response_file::ExtendWithResponseFile;
const INTERFACE: &'static str = r#"
namespace fo... | () {
create_model(TEMPLATE_INTERFACE);
}
#[test]
fn should_list_template_parameters() {
let model = create_model(TEMPLATE_INTERFACE);
assert!(model.interfaces.len() > 0);
assert_eq!(model.interfaces[0]
.clone()
.template_parameters... | should_parse_template_class | identifier_name |
parser_tests.rs | #[cfg(test)] | use model::{Model, TemplateParameter};
use std::fs::File;
use std::io::Write;
use clang::{Clang, Index};
use tempdir::TempDir;
use serde_json;
use std::fmt::Debug;
use response_file::ExtendWithResponseFile;
const INTERFACE: &'static str = r#"
namespace foo { namespace sample {
s... | mod tests { | random_line_split |
cci_no_inline_lib.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 ... |
// same as cci_iter_lib, more-or-less, but not marked inline
pub fn iter<F>(v: Vec<uint>, mut f: F) where F: FnMut(uint) {
let mut i = 0_usize;
let n = v.len();
while i < n {
f(v[i]);
i += 1_usize;
}
} | #![crate_name="cci_no_inline_lib"]
| random_line_split |
cci_no_inline_lib.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 ... | <F>(v: Vec<uint>, mut f: F) where F: FnMut(uint) {
let mut i = 0_usize;
let n = v.len();
while i < n {
f(v[i]);
i += 1_usize;
}
}
| iter | identifier_name |
cci_no_inline_lib.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let mut i = 0_usize;
let n = v.len();
while i < n {
f(v[i]);
i += 1_usize;
}
} | identifier_body | |
test.rs | use intern::intern;
use grammar::repr::*;
use lr1::Lookahead;
use lr1::Lookahead::EOF;
use test_util::{normalized_grammar};
use super::FirstSets;
pub fn nt(t: &str) -> Symbol {
Symbol::Nonterminal(NonterminalString(intern(t)))
}
pub fn term(t: &str) -> Symbol {
Symbol::Terminal(TerminalString::Quoted(intern(t... | "D" => Some(1);
=> None;
};
"#);
let first_sets = FirstSets::new(&grammar);
assert_eq!(
first(&first_sets, &[nt("A")], EOF),
vec![la("C"), la("D")]);
assert_eq!(
first(&first_sets, &[nt("B")], EOF),
vec![EOF, la("D")]);
assert_eq!(
first(&fi... | let grammar = normalized_grammar(r#"
grammar;
extern { enum Tok { } }
A = B "C";
B: Option<u32> = { | random_line_split |
test.rs | use intern::intern;
use grammar::repr::*;
use lr1::Lookahead;
use lr1::Lookahead::EOF;
use test_util::{normalized_grammar};
use super::FirstSets;
pub fn nt(t: &str) -> Symbol {
Symbol::Nonterminal(NonterminalString(intern(t)))
}
pub fn | (t: &str) -> Symbol {
Symbol::Terminal(TerminalString::Quoted(intern(t)))
}
fn la(t: &str) -> Lookahead {
Lookahead::Terminal(TerminalString::Quoted(intern(t)))
}
fn first(first: &FirstSets, symbols: &[Symbol], lookahead: Lookahead) -> Vec<Lookahead> {
let mut v = first.first(symbols, lookahead);
v.so... | term | identifier_name |
test.rs | use intern::intern;
use grammar::repr::*;
use lr1::Lookahead;
use lr1::Lookahead::EOF;
use test_util::{normalized_grammar};
use super::FirstSets;
pub fn nt(t: &str) -> Symbol {
Symbol::Nonterminal(NonterminalString(intern(t)))
}
pub fn term(t: &str) -> Symbol |
fn la(t: &str) -> Lookahead {
Lookahead::Terminal(TerminalString::Quoted(intern(t)))
}
fn first(first: &FirstSets, symbols: &[Symbol], lookahead: Lookahead) -> Vec<Lookahead> {
let mut v = first.first(symbols, lookahead);
v.sort();
v
}
#[test]
fn basic() {
let grammar = normalized_grammar(r#"
gr... | {
Symbol::Terminal(TerminalString::Quoted(intern(t)))
} | identifier_body |
compile.rs | use basm;
use beast;
use core::error::*;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::str::FromStr;
const BAKERVM_IMAGE_EXTENSION: &str = "img";
pub const DEFAULT_LANG: Lang = Lang::Beast;
#[derive(Debug)]
pub enum | {
Beast,
Basm,
}
impl FromStr for Lang {
type Err = &'static str;
fn from_str(s: &str) -> ::std::result::Result<Self, Self::Err> {
match s {
"basm" => Ok(Lang::Basm),
"beast" | "bst" => Ok(Lang::Beast),
_ => bail!("unknown language. Language must be one of [... | Lang | identifier_name |
compile.rs | use basm;
use beast;
use core::error::*;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::str::FromStr;
const BAKERVM_IMAGE_EXTENSION: &str = "img";
pub const DEFAULT_LANG: Lang = Lang::Beast;
#[derive(Debug)]
pub enum Lang {
Beast,
Basm,
}
impl FromStr for Lang {
typ... | pub fn compile(lang: Option<Lang>, input: PathBuf, output: Option<PathBuf>) -> Result<()> {
let input = input
.canonicalize()
.chain_err(|| "unable to canonicalize input path")?;
// We don't want to fail at recognizing the language, so we just default to
// Beast
let lang = lang.unwrap_or... | random_line_split | |
compile.rs | use basm;
use beast;
use core::error::*;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::str::FromStr;
const BAKERVM_IMAGE_EXTENSION: &str = "img";
pub const DEFAULT_LANG: Lang = Lang::Beast;
#[derive(Debug)]
pub enum Lang {
Beast,
Basm,
}
impl FromStr for Lang {
typ... |
ensure!(
fallback_output.set_extension(BAKERVM_IMAGE_EXTENSION),
"unable to set file extension"
);
let output = output.unwrap_or(fallback_output);
let start_dir = env::current_dir().chain_err(|| "unable to get current directory")?;
let program = match lang {
Lang::Basm =>... | {
let input = input
.canonicalize()
.chain_err(|| "unable to canonicalize input path")?;
// We don't want to fail at recognizing the language, so we just default to
// Beast
let lang = lang.unwrap_or_else(|| {
if let Some(extension) = input.extension() {
if let Some(... | identifier_body |
eh.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 ... | return reader.read::<usize>();
}
let mut result = match encoding & 0x0F {
DW_EH_PE_absptr => reader.read::<usize>(),
DW_EH_PE_uleb128 => reader.read_uleb128() as usize,
DW_EH_PE_udata2 => reader.read::<u16>() as usize,
DW_EH_PE_udata4 => reader.read::<u32>() as usize,
... | // DW_EH_PE_aligned implies it's an absolute pointer value
if encoding == DW_EH_PE_aligned {
reader.ptr = round_up(reader.ptr as usize,
mem::size_of::<usize>()) as *const u8; | random_line_split |
eh.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 ... | (lsda: *const u8, context: &EHContext)
-> Option<usize> {
if lsda.is_null() {
return None;
}
let func_start = context.func_start;
let mut reader = DwarfReader::new(lsda);
let start_encoding = reader.read::<u8>();
// base address for landing pad offsets
... | find_landing_pad | identifier_name |
eh.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 ... | }
let call_site_encoding = reader.read::<u8>();
let call_site_table_length = reader.read_uleb128();
let action_table = reader.ptr.offset(call_site_table_length as isize);
// Return addresses point 1 byte past the call instruction, which could
// be in the next IP range.
let ip = context.ip-... | {
if lsda.is_null() {
return None;
}
let func_start = context.func_start;
let mut reader = DwarfReader::new(lsda);
let start_encoding = reader.read::<u8>();
// base address for landing pad offsets
let lpad_base = if start_encoding != DW_EH_PE_omit {
read_encoded_pointer(&mu... | identifier_body |
selection_sort.rs | /*
* Implementation of selection_sort in Rust
*/
fn selection_sort(mut list: Vec<i32>) -> Vec<i32> {
let n = list.len();
for j in 0..n-1 {
let mut cur_min = j;
for i in j+1..n {
if list[i] < list[cur_min] {
cur_min = i;
}
}
if cur_min... | {
let mut mylist = Vec::new();
mylist.push(5);
mylist.push(4);
mylist.push(8);
mylist.push(9);
mylist.push(20);
mylist.push(14);
mylist.push(3);
mylist.push(1);
mylist.push(2);
mylist.push(2);
println!("{:?}", mylist);
let selection_sorted = selection_sort(mylist);
... | identifier_body | |
selection_sort.rs | /*
* Implementation of selection_sort in Rust
*/
fn selection_sort(mut list: Vec<i32>) -> Vec<i32> {
let n = list.len();
for j in 0..n-1 {
let mut cur_min = j;
for i in j+1..n {
if list[i] < list[cur_min] {
cur_min = i;
}
}
if cur_min... |
}
return list;
}
fn main() {
let mut mylist = Vec::new();
mylist.push(5);
mylist.push(4);
mylist.push(8);
mylist.push(9);
mylist.push(20);
mylist.push(14);
mylist.push(3);
mylist.push(1);
mylist.push(2);
mylist.push(2);
println!("{:?}", mylist);
let sel... | {
list.swap(j, cur_min);
} | conditional_block |
selection_sort.rs | /*
* Implementation of selection_sort in Rust
*/
fn selection_sort(mut list: Vec<i32>) -> Vec<i32> {
let n = list.len(); | if list[i] < list[cur_min] {
cur_min = i;
}
}
if cur_min!= j {
list.swap(j, cur_min);
}
}
return list;
}
fn main() {
let mut mylist = Vec::new();
mylist.push(5);
mylist.push(4);
mylist.push(8);
mylist.push(9);
... |
for j in 0..n-1 {
let mut cur_min = j;
for i in j+1..n { | random_line_split |
selection_sort.rs | /*
* Implementation of selection_sort in Rust
*/
fn | (mut list: Vec<i32>) -> Vec<i32> {
let n = list.len();
for j in 0..n-1 {
let mut cur_min = j;
for i in j+1..n {
if list[i] < list[cur_min] {
cur_min = i;
}
}
if cur_min!= j {
list.swap(j, cur_min);
}
}
return... | selection_sort | identifier_name |
serialization.rs | use serde::de::DeserializeOwned;
use serde::ser::Serialize;
use serde_json::map::Map;
use serde_json::{from_str, to_string, Value};
use crate::errors::Result;
pub(crate) fn b64_encode(input: &[u8]) -> String {
base64::encode_config(input, base64::URL_SAFE_NO_PAD)
}
pub(crate) fn b64_decode(input: &str) -> Result... | }
/// Decodes from base64 and deserializes from JSON to a struct AND a hashmap of Value so we can
/// run validation on it
pub(crate) fn from_jwt_part_claims<B: AsRef<str>, T: DeserializeOwned>(
encoded: B,
) -> Result<(T, Map<String, Value>)> {
let s = String::from_utf8(b64_decode(encoded.as_ref())?)?;
l... | let json = to_string(input)?;
Ok(b64_encode(json.as_bytes())) | random_line_split |
serialization.rs | use serde::de::DeserializeOwned;
use serde::ser::Serialize;
use serde_json::map::Map;
use serde_json::{from_str, to_string, Value};
use crate::errors::Result;
pub(crate) fn b64_encode(input: &[u8]) -> String {
base64::encode_config(input, base64::URL_SAFE_NO_PAD)
}
pub(crate) fn b64_decode(input: &str) -> Result... | <T: Serialize>(input: &T) -> Result<String> {
let json = to_string(input)?;
Ok(b64_encode(json.as_bytes()))
}
/// Decodes from base64 and deserializes from JSON to a struct AND a hashmap of Value so we can
/// run validation on it
pub(crate) fn from_jwt_part_claims<B: AsRef<str>, T: DeserializeOwned>(
enco... | b64_encode_part | identifier_name |
serialization.rs | use serde::de::DeserializeOwned;
use serde::ser::Serialize;
use serde_json::map::Map;
use serde_json::{from_str, to_string, Value};
use crate::errors::Result;
pub(crate) fn b64_encode(input: &[u8]) -> String |
pub(crate) fn b64_decode(input: &str) -> Result<Vec<u8>> {
base64::decode_config(input, base64::URL_SAFE_NO_PAD).map_err(|e| e.into())
}
/// Serializes a struct to JSON and encodes it in base64
pub(crate) fn b64_encode_part<T: Serialize>(input: &T) -> Result<String> {
let json = to_string(input)?;
Ok(b64... | {
base64::encode_config(input, base64::URL_SAFE_NO_PAD)
} | identifier_body |
static-reference-to-fn-2.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 ... |
impl<'a> Iterator for StateMachineIter<'a> {
type Item = &'static str;
fn next(&mut self) -> Option<&'static str> {
return (*self.statefn)(self);
}
}
fn state1(self_: &mut StateMachineIter) -> Option<&'static str> {
self_.statefn = &id(state2 as StateMachineFunc);
//~^ ERROR borrowed val... | type StateMachineFunc<'a> = fn(&mut StateMachineIter<'a>) -> Option<&'static str>; | random_line_split |
static-reference-to-fn-2.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 state1(self_: &mut StateMachineIter) -> Option<&'static str> {
self_.statefn = &id(state2 as StateMachineFunc);
//~^ ERROR borrowed value does not live long enough
return Some("state1");
}
fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> {
self_.statefn = &id(state3 as StateMach... | {
return (*self.statefn)(self);
} | identifier_body |
static-reference-to-fn-2.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 ... | (self_: &mut StateMachineIter) -> Option<&'static str> {
self_.statefn = &id(state2 as StateMachineFunc);
//~^ ERROR borrowed value does not live long enough
return Some("state1");
}
fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> {
self_.statefn = &id(state3 as StateMachineFunc);
... | state1 | identifier_name |
main.rs | #![feature(core_intrinsics, asm)]
#![feature(start, lang_items)]
#![allow(clippy::missing_safety_doc, unused_imports, dead_code)]
use core::intrinsics::likely;
use faf::const_concat_bytes;
use faf::const_http::*;
use faf::util::{const_len, memcmp};
const ROUTE_PLAINTEXT: &[u8] = b"/plaintext";
const ROUTE_PLAINTEXT_L... | {
faf::epoll::go(8089, cb);
} | identifier_body | |
main.rs | #![feature(core_intrinsics, asm)]
#![feature(start, lang_items)]
#![allow(clippy::missing_safety_doc, unused_imports, dead_code)]
use core::intrinsics::likely;
use faf::const_concat_bytes;
use faf::const_http::*;
use faf::util::{const_len, memcmp};
const ROUTE_PLAINTEXT: &[u8] = b"/plaintext";
const ROUTE_PLAINTEXT_L... | () {
faf::epoll::go(8089, cb);
}
| main | identifier_name |
main.rs | #![feature(core_intrinsics, asm)]
#![feature(start, lang_items)]
#![allow(clippy::missing_safety_doc, unused_imports, dead_code)]
use core::intrinsics::likely;
use faf::const_concat_bytes;
use faf::const_http::*;
use faf::util::{const_len, memcmp};
const ROUTE_PLAINTEXT: &[u8] = b"/plaintext";
const ROUTE_PLAINTEXT_L... |
} else {
0
}
}
}
pub fn main() {
faf::epoll::go(8089, cb);
}
| {
core::ptr::copy_nonoverlapping(HTTP_405_NOTALLOWED.as_ptr(), response_buffer, HTTP_405_NOTALLOWED_LEN);
HTTP_405_NOTALLOWED_LEN
} | conditional_block |
main.rs | #![feature(core_intrinsics, asm)]
#![feature(start, lang_items)]
#![allow(clippy::missing_safety_doc, unused_imports, dead_code)]
use core::intrinsics::likely;
use faf::const_concat_bytes;
use faf::const_http::*;
use faf::util::{const_len, memcmp};
const ROUTE_PLAINTEXT: &[u8] = b"/plaintext";
const ROUTE_PLAINTEXT_L... |
const PLAINTEXT_BASE_LEN: usize = const_len(PLAINTEXT_BASE);
const PLAINTEXT_TEST: &[u8] = b"HTTP/1.1 200 OK\r\nServer: F\r\nContent-Type: text/plain\r\nContent-Length: 13\r\nDate: Thu, 18 Nov 2021 23:15:07 GMT\r\n\r\nHello, World!";
const PLAINTEXT_TEST_LEN: usize = const_len(PLAINTEXT_TEST);
#[inline]
fn cb(
me... | CRLF
); | random_line_split |
lib.rs | extern crate bigtable as bt;
#[macro_use]
extern crate error_chain;
extern crate libc;
extern crate goauth;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate protobuf;
extern crate rustc_serialize;
mod fdw_error {
error_chain! {
foreign_links {
FromUtf8(::std::string... | #[allow(non_snake_case)]
#[allow(non_upper_case_globals)]
mod pg; // Generated PG bindings
mod structs;
static mut LIMIT: Option<i64> = Some(0); | #[allow(non_camel_case_types)]
#[allow(improper_ctypes)] | random_line_split |
mod.rs | #![cfg_attr(test, allow(dead_code))]
use ::scene::{Camera, Scene};
pub mod bunny;
pub mod cornell;
pub mod cow;
pub mod easing;
pub mod fresnel;
pub mod heptoroid;
pub mod lucy;
pub mod sibenik;
pub mod sphere;
pub mod sponza;
pub mod tachikoma;
pub mod teapot;
pub trait SceneConfig {
fn get_camera(&self, image_w... |
pub fn scene_by_name(name: &str) -> Option<Box<SceneConfig>> {
Some(match name {
"bunny" => Box::new(bunny::BunnyConfig),
"cornell" => Box::new(cornell::CornelConfig),
"cow" => Box::new(cow::CowConfig),
"easing" => Box::new(easing::EasingConfig),
"fresnel" => Box::new(fresne... | random_line_split | |
mod.rs | #![cfg_attr(test, allow(dead_code))]
use ::scene::{Camera, Scene};
pub mod bunny;
pub mod cornell;
pub mod cow;
pub mod easing;
pub mod fresnel;
pub mod heptoroid;
pub mod lucy;
pub mod sibenik;
pub mod sphere;
pub mod sponza;
pub mod tachikoma;
pub mod teapot;
pub trait SceneConfig {
fn get_camera(&self, image_w... |
fn get_scene(&self) -> Scene;
}
pub fn scene_by_name(name: &str) -> Option<Box<SceneConfig>> {
Some(match name {
"bunny" => Box::new(bunny::BunnyConfig),
"cornell" => Box::new(cornell::CornelConfig),
"cow" => Box::new(cow::CowConfig),
"easing" => Box::new(easing::EasingConfig)... | {
self.get_camera(image_width, image_height, fov)
} | identifier_body |
mod.rs | #![cfg_attr(test, allow(dead_code))]
use ::scene::{Camera, Scene};
pub mod bunny;
pub mod cornell;
pub mod cow;
pub mod easing;
pub mod fresnel;
pub mod heptoroid;
pub mod lucy;
pub mod sibenik;
pub mod sphere;
pub mod sponza;
pub mod tachikoma;
pub mod teapot;
pub trait SceneConfig {
fn get_camera(&self, image_w... | (name: &str) -> Option<Box<SceneConfig>> {
Some(match name {
"bunny" => Box::new(bunny::BunnyConfig),
"cornell" => Box::new(cornell::CornelConfig),
"cow" => Box::new(cow::CowConfig),
"easing" => Box::new(easing::EasingConfig),
"fresnel" => Box::new(fresnel::FresnelConfig),
... | scene_by_name | identifier_name |
image.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/. */
//! Generic types for the handling of [images].
//!
//! [images]: https://drafts.csswg.org/css-images/#image-valu... | <LineDirection, Length, LengthOrPercentage, Position, Angle> {
/// A linear gradient.
Linear(LineDirection),
/// A radial gradient.
Radial(
EndingShape<Length, LengthOrPercentage>,
Position,
Option<Angle>,
),
}
/// A radial gradient's ending shape.
#[derive(Clone, Copy, Debu... | GradientKind | identifier_name |
image.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/. */
//! Generic types for the handling of [images].
//!
//! [images]: https://drafts.csswg.org/css-images/#image-valu... | Extent(ShapeExtent),
}
/// An ellipse shape.
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
pub enum Ellipse<LengthOrPercentage> {
/// An ellipse pair of radii.
Radii(LengthOrPercentage, LengthOrPercentage),
/// An ellipse extent.
Extent(ShapeExtent),
}
/// <https:/... | #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
pub enum Circle<Length> {
/// A circle radius.
Radius(Length),
/// A circle extent. | random_line_split |
image.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/. */
//! Generic types for the handling of [images].
//!
//! [images]: https://drafts.csswg.org/css-images/#image-valu... | ,
GradientKind::Radial(ref shape, ref position, ref angle) => {
let omit_shape = match *shape {
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::Cover)) |
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::FarthestCorner)) => true,
... | {
direction.to_css(dest, self.compat_mode)?;
false
} | conditional_block |
nutation.rs | /*
Copyright (c) 2015, 2016 Saurav Sachidanand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, di... |
#[test]
fn nutation_in_eq_coords() {
let eq_point = coords::EqPoint {
asc: 41.5555635_f64.to_radians(),
dec: 49.3503415_f64.to_radians()
};
let (a, b) = nutation::nutation_in_eq_coords(
&eq_point,
angle::deg_frm_dms(0, 0, 14.861).to_radians(),
angle::deg_frm_dms(0,... | {
let (nut_in_long, nut_in_oblq) = nutation::nutation(2446895.5);
let (d1, m1, s1) = angle::dms_frm_deg(nut_in_long.to_degrees());
assert_eq!((d1, m1, util::round_upto_digits(s1, 3)), (0, 0, -3.788));
let (d2, m2, s2) = angle::dms_frm_deg(nut_in_oblq.to_degrees());
assert_eq!((d2, m2, util::round... | identifier_body |
nutation.rs | /*
Copyright (c) 2015, 2016 Saurav Sachidanand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, di... | () {
let eq_point = coords::EqPoint {
asc: 41.5555635_f64.to_radians(),
dec: 49.3503415_f64.to_radians()
};
let (a, b) = nutation::nutation_in_eq_coords(
&eq_point,
angle::deg_frm_dms(0, 0, 14.861).to_radians(),
angle::deg_frm_dms(0, 0, 2.705).to_radians(),
2... | nutation_in_eq_coords | identifier_name |
nutation.rs | /*
Copyright (c) 2015, 2016 Saurav Sachidanand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, di... | #![allow(non_snake_case)]
extern crate astro;
use astro::*;
#[test]
fn nutation() {
let (nut_in_long, nut_in_oblq) = nutation::nutation(2446895.5);
let (d1, m1, s1) = angle::dms_frm_deg(nut_in_long.to_degrees());
assert_eq!((d1, m1, util::round_upto_digits(s1, 3)), (0, 0, -3.788));
let (d2, m2, s2)... | */
| random_line_split |
oneshot.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 ... | // Not possible, these are one-use channels
DATA => unreachable!(),
// There is a thread waiting on the other end. We leave the 'DATA'
// state inside so it'll pick it up on the other end.
ptr => unsafe {
SignalToken::cast_from_usize(ptr).sign... | {
// Sanity check
match self.upgrade {
NothingSent => {}
_ => panic!("sending on a oneshot that's already sent on "),
}
assert!(self.data.is_none());
self.data = Some(t);
self.upgrade = SendUsed;
match self.state.swap(DATA, Ordering::SeqCs... | identifier_body |
oneshot.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 ... | SelCanceled,
SelUpgraded(SignalToken, Receiver<T>),
SelSuccess,
}
enum MyUpgrade<T> {
NothingSent,
SendUsed,
GoUp(Receiver<T>),
}
impl<T> Packet<T> {
pub fn new() -> Packet<T> {
Packet {
data: None,
upgrade: NothingSent,
state: AtomicUsize::new(E... | pub enum SelectionResult<T> { | random_line_split |
oneshot.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 ... | (&mut self) -> Result<bool, Receiver<T>> {
let state = match self.state.load(Ordering::SeqCst) {
// Each of these states means that no further activity will happen
// with regard to abortion selection
s @ EMPTY |
s @ DATA |
s @ DISCONNECTED => s,
... | abort_selection | identifier_name |
page.rs | use iron::prelude::*;
use iron::middleware::Handler;
use iron::status;
use iron::headers::{ContentType};
use utils::Utils;
use rustview::view::View;
pub struct Index {
utils: Utils,
template: View,
}
impl Index {
pub fn new(utils: Utils, admin_template: View) -> Index {
Index {
utils:... | "newTitle": "New Cool Title here :)",
"helloUser": "Hi Andrei!",
"testText": "It's working!!!!!",
"user": "Andrei",
"child_user": "Pages"
});
let mut response = Response::with((status::Ok, self.template.render("home.html", model)));
re... | let model = json!({
"title": "Testing", | random_line_split |
page.rs | use iron::prelude::*;
use iron::middleware::Handler;
use iron::status;
use iron::headers::{ContentType};
use utils::Utils;
use rustview::view::View;
pub struct Index {
utils: Utils,
template: View,
}
impl Index {
pub fn new(utils: Utils, admin_template: View) -> Index |
}
impl Handler for Index {
fn handle(&self, req: &mut Request) -> IronResult<Response> {
let model = json!({
"title": "Testing",
"newTitle": "New Cool Title here :)",
"helloUser": "Hi Andrei!",
"testText": "It's working!!!!!",
"user": "Andrei",
... | {
Index {
utils: utils,
template: admin_template,
}
} | identifier_body |
page.rs | use iron::prelude::*;
use iron::middleware::Handler;
use iron::status;
use iron::headers::{ContentType};
use utils::Utils;
use rustview::view::View;
pub struct | {
utils: Utils,
template: View,
}
impl Index {
pub fn new(utils: Utils, admin_template: View) -> Index {
Index {
utils: utils,
template: admin_template,
}
}
}
impl Handler for Index {
fn handle(&self, req: &mut Request) -> IronResult<Response> {
let... | Index | identifier_name |
lib.rs | //! Provides a Cursor abstraction for use with the `postgres` crate.
//!
//! # Examples
//!
//! ```no_run
//! extern crate postgres;
//! extern crate postgres_cursor;
//!
//! use postgres::{Connection, TlsMode};
//! use postgres_cursor::Cursor;
//!
//! # fn main() {
//!
//! // First, establish a connection with postgre... |
/// Set the tag for cursor name.
///
/// Adding a tag to the cursor name can be helpful for identifying where
/// cursors originate when viewing `pg_stat_activity`.
///
/// Default is `default`.
///
/// # Examples
///
/// Any type that implements `fmt::Display` may be provided ... | {
self.batch_size = batch_size;
self
} | identifier_body |
lib.rs | //! Provides a Cursor abstraction for use with the `postgres` crate.
//!
//! # Examples
//!
//! ```no_run
//! extern crate postgres;
//! extern crate postgres_cursor;
//!
//! use postgres::{Connection, TlsMode};
//! use postgres_cursor::Cursor;
//!
//! # fn main() {
//!
//! // First, establish a connection with postgre... | <'c, 'a, D>(builder: Builder<'c, 'a, D>) -> postgres::Result<Cursor<'c>>
where D: fmt::Display +?Sized
{
let mut bytes: [u8; 8] = unsafe { mem::uninitialized() };
thread_rng().fill_bytes(&mut bytes[..]);
let cursor_name = format!("cursor:{}:{}", builder.tag, Hex(&bytes));
le... | new | identifier_name |
lib.rs | //! Provides a Cursor abstraction for use with the `postgres` crate.
//!
//! # Examples
//!
//! ```no_run
//! extern crate postgres;
//! extern crate postgres_cursor;
//!
//! use postgres::{Connection, TlsMode};
//! use postgres_cursor::Cursor;
//!
//! # fn main() {
//!
//! // First, establish a connection with postgre... |
Ok(())
}
}
impl<'a> Drop for Cursor<'a> {
fn drop(&mut self) {
let _ = self.close();
}
}
/// Builds a Cursor
///
/// This type is constructed by calling `Cursor::build`.
pub struct Builder<'conn, 'builder, D:?Sized + 'builder> {
batch_size: u32,
query: &'builder str,
conn: &'... | {
let close_query = format!("CLOSE \"{}\"", self.cursor_name);
self.conn.execute(&close_query[..], &[])?;
self.conn.execute("COMMIT", &[])?;
self.closed = true;
} | conditional_block |
lib.rs | //! Provides a Cursor abstraction for use with the `postgres` crate.
//!
//! # Examples
//!
//! ```no_run
//! extern crate postgres;
//! extern crate postgres_cursor;
//!
//! use postgres::{Connection, TlsMode};
//! use postgres_cursor::Cursor;
//!
//! # fn main() {
//!
//! // First, establish a connection with postgre... | /// Builds a Cursor
///
/// This type is constructed by calling `Cursor::build`.
pub struct Builder<'conn, 'builder, D:?Sized + 'builder> {
batch_size: u32,
query: &'builder str,
conn: &'conn Connection,
tag: &'builder D,
params: &'builder [&'builder ToSql],
}
impl<'conn, 'builder, D: fmt::Display ... | }
| random_line_split |
read.rs | use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use std::io;
use std::pin::Pin;
/// Future for the [`read`](super::AsyncReadExt::read) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Read<'a, R:?Sized> {
re... | impl<R:?Sized + Unpin> Unpin for Read<'_, R> {}
impl<'a, R: AsyncRead +?Sized + Unpin> Read<'a, R> {
pub(super) fn new(reader: &'a mut R, buf: &'a mut [u8]) -> Self {
Read { reader, buf }
}
}
impl<R: AsyncRead +?Sized + Unpin> Future for Read<'_, R> {
type Output = io::Result<usize>;
fn poll(... | buf: &'a mut [u8],
}
| random_line_split |
read.rs | use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use std::io;
use std::pin::Pin;
/// Future for the [`read`](super::AsyncReadExt::read) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct | <'a, R:?Sized> {
reader: &'a mut R,
buf: &'a mut [u8],
}
impl<R:?Sized + Unpin> Unpin for Read<'_, R> {}
impl<'a, R: AsyncRead +?Sized + Unpin> Read<'a, R> {
pub(super) fn new(reader: &'a mut R, buf: &'a mut [u8]) -> Self {
Read { reader, buf }
}
}
impl<R: AsyncRead +?Sized + Unpin> Future fo... | Read | identifier_name |
read.rs | use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use std::io;
use std::pin::Pin;
/// Future for the [`read`](super::AsyncReadExt::read) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Read<'a, R:?Sized> {
re... |
}
impl<R: AsyncRead +?Sized + Unpin> Future for Read<'_, R> {
type Output = io::Result<usize>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = &mut *self;
Pin::new(&mut this.reader).poll_read(cx, this.buf)
}
}
| {
Read { reader, buf }
} | identifier_body |
mod.rs | // This Source Code Form is subject to the terms of the GNU General Public
// License, version 3. If a copy of the GPL was not distributed with this file,
// You can obtain one at https://www.gnu.org/licenses/gpl.txt.
pub(super) mod tostr;
use crate::{path::ConcretePath, tree::Tree, value::Value};
use failure::Fallibl... |
}
impl fmt::Debug for Box<dyn NativeFunc + Send + Sync> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<Unknown NativeFunc>")
}
}
| {
self.box_clone()
} | identifier_body |
mod.rs | // This Source Code Form is subject to the terms of the GNU General Public
// License, version 3. If a copy of the GPL was not distributed with this file,
// You can obtain one at https://www.gnu.org/licenses/gpl.txt.
pub(super) mod tostr;
use crate::{path::ConcretePath, tree::Tree, value::Value};
use failure::Fallibl... | (&self) -> Box<dyn NativeFunc + Send + Sync> {
self.box_clone()
}
}
impl fmt::Debug for Box<dyn NativeFunc + Send + Sync> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<Unknown NativeFunc>")
}
}
| clone | identifier_name |
mod.rs | // This Source Code Form is subject to the terms of the GNU General Public
// License, version 3. If a copy of the GPL was not distributed with this file,
// You can obtain one at https://www.gnu.org/licenses/gpl.txt.
pub(super) mod tostr;
use crate::{path::ConcretePath, tree::Tree, value::Value};
use failure::Fallibl... | }
} | impl fmt::Debug for Box<dyn NativeFunc + Send + Sync> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<Unknown NativeFunc>") | random_line_split |
comm_adapters.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 ... |
}
#[cfg(test)]
mod test {
use prelude::v1::*;
use sync::mpsc::channel;
use super::*;
use old_io;
use thread::Thread;
#[test]
fn test_rx_reader() {
let (tx, rx) = channel();
Thread::spawn(move|| {
tx.send(vec![1u8, 2u8]).unwrap();
tx.send(vec![]).unwra... | {
self.tx.send(buf.to_vec()).map_err(|_| {
old_io::IoError {
kind: old_io::BrokenPipe,
desc: "Pipe closed",
detail: None
}
})
} | identifier_body |
comm_adapters.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 ... | if num_read == buf.len() || self.closed {
break;
}
}
if self.closed && num_read == 0 {
Err(old_io::standard_error(old_io::EndOfFile))
} else {
Ok(num_read)
}
}
}
/// Allows writing to a tx.
///
/// # Example
///
/// ```... | self.consume(count);
num_read += count; | random_line_split |
comm_adapters.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 ... |
}
}
if self.closed {
Err(old_io::standard_error(old_io::EndOfFile))
} else {
Ok(&self.buf[self.pos..])
}
}
fn consume(&mut self, amt: uint) {
self.pos += amt;
assert!(self.pos <= self.buf.len());
}
}
impl Reader for ChanR... | {
self.closed = true;
self.buf = Vec::new();
} | conditional_block |
comm_adapters.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&mut self, buf: &mut [u8]) -> IoResult<uint> {
let mut num_read = 0;
loop {
let count = match self.fill_buf().ok() {
Some(src) => {
let dst = &mut buf[num_read..];
let count = cmp::min(src.len(), dst.len());
bytes::... | read | identifier_name |
lib.rs | //! An asynchronous implementation of [STUN][RFC 5389] server and client.
//!
//! # Examples
//!
//! An example that issues a `BINDING` request:
//!
//! ```
//! # extern crate fibers_global;
//! # extern crate fibers_transport;
//! # extern crate futures;
//! # extern crate rustun;
//! # extern crate stun_codec;
//! # ... | () -> Result<(), MainError> {
let server = fibers_global::execute(UdpServer::start(
fibers_global::handle(),
"127.0.0.1:0".parse().unwrap(),
BindingHandler,
))?;
let server_addr = server.local_addr();
fibers_global::spawn(server.map(|_| ()).map_err(|e|... | basic_udp_test | identifier_name |
lib.rs | //! An asynchronous implementation of [STUN][RFC 5389] server and client.
//!
//! # Examples
//!
//! An example that issues a `BINDING` request:
//!
//! ```
//! # extern crate fibers_global;
//! # extern crate fibers_transport;
//! # extern crate futures;
//! # extern crate rustun;
//! # extern crate stun_codec;
//! # ... | let response = track!(fibers_global::execute(response))?;
assert!(response.is_ok());
Ok(())
}
}
| {
let server = fibers_global::execute(TcpServer::start(
fibers_global::handle(),
"127.0.0.1:0".parse().unwrap(),
DefaultFactory::<BindingHandler>::new(),
))?;
let server_addr = server.local_addr();
fibers_global::spawn(server.map(|_| ()).map_err(|e| p... | identifier_body |
lib.rs | //! An asynchronous implementation of [STUN][RFC 5389] server and client.
//!
//! # Examples
//!
//! An example that issues a `BINDING` request:
//!
//! ```
//! # extern crate fibers_global;
//! # extern crate fibers_transport;
//! # extern crate futures;
//! # extern crate rustun;
//! # extern crate stun_codec;
//! # ... | fibers_global::spawn(server.map(|_| ()).map_err(|e| panic!("{}", e)));
thread::sleep(Duration::from_millis(50));
let response = TcpTransporter::<MessageEncoder<_>, MessageDecoder<_>>::connect(server_addr)
.map_err(Error::from)
.map(StunTcpTransporter::new)
.map(... | random_line_split | |
popups.rs | use core::fmt::Write;
use libtww::game::Console;
use libtww::game::Flag;
use libtww::system::get_frame_count;
use libtww::system::memory::read;
use libtww::Addr;
use crate::flag_menu::FLAGS;
static mut global_flags_cache: [u8; 64] = [0; 64];
static mut end_frame: u32 = 0;
pub static mut visible: bool = false;
static ... | else {
let _ = write!(
console.lines[0].begin(),
"Flag {:02X} {} has been set",
0xFF & addr,
bit
);
}
}
for (index, cached_value) in unsafe { global_flags_cache.iter_mut().enumerate() } {
let addr = 0x803B8... | {
let text = if text.len() > 50 { &text[..50] } else { text };
let _ = write!(console.lines[0].begin(), "{}", text);
} | conditional_block |
popups.rs | use core::fmt::Write;
use libtww::game::Console;
use libtww::game::Flag;
use libtww::system::get_frame_count;
use libtww::system::memory::read;
use libtww::Addr;
use crate::flag_menu::FLAGS;
static mut global_flags_cache: [u8; 64] = [0; 64];
static mut end_frame: u32 = 0;
pub static mut visible: bool = false;
static ... | {
unsafe {
end_frame = get_frame_count() + 200;
visible = true;
flag = Flag(addr, bit);
}
} | identifier_body | |
popups.rs | use core::fmt::Write;
use libtww::game::Console;
use libtww::game::Flag;
use libtww::system::get_frame_count;
use libtww::system::memory::read;
use libtww::Addr;
use crate::flag_menu::FLAGS;
static mut global_flags_cache: [u8; 64] = [0; 64];
static mut end_frame: u32 = 0;
pub static mut visible: bool = false;
static ... | (f: Flag) -> Option<&'static str> {
for &(text, known_flag) in FLAGS.iter() {
if known_flag == f {
return Some(text);
}
}
None
}
pub fn check_global_flags() {
if unsafe { visible } && get_frame_count() > unsafe { end_frame } {
unsafe {
visible = false;
... | get_flag_str | identifier_name |
popups.rs | use core::fmt::Write;
use libtww::game::Console;
use libtww::game::Flag;
use libtww::system::get_frame_count;
use libtww::system::memory::read;
use libtww::Addr;
use crate::flag_menu::FLAGS;
static mut global_flags_cache: [u8; 64] = [0; 64];
static mut end_frame: u32 = 0;
pub static mut visible: bool = false;
static ... | let current_value = read::<u8>(addr);
let diff = current_value & (0xFF ^ *cached_value);
if diff!= 0 {
for bit in 0..8 {
if diff & (1 << bit)!= 0 {
show_popup(addr, bit);
}
}
*cached_value |= diff;
}
... |
for (index, cached_value) in unsafe { global_flags_cache.iter_mut().enumerate() } {
let addr = 0x803B872C + index; | random_line_split |
entry.rs | use memory::Frame;
pub struct Entry(u64);
impl Entry {
pub fn is_unused(&self) -> bool {
self.0 == 0
}
pub fn set_unused(&mut self) {
self.0 = 0
}
pub fn flags(&self) -> EntryFlags {
EntryFlags::from_bits_truncate(self.0)
}
pub fn pointed_frame(&self) -> Option<F... | const NO_CACHE = 1 << 4,
const ACCESSED = 1 << 5,
const DIRTY = 1 << 6,
const HUGE_PAGE = 1 << 7,
const GLOBAL = 1 << 8,
const NO_EXECUTE = 1 << 63,
}
} | const WRITE_THROUGH = 1 << 3, | random_line_split |
entry.rs | use memory::Frame;
pub struct Entry(u64);
impl Entry {
pub fn is_unused(&self) -> bool {
self.0 == 0
}
pub fn set_unused(&mut self) {
self.0 = 0
}
pub fn flags(&self) -> EntryFlags {
EntryFlags::from_bits_truncate(self.0)
}
pub fn pointed_frame(&self) -> Option<F... |
}
pub fn set(&mut self, frame: Frame, flags: EntryFlags) {
assert!(frame.start_address() &! 0x000fffff_fffff000 == 0);
self.0 = (frame.start_address() as u64) | flags.bits();
}
}
bitflags! {
pub flags EntryFlags: u64 {
const PRESENT = 1 << 0,
const WRITABLE = ... | {
None
} | conditional_block |
entry.rs | use memory::Frame;
pub struct Entry(u64);
impl Entry {
pub fn | (&self) -> bool {
self.0 == 0
}
pub fn set_unused(&mut self) {
self.0 = 0
}
pub fn flags(&self) -> EntryFlags {
EntryFlags::from_bits_truncate(self.0)
}
pub fn pointed_frame(&self) -> Option<Frame> {
if self.flags().contains(PRESENT) {
Some(Frame::c... | is_unused | identifier_name |
mod.rs | // Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#[cfg(feature = "libvda")]
pub mod vda;
use base::AsRawDescriptor;
use crate::virtio::video::error::VideoResult;
use crate::virtio::video::{
form... |
/// Requests the encoder to flush. When completed, an `EncoderEvent::FlushResponse` event will
/// be readable from the event pipe.
fn flush(&mut self) -> VideoResult<()>;
/// Requests the encoder to use new encoding parameters provided by `bitrate` and `framerate`.
fn request_encoding_params_chan... | &mut self,
resource: GuestResourceHandle,
offset: u32,
size: u32,
) -> VideoResult<OutputBufferId>; | random_line_split |
generic-type-params-name-repr.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | let _: HashMap<String, int> = ();
//~^ ERROR mismatched types: expected `HashMap<std::string::String,int>` but found `()`
let _: HashMap<String, int, Hash<String>> = ();
//~^ ERROR mismatched types: expected `HashMap<std::string::String,int>` but found `()`
// But not when there's a different type ... | // Including cases where the default is using previous type params. | random_line_split |
generic-type-params-name-repr.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | ;
struct C;
struct Foo<T = A, U = B, V = C>;
struct Hash<T>;
struct HashMap<K, V, H = Hash<K>>;
fn main() {
// Ensure that the printed type doesn't include the default type params...
let _: Foo<int> = ();
//~^ ERROR mismatched types: expected `Foo<int>` but found `()`
//...even when they're present, ... | B | identifier_name |
download.rs | use async_trait::async_trait;
use cucumber::given;
use snafu::ResultExt;
use crate::error;
use crate::error::Error;
use crate::state::{GlobalState, State, Step, StepStatus};
use tests::download;
// Download OSM
#[given(regex = r"osm file has been downloaded for (\S+)$")]
pub async fn download_osm(state: &mut GlobalS... | (&mut self, _state: &State) -> Result<StepStatus, Error> {
let Self { region } = self;
download::ntfs(region)
.await
.map(|status| status.into())
.context(error::DownloadSnafu)
}
}
| execute | identifier_name |
download.rs | use async_trait::async_trait;
use cucumber::given;
use snafu::ResultExt;
use crate::error;
use crate::error::Error;
use crate::state::{GlobalState, State, Step, StepStatus};
use tests::download;
// Download OSM
#[given(regex = r"osm file has been downloaded for (\S+)$")]
pub async fn download_osm(state: &mut GlobalS... |
}
| {
let Self { region } = self;
download::ntfs(region)
.await
.map(|status| status.into())
.context(error::DownloadSnafu)
} | identifier_body |
download.rs | use async_trait::async_trait;
use cucumber::given;
use snafu::ResultExt;
use crate::error;
use crate::error::Error;
use crate::state::{GlobalState, State, Step, StepStatus};
use tests::download;
// Download OSM
#[given(regex = r"osm file has been downloaded for (\S+)$")]
pub async fn download_osm(state: &mut GlobalS... | state
.execute_once(DownloadBano {
departments,
region,
})
.await
.expect("failed to download OSM file");
}
#[derive(PartialEq)]
pub struct DownloadBano {
pub departments: Vec<String>,
pub region: String,
}
#[async_trait(?Send)]
impl Step for DownloadBa... | random_line_split | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(box_syntax)]
#![feature(custom_derive)]
#![feature(plugin)]
#![feature(mpsc_select)]
#![feature(plugin)... | pub use pipeline::UnprivilegedPipelineContent;
#[cfg(not(target_os = "windows"))]
pub use sandboxing::content_process_sandbox_profile; |
pub use constellation::{Constellation, InitialConstellationState}; | random_line_split |
issue13507.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... | {
pub pub_foo_field: uint,
foo_field: uint
}
// Tests ty_tup
pub type FooTuple = (u8, i8, bool);
// Skipping ty_param
// Skipping ty_self
// Skipping ty_self
// Skipping ty_infer
// Skipping ty_err
}
| FooStruct | identifier_name |
issue13507.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... |
// Tests ty_nil
pub type FooNil = ();
// Skipping ty_bot
// Tests ty_bool
pub type FooBool = bool;
// Tests ty_char
pub type FooChar = char;
// Tests ty_int (does not test all variants of IntTy)
pub type FooInt = int;
// Tests ty_uint (does not test all variants of UintTy)... | {
let mut ids = vec!();
ids.push(TypeId::of::<FooNil>());
ids.push(TypeId::of::<FooBool>());
ids.push(TypeId::of::<FooInt>());
ids.push(TypeId::of::<FooUint>());
ids.push(TypeId::of::<FooFloat>());
ids.push(TypeId::of::<FooEnum>());
ids.push(TypeId::of::<F... | identifier_body |
issue13507.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... | }
// Tests ty_nil
pub type FooNil = ();
// Skipping ty_bot
// Tests ty_bool
pub type FooBool = bool;
// Tests ty_char
pub type FooChar = char;
// Tests ty_int (does not test all variants of IntTy)
pub type FooInt = int;
// Tests ty_uint (does not test all variants of Ui... | ids.push(TypeId::of::<FooTuple>());
ids | random_line_split |
payments.rs | use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use api::ErrorCode;
use errors::ToErrorCode;
use errors::prelude::*;
#[derive(Debug)]
pub enum PaymentsError {
PluggedMethodError(ErrorCode),
UnknownType(String),
CommonError(CommonError),
IncompatiblePaymentError(String),
}
imp... | (&self) -> ErrorCode {
match *self {
PaymentsError::PluggedMethodError(e) => e,
PaymentsError::CommonError(ref err) => err.to_error_code(),
PaymentsError::UnknownType(ref _str) => ErrorCode::PaymentUnknownMethodError,
PaymentsError::IncompatiblePaymentError(ref _s... | to_error_code | identifier_name |
payments.rs | use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use api::ErrorCode;
use errors::ToErrorCode;
use errors::prelude::*;
#[derive(Debug)]
pub enum PaymentsError {
PluggedMethodError(ErrorCode),
UnknownType(String),
CommonError(CommonError),
IncompatiblePaymentError(String),
}
imp... |
}
impl Display for PaymentsError {
fn fmt(&self, _f: &mut Formatter) -> fmt::Result {
match *self {
PaymentsError::CommonError(ref err) => err.fmt(_f),
PaymentsError::PluggedMethodError(_err_code) => write!(_f, "Plugged method error. Consider the error code."),
Payments... | {
match *self {
PaymentsError::CommonError(ref err) => err.description(),
PaymentsError::UnknownType(ref msg) => msg.as_str(),
PaymentsError::PluggedMethodError(_error_code) => "Plugged method error. Consider the error code.",
PaymentsError::IncompatiblePaymentErr... | identifier_body |
payments.rs | use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use api::ErrorCode;
use errors::ToErrorCode;
use errors::prelude::*;
#[derive(Debug)]
pub enum PaymentsError {
PluggedMethodError(ErrorCode),
UnknownType(String),
CommonError(CommonError),
IncompatiblePaymentError(String),
}
imp... | }
}
impl Display for PaymentsError {
fn fmt(&self, _f: &mut Formatter) -> fmt::Result {
match *self {
PaymentsError::CommonError(ref err) => err.fmt(_f),
PaymentsError::PluggedMethodError(_err_code) => write!(_f, "Plugged method error. Consider the error code."),
Pay... | PaymentsError::PluggedMethodError(_error_code) => "Plugged method error. Consider the error code.",
PaymentsError::IncompatiblePaymentError(ref msg) => msg.as_str(),
} | random_line_split |
gamepadbuttonlist.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::bindings::codegen::Bindings::GamepadButtonListBinding;
use crate::dom::bindings::codegen::Binding... |
}
| {
self.Item(index)
} | identifier_body |
gamepadbuttonlist.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::bindings::codegen::Bindings::GamepadButtonListBinding;
use crate::dom::bindings::codegen::Binding... | self.list.len() as u32
}
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
fn Item(&self, index: u32) -> Option<DomRoot<GamepadButton>> {
self.list
.get(index as usize)
.map(|button| DomRoot::from_ref(&**button))
}
// https://w3c.github.io/gamepad/#dom-gam... |
impl GamepadButtonListMethods for GamepadButtonList {
// https://w3c.github.io/gamepad/#dom-gamepad-buttons
fn Length(&self) -> u32 { | random_line_split |
gamepadbuttonlist.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::bindings::codegen::Bindings::GamepadButtonListBinding;
use crate::dom::bindings::codegen::Binding... | (&self, index: u32) -> Option<DomRoot<GamepadButton>> {
self.Item(index)
}
}
| IndexedGetter | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.