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
manifest.rs
prelude_items.len(), 0); let content = strip_hashbang(content); let (manifest, source) = find_embedded_manifest(content) .unwrap_or((Manifest::Toml(""), content)); (manifest, source, consts::FILE_TEMPLATE, false) }, Input::Expr(content) => { ...
fn extract_block(s: &str) -> Result<String> { /* On every line: - update nesting level and detect end-of-comment - if margin is None: - if there appears to be a margin, set margin. - strip off margin marker - update the leading space counter - str...
if !s.chars().take(n).all(|c| c == ' ') { return Err(format!("leading {:?} chars aren't all spaces: {:?}", n, s).into()) } Ok(()) }
identifier_body
manifest.rs
!(prelude_items.len(), 0); let content = strip_hashbang(content); let (manifest, source) = find_embedded_manifest(content) .unwrap_or((Manifest::Toml(""), content)); (manifest, source, consts::FILE_TEMPLATE, false) }, Input::Expr(content) => { ...
/** Returns a slice of the input string with the leading hashbang, if there is one, omitted. */ fn strip_hashbang(s: &str) -> &str { match RE_HASHBANG.find(s) { Some((_, end)) => &s[end..], None => s } } #[test] fn test_strip_hashbang() { assert_eq!(strip_hashbang("\ #!/usr/bin/env run-carg...
); }
random_line_split
application.rs
//! This module contains the base elements of an OrbTk application (Application, WindowBuilder and Window). use std::sync::mpsc; use dces::prelude::Entity; use crate::{ core::{application::WindowAdapter, localization::*, *}, shell::{Shell, ShellRequest}, }; /// The `Application` represents the entry point o...
/// Create a new application with the given name. pub fn from_name(name: impl Into<Box<str>>) -> Self { let (sender, receiver) = mpsc::channel(); Application { request_sender: sender, name: name.into(), shell: Shell::new(receiver), theme: Rc::ne...
{ self.localization = Some(Rc::new(RefCell::new(Box::new(localization)))); self }
identifier_body
application.rs
//! This module contains the base elements of an OrbTk application (Application, WindowBuilder and Window). use std::sync::mpsc; use dces::prelude::Entity; use crate::{ core::{application::WindowAdapter, localization::*, *}, shell::{Shell, ShellRequest}, }; /// The `Application` represents the entry point o...
localization: Option<Rc<RefCell<Box<dyn Localization>>>>, } impl Default for Application { fn default() -> Self { Application::from_name("orbtk_application") } } impl Application { /// Creates a new application. pub fn new() -> Self { Self::default() } /// Sets the default...
random_line_split
application.rs
//! This module contains the base elements of an OrbTk application (Application, WindowBuilder and Window). use std::sync::mpsc; use dces::prelude::Entity; use crate::{ core::{application::WindowAdapter, localization::*, *}, shell::{Shell, ShellRequest}, }; /// The `Application` represents the entry point o...
(mut self) { self.shell.run(); } }
run
identifier_name
main.rs
use std::env::args; use std::collections::HashMap; trait Validator { fn increment(&mut self) -> bool; fn has_sequence(&self) -> bool; fn no_forbidden_chars(&self) -> bool; fn has_two_doubles(&self) -> bool; } impl Validator for Vec<u8> { fn increment(&mut self) -> bool { *(self.last...
fn has_two_doubles(&self) -> bool { let mut double_count = 0; let mut pos = 0; while pos < (self.len() - 1) { if self[pos] == self[pos + 1] { double_count += 1; pos += 1; if double_count >= 2 { return true;...
{ let i = ('i' as u8) - ('a' as u8); let o = ('o' as u8) - ('a' as u8); let l = ('l' as u8) - ('a' as u8); !(self.contains(&i) || self.contains(&o) || self.contains(&l)) }
identifier_body
main.rs
use std::env::args; use std::collections::HashMap; trait Validator { fn increment(&mut self) -> bool; fn has_sequence(&self) -> bool; fn no_forbidden_chars(&self) -> bool; fn has_two_doubles(&self) -> bool; } impl Validator for Vec<u8> { fn increment(&mut self) -> bool { *(self.last...
(&self) -> bool { let mut double_count = 0; let mut pos = 0; while pos < (self.len() - 1) { if self[pos] == self[pos + 1] { double_count += 1; pos += 1; if double_count >= 2 { return true; } ...
has_two_doubles
identifier_name
main.rs
use std::env::args; use std::collections::HashMap; trait Validator { fn increment(&mut self) -> bool; fn has_sequence(&self) -> bool; fn no_forbidden_chars(&self) -> bool; fn has_two_doubles(&self) -> bool; } impl Validator for Vec<u8> { fn increment(&mut self) -> bool { *(self.last...
pos += 1; } false } } fn main() { let mut a = args(); a.next(); // The first argument is the binary name/path let start = a.next().unwrap(); // The puzzle input let mut char_to_num = HashMap::new(); let mut num_to_char = HashMap::new(); for i in 0..26 {...
{ double_count += 1; pos += 1; if double_count >= 2 { return true; } }
conditional_block
main.rs
use std::env::args; use std::collections::HashMap; trait Validator { fn increment(&mut self) -> bool; fn has_sequence(&self) -> bool; fn no_forbidden_chars(&self) -> bool; fn has_two_doubles(&self) -> bool; } impl Validator for Vec<u8> { fn increment(&mut self) -> bool { *(self.last_...
} if!passwd_vec.no_forbidden_chars() { continue; } if!passwd_vec.has_two_doubles() { continue; } break; } let readable_passwd = passwd_vec.iter().map(|ch_num| num_to_char[ch_num]).collect::<String>(); println!("The next password is...
random_line_split
main.rs
use std::thread; use std::time::Duration; use std::collections::HashMap; fn main() { let simulated_user_specified_value = 10; let simulated_random_number = 7; generate_workout(simulated_user_specified_value, simulated_random_number); } struct Cacher<T, K, V> where T: Fn(K) -> V, K: Eq + std...
(&mut self, arg: K) -> V { let closure = &self.calculation; let v = self.value .entry(arg.clone()) .or_insert_with(|| (closure)(arg)); (*v).clone() } } fn generate_workout(intensity: i32, random_number: i32) { let mut expensive_result = Cacher::new(|num| { ...
value
identifier_name
main.rs
use std::thread; use std::time::Duration; use std::collections::HashMap; fn main() { let simulated_user_specified_value = 10; let simulated_random_number = 7; generate_workout(simulated_user_specified_value, simulated_random_number); } struct Cacher<T, K, V> where T: Fn(K) -> V, K: Eq + std...
} fn generate_workout(intensity: i32, random_number: i32) { let mut expensive_result = Cacher::new(|num| { println!("calculating slowly..."); thread::sleep(Duration::from_secs(2)); ...
{ let closure = &self.calculation; let v = self.value .entry(arg.clone()) .or_insert_with(|| (closure)(arg)); (*v).clone() }
identifier_body
main.rs
use std::thread; use std::time::Duration; use std::collections::HashMap; fn main() { let simulated_user_specified_value = 10; let simulated_random_number = 7; generate_workout(simulated_user_specified_value, simulated_random_number); } struct Cacher<T, K, V> where T: Fn(K) -> V, K: Eq + std...
fn generate_workout(intensity: i32, random_number: i32) { let mut expensive_result = Cacher::new(|num| { println!("calculating slowly..."); thread::sleep(Duration::from_secs(2)); ...
} }
random_line_split
diffie_hellman.rs
use num_bigint::{BigUint, RandBigInt}; use num_integer::Integer; use num_traits::{One, Zero}; use once_cell::sync::Lazy; use rand::{CryptoRng, Rng}; static DH_GENERATOR: Lazy<BigUint> = Lazy::new(|| BigUint::from_bytes_be(&[0x02])); static DH_PRIME: Lazy<BigUint> = Lazy::new(|| { BigUint::from_bytes_be(&[ ...
exp >>= 1; base = (&base * &base) % modulus; } result } pub struct DhLocalKeys { private_key: BigUint, public_key: BigUint, } impl DhLocalKeys { pub fn random<R: Rng + CryptoRng>(rng: &mut R) -> DhLocalKeys { let private_key = rng.gen_biguint(95 * 8); let public_k...
{ result = (result * &base) % modulus; }
conditional_block
diffie_hellman.rs
use num_bigint::{BigUint, RandBigInt}; use num_integer::Integer; use num_traits::{One, Zero}; use once_cell::sync::Lazy; use rand::{CryptoRng, Rng}; static DH_GENERATOR: Lazy<BigUint> = Lazy::new(|| BigUint::from_bytes_be(&[0x02])); static DH_PRIME: Lazy<BigUint> = Lazy::new(|| { BigUint::from_bytes_be(&[ ...
}); fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint { let mut base = base.clone(); let mut exp = exp.clone(); let mut result: BigUint = One::one(); while!exp.is_zero() { if exp.is_odd() { result = (result * &base) % modulus; } exp >>= 1; ...
])
random_line_split
diffie_hellman.rs
use num_bigint::{BigUint, RandBigInt}; use num_integer::Integer; use num_traits::{One, Zero}; use once_cell::sync::Lazy; use rand::{CryptoRng, Rng}; static DH_GENERATOR: Lazy<BigUint> = Lazy::new(|| BigUint::from_bytes_be(&[0x02])); static DH_PRIME: Lazy<BigUint> = Lazy::new(|| { BigUint::from_bytes_be(&[ ...
(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint { let mut base = base.clone(); let mut exp = exp.clone(); let mut result: BigUint = One::one(); while!exp.is_zero() { if exp.is_odd() { result = (result * &base) % modulus; } exp >>= 1; base = (&ba...
powm
identifier_name
diffie_hellman.rs
use num_bigint::{BigUint, RandBigInt}; use num_integer::Integer; use num_traits::{One, Zero}; use once_cell::sync::Lazy; use rand::{CryptoRng, Rng}; static DH_GENERATOR: Lazy<BigUint> = Lazy::new(|| BigUint::from_bytes_be(&[0x02])); static DH_PRIME: Lazy<BigUint> = Lazy::new(|| { BigUint::from_bytes_be(&[ ...
}
{ let shared_key = powm( &BigUint::from_bytes_be(remote_key), &self.private_key, &DH_PRIME, ); shared_key.to_bytes_be() }
identifier_body
count.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::iter::Iterator; 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.begin < self.end { let ...
() { let mut a: A<T> = A { begin: 0, end: 10 }; assert_eq!(a.next(), Some::<T>(0)); let count: usize = a.count(); assert_eq!(count, 9); } }
count_test2
identifier_name
count.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::iter::Iterator; 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.begin < self.end {
None::<Self::Item> } } // fn count(self) -> usize where Self: Sized { // // Might overflow. // self.fold(0, |cnt, _| cnt + 1) // } } } } type T = i32; Iterator_impl!(T); #[test] fn count_test1() { let a: A<T> = A { begin: 0, end: 10 }; let count: usize = a.count...
let result = self.begin; self.begin = self.begin.wrapping_add(1); Some::<Self::Item>(result) } else {
random_line_split
main.rs
// Copyright 2020 Google LLC // // 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 ...
states: u32, width: u32, } const fn num_bits<T>() -> usize { std::mem::size_of::<T>() * 8 } fn log_2(x: u32) -> u32 { num_bits::<u32>() as u32 - x.leading_zeros() } impl Generator { fn generate<'a>(&'a self, c: &'a mut Context<'a>) -> &'a Module { let mut rng = rand::thread_rng(); //...
} struct Generator {
random_line_split
main.rs
// Copyright 2020 Google LLC // // 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 ...
<'a>(&'a self, c: &'a mut Context<'a>) -> &'a Module { let mut rng = rand::thread_rng(); // compute width of state register let state_reg_width = log_2(self.states - 1u32); // create lock module with a single state register and trigger input let lock = c.module("lock"); ...
generate
identifier_name
main.rs
// Copyright 2020 Google LLC // // 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 ...
fn log_2(x: u32) -> u32 { num_bits::<u32>() as u32 - x.leading_zeros() } impl Generator { fn generate<'a>(&'a self, c: &'a mut Context<'a>) -> &'a Module { let mut rng = rand::thread_rng(); // compute width of state register let state_reg_width = log_2(self.states - 1u32); /...
{ std::mem::size_of::<T>() * 8 }
identifier_body
slab.rs
use alloc::heap::{Alloc, AllocErr, Layout}; use spin::Mutex; use slab_allocator::Heap; static HEAP: Mutex<Option<Heap>> = Mutex::new(None); pub struct Allocator; impl Allocator { pub unsafe fn init(offset: usize, size: usize) { *HEAP.lock() = Some(Heap::new(offset, size)); } } unsafe impl<'a> Alloc ...
if let Some(ref mut heap) = *HEAP.lock() { heap.allocate(layout) } else { panic!("__rust_allocate: heap not initialized"); } } unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) { if let Some(ref mut heap) = *HEAP.lock() { heap.dealloc...
unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
random_line_split
slab.rs
use alloc::heap::{Alloc, AllocErr, Layout}; use spin::Mutex; use slab_allocator::Heap; static HEAP: Mutex<Option<Heap>> = Mutex::new(None); pub struct Allocator; impl Allocator { pub unsafe fn init(offset: usize, size: usize) { *HEAP.lock() = Some(Heap::new(offset, size)); } } unsafe impl<'a> Alloc ...
(&mut self, error: AllocErr) ->! { panic!("Out of memory: {:?}", error); } fn usable_size(&self, layout: &Layout) -> (usize, usize) { if let Some(ref mut heap) = *HEAP.lock() { heap.usable_size(layout) } else { panic!("__rust_usable_size: heap not initialized"); ...
oom
identifier_name
slab.rs
use alloc::heap::{Alloc, AllocErr, Layout}; use spin::Mutex; use slab_allocator::Heap; static HEAP: Mutex<Option<Heap>> = Mutex::new(None); pub struct Allocator; impl Allocator { pub unsafe fn init(offset: usize, size: usize) { *HEAP.lock() = Some(Heap::new(offset, size)); } } unsafe impl<'a> Alloc ...
fn usable_size(&self, layout: &Layout) -> (usize, usize) { if let Some(ref mut heap) = *HEAP.lock() { heap.usable_size(layout) } else { panic!("__rust_usable_size: heap not initialized"); } } }
{ panic!("Out of memory: {:?}", error); }
identifier_body
slab.rs
use alloc::heap::{Alloc, AllocErr, Layout}; use spin::Mutex; use slab_allocator::Heap; static HEAP: Mutex<Option<Heap>> = Mutex::new(None); pub struct Allocator; impl Allocator { pub unsafe fn init(offset: usize, size: usize) { *HEAP.lock() = Some(Heap::new(offset, size)); } } unsafe impl<'a> Alloc ...
} unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) { if let Some(ref mut heap) = *HEAP.lock() { heap.deallocate(ptr, layout) } else { panic!("__rust_deallocate: heap not initialized"); } } fn oom(&mut self, error: AllocErr) ->! { panic...
{ panic!("__rust_allocate: heap not initialized"); }
conditional_block
mod.rs
::headers::{HeaderFormat, UserAgent, Header}; use mime_guess::{guess_mime_type_opt, get_mime_type_str}; use xml::name::{OwnedName as OwnedXmlName, Name as XmlName}; use std::io::{ErrorKind as IoErrorKind, BufReader, BufRead, Result as IoResult, Error as IoError}; pub use self::os::*; pub use self::webdav::*; pub use s...
} /// Get the metadata of the specified file. /// /// The specified path must point to a file. pub fn get_raw_fs_metadata<P: AsRef<Path>>(f: P) -> RawFileData { get_raw_fs_metadata_impl(f.as_ref()) } fn get_raw_fs_metadata_impl(f: &Path) -> RawFileData { let meta = f.metadata().expect("Failed to get requested...
"" }
random_line_split
mod.rs
headers::{HeaderFormat, UserAgent, Header}; use mime_guess::{guess_mime_type_opt, get_mime_type_str}; use xml::name::{OwnedName as OwnedXmlName, Name as XmlName}; use std::io::{ErrorKind as IoErrorKind, BufReader, BufRead, Result as IoResult, Error as IoError}; pub use self::os::*; pub use self::webdav::*; pub use sel...
} impl<'n> BorrowXmlName<'n> for OwnedXmlName { #[inline(always)] fn borrow_xml_name(&'n self) -> XmlName<'n> { self.borrow() } } #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct Spaces(pub usize); impl fmt::Display for Spaces { fn fmt(&self, f: &mut fmt::Format...
{ *self }
identifier_body
mod.rs
headers::{HeaderFormat, UserAgent, Header}; use mime_guess::{guess_mime_type_opt, get_mime_type_str}; use xml::name::{OwnedName as OwnedXmlName, Name as XmlName}; use std::io::{ErrorKind as IoErrorKind, BufReader, BufRead, Result as IoResult, Error as IoError}; pub use self::os::*; pub use self::webdav::*; pub use sel...
f_whom { return true; } while let Some(who_p) = who.parent().map(|p| p.to_path_buf()) { who = who_p; if who == of_whom { return true; } } false } /// Check if the specified path is a direct descendant (or an equal) of the specified path, without without re...
alse; }; if who == o
conditional_block
mod.rs
headers::{HeaderFormat, UserAgent, Header}; use mime_guess::{guess_mime_type_opt, get_mime_type_str}; use xml::name::{OwnedName as OwnedXmlName, Name as XmlName}; use std::io::{ErrorKind as IoErrorKind, BufReader, BufRead, Result as IoResult, Error as IoError}; pub use self::os::*; pub use self::webdav::*; pub use sel...
-> Tm { match time.elapsed() { Ok(dur) => time::now_utc() - Duration::from_std(dur).unwrap(), Err(ste) => time::now_utc() + Duration::from_std(ste.duration()).unwrap(), } } /// Check, whether, in any place of the path, a file is treated like a directory. /// /// A file is treated like a direct...
e: SystemTime)
identifier_name
record-pat.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: t1, y: int} enum t3 { c(T2, uint), } fn m(in: t3) -> int { match in { c(T2 {x: a(m), _}, _) => { return m; } c(T2 {x: b(m), y: y}, z) => { return ((m + z) as int) + y; } } } pub fn main() { assert_eq!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); assert_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)), 19); ...
T2
identifier_name
record-pat.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
c(T2 {x: b(m), y: y}, z) => { return ((m + z) as int) + y; } } } pub fn main() { assert_eq!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); assert_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)), 19); }
{ return m; }
conditional_block
record-pat.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!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); assert_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)), 19); }
c(T2 {x: b(m), y: y}, z) => { return ((m + z) as int) + y; } } } pub fn main() {
random_line_split
length_limit.rs
//! See [`HtmlWithLimit`]. use std::fmt::Write; use std::ops::ControlFlow; use crate::html::escape::Escape; /// A buffer that allows generating HTML with a length limit. /// /// This buffer ensures that: /// /// * all tags are closed, /// * tags are closed in the reverse order of when they were opened (i.e., the cor...
/// Open an HTML tag. /// /// **Note:** HTML attributes have not yet been implemented. /// This function will panic if called with a non-alphabetic `tag_name`. pub(super) fn open_tag(&mut self, tag_name: &'static str) { assert!( tag_name.chars().all(|c| ('a'..='z').contains(&c)...
{ if self.len + text.len() > self.limit { return ControlFlow::BREAK; } self.flush_queue(); write!(self.buf, "{}", Escape(text)).unwrap(); self.len += text.len(); ControlFlow::CONTINUE }
identifier_body
length_limit.rs
//! See [`HtmlWithLimit`]. use std::fmt::Write; use std::ops::ControlFlow; use crate::html::escape::Escape; /// A buffer that allows generating HTML with a length limit. /// /// This buffer ensures that: /// /// * all tags are closed, /// * tags are closed in the reverse order of when they were opened (i.e., the cor...
// a tag is opened after the length limit is exceeded; // `flush_queue()` will never be called, and thus, the tag will // not end up being added to `unclosed_tags`. None => {} } } /// Write all queued tags and add them to the `unclosed_tags` list. fn ...
random_line_split
length_limit.rs
//! See [`HtmlWithLimit`]. use std::fmt::Write; use std::ops::ControlFlow; use crate::html::escape::Escape; /// A buffer that allows generating HTML with a length limit. /// /// This buffer ensures that: /// /// * all tags are closed, /// * tags are closed in the reverse order of when they were opened (i.e., the cor...
(&mut self) { while!self.unclosed_tags.is_empty() { self.close_tag(); } } } #[cfg(test)] mod tests;
close_all_tags
identifier_name
tuple_impl.rs
//! Some iterator that produces tuples use std::iter::Fuse; // `HomogeneousTuple` is a public facade for `TupleCollect`, allowing // tuple-related methods to be used by clients in generic contexts, while // hiding the implementation details of `TupleCollect`. // See https://github.com/rust-itertools/itertools/issues/...
where T: HomogeneousTuple { type Item = T::Item; fn next(&mut self) -> Option<Self::Item> { let s = self.buf.as_mut(); if let Some(ref mut item) = s.get_mut(self.cur) { self.cur += 1; item.take() } else { None } } fn size_hint(&se...
impl<T> Iterator for TupleBuffer<T>
random_line_split
tuple_impl.rs
//! Some iterator that produces tuples use std::iter::Fuse; // `HomogeneousTuple` is a public facade for `TupleCollect`, allowing // tuple-related methods to be used by clients in generic contexts, while // hiding the implementation details of `TupleCollect`. // See https://github.com/rust-itertools/itertools/issues/...
} pub trait TupleCollect: Sized { type Item; type Buffer: Default + AsRef<[Option<Self::Item>]> + AsMut<[Option<Self::Item>]>; fn collect_from_iter<I>(iter: I, buf: &mut Self::Buffer) -> Option<Self> where I: IntoIterator<Item = Self::Item>; fn collect_from_iter_no_buf<I>(iter: I) -> Option<...
{ if T::num_items() == 1 { return T::collect_from_iter_no_buf(&mut self.iter) } if let Some(ref mut last) = self.last { if let Some(new) = self.iter.next() { last.left_shift_push(new); return Some(last.clone()); } } ...
identifier_body
tuple_impl.rs
//! Some iterator that produces tuples use std::iter::Fuse; // `HomogeneousTuple` is a public facade for `TupleCollect`, allowing // tuple-related methods to be used by clients in generic contexts, while // hiding the implementation details of `TupleCollect`. // See https://github.com/rust-itertools/itertools/issues/...
; (len, Some(len)) } } impl<T> ExactSizeIterator for TupleBuffer<T> where T: HomogeneousTuple { } /// An iterator that groups the items in tuples of a specific size. /// /// See [`.tuples()`](../trait.Itertools.html#method.tuples) for more information. #[derive(Clone)] #[must_use = "iterator adaptors ...
{ buffer.iter() .position(|x| x.is_none()) .unwrap_or(buffer.len()) }
conditional_block
tuple_impl.rs
//! Some iterator that produces tuples use std::iter::Fuse; // `HomogeneousTuple` is a public facade for `TupleCollect`, allowing // tuple-related methods to be used by clients in generic contexts, while // hiding the implementation details of `TupleCollect`. // See https://github.com/rust-itertools/itertools/issues/...
(&mut self) -> Option<T> { if T::num_items() == 1 { return T::collect_from_iter_no_buf(&mut self.iter) } if let Some(ref mut last) = self.last { if let Some(new) = self.iter.next() { last.left_shift_push(new); return Some(last.clone()); ...
next
identifier_name
users.rs
#![crate_name = "users"] /* * This file is part of the uutils coreutils package. * * (c) KokaKiwi <kokakiwi@kokakiwi.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* last synced with: whoami (GNU coreutils) 8.22 */ // All...
if matches.opt_present("version") { println!("{} {}", NAME, VERSION); return 0; } let filename = if matches.free.len() > 0 { matches.free[0].as_ref() } else { DEFAULT_FILE }; exec(filename); 0 } fn exec(filename: &str) { unsafe { utmpxname(CS...
{ let mut opts = Options::new(); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(f) => panic!("{}", f), }; if matches.opt_present("help") ...
identifier_body
users.rs
#![crate_name = "users"] /* * This file is part of the uutils coreutils package. * * (c) KokaKiwi <kokakiwi@kokakiwi.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* last synced with: whoami (GNU coreutils) 8.22 */ // All...
(args: Vec<String>) -> i32 { let mut opts = Options::new(); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(f) => panic!("{}", f), }; if m...
uumain
identifier_name
users.rs
#![crate_name = "users"] /* * This file is part of the uutils coreutils package. * * (c) KokaKiwi <kokakiwi@kokakiwi.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* last synced with: whoami (GNU coreutils) 8.22 */ // All...
if (*line).ut_type == USER_PROCESS { let user = String::from_utf8_lossy(CStr::from_ptr(mem::transmute(&(*line).ut_user)).to_bytes()).to_string(); users.push(user); } } endutxent(); } if users.len() > 0 { users.sort(); pr...
{ break; }
conditional_block
users.rs
#![crate_name = "users"] /* * This file is part of the uutils coreutils package. * * (c) KokaKiwi <kokakiwi@kokakiwi.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* last synced with: whoami (GNU coreutils) 8.22 */ // All...
println!(""); println!("Usage:"); println!(" {} [OPTION]... [FILE]", NAME); println!(""); println!("{}", opts.usage("Output who is currently logged in according to FILE.")); return 0; } if matches.opt_present("version") { println!("{} {}", NAME, VERSION)...
println!("{} {}", NAME, VERSION);
random_line_split
hello_triangle.rs
extern crate bootstrap_rs as bootstrap; extern crate polygon; use bootstrap::window::*; use polygon::*; use polygon::anchor::*; use polygon::camera::*; use polygon::math::*; use polygon::mesh_instance::*; use polygon::geometry::mesh::*; static VERTEX_POSITIONS: [f32; 12] = [ -1.0, -1.0, 0.0, 1.0, 1.0, -1.0, ...
() { // Open a window and create the renderer instance. let mut window = Window::new("Hello, Triangle!").unwrap(); let mut renderer = RendererBuilder::new(&window).build(); // Build a triangle mesh. let mesh = MeshBuilder::new() .set_position_data(Point::slice_from_f32_slice(&VERTEX_POSITION...
main
identifier_name
hello_triangle.rs
extern crate bootstrap_rs as bootstrap; extern crate polygon; use bootstrap::window::*; use polygon::*; use polygon::anchor::*; use polygon::camera::*; use polygon::math::*; use polygon::mesh_instance::*; use polygon::geometry::mesh::*; static VERTEX_POSITIONS: [f32; 12] = [ -1.0, -1.0, 0.0, 1.0, 1.0, -1.0, ...
// Send the mesh to the GPU. let gpu_mesh = renderer.register_mesh(&mesh); // Create an anchor and register it with the renderer. let anchor = Anchor::new(); let anchor_id = renderer.register_anchor(anchor); // Setup the material for the mesh. let mut material = renderer.default_material(...
.set_indices(&INDICES) .build() .unwrap();
random_line_split
hello_triangle.rs
extern crate bootstrap_rs as bootstrap; extern crate polygon; use bootstrap::window::*; use polygon::*; use polygon::anchor::*; use polygon::camera::*; use polygon::math::*; use polygon::mesh_instance::*; use polygon::geometry::mesh::*; static VERTEX_POSITIONS: [f32; 12] = [ -1.0, -1.0, 0.0, 1.0, 1.0, -1.0, ...
let mut material = renderer.default_material(); material.set_color("surface_color", Color::rgb(1.0, 0.0, 0.0)); // Create a mesh instance, attach it to the anchor, and register it. let mut mesh_instance = MeshInstance::with_owned_material(gpu_mesh, material); mesh_instance.set_anchor(anchor_id); ...
{ // Open a window and create the renderer instance. let mut window = Window::new("Hello, Triangle!").unwrap(); let mut renderer = RendererBuilder::new(&window).build(); // Build a triangle mesh. let mesh = MeshBuilder::new() .set_position_data(Point::slice_from_f32_slice(&VERTEX_POSITIONS)...
identifier_body
xml.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/. */ #![allow(unrooted_must_root)] use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::trace::J...
} #[allow(unsafe_code)] unsafe impl JSTraceable for XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>> { unsafe fn trace(&self, trc: *mut JSTracer) { struct Tracer(*mut JSTracer); let tracer = Tracer(trc); impl XmlTracer for Tracer { type Handle = Dom<Node>; #[allow(unr...
{ &self.inner.sink.sink.base_url }
identifier_body
xml.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/. */ #![allow(unrooted_must_root)] use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::trace::J...
Ok(()) } pub fn end(&mut self) { self.inner.end() } pub fn url(&self) -> &ServoUrl { &self.inner.sink.sink.base_url } } #[allow(unsafe_code)] unsafe impl JSTraceable for XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>> { unsafe fn trace(&self, trc: *mut JSTracer) { ...
{ return Err(script); }
conditional_block
xml.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/. */ #![allow(unrooted_must_root)] use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::trace::J...
node.trace(self.0); } } } let tree_builder = &self.sink; tree_builder.trace_handles(&tracer); tree_builder.sink.trace(trc); } }
type Handle = Dom<Node>; #[allow(unrooted_must_root)] fn trace_handle(&self, node: &Dom<Node>) { unsafe {
random_line_split
xml.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/. */ #![allow(unrooted_must_root)] use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::trace::J...
(&self, trc: *mut JSTracer) { struct Tracer(*mut JSTracer); let tracer = Tracer(trc); impl XmlTracer for Tracer { type Handle = Dom<Node>; #[allow(unrooted_must_root)] fn trace_handle(&self, node: &Dom<Node>) { unsafe { nod...
trace
identifier_name
method_info.rs
use super::Attributes; #[derive(Debug)] pub struct
{ pub access_flags: MethodAccessFlags, pub name_index: u16, pub descriptor_index: u16, pub attrs: Attributes, } bitflags! { pub flags MethodAccessFlags: u16 { const METHOD_ACC_PUBLIC = 0x0001, const METHOD_ACC_PRIVATE = 0x0002, const METHOD_ACC_PROTECTED = ...
MethodInfo
identifier_name
method_info.rs
use super::Attributes; #[derive(Debug)] pub struct MethodInfo { pub access_flags: MethodAccessFlags, pub name_index: u16, pub descriptor_index: u16, pub attrs: Attributes, } bitflags! { pub flags MethodAccessFlags: u16 { const METHOD_ACC_PUBLIC = 0x0001, const METHOD_ACC_PRI...
} pub fn is_bridge(&self) -> bool { self.contains(METHOD_ACC_BRIDGE) } pub fn is_varargs(&self) -> bool { self.contains(METHOD_ACC_VARARGS) } pub fn is_native(&self) -> bool { self.contains(METHOD_ACC_NATIVE) } pub fn is_abstract(&self) -> bool { self....
random_line_split
text.rs
debug!("TextRunScanner: complete."); InlineFragments { fragments: new_fragments, } } /// A "clump" is a range of inline flow leaves that can be merged together into a single /// fragment. Adjacent text with the same style can be merged, and nothing else can. /// /...
UnscannedTextFragmentInfo::new(string_before, insertion_point_before)))
random_line_split
text.rs
t_newline_if_necessary(&mut fragments); self.clump.append(&mut split_off_head(&mut fragments)); } // Flush that clump to the list of fragments we're building up. last_whitespace = self.flush_clump_to_list(font_context, ...
yle: &ComputedValues, metrics: &FontMetrics) -> Au { let font_size = style.get_font().font_size; match style.get_inheritedbox().line_height { line_height::T::Normal => metrics.line_gap, line_height::T::Number(l) => font_size.scale_by(l), line_height::T::Length(l) => l } } fn split_f...
e_height_from_style(st
identifier_name
text.rs
at_newline_if_necessary(&mut fragments); self.clump.append(&mut split_off_head(&mut fragments)); } // Flush that clump to the list of fragments we're building up. last_whitespace = self.flush_clump_to_list(font_context, ...
_ => panic!("Expected an unscanned text fragment!"), }; let (mut start_position, mut end_position) = (0, 0); for character in text.chars() { // Search for the first font in this font group that contains a glyph for this ...
{ text = &text_fragment_info.text; insertion_point = text_fragment_info.insertion_point; }
conditional_block
progress.rs
//! A simple progress meter. //! //! Records updates of number of files visited, and number of bytes //! processed. When given an estimate, printes a simple periodic report of //! how far along we think we are. use env_logger::Builder; use lazy_static::lazy_static; use log::Log; use std::{ io::{stdout, Write}, ...
format!("{:6.*}{}", precision, value, UNITS[unit]) }
{ let mut value = value as f64; let mut unit = 0; while value > 1024.0 { value /= 1024.0; unit += 1; } static UNITS: [&str; 9] = [ "B ", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", ]; let precision = if value < 10.0 { 3 } else if value < 10...
identifier_body
progress.rs
//! A simple progress meter. //! //! Records updates of number of files visited, and number of bytes //! processed. When given an estimate, printes a simple periodic report of //! how far along we think we are. use env_logger::Builder; use lazy_static::lazy_static; use log::Log; use std::{ io::{stdout, Write}, ...
next_update: update_interval(false), is_logging: false, }); } impl State { /// Called to advance to the next message, sets the update time /// appropriately. fn next(&mut self) { self.next_update = update_interval(self.is_logging); } /// Clears the visual text of the cu...
message: String::new(),
random_line_split
progress.rs
//! A simple progress meter. //! //! Records updates of number of files visited, and number of bytes //! processed. When given an estimate, printes a simple periodic report of //! how far along we think we are. use env_logger::Builder; use lazy_static::lazy_static; use log::Log; use std::{ io::{stdout, Write}, ...
(&mut self) { self.next_update = update_interval(self.is_logging); } /// Clears the visual text of the current message (but not the message /// buffer itself, so that it can be redisplayed if needed). fn clear(&self) { for ch in self.message.chars() { if ch == '\n' { ...
next
identifier_name
progress.rs
//! A simple progress meter. //! //! Records updates of number of files visited, and number of bytes //! processed. When given an estimate, printes a simple periodic report of //! how far along we think we are. use env_logger::Builder; use lazy_static::lazy_static; use log::Log; use std::{ io::{stdout, Write}, ...
} lazy_static! { // The current global state. static ref STATE: Mutex<State> = Mutex::new(State { message: String::new(), next_update: update_interval(false), is_logging: false, }); } impl State { /// Called to advance to the next message, sets the update time /// appropri...
{ OffsetDateTime::now_utc() + Duration::seconds(5) }
conditional_block
shared_lock.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/. */ //! Different objects protected by the same lock use crate::str::{CssString, CssStringWriter}; use crate::styles...
/// A trait to do a deep clone of a given CSS type. Gets a lock and a read /// guard, in order to be able to read and clone nested structures. pub trait DeepCloneWithLock: Sized { /// Deep clones this object. fn deep_clone_with_lock( &self, lock: &SharedRwLock, guard: &SharedRwLockReadGu...
pub struct DeepCloneParams;
random_line_split
shared_lock.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/. */ //! Different objects protected by the same lock use crate::str::{CssString, CssStringWriter}; use crate::styles...
trait to do a deep clone of a given CSS type. Gets a lock and a read /// guard, in order to be able to read and clone nested structures. pub trait DeepCloneWithLock: Sized { /// Deep clones this object. fn deep_clone_with_lock( &self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard, ...
eParams; /// A
identifier_name
rotation.rs
// Copyright 2015 The CGMath Developers. For a full listing of the authors, // refer to the Cargo.toml file at the top-level directory of this distribution. // // 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 ...
() { let a: Basis3<_> = rotation::a3(); assert!(a.concat(&a.invert()).as_matrix3().is_identity()); }
test_invert_basis3
identifier_name
rotation.rs
// Copyright 2015 The CGMath Developers. For a full listing of the authors, // refer to the Cargo.toml file at the top-level directory of this distribution. // // 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 ...
} #[test] fn test_invert_basis3() { let a: Basis3<_> = rotation::a3(); assert!(a.concat(&a.invert()).as_matrix3().is_identity()); }
let a: Basis2<_> = rotation::a2(); assert!(a.concat(&a.invert()).as_matrix2().is_identity());
random_line_split
rotation.rs
// Copyright 2015 The CGMath Developers. For a full listing of the authors, // refer to the Cargo.toml file at the top-level directory of this distribution. // // 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 ...
#[test] fn test_invert_basis3() { let a: Basis3<_> = rotation::a3(); assert!(a.concat(&a.invert()).as_matrix3().is_identity()); }
{ let a: Basis2<_> = rotation::a2(); assert!(a.concat(&a.invert()).as_matrix2().is_identity()); }
identifier_body
doc_test_lints.rs
//! This pass is overloaded and runs two different lints. //! //! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests //! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests. use super::Pass; use crate::clean; use crate::clean::*; use cr...
} pub(crate) struct Tests { pub(crate) found_tests: usize, } impl crate::doctest::Tester for Tests { fn add_test(&mut self, _: String, config: LangString, _: usize) { if config.rust && config.ignore == Ignore::None { self.found_tests += 1; } } } crate fn should_have_doc_exampl...
random_line_split
doc_test_lints.rs
//! This pass is overloaded and runs two different lints. //! //! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests //! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests. use super::Pass; use crate::clean; use crate::clean::*; use cr...
<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) { let hir_id = match DocContext::as_local_hir_id(cx.tcx, item.def_id) { Some(hir_id) => hir_id, None => { // If non-local, no need to check anything. return; } }; let mut tests = Tests { found_tests: 0 }; ...
look_for_tests
identifier_name
doc_test_lints.rs
//! This pass is overloaded and runs two different lints. //! //! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests //! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests. use super::Pass; use crate::clean; use crate::clean::*; use cr...
} pub(crate) struct Tests { pub(crate) found_tests: usize, } impl crate::doctest::Tester for Tests { fn add_test(&mut self, _: String, config: LangString, _: usize) { if config.rust && config.ignore == Ignore::None { self.found_tests += 1; } } } crate fn should_have_doc_examp...
{ let dox = item.attrs.collapsed_doc_value().unwrap_or_else(String::new); look_for_tests(self.cx, &dox, &item); Some(self.fold_item_recur(item)) }
identifier_body
doc_test_lints.rs
//! This pass is overloaded and runs two different lints. //! //! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests //! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests. use super::Pass; use crate::clean; use crate::clean::*; use cr...
} } crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool { if!cx.cache.access_levels.is_public(item.def_id.expect_def_id()) || matches!( *item.kind, clean::StructFieldItem(_) | clean::VariantItem(_) | clean::AssocCons...
{ self.found_tests += 1; }
conditional_block
mut_mut.rs
use clippy_utils::diagnostics::span_lint; use clippy_utils::higher; use rustc_hir as hir; use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::map::Map; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_...
{ span_lint( self.cx, MUT_MUT, ty.span, "generally you want to avoid `&mut &mut _` if possible", ); } } intravisit::walk_ty(self, ty); } fn nested_visit_map(&...
{ if in_external_macro(self.cx.sess(), ty.span) { return; } if let hir::TyKind::Rptr( _, hir::MutTy { ty: pty, mutbl: hir::Mutability::Mut, }, ) = ty.kind { if let hir::TyKind::Rptr( ...
identifier_body
mut_mut.rs
use clippy_utils::diagnostics::span_lint; use clippy_utils::higher; use rustc_hir as hir; use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::map::Map; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_...
} intravisit::walk_ty(self, ty); } fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> { intravisit::NestedVisitorMap::None } }
random_line_split
mut_mut.rs
use clippy_utils::diagnostics::span_lint; use clippy_utils::higher; use rustc_hir as hir; use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::map::Map; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_...
<'a, 'tcx> { cx: &'a LateContext<'tcx>, } impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { type Map = Map<'tcx>; fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) { if in_external_macro(self.cx.sess(), expr.span) { return; } if let Some(higher::For...
MutVisitor
identifier_name
borrowed-unique-basic.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...
() {()}
zzz
identifier_name
borrowed-unique-basic.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...
// gdb-command:print/d *i8_ref // gdb-check:$4 = 68 // gdb-command:print *i16_ref // gdb-check:$5 = -16 // gdb-command:print *i32_ref // gdb-check:$6 = -32 // gdb-command:print *i64_ref // gdb-check:$7 = -64 // gdb-command:print *uint_ref // gdb-check:$8 = 1 // gdb-command:print/d *u8_ref // gdb-check:$9 = 100 /...
// gdb-command:print *char_ref // gdb-check:$3 = 97
random_line_split
borrowed-unique-basic.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...
{()}
identifier_body
coherence-blanket-conflicts-with-specific-cross-crate.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self, arg: isize) { } } impl GoMut for MyThingy { //~ ERROR conflicting implementations fn go_mut(&mut self, arg: isize) { } } fn main() { }
go
identifier_name
coherence-blanket-conflicts-with-specific-cross-crate.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 go_mut(&mut self, arg: isize) { } } fn main() { }
random_line_split
coherence-blanket-conflicts-with-specific-cross-crate.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 GoMut for MyThingy { //~ ERROR conflicting implementations fn go_mut(&mut self, arg: isize) { } } fn main() { }
{ }
identifier_body
can_read_log_from_rosout.rs
use crossbeam::channel::unbounded; use std::collections::BTreeSet; mod util; mod msg { rosrust::rosmsg_include!(rosgraph_msgs / Log); } #[test] fn
() { let _roscore = util::run_roscore_for(util::Language::None, util::Feature::Log); rosrust::init("rosout_agg_listener"); let (tx, rx) = unbounded(); let _subscriber = rosrust::subscribe::<msg::rosgraph_msgs::Log, _>("/rosout_agg", 100, move |data| { tx.send((data.level, data.msg...
can_read_log_from_rosout
identifier_name
can_read_log_from_rosout.rs
use crossbeam::channel::unbounded; use std::collections::BTreeSet; mod util; mod msg { rosrust::rosmsg_include!(rosgraph_msgs / Log); } #[test] fn can_read_log_from_rosout() { let _roscore = util::run_roscore_for(util::Language::None, util::Feature::Log); rosrust::init("rosout_agg_listener"); let (...
rosrust::ros_debug!("debug message"); rosrust::ros_info!("info message"); rosrust::ros_warn!("warn message"); rosrust::ros_err!("err message"); rosrust::ros_fatal!("fatal message"); rate.sleep(); } panic!("Failed to receive data on /rosout_agg"); }
{ return; }
conditional_block
can_read_log_from_rosout.rs
use crossbeam::channel::unbounded; use std::collections::BTreeSet; mod util; mod msg { rosrust::rosmsg_include!(rosgraph_msgs / Log); } #[test] fn can_read_log_from_rosout() { let _roscore = util::run_roscore_for(util::Language::None, util::Feature::Log); rosrust::init("rosout_agg_listener"); let (...
expected_messages.insert((16, "fatal message".to_owned())); for _ in 0..10 { for item in rx.try_iter() { println!("Received message at level {}: {}", item.0, item.1); expected_messages.remove(&item); } if expected_messages.is_empty() { return; ...
random_line_split
can_read_log_from_rosout.rs
use crossbeam::channel::unbounded; use std::collections::BTreeSet; mod util; mod msg { rosrust::rosmsg_include!(rosgraph_msgs / Log); } #[test] fn can_read_log_from_rosout()
expected_messages.insert((16, "fatal message".to_owned())); for _ in 0..10 { for item in rx.try_iter() { println!("Received message at level {}: {}", item.0, item.1); expected_messages.remove(&item); } if expected_messages.is_empty() { return; ...
{ let _roscore = util::run_roscore_for(util::Language::None, util::Feature::Log); rosrust::init("rosout_agg_listener"); let (tx, rx) = unbounded(); let _subscriber = rosrust::subscribe::<msg::rosgraph_msgs::Log, _>("/rosout_agg", 100, move |data| { tx.send((data.level, data.msg))....
identifier_body
origin.rs
extern crate regex; use std::fmt; use std::str::FromStr; use std::string::ToString; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use regex::Regex; use super::{ NetType, AddrType }; use super::{ ProtocolVersion, SessionVersion }; use error::Error; // o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicas...
Err(_) => return Err(Error::SessionVersion) }, None => return Err(Error::SessionVersion) }; let nettype = match cap.at(4) { Some(nettype) => { match NetType::from_str(nettype) { Ok(net...
{ let re = match Regex::new(r"(\S+)\s(\S+)\s(\d+)\s(IN)\s(IP\d)\s(\d+\.\d+\.\d+\.\d+)") { Ok(re) => re, Err(e) => { println!("[Regex] {:?}", e); return Err(Error::Origin); } }; let cap = re.captures(s).unwrap(); let use...
identifier_body
origin.rs
extern crate regex; use std::fmt; use std::str::FromStr; use std::string::ToString; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use regex::Regex; use super::{ NetType, AddrType }; use super::{ ProtocolVersion, SessionVersion }; use error::Error; // o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicas...
}; let cap = re.captures(s).unwrap(); let username = match cap.at(1) { Some(username) => username.to_string(), None => return Err(Error::SessionName) }; let session_id = match cap.at(2) { Some(session_id) => session_id.to_string(), ...
Ok(re) => re, Err(e) => { println!("[Regex] {:?}", e); return Err(Error::Origin); }
random_line_split
origin.rs
extern crate regex; use std::fmt; use std::str::FromStr; use std::string::ToString; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use regex::Regex; use super::{ NetType, AddrType }; use super::{ ProtocolVersion, SessionVersion }; use error::Error; // o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicas...
(&self) -> String { let origin = "o=".to_string() + self.username.as_ref() + " " + self.session_id.as_ref() + " " + self.session_version.to_string().as_ref() + " " + self.nettype.to_string().as_ref() + " " + self.a...
to_string
identifier_name
functions.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
}
random_line_split
functions.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
// receives two u8 and prints the bigger, without any return fn print_max(a: u8, b: u8) -> () { let mut low; if a > b { low = a; }else{ low = b; } println!("{}", low); } fn main() { println!("{}", return_max(10, 50)); print_max(10, 50); }
{ if a > b { a }else{ b } }
identifier_body
functions.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
else{ low = b; } println!("{}", low); } fn main() { println!("{}", return_max(10, 50)); print_max(10, 50); }
{ low = a; }
conditional_block
functions.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
(a: u8, b: u8) -> u8 { if a > b { a }else{ b } } // receives two u8 and prints the bigger, without any return fn print_max(a: u8, b: u8) -> () { let mut low; if a > b { low = a; }else{ low = b; } println!("{}", low); } fn main() { println!("{}", retu...
return_max
identifier_name
issue-11881.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 encode_json<'a, T: Encodable<json::Encoder<'a>, std::io::IoError>>(val: &T, wr: &'a mut SeekableMemWriter) { let mut encoder = json::Encoder::new(wr); val.encode(&mut encoder); } fn encode_rbml<'a, ...
random_line_split
issue-11881.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 ...
{ baz: bool, } #[deriving(Encodable)] struct Bar { froboz: uint, } enum WireProtocol { JSON, RBML, //... } fn encode_json<'a, T: Encodable<json::Encoder<'a>, std::io::IoError>>(val: &T, wr: &'a mut Seekable...
Foo
identifier_name
macro-doc-escapes.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { }
random_line_split
macro-doc-escapes.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name
macro-doc-escapes.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ }
identifier_body
mod.rs
//! The SMTP transport sends emails using the SMTP protocol. //! //! This SMTP client follows [RFC //! 5321](https://tools.ietf.org/html/rfc5321), and is designed to efficiently send emails from an //! application to a relay email server, as it relies as much as possible on the relay server //! for sanity and RFC compl...
() -> Self { Self { server: "localhost".to_string(), port: SMTP_PORT, hello_name: ClientId::default(), credentials: None, authentication: DEFAULT_MECHANISMS.into(), timeout: Some(DEFAULT_TIMEOUT), tls: Tls::None, } }...
default
identifier_name
mod.rs
//! The SMTP transport sends emails using the SMTP protocol. //! //! This SMTP client follows [RFC //! 5321](https://tools.ietf.org/html/rfc5321), and is designed to efficiently send emails from an //! application to a relay email server, as it relies as much as possible on the relay server //! for sanity and RFC compl...
//! * Fast: supports connection reuse and pooling //! //! This client is designed to send emails to a relay server, and should *not* be used to send //! emails directly to the destination server. //! //! The relay server can be the local email server, a specific host or a third-party service. //! //! #### Simple exampl...
//! It is designed to be: //! //! * Secured: connections are encrypted by default //! * Modern: unicode support for email contents and sender/recipient addresses when compatible
random_line_split
rec-align-u64.rs
// Copyright 2012-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 fn main() { unsafe { let x = Outer {c8: 22, t: Inner {c64: 44}}; let y = format!("{:?}", x); println!("align inner = {:?}", rusti::min_align_of::<Inner>()); println!("size outer = {:?}", mem::size_of::<Outer>()); println!("y = {:?}", y); // per clang/gcc the...
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] pub mod m { pub fn align() -> uint { 8 } pub fn size() -> uint { 16 } }
random_line_split
rec-align-u64.rs
// Copyright 2012-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...
() -> uint { 8 } pub fn size() -> uint { 16 } } } #[cfg(target_os = "android")] mod m { #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] pub mod m { pub fn align() -> uint { 8 } pub fn size() -> uint { 16 } } } pub fn main() { unsafe { let x = Outer {c8: 22...
align
identifier_name
rec-align-u64.rs
// Copyright 2012-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 fn size() -> uint { 16 } } } #[cfg(target_os = "bitrig")] mod m { #[cfg(target_arch = "x86_64")] pub mod m { pub fn align() -> uint { 8 } pub fn size() -> uint { 16 } } } #[cfg(target_os = "windows")] mod m { #[cfg(target_arch = "x86")] pub mod m { pub fn a...
{ 8 }
identifier_body
easy.rs
use std::sync::{Once, ONCE_INIT}; use std::c_vec::CVec; use std::{io,mem}; use std::collections::HashMap; use libc::{c_void,c_int,c_long,c_double,size_t}; use super::{consts,err,info,opt}; use super::err::ErrCode; use http::body::Body; use http::{header,Response}; type CURL = c_void; pub type ProgressCb<'a> = |uint, u...
() { // Schedule curl to be cleaned up after we're done with this whole process static mut INIT: Once = ONCE_INIT; unsafe { INIT.doit(|| ::std::rt::at_exit(proc() curl_global_cleanup())) } } impl Drop for Easy { fn drop(&mut self) { unsafe { curl_easy_cleanup(self.curl) } } } /...
global_init
identifier_name
easy.rs
use std::sync::{Once, ONCE_INIT}; use std::c_vec::CVec; use std::{io,mem}; use std::collections::HashMap; use libc::{c_void,c_int,c_long,c_double,size_t}; use super::{consts,err,info,opt}; use super::err::ErrCode; use http::body::Body; use http::{header,Response}; type CURL = c_void; pub type ProgressCb<'a> = |uint, u...
pub extern "C" fn curl_header_fn(p: *mut u8, size: size_t, nmemb: size_t, resp: &mut ResponseBuilder) -> size_t { // TODO: Skip the first call (it seems to be the status line) let vec = unsafe { CVec::new(p, (size * nmemb) as uint) }; match header::parse(vec.as_slice()) { Some((name, val)) => { ...
{ if !resp.is_null() { let builder: &mut ResponseBuilder = unsafe { mem::transmute(resp) }; let chunk = unsafe { CVec::new(p, (size * nmemb) as uint) }; builder.body.push_all(chunk.as_slice()); } size * nmemb }
identifier_body