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
udp.rs
use crate::sys::unix::net::{new_ip_socket, socket_addr}; use std::io; use std::mem; use std::net::{self, SocketAddr}; use std::os::unix::io::{AsRawFd, FromRawFd}; pub fn bind(addr: SocketAddr) -> io::Result<net::UdpSocket>
pub(crate) fn only_v6(socket: &net::UdpSocket) -> io::Result<bool> { let mut optval: libc::c_int = 0; let mut optlen = mem::size_of::<libc::c_int>() as libc::socklen_t; syscall!(getsockopt( socket.as_raw_fd(), libc::IPPROTO_IPV6, libc::IPV6_V6ONLY, &mut optval as *mut _ as...
{ // Gives a warning for non Apple platforms. #[allow(clippy::let_and_return)] let socket = new_ip_socket(addr, libc::SOCK_DGRAM); socket.and_then(|socket| { let (raw_addr, raw_addr_length) = socket_addr(&addr); syscall!(bind(socket, raw_addr.as_ptr(), raw_addr_length)) .map...
identifier_body
udp.rs
use crate::sys::unix::net::{new_ip_socket, socket_addr}; use std::io; use std::mem; use std::net::{self, SocketAddr}; use std::os::unix::io::{AsRawFd, FromRawFd}; pub fn
(addr: SocketAddr) -> io::Result<net::UdpSocket> { // Gives a warning for non Apple platforms. #[allow(clippy::let_and_return)] let socket = new_ip_socket(addr, libc::SOCK_DGRAM); socket.and_then(|socket| { let (raw_addr, raw_addr_length) = socket_addr(&addr); syscall!(bind(socket, raw_...
bind
identifier_name
udp.rs
use crate::sys::unix::net::{new_ip_socket, socket_addr};
use std::io; use std::mem; use std::net::{self, SocketAddr}; use std::os::unix::io::{AsRawFd, FromRawFd}; pub fn bind(addr: SocketAddr) -> io::Result<net::UdpSocket> { // Gives a warning for non Apple platforms. #[allow(clippy::let_and_return)] let socket = new_ip_socket(addr, libc::SOCK_DGRAM); socke...
random_line_split
reference-to-tuple.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// compile-flags:-Z extra-debug-info // debugger:break zzz // debugger:run // debugger:finish // debugger:print *stack_val_ref // check:$1 = {-14, -19} // debugger:print *ref_to_unnamed // check:$2 = {-15, -20} // debugger:print *managed_val_ref // check:$3 = {-16, -21} // debugger:print *unique_val_ref // check:$...
// GDB doesn't know about UTF-32 character encoding and will print a rust char as only its numerical // value.
random_line_split
reference-to-tuple.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 ...
() {()}
zzz
identifier_name
reference-to-tuple.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn zzz() {()}
{ let stack_val: (i16, f32) = (-14, -19f32); let stack_val_ref : &(i16, f32) = &stack_val; let ref_to_unnamed : &(i16, f32) = &(-15, -20f32); let managed_val : @(i16, f32) = @(-16, -21f32); let managed_val_ref : &(i16, f32) = managed_val; let unique_val: ~(i16, f32) = ~(-17, -22f32); let u...
identifier_body
cast.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...
/// Transforms lifetime of the second pointer to match the first. #[inline] pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T { transmute_lifetime(ptr) } /**************************************************************************** * Tests ***********************************************...
{ transmute_mut_lifetime(ptr) }
identifier_body
cast.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...
/// Transforms lifetime of the second pointer to match the first. #[inline] pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T { transmute_lifetime(ptr) } /**************************************************************************** * Tests ************************************************...
}
random_line_split
cast.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
<T>(ptr: *T) -> *mut T { transmute(ptr) } /// Coerce a mutable reference to have an arbitrary associated lifetime. #[inline] pub unsafe fn transmute_mut_lifetime<'a,'b,T>(ptr: &'a mut T) -> &'b mut T { transmute(ptr) } /// Transforms lifetime of the second pointer to match the first. #[inline] pub unsafe fn c...
transmute_mut_unsafe
identifier_name
feature-gate-arbitrary-self-types.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//~ ERROR arbitrary `self` types are unstable } impl Bar { fn bar(self: Box<Rc<Self>>) {} //~ ERROR arbitrary `self` types are unstable } fn main() {}
{}
identifier_body
feature-gate-arbitrary-self-types.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() {}
random_line_split
feature-gate-arbitrary-self-types.rs
// Copyright 2017 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: Box<Rc<Self>>) {} //~ ERROR arbitrary `self` types are unstable } fn main() {}
bar
identifier_name
read_file_specific_line.rs
// http://rosettacode.org/wiki/Read_a_specific_line_from_a_file use std::fs::File; use std::io::{BufReader, BufRead}; use std::env::args; use std::borrow::ToOwned; fn main()
let file = File::open(filename).unwrap(); let reader = BufReader::new(file); match reader.lines().skip(line_number-1).next() { None => panic!("No such line (file is too short)"), Some(result) => match result { // Handle any errors that may arise Ok(ln) => print!("{}...
{ let mut args = args(); let filename = { if let Some(o_s) = args.nth(1) { o_s.to_owned() } else { panic!("You must enter a filename to read line by line") } }; let line_number = { if let Some(o_s) = args.next() { o_s.to_owned() ...
identifier_body
read_file_specific_line.rs
// http://rosettacode.org/wiki/Read_a_specific_line_from_a_file use std::fs::File; use std::io::{BufReader, BufRead}; use std::env::args; use std::borrow::ToOwned; fn
() { let mut args = args(); let filename = { if let Some(o_s) = args.nth(1) { o_s.to_owned() } else { panic!("You must enter a filename to read line by line") } }; let line_number = { if let Some(o_s) = args.next() { o_s.to_owned() ...
main
identifier_name
read_file_specific_line.rs
// http://rosettacode.org/wiki/Read_a_specific_line_from_a_file use std::fs::File; use std::io::{BufReader, BufRead}; use std::env::args; use std::borrow::ToOwned; fn main() { let mut args = args(); let filename = { if let Some(o_s) = args.nth(1) { o_s.to_owned() } else { ...
match reader.lines().skip(line_number-1).next() { None => panic!("No such line (file is too short)"), Some(result) => match result { // Handle any errors that may arise Ok(ln) => print!("{}", ln), Err(error) => print!("{}", error) } } }
random_line_split
kernel_set.rs
use std::collections::VecDeque; use std::fmt::Debug; use std::hash::Hash; use util::{map, Map}; pub struct KernelSet<K: Kernel> { counter: usize, kernels: VecDeque<K>, map: Map<K, K::Index>, } pub trait Kernel: Clone + Debug + Hash + Eq { type Index: Copy + Debug; fn index(c: usize) -> Self::Inde...
(&mut self, kernel: K) -> K::Index { let kernels = &mut self.kernels; let counter = &mut self.counter; *self.map.entry(kernel.clone()).or_insert_with(|| { let index = *counter; *counter += 1; kernels.push_back(kernel); K::index(index) }) ...
add_state
identifier_name
kernel_set.rs
use std::collections::VecDeque; use std::fmt::Debug; use std::hash::Hash; use util::{map, Map}; pub struct KernelSet<K: Kernel> { counter: usize, kernels: VecDeque<K>, map: Map<K, K::Index>, } pub trait Kernel: Clone + Debug + Hash + Eq { type Index: Copy + Debug; fn index(c: usize) -> Self::Inde...
pub fn add_state(&mut self, kernel: K) -> K::Index { let kernels = &mut self.kernels; let counter = &mut self.counter; *self.map.entry(kernel.clone()).or_insert_with(|| { let index = *counter; *counter += 1; kernels.push_back(kernel); K::inde...
{ KernelSet { kernels: VecDeque::new(), map: map(), counter: 0 } }
identifier_body
kernel_set.rs
use std::collections::VecDeque;
pub struct KernelSet<K: Kernel> { counter: usize, kernels: VecDeque<K>, map: Map<K, K::Index>, } pub trait Kernel: Clone + Debug + Hash + Eq { type Index: Copy + Debug; fn index(c: usize) -> Self::Index; } impl<K:Kernel> KernelSet<K> { pub fn new() -> KernelSet<K> { KernelSet { kernel...
use std::fmt::Debug; use std::hash::Hash; use util::{map, Map};
random_line_split
mod.rs
/*! * Normalization processes a parse tree until it is in suitable form to * be converted to the more canonical form. This is done as a series of * passes, each contained in their own module below. */ use grammar::parse_tree as pt; use grammar::repr as r; pub type NormResult<T> = Result<T, NormError>; #[derive(C...
(grammar: pt::Grammar, validate: bool) -> NormResult<r::Grammar> { if validate { try!(prevalidate::validate(&grammar)); } let grammar = try!(resolve::resolve(grammar)); let grammar = try!(macro_expand::expand_macros(grammar)); if validate { try!(postvalidate::validate(&grammar)); } let types = try!(...
normalize_helper
identifier_name
mod.rs
/*! * Normalization processes a parse tree until it is in suitable form to * be converted to the more canonical form. This is done as a series of * passes, each contained in their own module below. */ use grammar::parse_tree as pt; use grammar::repr as r; pub type NormResult<T> = Result<T, NormError>; #[derive(C...
let grammar = try!(resolve::resolve(grammar)); let grammar = try!(macro_expand::expand_macros(grammar)); if validate { try!(postvalidate::validate(&grammar)); } let types = try!(tyinfer::infer_types(&grammar)); lower::lower(grammar, types) } // These are executed *IN ORDER*: // Check most safety ...
{ try!(prevalidate::validate(&grammar)); }
conditional_block
mod.rs
/*! * Normalization processes a parse tree until it is in suitable form to * be converted to the more canonical form. This is done as a series of * passes, each contained in their own module below. */ use grammar::parse_tree as pt; use grammar::repr as r; pub type NormResult<T> = Result<T, NormError>; #[derive(C...
} macro_rules! return_err { ($span: expr, $($args:expr),+) => { return Err(NormError { message: format!($($args),+), span: $span }); } } pub fn normalize(grammar: pt::Grammar) -> NormResult<r::Grammar> { normalize_helper(grammar, true) } /// for unit tests, it is c...
pub struct NormError { pub message: String, pub span: pt::Span,
random_line_split
mod.rs
/*! * Normalization processes a parse tree until it is in suitable form to * be converted to the more canonical form. This is done as a series of * passes, each contained in their own module below. */ use grammar::parse_tree as pt; use grammar::repr as r; pub type NormResult<T> = Result<T, NormError>; #[derive(C...
// These are executed *IN ORDER*: // Check most safety conditions. mod prevalidate; // Resolve identifiers into terminals/nonterminals etc. mod resolve; // Expands macros and expressions // // X =...1 Comma<X> (X Y Z)...2 // // to // // X =...1 `Comma<X>` `(X Y Z)`...2 // `Comma_X`: Vec<<X>> =...; // ...
{ if validate { try!(prevalidate::validate(&grammar)); } let grammar = try!(resolve::resolve(grammar)); let grammar = try!(macro_expand::expand_macros(grammar)); if validate { try!(postvalidate::validate(&grammar)); } let types = try!(tyinfer::infer_types(&grammar)); lower::lower(grammar, types)...
identifier_body
mod.rs
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CNT { #[doc = r" Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &...
#[doc = r" Reads the contents of the register"] #[inline(always)] pub fn read(&self) -> R { R { bits: self.register.get(), } } #[doc = r" Writes to the register"] #[inline(always)] pub fn write<F>(&self, f: F) where F: FnOnce(&mut W) -> &mut W, { ...
{ let bits = self.register.get(); let r = R { bits: bits }; let mut w = W { bits: bits }; f(&r, &mut w); self.register.set(w.bits); }
identifier_body
mod.rs
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CNT { #[doc = r" Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &...
(&self) -> R { R { bits: self.register.get(), } } #[doc = r" Writes to the register"] #[inline(always)] pub fn write<F>(&self, f: F) where F: FnOnce(&mut W) -> &mut W, { let mut w = W::reset_value(); f(&mut w); self.register.set(w.bits)...
read
identifier_name
mod.rs
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CNT { #[doc = r" Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &...
_CNTW { w: self } } }
pub fn cnt(&mut self) -> _CNTW {
random_line_split
find_exec_tests.rs
// Copyright 2017 Google Inc. // // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. ///! This file contains what would be normally be unit tests for find::find_main ///! related to -exec[dir] and ok[dir] clauses. ///! Bu...
"{}", ",", ";"], &deps); assert_eq!(rc, 0); // exec has side effects, so we won't output anything unless -print is // explicitly passed in. assert_eq!(deps.get_output_as_string(), ""); // check the ex...
"-execdir", &path_to_testing_commandline(), temp_dir_path.as_ref(), ")",
random_line_split
find_exec_tests.rs
// Copyright 2017 Google Inc. // // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. ///! This file contains what would be normally be unit tests for find::find_main ///! related to -exec[dir] and ok[dir] clauses. ///! Bu...
() { let temp_dir = TempDir::new("find_execdir").unwrap(); let temp_dir_path = temp_dir.path().to_string_lossy(); let deps = FakeDependencies::new(); // only look at files because the "size" of a directory is a system (and filesystem) // dependent thing and we want these tests to be universal. l...
find_execdir
identifier_name
find_exec_tests.rs
// Copyright 2017 Google Inc. // // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. ///! This file contains what would be normally be unit tests for find::find_main ///! related to -exec[dir] and ok[dir] clauses. ///! Bu...
// explicitly passed in. assert_eq!(deps.get_output_as_string(), ""); // check the executable ran as expected let mut f = File::open(temp_dir.path().join("1.txt")).expect("Failed to open output file"); let mut s = String::new(); f.read_to_string(&mut s).expect("failed to read output file"); ...
{ let temp_dir = TempDir::new("find_exec").unwrap(); let temp_dir_path = temp_dir.path().to_string_lossy(); let deps = FakeDependencies::new(); let rc = find_main(&["find", &fix_up_slashes("./test_data/simple/subdir"), "-type", ...
identifier_body
main.rs
use std::fs::File; use std::io::BufWriter; use std::io::Write; use std::io::BufReader; use std::io::Read; extern crate modfile; use modfile::ptmf; #[macro_use] extern crate serde_derive; extern crate docopt; use docopt::Docopt; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); static USAGE: &'static str = " ...
row_no = 0; for row in &pattern.rows { let ref channel = row.channels[2]; if row_no!= 0 { write!(writer,",").unwrap(); } if channel.period > 0 { let note = note_from_period(channel.period); write!(writer,"{}", note).unwrap(); } row_no += 1; if is_pattern_break(&row.chan...
write!(writer,"\t{}:", pattern_no).unwrap();
random_line_split
main.rs
use std::fs::File; use std::io::BufWriter; use std::io::Write; use std::io::BufReader; use std::io::Read; extern crate modfile; use modfile::ptmf; #[macro_use] extern crate serde_derive; extern crate docopt; use docopt::Docopt; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); static USAGE: &'static str = " ...
fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.deserialize()) .unwrap_or_else(|e| e.exit()); // println!("{:?}", args); if args.flag_version { println!("Version: {}", VERSION); return; } if args.flag_in == "" { println!("No in...
{ // Check for pattern break let effect = channels[0].effect | channels[1].effect | channels[2].effect; if effect & 0x0f00 == 0x0d00 { true } else { false } }
identifier_body
main.rs
use std::fs::File; use std::io::BufWriter; use std::io::Write; use std::io::BufReader; use std::io::Read; extern crate modfile; use modfile::ptmf; #[macro_use] extern crate serde_derive; extern crate docopt; use docopt::Docopt; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); static USAGE: &'static str = " ...
() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.deserialize()) .unwrap_or_else(|e| e.exit()); // println!("{:?}", args); if args.flag_version { println!("Version: {}", VERSION); return; } if args.flag_in == "" { println!("No inputfile s...
main
identifier_name
main.rs
use std::fs::File; use std::io::BufWriter; use std::io::Write; use std::io::BufReader; use std::io::Read; extern crate modfile; use modfile::ptmf; #[macro_use] extern crate serde_derive; extern crate docopt; use docopt::Docopt; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); static USAGE: &'static str = " ...
if channel.period > 0 { let note = note_from_period(channel.period); write!(writer,"{}", note).unwrap(); } row_no += 1; if is_pattern_break(&row.channels) { break; } } write!(writer,"\n").unwrap(); write!(writer,"\n").unwrap(); pattern_no += 1; } write!(writer, "}...
{ write!(writer,",").unwrap(); }
conditional_block
lib.rs
/* Copyright (C) 2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
{ applayerevent::derive_app_layer_event(input) }
identifier_body
lib.rs
/* Copyright (C) 2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
(input: TokenStream) -> TokenStream { applayerevent::derive_app_layer_event(input) }
derive_app_layer_event
identifier_name
lib.rs
/* Copyright (C) 2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful,
* version 2 along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ extern crate proc_macro; use proc_macro::TokenStream; mod applayerevent; /// The `AppLayerEvent` derive macro generates a `AppLayerEvent` trait /// implem...
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License
random_line_split
count.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::iter::Iterator; use core::iter::Skip; struct A<T> { begin: T, end: T } macro_rules! Iterator_impl { ($T:ty) => { impl Iterator for A<$T> { type Item = $T; fn next(&mut self) -> Option<Self::Item> { if self....
// } #[test] fn count_test1() { let a: A<T> = A { begin: 0, end: 10 }; let n: usize = 3; let skip: Skip<A<T>> = a.skip(n); let count: usize = skip.count(); assert_eq!(count, 10 - n); } }
// let lower = lower.saturating_sub(self.n); // let upper = upper.map(|x| x.saturating_sub(self.n)); // // (lower, upper) // }
random_line_split
count.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::iter::Iterator; use core::iter::Skip; struct
<T> { begin: T, end: T } macro_rules! Iterator_impl { ($T:ty) => { impl Iterator for A<$T> { type Item = $T; fn next(&mut self) -> Option<Self::Item> { if self.begin < self.end { let result = self.begin; self.begin = self.begin.wrapping_add(1); Some::<Self::Item>(result) } els...
A
identifier_name
count.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::iter::Iterator; use core::iter::Skip; struct A<T> { begin: T, end: T } macro_rules! Iterator_impl { ($T:ty) => { impl Iterator for A<$T> { type Item = $T; fn next(&mut self) -> Option<Self::Item> { if self....
}
{ let a: A<T> = A { begin: 0, end: 10 }; let n: usize = 3; let skip: Skip<A<T>> = a.skip(n); let count: usize = skip.count(); assert_eq!(count, 10 - n); }
identifier_body
udp_client_connection.rs
// Copyright 2015-2018 Benjamin Fry <benjaminfry@me.com> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed...
/// Allows a custom timeout pub fn with_timeout(name_server: SocketAddr, timeout: Duration) -> ClientResult<Self> { Ok(UdpClientConnection { name_server, timeout, }) } } impl ClientConnection for UdpClientConnection { type Sender = UdpClientStream<UdpSocket, Sig...
}
random_line_split
udp_client_connection.rs
// Copyright 2015-2018 Benjamin Fry <benjaminfry@me.com> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed...
} impl ClientConnection for UdpClientConnection { type Sender = UdpClientStream<UdpSocket, Signer>; type Response = <Self::Sender as DnsRequestSender>::DnsResponseFuture; type SenderFuture = UdpClientConnect<UdpSocket, Signer>; fn new_stream(&self, signer: Option<Arc<Signer>>) -> Self::SenderFuture {...
{ Ok(UdpClientConnection { name_server, timeout, }) }
identifier_body
udp_client_connection.rs
// Copyright 2015-2018 Benjamin Fry <benjaminfry@me.com> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed...
(name_server: SocketAddr, timeout: Duration) -> ClientResult<Self> { Ok(UdpClientConnection { name_server, timeout, }) } } impl ClientConnection for UdpClientConnection { type Sender = UdpClientStream<UdpSocket, Signer>; type Response = <Self::Sender as DnsRequestSen...
with_timeout
identifier_name
exhaustive_ordered_unique_vecs_length_range.rs
use itertools::Itertools; use malachite_base::bools::exhaustive::exhaustive_bools; use malachite_base::nevers::nevers; use malachite_base::tuples::exhaustive::exhaustive_units; use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_length_range; use std::fmt::Debug; fn exhaustive_ordered_unique_vecs_leng...
); exhaustive_ordered_unique_vecs_length_range_small_helper( 1, 2, 'a'..='c', 3, &[&['a'], &['b'], &['c']], ); }
1, &[&[false, true]],
random_line_split
exhaustive_ordered_unique_vecs_length_range.rs
use itertools::Itertools; use malachite_base::bools::exhaustive::exhaustive_bools; use malachite_base::nevers::nevers; use malachite_base::tuples::exhaustive::exhaustive_units; use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_length_range; use std::fmt::Debug; fn exhaustive_ordered_unique_vecs_leng...
#[test] fn test_exhaustive_ordered_unique_vecs_length_range() { exhaustive_ordered_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]); exhaustive_ordered_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]); exhaustive_ordered_unique_vecs_length_range_small_helper( 0, ...
{ let xss = exhaustive_ordered_unique_vecs_length_range(a, b, xs); let xss_prefix = xss.clone().take(20).collect_vec(); assert_eq!( xss_prefix .iter() .map(Vec::as_slice) .collect_vec() .as_slice(), out ); assert_eq!(xss.count(), out_le...
identifier_body
exhaustive_ordered_unique_vecs_length_range.rs
use itertools::Itertools; use malachite_base::bools::exhaustive::exhaustive_bools; use malachite_base::nevers::nevers; use malachite_base::tuples::exhaustive::exhaustive_units; use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_length_range; use std::fmt::Debug; fn exhaustive_ordered_unique_vecs_leng...
() { exhaustive_ordered_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]); exhaustive_ordered_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]); exhaustive_ordered_unique_vecs_length_range_small_helper( 0, 5, exhaustive_units(), 2, &[&[], &...
test_exhaustive_ordered_unique_vecs_length_range
identifier_name
fmt.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...
-> string::String { let mut output = string::String::new(); let _ = output.write_fmt(args); output }
ents)
identifier_name
fmt.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...
ut = string::String::new(); let _ = output.write_fmt(args); output }
identifier_body
fmt.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...
//! width := count //! precision := count | '*' //! type := identifier | '' //! count := parameter | integer //! parameter := integer '$' //! ``` //! //! # Formatting Parameters //! //! Each argument being formatted can be transformed by a number of formatting //! parameters (corresponding to `format_spec` in the synta...
//! align := '<' | '^' | '>' //! sign := '+' | '-'
random_line_split
main.rs
extern crate bodyparser; extern crate crypto; extern crate env_logger; extern crate iron; extern crate persistent; extern crate router; extern crate rustc_serialize; #[macro_use] extern crate hyper; #[macro_use] extern crate log; mod hook; mod repo_config; use std::env; use std::thread; use hook::*; use iron::prel...
info!("Will listen on {}...", listen); Iron::new(chain).http(&listen[..]).unwrap(); }
{ env_logger::init().unwrap(); let args: Vec<_> = env::args().collect(); if args.len() < 2 || args.len() > 3 { println!("Usage: github-hook-receiver <config dir (no trailing slash.)> [<listen address (127.0.0.1:3000)>]"); std::process::exit(1); } let config_dir = args.get(1).unwrap...
identifier_body
main.rs
extern crate bodyparser; extern crate crypto; extern crate env_logger; extern crate iron; extern crate persistent; extern crate router; extern crate rustc_serialize; #[macro_use] extern crate hyper; #[macro_use] extern crate log; mod hook; mod repo_config; use std::env; use std::thread; use hook::*; use iron::prel...
info!("Will listen on {}...", listen); Iron::new(chain).http(&listen[..]).unwrap(); }
chain.link_before(Read::<bodyparser::MaxBodyLength>::one(MAX_BODY_LENGTH));
random_line_split
main.rs
extern crate bodyparser; extern crate crypto; extern crate env_logger; extern crate iron; extern crate persistent; extern crate router; extern crate rustc_serialize; #[macro_use] extern crate hyper; #[macro_use] extern crate log; mod hook; mod repo_config; use std::env; use std::thread; use hook::*; use iron::prel...
(config_dir_str: &str, req: &mut Request) -> IronResult<Response> { let config_dir = config_dir_str.to_string(); let body = req.get::<bodyparser::Raw>(); let event = req.headers.get::<XGitHubEvent>().unwrap(); let empty_sig = &XHubSignature("".to_string()); let signature = req.headers.get::<XHubSig...
parse_hook
identifier_name
fetch.rs
use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; #[derive(RustcDecodable)] pub struct Options { flag_manifest_path: Option<String>, flag_verbose: bool, flag_quiet: bool, flag_color: Option<String>, } pub const USAGE: &'static str = " Fe...
(options: Options, config: &Config) -> CliResult<Option<()>> { try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())...
execute
identifier_name
fetch.rs
use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; #[derive(RustcDecodable)] pub struct Options { flag_manifest_path: Option<String>, flag_verbose: bool, flag_quiet: bool, flag_color: Option<String>, }
pub const USAGE: &'static str = " Fetch dependencies of a package from the network. Usage: cargo fetch [options] Options: -h, --help Print this message --manifest-path PATH Path to the manifest to fetch dependencies for -v, --verbose Use verbose output -q, --quiet ...
random_line_split
fetch.rs
use cargo::ops; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::find_root_manifest_for_wd; #[derive(RustcDecodable)] pub struct Options { flag_manifest_path: Option<String>, flag_verbose: bool, flag_quiet: bool, flag_color: Option<String>, } pub const USAGE: &'static str = " Fe...
{ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); try!(ops::fetch(&root, config)); Ok(None) }
identifier_body
deriving-global.rs
// xfail-fast #7103 `extern mod` does not work on check-fast // xfail-pretty - does not converge // 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 <LICEN...
() {}
main
identifier_name
deriving-global.rs
// xfail-fast #7103 `extern mod` does not work on check-fast // xfail-pretty - does not converge // 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 <LICEN...
// option. This file may not be copied, modified, or distributed // except according to those terms. extern mod extra; // {En,De}codable mod submod { // if any of these are implemented without global calls for any // function calls, then being in a submodule will (correctly) // cause errors about unrecogni...
random_line_split
deriving-cmp-generic-enum.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 ...
<T> { E0, E1(T), E2(T,T) } pub fn main() { let e0 = E::E0; let e11 = E::E1(1); let e12 = E::E1(2); let e21 = E::E2(1, 1); let e22 = E::E2(1, 2); // in order for both PartialOrd and Ord let es = [e0, e11, e12, e21, e22]; for (i, e1) in es.iter().enumerate() { for (j...
E
identifier_name
deriving-cmp-generic-enum.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let e22 = E::E2(1, 2); // in order for both PartialOrd and Ord let es = [e0, e11, e12, e21, e22]; for (i, e1) in es.iter().enumerate() { for (j, e2) in es.iter().enumerate() { let ord = i.cmp(&j); let eq = i == j; let lt = i < j; let le = i <= j...
random_line_split
lib.rs
#[cfg(test)] mod tests { use rusqlite::{Connection, Result}; use tagged_rusqlite::tagged_sql; #[test] fn
() -> Result<()> { let conn = Connection::open_in_memory()?; tagged_sql!( CreateTable, "CREATE TABLE person ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, data BLOB );" ); ...
smoke_test
identifier_name
lib.rs
#[cfg(test)] mod tests { use rusqlite::{Connection, Result}; use tagged_rusqlite::tagged_sql; #[test] fn smoke_test() -> Result<()> { let conn = Connection::open_in_memory()?; tagged_sql!( CreateTable, "CREATE TABLE person ( id INTEGER PRI...
CreateTable::prepare(&conn).execute()?; tagged_sql!( InsertPerson, r#"INSERT INTO person (name, data) VALUES ( ?1 /*:name:String*/, ?2 /*:data:Option<Vec<u8>>*/ ) RETURNING id /*:i64*/...
random_line_split
lib.rs
#[cfg(test)] mod tests { use rusqlite::{Connection, Result}; use tagged_rusqlite::tagged_sql; #[test] fn smoke_test() -> Result<()>
?2 /*:data:Option<Vec<u8>>*/ ) RETURNING id /*:i64*/; "# ); let mut insert = InsertPerson::prepare(&conn); let id = insert.query_row_bind(&InsertPersonParams { name: "Steven".to_string(), data: Some(vec![1u8,...
{ let conn = Connection::open_in_memory()?; tagged_sql!( CreateTable, "CREATE TABLE person ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, data BLOB );" ); CreateTable::...
identifier_body
spec_from_iter_nested.rs
use core::iter::TrustedLen; use core::ptr::{self}; use super::{SpecExtend, Vec}; /// Another specialization trait for Vec::from_iter /// necessary to manually prioritize overlapping specializations /// see [`SpecFromIter`](super::SpecFromIter) for details. pub(super) trait SpecFromIterNested<T, I> { fn from_iter(...
(mut iterator: I) -> Self { // Unroll the first iteration, as the vector is going to be // expanded on this iteration in every case when the iterable is not // empty, but the loop in extend_desugared() is not going to see the // vector being full in the few subsequent loop iterations. ...
from_iter
identifier_name
spec_from_iter_nested.rs
use core::iter::TrustedLen; use core::ptr::{self}; use super::{SpecExtend, Vec}; /// Another specialization trait for Vec::from_iter /// necessary to manually prioritize overlapping specializations /// see [`SpecFromIter`](super::SpecFromIter) for details. pub(super) trait SpecFromIterNested<T, I> { fn from_iter(...
// vector being full in the few subsequent loop iterations. // So we get better branch prediction. let mut vector = match iterator.next() { None => return Vec::new(), Some(element) => { let (lower, _) = iterator.size_hint(); let mut vector ...
// expanded on this iteration in every case when the iterable is not // empty, but the loop in extend_desugared() is not going to see the
random_line_split
spec_from_iter_nested.rs
use core::iter::TrustedLen; use core::ptr::{self}; use super::{SpecExtend, Vec}; /// Another specialization trait for Vec::from_iter /// necessary to manually prioritize overlapping specializations /// see [`SpecFromIter`](super::SpecFromIter) for details. pub(super) trait SpecFromIterNested<T, I> { fn from_iter(...
}; // must delegate to spec_extend() since extend() itself delegates // to spec_from for empty Vecs <Vec<T> as SpecExtend<T, I>>::spec_extend(&mut vector, iterator); vector } } impl<T, I> SpecFromIterNested<T, I> for Vec<T> where I: TrustedLen<Item = T>, { fn from_i...
{ let (lower, _) = iterator.size_hint(); let mut vector = Vec::with_capacity(lower.saturating_add(1)); unsafe { ptr::write(vector.as_mut_ptr(), element); vector.set_len(1); } vector }
conditional_block
spec_from_iter_nested.rs
use core::iter::TrustedLen; use core::ptr::{self}; use super::{SpecExtend, Vec}; /// Another specialization trait for Vec::from_iter /// necessary to manually prioritize overlapping specializations /// see [`SpecFromIter`](super::SpecFromIter) for details. pub(super) trait SpecFromIterNested<T, I> { fn from_iter(...
<Vec<T> as SpecExtend<T, I>>::spec_extend(&mut vector, iterator); vector } } impl<T, I> SpecFromIterNested<T, I> for Vec<T> where I: TrustedLen<Item = T>, { fn from_iter(iterator: I) -> Self { let mut vector = match iterator.size_hint() { (_, Some(upper)) => Vec::with_c...
{ // Unroll the first iteration, as the vector is going to be // expanded on this iteration in every case when the iterable is not // empty, but the loop in extend_desugared() is not going to see the // vector being full in the few subsequent loop iterations. // So we get better ...
identifier_body
weak-lang-items.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 ...
// This aux-file will require the eh_personality function to be codegen'd, but // it hasn't been defined just yet. Make sure we don't explode. #![feature(no_std)] #![no_std] #![crate_type = "rlib"] #[macro_use] extern crate core; struct A; impl core::ops::Drop for A { fn drop(&mut self) {} } pub fn foo() { ...
// except according to those terms. // no-prefer-dynamic
random_line_split
weak-lang-items.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub fn foo() { let _a = A; panic!("wut"); } mod std { pub use core::{option, fmt}; }
{}
identifier_body
weak-lang-items.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 core::ops::Drop for A { fn drop(&mut self) {} } pub fn foo() { let _a = A; panic!("wut"); } mod std { pub use core::{option, fmt}; }
A
identifier_name
font.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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern crate core_foundation; extern crate core_graphics; exte...
(_fctx: &FontContextHandle, template: Arc<FontTemplateData>, pt_size: Option<Au>) -> Result<FontHandle, ()> { let size = match pt_size { Some(s) => s.to_f64_px(), None => 0.0 }; match template.ctfo...
new_from_template
identifier_name
font.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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern crate core_foundation; extern crate core_graphics; exte...
impl FontTableMethods for FontTable { fn buffer(&self) -> &[u8] { self.data.bytes() } } #[derive(Debug)] pub struct FontHandle { font_data: Arc<FontTemplateData>, ctfont: CTFont, h_kern_subtable: Option<CachedKernTable>, can_do_fast_shaping: bool, } impl FontHandle { /// Cache all ...
}
random_line_split
font.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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern crate core_foundation; extern crate core_graphics; exte...
fn glyph_h_advance(&self, glyph: GlyphId) -> Option<FractionalPixel> { let glyphs = [glyph as CGGlyph]; let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation, &glyphs[0], ...
{ self.can_do_fast_shaping }
identifier_body
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 zzz() {()}
{ let no_padding16 = NoPadding16(10000, -10001); let no_padding32 = NoPadding32(-10002, -10003.5, 10004); let no_padding64 = NoPadding64(-10005.5, 10006, 10007); let no_padding163264 = NoPadding163264(-10008, 10009, 10010, 10011); let internal_padding = InternalPadding(10012, -10013); let paddi...
identifier_body
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...
(u16, i16); struct NoPadding32(i32, f32, u32); struct NoPadding64(f64, i64, u64); struct NoPadding163264(i16, u16, i32, u64); struct InternalPadding(u16, i64); struct PaddingAtEnd(i64, u16); fn main() { let no_padding16 = NoPadding16(10000, -10001); let no_padding32 = NoPadding32(-10002, -10003.5, 10004); ...
NoPadding16
identifier_name
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...
// lldb-command:print no_padding16 // lldb-check:[...]$0 = NoPadding16(10000, -10001) // lldb-command:print no_padding32 // lldb-check:[...]$1 = NoPadding32(-10002, -10003.5, 10004) // lldb-command:print no_padding64 // lldb-check:[...]$2 = NoPadding64(-10005.5, 10006, 10007) // lldb-command:print no_padding163264 ...
random_line_split
types.rs
// Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use crate::python::TypeId; pub struct Types { pub directory_digest: TypeId, pub file_digest: TypeId, pub snapshot: TypeId,
pub file_content: TypeId, pub file_entry: TypeId, pub directory: TypeId, pub digest_contents: TypeId, pub digest_entries: TypeId, pub path_globs: TypeId, pub merge_digests: TypeId, pub add_prefix: TypeId, pub remove_prefix: TypeId, pub create_digest: TypeId, pub digest_subset: TypeId, pub downlo...
pub paths: TypeId,
random_line_split
types.rs
// Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use crate::python::TypeId; pub struct
{ pub directory_digest: TypeId, pub file_digest: TypeId, pub snapshot: TypeId, pub paths: TypeId, pub file_content: TypeId, pub file_entry: TypeId, pub directory: TypeId, pub digest_contents: TypeId, pub digest_entries: TypeId, pub path_globs: TypeId, pub merge_digests: TypeId, pub add_prefix: ...
Types
identifier_name
scoped_tls.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(&'static self) -> bool { unsafe {!self.inner.get().is_null() } } } #[cfg(not(any(windows, target_os = "android", target_os = "ios", target_os = "openbsd", target_arch = "aarch64", no_elf_tls)))] mod imp { use std::cell::Cell; p...
is_set
identifier_name
scoped_tls.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
cb() } /// Gets a value out of this scoped variable. /// /// This function takes a closure which receives the value of this /// variable. /// /// # Panics /// /// This function will panic if `set` has not previously been called. /// /// # Examples /// /// ```...
random_line_split
scoped_tls.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
pub unsafe fn get(&self) -> *mut T { self.inner.get() as *mut _ } } } #[cfg(test)] mod tests { use cell::Cell; use prelude::v1::*; scoped_thread_local!(static FOO: u32); #[test] fn smoke() { scoped_thread_local!(static BAR: u32); assert!(!BAR.is_set()); BAR....
{ self.inner.set(ptr as *mut _) }
identifier_body
media_rule.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/. */ //! An [`@media`][media] urle. //! //! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media use c...
} impl ToCssWithGuard for MediaRule { // Serialization of MediaRule is not specced. // https://drafts.csswg.org/cssom/#serialize-a-css-rule CSSMediaRule fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result { dest.write_str("@media ")?; self.media_queri...
{ // Measurement of other fields may be added later. self.rules.unconditional_shallow_size_of(ops) + self.rules.read_with(guard).size_of(guard, ops) }
identifier_body
media_rule.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/. */ //! An [`@media`][media] urle. //! //! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media use c...
/// [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media #[derive(Debug, ToShmem)] pub struct MediaRule { /// The list of media queries used by this media rule. pub media_queries: Arc<Locked<MediaList>>, /// The nested rules to this media rule. pub rules: Arc<Locked<CssRules>>, /// Th...
/// An [`@media`][media] urle. ///
random_line_split
media_rule.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/. */ //! An [`@media`][media] urle. //! //! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media use c...
{ /// The list of media queries used by this media rule. pub media_queries: Arc<Locked<MediaList>>, /// The nested rules to this media rule. pub rules: Arc<Locked<CssRules>>, /// The source position where this media rule was found. pub source_location: SourceLocation, } impl MediaRule { //...
MediaRule
identifier_name
main.rs
use std::env; use std::io; use std::error::Error; use std::process; use std::process::Command; use std::io::Write; use std::os::unix::process::CommandExt; mod session; mod auth; use auth::authenticate_current_user_n; mod osutils; use osutils::OSUtils; use osutils::unix::UnixOSUtils; mod settings; use settings::Setti...
<T: OSUtils>(osutils: &T) -> Result<i32, Box<dyn Error>> { // Load the settings file let settings = Settings::from_file(CONFIG_PATH) .expect("Unable to read configuration file! Run --genconfig."); // Give the user 3 tries to authenticate let auth_res = authenticate_current_user_n::<T>(osutils, &...
list_permissions
identifier_name
main.rs
use std::env; use std::io; use std::error::Error; use std::process; use std::process::Command; use std::io::Write; use std::os::unix::process::CommandExt; mod session; mod auth; use auth::authenticate_current_user_n; mod osutils; use osutils::OSUtils; use osutils::unix::UnixOSUtils; mod settings; use settings::Setti...
return Ok(1); } }; // Determine the uid of the user to impersonate let mut uid: u32 = 0; let mut gid: u32 = 0; if let Some(username) = user { let uidgid = osutils.get_uidgid_by_username(&username)?; uid = uidgid.0; gid = uidgid.1; } // If the use...
{ // Load the settings file let settings = Settings::from_file(CONFIG_PATH) .expect("Unable to read configuration file! Run --genconfig."); // Give the user 3 tries to authenticate let auth_res = authenticate_current_user_n::<T>(osutils, &settings, 3)?; if !auth_res { return Ok(1);...
identifier_body
main.rs
use std::env; use std::io; use std::error::Error; use std::process; use std::process::Command; use std::io::Write; use std::os::unix::process::CommandExt; mod session; mod auth; use auth::authenticate_current_user_n; mod osutils; use osutils::OSUtils; use osutils::unix::UnixOSUtils; mod settings; use settings::Setti...
// Confirm that user is in the settings file and has permission let username: String = osutils.get_username()?; let safe_command_path = match settings.sanitize_user_command(&username, command) { Ok(v) => v, Err(e) => { dbg!(e); writeln!(&mut io::stderr(), "You don't...
{ return Ok(1); }
conditional_block
main.rs
use std::env; use std::io; use std::error::Error; use std::process; use std::process::Command; use std::io::Write; use std::os::unix::process::CommandExt; mod session; mod auth; use auth::authenticate_current_user_n; mod osutils; use osutils::OSUtils; use osutils::unix::UnixOSUtils; mod settings; use settings::Setti...
} // Confirm that user is in the settings file and has permission let username: String = osutils.get_username()?; let safe_command_path = match settings.sanitize_user_command(&username, command) { Ok(v) => v, Err(e) => { dbg!(e); writeln!(&mut io::stderr(), "You ...
random_line_split
parsers.rs
//! Contains useful [nom](https://github.com/Geal/nom) parsers. use std::path::PathBuf; use nom::not_line_ending; use std::str::{self, FromStr}; use std::borrow::ToOwned; use nom::{digit, alphanumeric}; named!(pub consume_until_line_ending, take_until_and_consume!("\n")); named!(pub parse_line<String>, map!(m...
|s| u32::from_str_radix(s, 8))); named!(pub parse_u8<u8>, map_res!(map_res!(digit, str::from_utf8), FromStr::from_str)); named!(pub parse_u32<u32>, map_res!(map_res!(digit, str::from_utf8), FromStr::from_str)); named!(pub parse_u64<u64>, map_res!(map_res!(digit, str::from_utf8), ...
map_res!(map_res!(alphanumeric, str::from_utf8),
random_line_split
gc_worker.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use engine_traits::{Peekable, CF_WRITE}; use grpcio::{ChannelBuilder, Environment}; use keys::data_key; use kvproto::{kvrpcpb::*, metapb, tikvpb::TikvClient}; use std::sync::Arc; use test_raftstore::*; use tikv::server::gc_wor...
// Create a LockInfo that matches the prewrite request in `must_kv_prewrite`. let mut lock_info = LockInfo::default(); lock_info.set_primary_lock(k.clone()); lock_info.set_lock_version(ts); lock_info.set_key(k); lock_info.set_lock_ttl(3000); ...
.map(|(ts, k, _)| {
random_line_split
gc_worker.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use engine_traits::{Peekable, CF_WRITE}; use grpcio::{ChannelBuilder, Environment}; use keys::data_key; use kvproto::{kvrpcpb::*, metapb, tikvpb::TikvClient}; use std::sync::Arc; use test_raftstore::*; use tikv::server::gc_wor...
retry_times += 1; sleep_ms(20); } }); }; let check_lock = |lock: &LockInfo, k: &[u8], pk: &[u8], ts| { assert_eq!(lock.get_key(), k); assert_eq!(lock.get_primary_lock(), pk); assert_eq!(lock.get_lock_version(), ts); }; // Reg...
{ panic!("failed to read on {:?}: {:?}", p, resp); }
conditional_block
gc_worker.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use engine_traits::{Peekable, CF_WRITE}; use grpcio::{ChannelBuilder, Environment}; use keys::data_key; use kvproto::{kvrpcpb::*, metapb, tikvpb::TikvClient}; use std::sync::Arc; use test_raftstore::*; use tikv::server::gc_wor...
let key = Key::from_raw(b"k1").append_ts(start_ts.into()); let key = data_key(key.as_encoded()); assert!(engine.kv.get_value(&key).unwrap().is_some()); let key = Key::from_raw(b"k1").append_ts(commit_ts.into()); let key = data_key(key.as_encoded()); assert!(engine.kv.ge...
{ let (cluster, leader, ctx) = must_new_cluster_mul(1); cluster.pd_client.disable_default_operator(); let env = Arc::new(Environment::new(1)); let leader_store = leader.get_store_id(); let channel = ChannelBuilder::new(env).connect(&cluster.sim.rl().get_addr(leader_store)); let client = TikvCli...
identifier_body
gc_worker.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use engine_traits::{Peekable, CF_WRITE}; use grpcio::{ChannelBuilder, Environment}; use keys::data_key; use kvproto::{kvrpcpb::*, metapb, tikvpb::TikvClient}; use std::sync::Arc; use test_raftstore::*; use tikv::server::gc_wor...
() { let mut cluster = new_server_cluster(0, 3); cluster.pd_client.disable_default_operator(); cluster.run(); // Create all stores' clients. let env = Arc::new(Environment::new(1)); let mut clients = HashMap::default(); for node_id in cluster.get_node_ids() { let channel = ...
test_applied_lock_collector
identifier_name
counter_button.rs
extern crate domafic; use domafic::tags::{button, div, h1}; use domafic::listener::on; // If rendering client-side with asm.js or WebAssembly: #[cfg(target_os = "emscripten")] use domafic::web_render::{run, JsIo}; #[cfg(target_os = "emscripten")] use domafic::KeyIter; type State = isize; enum Msg { Increment, ...
)), )) }; // If rendering server-side: #[cfg(not(target_os = "emscripten"))] println!("HTML: {}", render(&0)); // If rendering client-side with asm.js or WebAssembly: #[cfg(target_os = "emscripten")] run("body", update, render, 0); }
{ #[cfg(target_os = "emscripten")] let update = |state: &mut State, msg: Msg, _: KeyIter, _: &JsIo<Msg>| { *state = match msg { Msg::Increment => *state + 1, Msg::Decrement => *state - 1, } }; let render = |state: &State| { div (( h1("Hello fr...
identifier_body
counter_button.rs
extern crate domafic; use domafic::tags::{button, div, h1}; use domafic::listener::on; // If rendering client-side with asm.js or WebAssembly: #[cfg(target_os = "emscripten")] use domafic::web_render::{run, JsIo}; #[cfg(target_os = "emscripten")] use domafic::KeyIter; type State = isize; enum Msg { Increment, ...
() { #[cfg(target_os = "emscripten")] let update = |state: &mut State, msg: Msg, _: KeyIter, _: &JsIo<Msg>| { *state = match msg { Msg::Increment => *state + 1, Msg::Decrement => *state - 1, } }; let render = |state: &State| { div (( h1("Hello...
main
identifier_name
counter_button.rs
extern crate domafic; use domafic::tags::{button, div, h1}; use domafic::listener::on; // If rendering client-side with asm.js or WebAssembly: #[cfg(target_os = "emscripten")] use domafic::web_render::{run, JsIo}; #[cfg(target_os = "emscripten")] use domafic::KeyIter; type State = isize; enum Msg { Increment, ...
let update = |state: &mut State, msg: Msg, _: KeyIter, _: &JsIo<Msg>| { *state = match msg { Msg::Increment => *state + 1, Msg::Decrement => *state - 1, } }; let render = |state: &State| { div (( h1("Hello from rust!"), button (( ...
fn main() { #[cfg(target_os = "emscripten")]
random_line_split
b58.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty....
/// Obtain a string with the base58check encoding of a slice /// (Tack the first 4 256-digits of the object's Bitcoin hash onto the end.) pub fn check_encode_slice_to_fmt(fmt: &mut fmt::Formatter, data: &[u8]) -> fmt::Result { let checksum = DoubleSha256::from_data(&data); let iter = data.iter() .clone...
{ let checksum = DoubleSha256::from_data(&data); encode_iter( data.iter() .cloned() .chain(checksum[0..4].iter().cloned()) ) }
identifier_body
b58.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty....
let ck_start = ret.len() - 4; let expected = DoubleSha256::from_data(&ret[..ck_start]).into_le().low_u32(); let actual = LittleEndian::read_u32(&ret[ck_start..(ck_start + 4)]); if expected!= actual { return Err(Error::BadChecksum(expected, actual)); } ret.truncate(ck_start); Ok(ret...
{ return Err(Error::TooShort(ret.len())); }
conditional_block
b58.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty....
assert_eq!(from_check("1PfJpZsjreyVrqeoAfabrRwwjQyoSQMmHH").ok(), Some(hex_decode("00f8917303bfa8ef24f292e8fa1419b20460ba064d").unwrap())) } #[test] fn test_base58_roundtrip() { let s = "xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8...
assert_eq!(from("1211").ok(), Some(vec![0u8, 13, 36])); assert_eq!(from("111211").ok(), Some(vec![0u8, 0, 0, 13, 36])); // Addresses
random_line_split
b58.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty....
() { // Basics assert_eq!(&encode_slice(&[0][..]), "1"); assert_eq!(&encode_slice(&[1][..]), "2"); assert_eq!(&encode_slice(&[58][..]), "21"); assert_eq!(&encode_slice(&[13, 36][..]), "211"); // Leading zeroes assert_eq!(&encode_slice(&[0, 13, 36][..]), "1211"); ...
test_base58_encode
identifier_name
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/. */ //! This module contains traits in script used generically in the rest of Servo. //! The traits are here instead o...
{ pub width: u32, pub height: u32, } /// The address of a node known to be valid. These are sent from script to layout. #[derive(Clone, PartialEq, Eq, Copy)] pub struct TrustedNodeAddress(pub *const c_void); #[allow(unsafe_code)] unsafe impl Send for TrustedNodeAddress {} pub fn is_image_data(uri: &str) -> ...
SVGSVGData
identifier_name
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/. */ //! This module contains traits in script used generically in the rest of Servo. //! The traits are here instead o...
#[derive(Clone, PartialEq, Eq, Copy)] pub struct TrustedNodeAddress(pub *const c_void); #[allow(unsafe_code)] unsafe impl Send for TrustedNodeAddress {} pub fn is_image_data(uri: &str) -> bool { static TYPES: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"]; TYPES.iter().any(...
pub width: u32, pub height: u32, } /// The address of a node known to be valid. These are sent from script to layout.
random_line_split
blink_ops.rs
/* Copyright 2013 Leon Sixt * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
} let idx = algorithm::bsearch_idx(inode.keys().slice_from(0), key); debug!("[get_ptr] key: {}, ptr: {}, keys: {} values: {}, idx: {}, is_most_right_node: {}, is_root: {}", key.to_str(), inode.my_ptr().to_str(), inode.keys().to_str(), inode.values().to_str(), i...
} } fn get_ptr<'a>(&self, inode: &'a INODE, key: &K) -> Option<&'a Ptr> { if !self.can_contain_key(inode,key) { return None;
random_line_split