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
dependency_graph.rs
//! Functions related to working with dependency graphs //! //! For example, given a set of maybe recursive functions, you want //! to order them such that the type signatures can be determined completely. //! If you put mutually recursive functions together in groups, these groups //! can then be placed in a DAG of de...
/// Group sets of circularly referencing bindings together, to make /// the inter-group relation acyclic. fn group_by_circularity<'src>( mut bindings: BTreeMap<&'src str, Binding<'src>>, siblings_out_refs: &BTreeMap<&'src str, BTreeSet<&'src str>>, ) -> BTreeMap<usize, Group<'src>> { let mut n = 0; le...
{ let mut visited = BTreeSet::new(); circular_def_members_(s, s, siblings_out_refs, &mut visited) }
identifier_body
load.rs
use cpython::{PyDict, PyList, PyObject, PyResult, PyString, Python, PythonObject, ToPyObject}; use linked_hash_map::LinkedHashMap; use yaml_rust::{Yaml, YamlLoader}; fn convert_yaml_to_dict(py: Python, yaml: &LinkedHashMap<Yaml, Yaml>) -> PyDict { yaml.iter().fold(PyDict::new(py), |acc, (k, v)| { let key =...
(py: Python, yaml: &Yaml) -> PyObject { match &yaml { Yaml::Null => py.None(), Yaml::Hash(_) => convert_yaml_to_dict(py, yaml.as_hash().unwrap()).into_object(), Yaml::String(_) => PyString::new(py, yaml.as_str().unwrap()).into_object(), Yaml::Integer(_) => yaml.as_i64().unwrap().to_p...
from_yaml_to_python
identifier_name
load.rs
use cpython::{PyDict, PyList, PyObject, PyResult, PyString, Python, PythonObject, ToPyObject}; use linked_hash_map::LinkedHashMap; use yaml_rust::{Yaml, YamlLoader}; fn convert_yaml_to_dict(py: Python, yaml: &LinkedHashMap<Yaml, Yaml>) -> PyDict { yaml.iter().fold(PyDict::new(py), |acc, (k, v)| { let key =...
Err(e) => panic!("Cannot convert Python string into &str: {:?}", e), }; // Load first doc from stream let docs = match YamlLoader::load_from_str(&native_stream) { Ok(d) => d, Err(e) => panic!("{:?}", e), }; let doc = &docs[0]; // Convert into proper Python's objects ...
random_line_split
load.rs
use cpython::{PyDict, PyList, PyObject, PyResult, PyString, Python, PythonObject, ToPyObject}; use linked_hash_map::LinkedHashMap; use yaml_rust::{Yaml, YamlLoader}; fn convert_yaml_to_dict(py: Python, yaml: &LinkedHashMap<Yaml, Yaml>) -> PyDict { yaml.iter().fold(PyDict::new(py), |acc, (k, v)| { let key =...
pub fn safe_load(py: Python, stream: &PyString) -> PyResult<PyObject> { // Convert stream into Rust string let native_stream = match stream.to_string(py) { Ok(s) => s, Err(e) => panic!("Cannot convert Python string into &str: {:?}", e), }; // Load first doc from stream let docs = ...
{ match &yaml { Yaml::Null => py.None(), Yaml::Hash(_) => convert_yaml_to_dict(py, yaml.as_hash().unwrap()).into_object(), Yaml::String(_) => PyString::new(py, yaml.as_str().unwrap()).into_object(), Yaml::Integer(_) => yaml.as_i64().unwrap().to_py_object(py).into_object(), Ya...
identifier_body
load.rs
use cpython::{PyDict, PyList, PyObject, PyResult, PyString, Python, PythonObject, ToPyObject}; use linked_hash_map::LinkedHashMap; use yaml_rust::{Yaml, YamlLoader}; fn convert_yaml_to_dict(py: Python, yaml: &LinkedHashMap<Yaml, Yaml>) -> PyDict { yaml.iter().fold(PyDict::new(py), |acc, (k, v)| { let key =...
, Yaml::Alias(_) => unimplemented!(), // Not supported yet http://chyh1990.github.io/yaml-rust/doc/yaml_rust/yaml/enum.Yaml.html#variant.Alias Yaml::BadValue => panic!("Bad value converting {:?}", yaml), } } pub fn safe_load(py: Python, stream: &PyString) -> PyResult<PyObject> { // Convert stre...
{ py.False().into_object() }
conditional_block
multiplexed.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may n...
else { stored.processors.insert(name, processor); Ok(()) } } else { Err(format!("cannot overwrite existing processor for service {}", name).into()) } } fn process_message( &self, msg_ident: &TMessageIdentifier, i_p...
{ if stored.default_processor.is_none() { stored.processors.insert(name, processor.clone()); stored.default_processor = Some(processor.clone()); Ok(()) } else { Err("cannot reset default processor".into()) ...
conditional_block
multiplexed.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may n...
() { let ident_name = "foo:bar_call"; let (serv, call) = split_ident_name(&ident_name); assert_eq!(serv, Some("foo")); assert_eq!(call, "bar_call"); } #[test] fn should_return_full_ident_if_no_separator_exists() { let ident_name = "bar_call"; let (serv, call)...
should_split_name_into_proper_separator_and_service_call
identifier_name
multiplexed.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may n...
let mut proxy_i_prot = TStoredInputProtocol::new(i_prot, new_msg_ident); (*arc).process(&mut proxy_i_prot, o_prot) } None => Err(missing_processor_message(svc_name).into()), } } } impl TProcessor for TMultiplexedProcessor { fn process( &s...
{ let (svc_name, svc_call) = split_ident_name(&msg_ident.name); debug!("routing svc_name {:?} svc_call {}", &svc_name, &svc_call); let processor: Option<Arc<ThreadSafeProcessor>> = { let stored = self.stored.lock().unwrap(); if let Some(name) = svc_name { ...
identifier_body
multiplexed.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may n...
// under the License. use log::debug; use std::collections::HashMap; use std::convert::Into; use std::fmt; use std::fmt::{Debug, Formatter}; use std::sync::{Arc, Mutex}; use crate::protocol::{TInputProtocol, TMessageIdentifier, TOutputProtocol, TStoredInputProtocol}; use super::{handle_process_result, TProcessor}; ...
random_line_split
permission.rs
use std::{error::Error as StdError, fmt, io::Write, str::FromStr}; use diesel::{backend::Backend, deserialize, serialize, sql_types::Text}; #[derive(AsExpression, Clone, Copy, Debug, Eq, FromSqlRow, Hash, PartialEq)] #[sql_type = "Text"] pub enum Permission { MakePost, MakeMediaPost, MakeComment, Foll...
(&self) -> Option<&dyn StdError> { None } }
cause
identifier_name
permission.rs
use std::{error::Error as StdError, fmt, io::Write, str::FromStr}; use diesel::{backend::Backend, deserialize, serialize, sql_types::Text}; #[derive(AsExpression, Clone, Copy, Debug, Eq, FromSqlRow, Hash, PartialEq)] #[sql_type = "Text"] pub enum Permission { MakePost, MakeMediaPost, MakeComment, Foll...
} impl<DB> deserialize::FromSql<Text, DB> for Permission where DB: Backend<RawValue = [u8]>, { fn from_sql(bytes: Option<&DB::RawValue>) -> deserialize::Result<Self> { deserialize::FromSql::<Text, DB>::from_sql(bytes).and_then(|string: String| { string .parse::<Permission>()...
{ serialize::ToSql::<Text, DB>::to_sql(&format!("{}", self), out) }
identifier_body
permission.rs
use std::{error::Error as StdError, fmt, io::Write, str::FromStr}; use diesel::{backend::Backend, deserialize, serialize, sql_types::Text}; #[derive(AsExpression, Clone, Copy, Debug, Eq, FromSqlRow, Hash, PartialEq)] #[sql_type = "Text"] pub enum Permission { MakePost, MakeMediaPost, MakeComment, Foll...
DB: Backend, { fn to_sql<W: Write>(&self, out: &mut serialize::Output<W, DB>) -> serialize::Result { serialize::ToSql::<Text, DB>::to_sql(&format!("{}", self), out) } } impl<DB> deserialize::FromSql<Text, DB> for Permission where DB: Backend<RawValue = [u8]>, { fn from_sql(bytes: Option<&DB...
impl<DB> serialize::ToSql<Text, DB> for Permission where
random_line_split
box_vec.rs
#![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::blacklisted_name)] macro_rules! boxit { ($init:expr, $x:ty) => { let _: Box<$x> = Box::new($init); }; } fn test_macro() { boxit!(Vec::new(), Vec<u8>); } pub fn test(foo: Box<Vec<bool>>) { prin...
}
test2(Box::new(|v| println!("{:?}", v))); test_macro(); test_local_not_linted();
random_line_split
box_vec.rs
#![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::blacklisted_name)] macro_rules! boxit { ($init:expr, $x:ty) => { let _: Box<$x> = Box::new($init); }; } fn test_macro() { boxit!(Vec::new(), Vec<u8>); } pub fn
(foo: Box<Vec<bool>>) { println!("{:?}", foo.get(0)) } pub fn test2(foo: Box<dyn Fn(Vec<u32>)>) { // pass if #31 is fixed foo(vec![1, 2, 3]) } pub fn test_local_not_linted() { let _: Box<Vec<bool>>; } fn main() { test(Box::new(Vec::new())); test2(Box::new(|v| println!("{:?}", v))); test_m...
test
identifier_name
box_vec.rs
#![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::blacklisted_name)] macro_rules! boxit { ($init:expr, $x:ty) => { let _: Box<$x> = Box::new($init); }; } fn test_macro() { boxit!(Vec::new(), Vec<u8>); } pub fn test(foo: Box<Vec<bool>>) { prin...
{ test(Box::new(Vec::new())); test2(Box::new(|v| println!("{:?}", v))); test_macro(); test_local_not_linted(); }
identifier_body
elf.rs
//! ELF executables use collections::{String, Vec}; use core::{ptr, str}; use common::slice::GetSlice; #[cfg(target_arch = "x86")] use goblin::elf32::{header, program_header}; #[cfg(target_arch = "x86_64")] use goblin::elf64::{header, program_header}; /// An ELF executable pub struct Elf<'a> { pub data: &'a [...
} pub unsafe fn load_segments(&self) -> Vec<program_header::ProgramHeader> { let mut segments = Vec::new(); let header = &*(self.data.as_ptr() as usize as *const header::Header); for i in 0..header.e_phnum { let segment = ptr::read((self.data.as_ptr() as usize + header.e_p...
}
random_line_split
elf.rs
//! ELF executables use collections::{String, Vec}; use core::{ptr, str}; use common::slice::GetSlice; #[cfg(target_arch = "x86")] use goblin::elf32::{header, program_header}; #[cfg(target_arch = "x86_64")] use goblin::elf64::{header, program_header}; /// An ELF executable pub struct
<'a> { pub data: &'a [u8], } impl<'a> Elf<'a> { /// Create a ELF executable from data pub fn from(data: &'a [u8]) -> Result<Elf<'a>, String> { if data.len() < header::SIZEOF_EHDR { Err(format!("Elf: Not enough data: {} < {}", data.len(), header::SIZEOF_EHDR)) } else if data.get_...
Elf
identifier_name
elf.rs
//! ELF executables use collections::{String, Vec}; use core::{ptr, str}; use common::slice::GetSlice; #[cfg(target_arch = "x86")] use goblin::elf32::{header, program_header}; #[cfg(target_arch = "x86_64")] use goblin::elf64::{header, program_header}; /// An ELF executable pub struct Elf<'a> { pub data: &'a [...
}
{ let header = &*(self.data.as_ptr() as usize as *const header::Header); header.e_entry as usize }
identifier_body
elf.rs
//! ELF executables use collections::{String, Vec}; use core::{ptr, str}; use common::slice::GetSlice; #[cfg(target_arch = "x86")] use goblin::elf32::{header, program_header}; #[cfg(target_arch = "x86_64")] use goblin::elf64::{header, program_header}; /// An ELF executable pub struct Elf<'a> { pub data: &'a [...
else if data.get_slice(..header::SELFMAG)!= header::ELFMAG { Err(format!("Elf: Invalid magic: {:?}!= {:?}", data.get_slice(..4), header::ELFMAG)) } else if data.get(header::EI_CLASS)!= Some(&header::ELFCLASS) { Err(format!("Elf: Invalid architecture: {:?}!= {:?}", data.get(header::EI_CL...
{ Err(format!("Elf: Not enough data: {} < {}", data.len(), header::SIZEOF_EHDR)) }
conditional_block
qualified.rs
use syn::ext::IdentExt; use syn::parse::{ParseStream, Result}; use syn::{Ident, LitStr, Token}; pub struct QualifiedName { pub segments: Vec<Ident>, } impl QualifiedName { pub fn parse_unquoted(input: ParseStream) -> Result<Self> { let mut segments = Vec::new(); let mut trailing_punct = true; ...
Ok(QualifiedName { segments }) } else { lit.parse_with(Self::parse_unquoted) } } else { Self::parse_unquoted(input) } } }
if input.peek(LitStr) { let lit: LitStr = input.parse()?; if lit.value().is_empty() { let segments = Vec::new();
random_line_split
qualified.rs
use syn::ext::IdentExt; use syn::parse::{ParseStream, Result}; use syn::{Ident, LitStr, Token}; pub struct QualifiedName { pub segments: Vec<Ident>, } impl QualifiedName { pub fn parse_unquoted(input: ParseStream) -> Result<Self> { let mut segments = Vec::new(); let mut trailing_punct = true; ...
(input: ParseStream) -> Result<Self> { if input.peek(LitStr) { let lit: LitStr = input.parse()?; if lit.value().is_empty() { let segments = Vec::new(); Ok(QualifiedName { segments }) } else { lit.parse_with(Self::parse_unquoted)...
parse_quoted_or_unquoted
identifier_name
qualified.rs
use syn::ext::IdentExt; use syn::parse::{ParseStream, Result}; use syn::{Ident, LitStr, Token}; pub struct QualifiedName { pub segments: Vec<Ident>, } impl QualifiedName { pub fn parse_unquoted(input: ParseStream) -> Result<Self> { let mut segments = Vec::new(); let mut trailing_punct = true; ...
} }
{ Self::parse_unquoted(input) }
conditional_block
main.rs
use std::env;
#[cfg(not(unix))] mod platform { use std::ffi::OsString; pub const BUFFER_CAPACITY: usize = 16 * 1024; pub fn to_bytes(os_str: OsString) -> Vec<u8> { os_str.into_string().expect("non utf-8 argument only supported on unix").into() } } #[cfg(unix)] mod platform { use std::ffi::OsString; ...
use std::io::{self, Write}; use std::process; use std::borrow::Cow;
random_line_split
main.rs
use std::env; use std::io::{self, Write}; use std::process; use std::borrow::Cow; #[cfg(not(unix))] mod platform { use std::ffi::OsString; pub const BUFFER_CAPACITY: usize = 16 * 1024; pub fn to_bytes(os_str: OsString) -> Vec<u8> { os_str.into_string().expect("non utf-8 argument only supported on ...
<'a>(buffer: &'a mut [u8], output: &'a [u8]) -> &'a [u8] { if output.len() > buffer.len() / 2 { return output; } let mut buffer_size = output.len(); buffer[..buffer_size].clone_from_slice(output); while buffer_size < buffer.len() / 2 { let (left, right) = buffer.split_at_mut(buffer...
fill_up_buffer
identifier_name
main.rs
use std::env; use std::io::{self, Write}; use std::process; use std::borrow::Cow; #[cfg(not(unix))] mod platform { use std::ffi::OsString; pub const BUFFER_CAPACITY: usize = 16 * 1024; pub fn to_bytes(os_str: OsString) -> Vec<u8> { os_str.into_string().expect("non utf-8 argument only supported on ...
let mut buffer_size = output.len(); buffer[..buffer_size].clone_from_slice(output); while buffer_size < buffer.len() / 2 { let (left, right) = buffer.split_at_mut(buffer_size); right[..buffer_size].clone_from_slice(left); buffer_size *= 2; } &buffer[..buffer_size] } fn ...
{ return output; }
conditional_block
main.rs
use std::env; use std::io::{self, Write}; use std::process; use std::borrow::Cow; #[cfg(not(unix))] mod platform { use std::ffi::OsString; pub const BUFFER_CAPACITY: usize = 16 * 1024; pub fn to_bytes(os_str: OsString) -> Vec<u8>
} #[cfg(unix)] mod platform { use std::ffi::OsString; pub const BUFFER_CAPACITY: usize = 64 * 1024; pub fn to_bytes(os_str: OsString) -> Vec<u8> { use std::os::unix::ffi::OsStringExt; os_str.into_vec() } } use platform::*; fn fill_up_buffer<'a>(buffer: &'a mut [u8], output: &'a [u8]...
{ os_str.into_string().expect("non utf-8 argument only supported on unix").into() }
identifier_body
libdump1090.rs
// Pitot - a customizable aviation information receiver // Copyright (C) 2017-2018 Datong Sun (dndx@idndx.com) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the Lice...
pub fn process_data(&mut self, buf: &[u8]) { unsafe { dump1090_process(buf.as_ptr(), buf.len()) } } pub fn parsed_as_mut_ref(&mut self) -> &mut VecDeque<TrafficData> { &mut self.parsed } fn push_message(&mut self, msg: TrafficData) { trace!("got a Mode S message: {:?}", m...
{ // this has to be boxed to get the address of self for callback // now let me = Box::new(Self { parsed: VecDeque::new(), }); unsafe { if dump1090_init(callback, &*me as *const _ as *const c_void) != 0 { panic!("unable to init libdump1090...
identifier_body
libdump1090.rs
// Pitot - a customizable aviation information receiver // Copyright (C) 2017-2018 Datong Sun (dndx@idndx.com) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the Lice...
_ => None, }, on_ground: match traffic.airground_valid { 1 => Some(traffic.on_ground == 1), _ => None, }, source: TrafficSource::ES, }; (*inst).push_message(msg); } }
nacp: match traffic.nacp_valid { 1 => Some(traffic.nacp as u8),
random_line_split
libdump1090.rs
// Pitot - a customizable aviation information receiver // Copyright (C) 2017-2018 Datong Sun (dndx@idndx.com) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the Lice...
{ addr: u32, altitude: i32, gnss_delta: i32, heading: u32, speed: u32, vs: i32, squawk: u32, callsign: *const u8, category: u32, lat: f64, lon: f64, nic: u32, nacp: u32, on_ground: u8, addr_type: u8, altitude_valid: u8, altitude_is_baro: u8, gnss...
TrafficT
identifier_name
markdown.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 ...
Some(out.into_owned()) } /// Render `input` (e.g. "foo.md") into an HTML file in `output` /// (e.g. output = "bar" => "bar/foo.html"). pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int { let input_p = Path::new(input); output.push(input_p.filestem().unwrap()); output.set_e...
random_line_split
markdown.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 ...
(Some(a), Some(b), Some(c)) => (a,b,c), _ => return 3 }; let mut out = match io::File::create(&output) { Err(e) => { let _ = writeln!(&mut io::stderr(), "error opening `{}` for writing: {}", output.display(), e); ...
{ let input_p = Path::new(input); output.push(input_p.filestem().unwrap()); output.set_extension("html"); let mut css = StrBuf::new(); for name in matches.opt_strs("markdown-css").iter() { let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">\n", name); css.push_s...
identifier_body
markdown.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) { let mut metadata = Vec::new(); for line in s.lines() { if line.starts_with("%") { // remove %<whitespace> metadata.push(line.slice_from(1).trim_left()) } else { let line_start_byte = s.subslice_offset(line); ...
extract_leading_metadata
identifier_name
events.rs
use std::collections::{HashMap}; ///All user events pass through and/or are recorded in this structure. pub struct Events { ///Central Dispatch pub messages: Vec<Vec<String>>, /// Component State pub state: String, /// Global Key-Val State pub keyval: HashMap<String,String>, /// Time elapsed si...
///Send a method to central dispatch pub fn message(&mut self, msg: Vec<String>) { self.messages.push( msg ) } ///Set a state variable pub fn set(&mut self, key: &str, val: &str) { self.keyval.insert(key.to_string(), val.to_string()); } ///Get a state variable pub fn get(&mut self, ...
{ Events { messages: Vec::new(), state: "".to_owned(), keyval: HashMap::new(), time_elapsed: 0.0, } }
identifier_body
events.rs
use std::collections::{HashMap}; ///All user events pass through and/or are recorded in this structure. pub struct Events { ///Central Dispatch pub messages: Vec<Vec<String>>, /// Component State pub state: String, /// Global Key-Val State pub keyval: HashMap<String,String>, /// Time elapsed si...
impl Events { ///Creates a new Events object. Used in Window rendering and is not meant for general use. pub fn new() -> Events { Events { messages: Vec::new(), state: "".to_owned(), keyval: HashMap::new(), time_elapsed: 0.0, } } ///Send a method to central di...
random_line_split
events.rs
use std::collections::{HashMap}; ///All user events pass through and/or are recorded in this structure. pub struct Events { ///Central Dispatch pub messages: Vec<Vec<String>>, /// Component State pub state: String, /// Global Key-Val State pub keyval: HashMap<String,String>, /// Time elapsed si...
(&mut self, key: &str, val: &str) { self.keyval.insert(key.to_string(), val.to_string()); } ///Get a state variable pub fn get(&mut self, key: &str) -> String { self.keyval.get(&key.to_string()).unwrap_or(&"".to_string()).clone() } }
set
identifier_name
transform.rs
// Copyright 2019 Yin Guanhao <sopium@mysterious.site> // This file is part of TiTun. // TiTun 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...
} // No `"` or `[`, not toml. true } fn transform_value(value: &str) -> String { let value = value.trim(); if value.contains(',') { // Array of strings. let a: toml::value::Array = value .split(',') .map(|v| toml::Value::String(v.trim().into())) .col...
random_line_split
transform.rs
// Copyright 2019 Yin Guanhao <sopium@mysterious.site> // This file is part of TiTun. // TiTun 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...
), r##" [General] log = "info" # Some comment [Interface] ListenPort = 7777 PrivateKey = "INZz5evbJBekyvtjRLHdnigrKeJ7HxOXR7lLm6yqMW4=" # Some more comment. [[Peer]] PublicKey = "NGnPOc0pxlnOjQz5DDSBJsSM6rf2T1MjBduxmvKBLiU=" # Some more comment. AllowedIPs = ["192.168.77.2/32", "192.168.77.4...
{ assert_eq!( super::maybe_transform( r##" [General] log = info # Some comment [Interface] ListenPort = 7777 PrivateKey = INZz5evbJBekyvtjRLHdnigrKeJ7HxOXR7lLm6yqMW4= # Some more comment. [Peer] PublicKey = NGnPOc0pxlnOjQz5DDSBJsSM6rf2T1MjBduxmvKBLiU= # Some more comment. Allowed...
identifier_body
transform.rs
// Copyright 2019 Yin Guanhao <sopium@mysterious.site> // This file is part of TiTun. // TiTun 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...
(input: &str) -> bool { for l in input.lines() { let l = l.trim(); if l == "[Peer]" { // Not toml. return true; } if l.starts_with('#') || l.starts_with('[') { continue; } if l.contains('"') || l.contains('[') { // Is to...
need_transform
identifier_name
transform.rs
// Copyright 2019 Yin Guanhao <sopium@mysterious.site> // This file is part of TiTun. // TiTun 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...
} } output } #[cfg(test)] mod tests { #[test] fn test_transform() { assert_eq!( super::maybe_transform( r##" [General] log = info # Some comment [Interface] ListenPort = 7777 PrivateKey = INZz5evbJBekyvtjRLHdnigrKeJ7HxOXR7lLm6yqMW4= # Some more comment. ...
{ output.push_str(l); output.push('\n'); }
conditional_block
simple_treeview.rs
//! # TreeView Sample //! //! This sample demonstrates how to create a TreeView with a ListStore. extern crate gio; extern crate gtk; use gio::prelude::*; use gtk::prelude::*; use gtk::{ ApplicationWindow, CellRendererText, Label, ListStore, Orientation, TreeView, TreeViewColumn, WindowPosition, }; use std::...
(application: &gtk::Application) { let window = ApplicationWindow::new(application); window.set_title("Simple TreeView example"); window.set_position(WindowPosition::Center); // Creating a vertical layout to place both tree view and label in the window. let vertical_layout = gtk::Box::new(Orientat...
build_ui
identifier_name
simple_treeview.rs
//! # TreeView Sample //! //! This sample demonstrates how to create a TreeView with a ListStore. extern crate gio; extern crate gtk; use gio::prelude::*; use gtk::prelude::*; use gtk::{ ApplicationWindow, CellRendererText, Label, ListStore, Orientation, TreeView, TreeViewColumn, WindowPosition, }; use std::...
application.connect_activate(|app| { build_ui(app); }); application.run(&args().collect::<Vec<_>>()); }
) .expect("Initialization failed...");
random_line_split
simple_treeview.rs
//! # TreeView Sample //! //! This sample demonstrates how to create a TreeView with a ListStore. extern crate gio; extern crate gtk; use gio::prelude::*; use gtk::prelude::*; use gtk::{ ApplicationWindow, CellRendererText, Label, ListStore, Orientation, TreeView, TreeViewColumn, WindowPosition, }; use std::...
}); // Adding the layout to the window. window.add(&vertical_layout); window.show_all(); } fn main() { let application = gtk::Application::new( Some("com.github.gtk-rs.examples.simple_treeview"), Default::default(), ) .expect("Initialization failed..."); application.c...
{ // Now getting back the values from the row corresponding to the // iterator `iter`. // // The `get_value` method do the conversion between the gtk type and Rust. label.set_text(&format!( "Hello '{}' from row {}", model ...
conditional_block
simple_treeview.rs
//! # TreeView Sample //! //! This sample demonstrates how to create a TreeView with a ListStore. extern crate gio; extern crate gtk; use gio::prelude::*; use gtk::prelude::*; use gtk::{ ApplicationWindow, CellRendererText, Label, ListStore, Orientation, TreeView, TreeViewColumn, WindowPosition, }; use std::...
fn append_column(tree: &TreeView, id: i32) { let column = TreeViewColumn::new(); let cell = CellRendererText::new(); column.pack_start(&cell, true); // Association of the view's column with the model's `id` column. column.add_attribute(&cell, "text", id); tree.append_column(&column); } fn cr...
{ // Creation of a model with two rows. let model = ListStore::new(&[u32::static_type(), String::static_type()]); // Filling up the tree view. let entries = &["Michel", "Sara", "Liam", "Zelda", "Neo", "Octopus master"]; for (i, entry) in entries.iter().enumerate() { model.insert_with_values...
identifier_body
main.rs
#[allow(dead_code)] struct Nil; #[allow(dead_code)] struct Pair(i32, f32); #[allow(dead_code)] struct Point { x: i32, y: i32, } #[allow(dead_code)] struct Rectangle { p1: Point, p2: Point, } #[allow(unused_variables)] fn main() { let point1: Point = Point { x: 4, y: 5 }; println!("point coo...
}
random_line_split
main.rs
#[allow(dead_code)] struct
; #[allow(dead_code)] struct Pair(i32, f32); #[allow(dead_code)] struct Point { x: i32, y: i32, } #[allow(dead_code)] struct Rectangle { p1: Point, p2: Point, } #[allow(unused_variables)] fn main() { let point1: Point = Point { x: 4, y: 5 }; println!("point coordinates: ({}, {})", point1.x,...
Nil
identifier_name
mod.rs
// Copyright 2017 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
mod delegator; pub mod miner;
random_line_split
url.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 url properties. /// An image url or none, used for example in list-style-image /// /// cbi...
/// Returns whether the value is `none`. pub fn is_none(&self) -> bool { match *self { UrlOrNone::None => true, UrlOrNone::Url(..) => false, } } }
{ UrlOrNone::None }
identifier_body
url.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 url properties. /// An image url or none, used for example in list-style-image /// /// cbindgen:derive-tagged-enum-copy-constructor=true #[derive( Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, Parse, SpecifiedValueInfo, ToAnimatedValue...
random_line_split
url.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 url properties. /// An image url or none, used for example in list-style-image /// /// cbi...
() -> Self { UrlOrNone::None } /// Returns whether the value is `none`. pub fn is_none(&self) -> bool { match *self { UrlOrNone::None => true, UrlOrNone::Url(..) => false, } } }
none
identifier_name
features.rs
//! Support for nightly features in Cargo itself //! //! This file is the version of `feature_gate.rs` in upstream Rust for Cargo //! itself and is intended to be the avenue for which new features in Cargo are //! gated by default and then eventually stabilized. All known stable and //! unstable features are tracked in...
//! unintended damage to your codebase, use with caution" //! })?; //! ``` //! //! Notably you'll notice the `require` function called with your `Feature`, and //! then you use `chain_err` to tack on more context for why the feature was //! required when the feature isn't activated. //! //! 4. Update the unstable ...
//! package.manifest().features().require(feature).chain_err(|| { //! "launching Cargo into space right now is unstable and may result in \
random_line_split
features.rs
//! Support for nightly features in Cargo itself //! //! This file is the version of `feature_gate.rs` in upstream Rust for Cargo //! itself and is intended to be the avenue for which new features in Cargo are //! gated by default and then eventually stabilized. All known stable and //! unstable features are tracked in...
(&self, feature: &Feature) -> CargoResult<()> { if feature.is_enabled(self) { Ok(()) } else { let feature = feature.name.replace("_", "-"); let mut msg = format!("feature `{}` is required", feature); if nightly_features_allowed() { let s =...
require
identifier_name
features.rs
//! Support for nightly features in Cargo itself //! //! This file is the version of `feature_gate.rs` in upstream Rust for Cargo //! itself and is intended to be the avenue for which new features in Cargo are //! gated by default and then eventually stabilized. All known stable and //! unstable features are tracked in...
} enum Status { Stable, Unstable, } macro_rules! features { ( pub struct Features { $([$stab:ident] $feature:ident: bool,)* } ) => ( #[derive(Default, Clone, Debug)] pub struct Features { $($feature: bool,)* activated: Vec<String>, ...
{ match s { "2015" => Ok(Edition::Edition2015), "2018" => Ok(Edition::Edition2018), s => { bail!("supported edition values are `2015` or `2018`, but `{}` \ is unknown", s) } } }
identifier_body
mod.rs
_press.time, axis: match button_press.detail { // Up | Down 4 | 5 => Axis::Vertical, // Right | Left 6 | 7 => Axis::Horizon...
&x11.log, "DRM Device does not have a render node, falling back to primary node" );
random_line_split
mod.rs
window we never map or provide to users to the backend // can be sent a message for shutdown. let close_window = WindowWrapper::create_window( &*connection, x11rb::COPY_DEPTH_FROM_PARENT, screen.root, 0, 0, 1, 1, ...
(self, size: Size<u16, Logical>) -> Self { Self { size: Some(size), ..self } } /// Creates a window using the options specified in the builder. pub fn build(self, handle: &X11Handle) -> Result<Window, X11Error> { let connection = handle.connection(); ...
size
identifier_name
mod.rs
window we never map or provide to users to the backend // can be sent a message for shutdown. let close_window = WindowWrapper::create_window( &*connection, x11rb::COPY_DEPTH_FROM_PARENT, screen.root, 0, 0, 1, 1, ...
let mut modifiers = modifiers.collect::<Vec<_>>(); // older dri3 versions do only support buffers with one plane. // we need to make sure, we don't accidently allocate buffers with more. if window.0.extensions.dri3 < Some((1, 2)) { modifiers.retain(|modi| modi == &DrmModifi...
{ return Err(X11Error::InvalidWindow); }
conditional_block
mod.rs
window we never map or provide to users to the backend // can be sent a message for shutdown. let close_window = WindowWrapper::create_window( &*connection, x11rb::COPY_DEPTH_FROM_PARENT, screen.root, 0, 0, 1, 1, ...
Ok(Window(window)) } } /// An X11 window. /// /// Dropping an instance of the window will destroy it. #[derive(Debug)] pub struct Window(Arc<WindowInner>); impl Window { /// Sets the title of the window. pub fn set_title(&self, title: &str) { self.0.set_title(title); } /// Maps ...
{ let connection = handle.connection(); let inner = &mut *handle.inner.lock().unwrap(); let window = Arc::new(WindowInner::new( Arc::downgrade(&connection), &connection.setup().roots[inner.screen_number], self.size.unwrap_or_else(|| (1280, 800).into()), ...
identifier_body
format_ctree.rs
use itertools::Itertools; use std::fmt::Display; use std::fs::OpenOptions; use std::io::Write; use std::ops::AddAssign; use std::path::PathBuf; use error::{Error, ResultExt}; use types::{CCode, CTree, Field, ToC}; #[derive(Debug, Default)] pub struct CFilePair { pub h: CCode, // for header file pub c: CCode, ...
let mut saved_paths = Vec::new(); // TODO if the c file tries to include an empty h file, it will fail to // compile... // TODO share code between c and h? if!self.h.is_empty() { let mut path = path_base.clone(); path.set_extension("h"); write...
random_line_split
format_ctree.rs
use itertools::Itertools; use std::fmt::Display; use std::fs::OpenOptions; use std::io::Write; use std::ops::AddAssign; use std::path::PathBuf; use error::{Error, ResultExt}; use types::{CCode, CTree, Field, ToC}; #[derive(Debug, Default)] pub struct CFilePair { pub h: CCode, // for header file pub c: CCode, ...
pub fn with_h<T>(contents: T) -> Self where T: ToC, { Self { h: contents.to_c(), c: CCode::new(), } } pub fn with<T>(contents: T) -> Self where T: ToC, { let contents = contents.to_c(); Self { h: contents....
{ Self { h: CCode::new(), c: contents.to_c(), } }
identifier_body
format_ctree.rs
use itertools::Itertools; use std::fmt::Display; use std::fs::OpenOptions; use std::io::Write; use std::ops::AddAssign; use std::path::PathBuf; use error::{Error, ResultExt}; use types::{CCode, CTree, Field, ToC}; #[derive(Debug, Default)] pub struct CFilePair { pub h: CCode, // for header file pub c: CCode, ...
(&self, file_name_base: &str) -> Result<CFilePair, Error> { Ok(match *self { CTree::IncludeH { ref path } => format_include_h(path), CTree::IncludeSelf => format_include_self(file_name_base), CTree::LiteralH(ref text) => CFilePair::with_h(text), CTree::LiteralC(re...
format
identifier_name
unresolved-import.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432] //~^ no `Baz` in `bar`. Did you mean to use `Bar`? use food::baz; //~ ERROR unresolved import `food::baz` //~^ no `baz` in `food`. Did you mean to use `bag`? use food::{beens as Foo}; //~ ERROR unresolved import `food:...
use foo::bar; //~ ERROR unresolved import `foo` [E0432] //~^ maybe a missing `extern crate foo;`?
random_line_split
unresolved-import.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
; } } } mod m { enum MyEnum { MyVariant } use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432] //~^ did you mean `self::MyEnum`? } mod items { enum Enum { Variant } use Enum::*; //~ ERROR unresolved import `Enum` [E0432] ...
foobar
identifier_name
borrowck-mut-vec-as-imm-slice.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // run-pass fn...
// http://rust-lang.org/COPYRIGHT.
random_line_split
borrowck-mut-vec-as-imm-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 ...
pub fn main() { assert_eq!(has_mut_vec(vec![1, 2, 3]), 6); }
{ want_slice(&v) }
identifier_body
borrowck-mut-vec-as-imm-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 ...
(v: &[isize]) -> isize { let mut sum = 0; for i in v { sum += *i; } sum } fn has_mut_vec(v: Vec<isize> ) -> isize { want_slice(&v) } pub fn main() { assert_eq!(has_mut_vec(vec![1, 2, 3]), 6); }
want_slice
identifier_name
traversal.rs
//! Traversal of the graph of IR items and types. use super::context::{BindgenContext, ItemId}; use super::item::ItemSet; use std::collections::{BTreeMap, VecDeque}; /// An outgoing edge in the IR graph is a reference from some item to another /// item: /// /// from --> to /// /// The `from` is left implicit: it is...
fn trace<T>( &self, context: &BindgenContext, tracer: &mut T, extra: &Self::Extra, ) where T: Tracer; } /// An graph traversal of the transitive closure of references between items. /// /// See `BindgenContext::allowlisted_items` for more information. pub struct ItemTrav...
type Extra; /// Trace all of this item's outgoing edges to other items.
random_line_split
traversal.rs
//! Traversal of the graph of IR items and types. use super::context::{BindgenContext, ItemId}; use super::item::ItemSet; use std::collections::{BTreeMap, VecDeque}; /// An outgoing edge in the IR graph is a reference from some item to another /// item: /// /// from --> to /// /// The `from` is left implicit: it is...
(ctx: &BindgenContext, edge: Edge) -> bool { let cc = &ctx.options().codegen_config; match edge.kind { EdgeKind::Generic => { ctx.resolve_item(edge.to).is_enabled_for_codegen(ctx) } // We statically know the kind of item that non-generic edges can point // to, so we ...
codegen_edges
identifier_name
traversal.rs
//! Traversal of the graph of IR items and types. use super::context::{BindgenContext, ItemId}; use super::item::ItemSet; use std::collections::{BTreeMap, VecDeque}; /// An outgoing edge in the IR graph is a reference from some item to another /// item: /// /// from --> to /// /// The `from` is left implicit: it is...
fn next(&mut self) -> Option<ItemId> { self.pop_front() } } /// Something that can receive edges from a `Trace` implementation. pub trait Tracer { /// Note an edge between items. Called from within a `Trace` implementation. fn visit_kind(&mut self, item: ItemId, kind: EdgeKind); /// A sy...
{ self.push_back(item); }
identifier_body
traversal.rs
//! Traversal of the graph of IR items and types. use super::context::{BindgenContext, ItemId}; use super::item::ItemSet; use std::collections::{BTreeMap, VecDeque}; /// An outgoing edge in the IR graph is a reference from some item to another /// item: /// /// from --> to /// /// The `from` is left implicit: it is...
let is_newly_discovered = self.seen.add(self.currently_traversing, item); if is_newly_discovered { self.queue.push(item) } } } impl<'ctx, Storage, Queue, Predicate> Iterator for ItemTraversal<'ctx, Storage, Queue, Predicate> where Storage: TraversalStorage<...
{ return; }
conditional_block
small_crush_xorshift.rs
// A rust wrapper to a small subset of TestU01 // (http://simul.iro.umontreal.ca/testu01/tu01.html). // Copyright (C) 2015 Loïc Damien // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, eith...
let experiment_name = "Test of rust weak rng with small crush"; swrite::set_experiment_name(&CString::new(experiment_name).unwrap()); swrite::set_host(false); // Disable the printing of the hostname in the results let name = "weak_rng"; let c_name = CString::new(name).unwrap(); let rng = rand...
identifier_body
small_crush_xorshift.rs
// A rust wrapper to a small subset of TestU01 // (http://simul.iro.umontreal.ca/testu01/tu01.html). // Copyright (C) 2015 Loïc Damien // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, eith...
println!("P-values: {:?}", testu01::battery::get_pvalues()); }
// Print the p-values for the differents test of the battery:
random_line_split
small_crush_xorshift.rs
// A rust wrapper to a small subset of TestU01 // (http://simul.iro.umontreal.ca/testu01/tu01.html). // Copyright (C) 2015 Loïc Damien // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, eith...
) { let experiment_name = "Test of rust weak rng with small crush"; swrite::set_experiment_name(&CString::new(experiment_name).unwrap()); swrite::set_host(false); // Disable the printing of the hostname in the results let name = "weak_rng"; let c_name = CString::new(name).unwrap(); let rng = r...
ain(
identifier_name
var_alt_dir_ind.rs
use std::collections::HashMap; use pest::Error; use var_instr::variable::{Variable, AsComplete, LabelNotFound}; use var_instr::variable::FromPair; use machine::instruction::mem_size::MemSize; use machine::instruction::parameter::{AltDirect, Indirect, AltDirInd}; use label::Label; #[derive(Debug)] pub enum VarAltDirInd...
(pair: ::AsmPair) -> Result<Self, ::AsmError> { match pair.as_rule() { ::Rule::direct => Ok(VarAltDirInd::AltDirect(Variable::from_pair(pair)?)), ::Rule::indirect => Ok(VarAltDirInd::Indirect(Variable::from_pair(pair)?)), _ => Err(Error::CustomErrorSpan { mess...
from_pair
identifier_name
var_alt_dir_ind.rs
use std::collections::HashMap; use pest::Error; use var_instr::variable::{Variable, AsComplete, LabelNotFound}; use var_instr::variable::FromPair; use machine::instruction::mem_size::MemSize; use machine::instruction::parameter::{AltDirect, Indirect, AltDirInd}; use label::Label; #[derive(Debug)] pub enum VarAltDirInd...
} impl AsComplete<AltDirInd> for VarAltDirInd { fn as_complete(&self, offset: usize, label_offsets: &HashMap<Label, usize>) -> Result<AltDirInd, LabelNotFound> { use self::VarAltDirInd::*; match *self { AltDirect(ref alt_direct) => Ok(AltDirInd::AltDirect(alt_direct.as_complete(offset,...
{ match pair.as_rule() { ::Rule::direct => Ok(VarAltDirInd::AltDirect(Variable::from_pair(pair)?)), ::Rule::indirect => Ok(VarAltDirInd::Indirect(Variable::from_pair(pair)?)), _ => Err(Error::CustomErrorSpan { message: format!("expected direct, indirect found ...
identifier_body
var_alt_dir_ind.rs
use std::collections::HashMap; use pest::Error; use var_instr::variable::{Variable, AsComplete, LabelNotFound}; use var_instr::variable::FromPair; use machine::instruction::mem_size::MemSize; use machine::instruction::parameter::{AltDirect, Indirect, AltDirInd}; use label::Label;
impl MemSize for VarAltDirInd { fn mem_size(&self) -> usize { match *self { VarAltDirInd::AltDirect(ref alt_direct) => alt_direct.mem_size(), VarAltDirInd::Indirect(ref indirect) => indirect.mem_size(), } } } impl FromPair for VarAltDirInd { fn from_pair(pair: ::Asm...
#[derive(Debug)] pub enum VarAltDirInd { AltDirect(Variable<AltDirect>), Indirect(Variable<Indirect>), }
random_line_split
mod.rs
#[derive(Debug, PartialEq)] pub enum CentrifugeError { WrongProtocol, ParsingError, UnknownProtocol, InvalidPacket, } pub mod prelude { pub use crate::structs::raw::Raw::*;
pub use crate::structs::ether::Ether::*; } /// `Zero` - This packet is very interesting /// `One` - This packet is somewhat interesting /// `Two` - Stuff you want to see if you're looking really hard /// `AlmostMaximum` - Some binary data /// `Maximum` - We couldn't par...
random_line_split
mod.rs
#[derive(Debug, PartialEq)] pub enum CentrifugeError { WrongProtocol, ParsingError, UnknownProtocol, InvalidPacket, } pub mod prelude { pub use crate::structs::raw::Raw::*; pub use crate::structs::ether::Ether::*; } /// `Zero` - This packet is very interesting /// `One` ...
(self) -> u8 { self as u8 } } pub mod raw; pub mod ether; pub mod arp; pub mod cjdns; pub mod icmp; pub mod ipv4; pub mod ipv6; pub mod ip; pub mod tcp; pub mod udp; pub mod tls; pub mod http; pub mod dhcp; pub mod dns; pub mod ssdp; pub mod dropbox;
into_u8
identifier_name
method-on-tuple-struct.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// STACK BY VAL // lldb-command:print self // lldb-check:[...]$3 = TupleStruct(100, -100.5) // lldb-command:print arg1 // lldb-check:[...]$4 = -3 // lldb-command:print arg2 // lldb-check:[...]$5 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self // lldb-check:[...]$6 = TupleStruct(200, -200.5) ...
random_line_split
method-on-tuple-struct.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(int, f64); impl TupleStruct { fn self_by_ref(&self, arg1: int, arg2: int) -> int { zzz(); // #break arg1 + arg2 } fn self_by_val(self, arg1: int, arg2: int) -> int { zzz(); // #break arg1 + arg2 } fn self_owned(self: Box<TupleStruct>, arg1: int, arg2: int) -> int...
TupleStruct
identifier_name
method-on-tuple-struct.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn self_by_val(self, arg1: int, arg2: int) -> int { zzz(); // #break arg1 + arg2 } fn self_owned(self: Box<TupleStruct>, arg1: int, arg2: int) -> int { zzz(); // #break arg1 + arg2 } } fn main() { let stack = TupleStruct(100, -100.5); let _ = stack.self_by_ref...
{ zzz(); // #break arg1 + arg2 }
identifier_body
stub_activity.rs
// Copyright (C) 2011 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applic...
// Return value tells RS roughly how often to redraw // in this case 20 ms return 20; }
rsgDrawText("Hello World!", 50, 50);
random_line_split
assignability-trait.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 ...
trait iterable<A> { fn iterate(&self, blk: |x: &A| -> bool) -> bool; } impl<'a,A> iterable<A> for &'a [A] { fn iterate(&self, f: |x: &A| -> bool) -> bool { self.iter().advance(f) } } impl<A> iterable<A> for Vec<A> { fn iterate(&self, f: |x: &A| -> bool) -> bool { self.iter().advance(f)...
// making method calls, but only if there aren't any matches without // it.
random_line_split
assignability-trait.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self, f: |x: &A| -> bool) -> bool { self.iter().advance(f) } } impl<A> iterable<A> for Vec<A> { fn iterate(&self, f: |x: &A| -> bool) -> bool { self.iter().advance(f) } } fn length<A, T: iterable<A>>(x: T) -> uint { let mut len = 0; x.iterate(|_y| { len += 1; true...
iterate
identifier_name
assignability-trait.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 ...
} impl<A> iterable<A> for Vec<A> { fn iterate(&self, f: |x: &A| -> bool) -> bool { self.iter().advance(f) } } fn length<A, T: iterable<A>>(x: T) -> uint { let mut len = 0; x.iterate(|_y| { len += 1; true }); return len; } pub fn main() { let x: Vec<int> = vec!(0,1...
{ self.iter().advance(f) }
identifier_body
hrtb-precedence-of-plus-where-clause.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 ...
// distinct bounds on `F`. fn foo1<F>(f: F) where F : FnOnce(isize) -> isize + Send { bar(f); } fn foo2<F>(f: F) where F : FnOnce(isize) -> isize + Send { baz(f); } fn bar<F:Send>(f: F) { } fn baz<F:FnOnce(isize) -> isize>(f: F) { } fn main() {}
// Test that `F : Fn(isize) -> isize + Send` is interpreted as two
random_line_split
hrtb-precedence-of-plus-where-clause.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 foo2<F>(f: F) where F : FnOnce(isize) -> isize + Send { baz(f); } fn bar<F:Send>(f: F) { } fn baz<F:FnOnce(isize) -> isize>(f: F) { } fn main() {}
{ bar(f); }
identifier_body
hrtb-precedence-of-plus-where-clause.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 ...
<F>(f: F) where F : FnOnce(isize) -> isize + Send { bar(f); } fn foo2<F>(f: F) where F : FnOnce(isize) -> isize + Send { baz(f); } fn bar<F:Send>(f: F) { } fn baz<F:FnOnce(isize) -> isize>(f: F) { } fn main() {}
foo1
identifier_name
scene_test.rs
extern crate ggez; extern crate ggez_goodies; use ggez::conf; /* use ggez::event; use ggez::graphics; use ggez::timer; use ggez::GameResult; use std::time::Duration; use ggez_goodies::scene::*; struct MainState { font: graphics::Font, message_text: graphics::Text, } /// A bootstrap scene whose only purpose i...
let s1 = SavedScene1::new("Scene 1", "Scene 2"); let s2 = SavedScene1::new("Scene 2", "Scene 1"); state.add(s1); state.add(s2); Ok(Some("Scene 1".to_string())) } fn draw(&mut self, _ctx: &mut ggez::Context, _store: &mut SceneStore<MainState>) ...
state: &mut SceneStore<MainState>) -> GameResult<Option<String>> {
random_line_split
scene_test.rs
extern crate ggez; extern crate ggez_goodies; use ggez::conf; /* use ggez::event; use ggez::graphics; use ggez::timer; use ggez::GameResult; use std::time::Duration; use ggez_goodies::scene::*; struct MainState { font: graphics::Font, message_text: graphics::Text, } /// A bootstrap scene whose only purpose i...
() { let _c = conf::Conf::new(); /*let mut game: Game<SceneManager<MainState>> = Game::new("scenetest", c).unwrap(); if let Err(e) = game.run() { println!("Error encountered: {:?}", e); } else { println!("Game exited cleanly."); } */ }
main
identifier_name
scene_test.rs
extern crate ggez; extern crate ggez_goodies; use ggez::conf; /* use ggez::event; use ggez::graphics; use ggez::timer; use ggez::GameResult; use std::time::Duration; use ggez_goodies::scene::*; struct MainState { font: graphics::Font, message_text: graphics::Text, } /// A bootstrap scene whose only purpose i...
{ let _c = conf::Conf::new(); /*let mut game: Game<SceneManager<MainState>> = Game::new("scenetest", c).unwrap(); if let Err(e) = game.run() { println!("Error encountered: {:?}", e); } else { println!("Game exited cleanly."); } */ }
identifier_body
binops.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 test_bool() { assert!((!(true < false))); assert!((!(true <= false))); assert!((true > false)); assert!((true >= false)); assert!((false < true)); assert!((false <= true)); assert!((!(false > true))); assert!((!(false >= true))); // Bools support bitwise binops assert_eq!(...
{ assert_eq!((), ()); assert!((!(() != ()))); assert!((!(() < ()))); assert!((() <= ())); assert!((!(() > ()))); assert!((() >= ())); }
identifier_body
binops.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 q = p(1, 2); let mut r = p(1, 2); unsafe { println!("q = {:x}, r = {:x}", (::std::mem::transmute::<*const p, uint>(&q)), (::std::mem::transmute::<*const p, uint>(&r))); } assert_eq!(q, r); r.y = 17; assert!((r.y!= q.y)); assert_eq!(r.y, 17); assert!((q!= r)); } pub fn ma...
test_class
identifier_name
binops.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 ...
x: int, y: int, } fn p(x: int, y: int) -> p { p { x: x, y: y } } fn test_class() { let q = p(1, 2); let mut r = p(1, 2); unsafe { println!("q = {:x}, r = {:x}", (::std::mem::transmute::<*const p, uint>(&q)), (::std::mem::transmute::<*const p, uint>(&r))); } a...
struct p {
random_line_split
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{IoResult, Stream}; use std::cmp::min; use std::slice; use std::fmt::radix; use std::ptr; // 64KB chunks (moderately arbitrary) const READ_BUF_SIZE: usize = 0x10000; const WRITE_BUF_SIZE: usize = 0x10000; // TODO: consider re...
} impl<T: Reader> BufferedStream<T> { /// Poke a single byte back so it will be read next. For this to make sense, you must have just /// read that byte. If `self.pos` is 0 and `self.max` is not 0 (i.e. if the buffer is just /// filled /// Very great caution must be used in calling this as it will fai...
{ let mut read_buffer = Vec::with_capacity(READ_BUF_SIZE); unsafe { read_buffer.set_len(READ_BUF_SIZE); } let mut write_buffer = Vec::with_capacity(WRITE_BUF_SIZE); unsafe { write_buffer.set_len(WRITE_BUF_SIZE); } BufferedStream { wrapped: stream, read_buf...
identifier_body
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{IoResult, Stream}; use std::cmp::min; use std::slice; use std::fmt::radix; use std::ptr; // 64KB chunks (moderately arbitrary) const READ_BUF_SIZE: usize = 0x10000; const WRITE_BUF_SIZE: usize = 0x10000; // TODO: consider re...
/// Finish off writing a response: this flushes the writer and in case of chunked /// Transfer-Encoding writes the ending zero-length chunk to indicate completion. /// /// At the time of calling this, headers MUST have been written, including the /// ending CRLF, or else an invalid HTTP response may...
random_line_split
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{IoResult, Stream}; use std::cmp::min; use std::slice; use std::fmt::radix; use std::ptr; // 64KB chunks (moderately arbitrary) const READ_BUF_SIZE: usize = 0x10000; const WRITE_BUF_SIZE: usize = 0x10000; // TODO: consider re...
} else { unsafe { ptr::copy_memory(self.write_buffer.as_mut_ptr().offset(self.write_len as isize), buf.as_ptr(), buf.len()); } self.write_len += buf.len(); if self.write_len == self.write_buffer.len() { if self...
{ try!(self.wrapped.write(b"\r\n")); }
conditional_block
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{IoResult, Stream}; use std::cmp::min; use std::slice; use std::fmt::radix; use std::ptr; // 64KB chunks (moderately arbitrary) const READ_BUF_SIZE: usize = 0x10000; const WRITE_BUF_SIZE: usize = 0x10000; // TODO: consider re...
(&mut self) -> IoResult<()> { if self.write_len > 0 { if self.writing_chunked_body { let s = format!("{}\r\n", radix(self.write_len, 16)); try!(self.wrapped.write(s.as_bytes())); } try!(self.wrapped.write(&self.write_buffer[..self.write_len]));...
flush
identifier_name
last-use-in-cap-clause.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 ...
{ assert_eq!(foo().call_mut(()), 22); }
identifier_body
last-use-in-cap-clause.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 ...
() -> Box<FnMut() -> isize +'static> { let k: Box<_> = box 22; let _u = A {a: k.clone()}; // FIXME(#16640) suffix in `22` suffix shouldn't be necessary let result = || 22; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(result) } pub fn main() { assert_eq!(...
foo
identifier_name
last-use-in-cap-clause.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 _u = A {a: k.clone()}; // FIXME(#16640) suffix in `22` suffix shouldn't be necessary let result = || 22; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(result) } pub fn main() { assert_eq!(foo().call_mut(()), 22); }
struct A { a: Box<isize> } fn foo() -> Box<FnMut() -> isize + 'static> { let k: Box<_> = box 22;
random_line_split
lib.rs
#![allow(unused_variables, unused_imports, dead_code)] use m3u8_rs::*; use nom::AsBytes; use std::collections::HashMap; use std::fs; use std::fs::File; use std::io::Read; use std::path; fn all_sample_m3u_playlists() -> Vec<path::PathBuf> { let path: std::path::PathBuf = ["sample-playlists"].iter().collect(); ...
} #[test] fn playlist_master_with_alternatives() { assert!(print_parse_playlist_test("master-with-alternatives.m3u8")); } #[test] fn playlist_master_with_alternatives_2_3() { assert!(print_parse_playlist_test("master-with-alternatives-2.m3u8")); } #[test] fn playlist_master_with_i_frame_stream_inf() { a...
{ println!("Parsing failed:\n {:?}", parsed); false }
conditional_block