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
E0375.rs
// Copyright 2016 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 ...
#![feature(coerce_unsized)] use std::ops::CoerceUnsized; struct Foo<T:?Sized, U:?Sized> { a: i32, b: T, c: U, } impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {} //~^ ERROR E0375 fn main() {}
// option. This file may not be copied, modified, or distributed // except according to those terms. // ignore-tidy-linelength
random_line_split
E0375.rs
// Copyright 2016 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:?Sized, U:?Sized> { a: i32, b: T, c: U, } impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {} //~^ ERROR E0375 fn main() {}
Foo
identifier_name
E0375.rs
// Copyright 2016 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
generator.rs
// Copyright GFX Developers 2014-2017 // // 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 ...
fn shared_vertex(&self, i: usize) -> V; /// return the number of shared vertices required to represent the mesh fn shared_vertex_count(&self) -> usize; /// create an iterator that returns each shared vertex that is required to /// build the mesh. fn shared_vertex_iter<'a>(&'a self) -> SharedVe...
/// The `SharedVertex` trait is meant to be used with the `IndexedPolygon` trait. /// This trait is meant as a way to calculate the shared vertices that are /// required to build the implementors mesh. pub trait SharedVertex<V>: Sized { /// return the shared vertex at offset `i`
random_line_split
generator.rs
// Copyright GFX Developers 2014-2017 // // 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 ...
fn next(&mut self) -> Option<V> { self.idx.next().map(|idx| self.base.shared_vertex(idx)) } } /// The `IndexedPolygon` trait is used with the `SharedVertex` trait in order to build /// a mesh. `IndexedPolygon` calculates each polygon face required to build an implementors mesh. /// each face is alway...
{ self.idx.size_hint() }
identifier_body
generator.rs
// Copyright GFX Developers 2014-2017 // // 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 ...
(&self) -> (usize, Option<usize>) { self.idx.size_hint() } fn next(&mut self) -> Option<V> { self.idx.next().map(|idx| self.base.indexed_polygon(idx)) } }
size_hint
identifier_name
media_queries.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/. */ //! Gecko's media-query device and expression representation. use app_units::Au; use app_units::AU_PER_PX; use c...
/// Returns the current viewport size in app units. pub fn au_viewport_size(&self) -> Size2D<Au> { let area = &self.pres_context().mVisibleArea; Size2D::new(Au(area.width), Au(area.height)) } /// Returns the current viewport size in app units, recording that it's been /// used for...
{ // Gecko allows emulating random media with mIsEmulatingMedia and // mMediaEmulated. let context = self.pres_context(); let medium_to_use = if context.mIsEmulatingMedia() != 0 { context.mMediaEmulated.mRawPtr } else { context.mMedium }; ...
identifier_body
media_queries.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/. */ //! Gecko's media-query device and expression representation. use app_units::Au; use app_units::AU_PER_PX; use c...
let au_per_dpx = self.pres_context().mCurAppUnitsPerDevPixel as f32; let au_per_px = AU_PER_PX as f32; TypedScale::new(au_per_px / au_per_dpx) } /// Returns whether document colors are enabled. pub fn use_document_colors(&self) -> bool { self.pres_context().mUseDocumentColo...
{ return TypedScale::new(override_dppx); }
conditional_block
media_queries.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/. */ //! Gecko's media-query device and expression representation. use app_units::Au; use app_units::AU_PER_PX; use c...
/// /// <https://quirks.spec.whatwg.org/#the-tables-inherit-color-from-body-quirk> pub fn set_body_text_color(&self, color: RGBA) { self.body_text_color .store(convert_rgba_to_nscolor(&color) as usize, Ordering::Relaxed) } /// Returns the body text color. pub fn body_text_col...
self.root_font_size .store(size.0 as isize, Ordering::Relaxed) } /// Sets the body text color for the "inherit color from body" quirk.
random_line_split
media_queries.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/. */ //! Gecko's media-query device and expression representation. use app_units::Au; use app_units::AU_PER_PX; use c...
(&self, name: &KeyframesName) -> bool { unsafe { bindings::Gecko_AnimationNameMayBeReferencedFromStyle( self.pres_context(), name.as_atom().as_ptr(), ) } } /// Returns the default computed values as a reference, in order to match /// S...
animation_name_may_be_referenced
identifier_name
test.rs
#[macro_use] extern crate cfg_if; #[cfg_attr(not(target_os = "redox"), macro_use)] extern crate nix; #[macro_use] extern crate lazy_static; mod common; mod sys; #[cfg(not(target_os = "redox"))] mod test_dir; mod test_fcntl; #[cfg(any(target_os = "android", target_os = "linux"))] mod test_kmod; #[cfg(target_o...
pub static ref FORK_MTX: Mutex<()> = Mutex::new(()); /// Any test that changes the process's supplementary groups must grab this /// mutex pub static ref GROUPS_MTX: Mutex<()> = Mutex::new(()); /// Any tests that loads or unloads kernel modules must grab this mutex pub static ref KMOD_MTX: Mutex...
random_line_split
test.rs
#[macro_use] extern crate cfg_if; #[cfg_attr(not(target_os = "redox"), macro_use)] extern crate nix; #[macro_use] extern crate lazy_static; mod common; mod sys; #[cfg(not(target_os = "redox"))] mod test_dir; mod test_fcntl; #[cfg(any(target_os = "android", target_os = "linux"))] mod test_kmod; #[cfg(target_o...
} }
{ r.unwrap(); }
conditional_block
test.rs
#[macro_use] extern crate cfg_if; #[cfg_attr(not(target_os = "redox"), macro_use)] extern crate nix; #[macro_use] extern crate lazy_static; mod common; mod sys; #[cfg(not(target_os = "redox"))] mod test_dir; mod test_fcntl; #[cfg(any(target_os = "android", target_os = "linux"))] mod test_kmod; #[cfg(target_o...
<'a> { d: PathBuf, _g: RwLockWriteGuard<'a, ()> } impl<'a> DirRestore<'a> { fn new() -> Self { let guard = crate::CWD_LOCK.write() .expect("Lock got poisoned by another test"); DirRestore{ _g: guard, d: getcwd().unwrap(), } } } impl<'a> Drop f...
DirRestore
identifier_name
test.rs
#[macro_use] extern crate cfg_if; #[cfg_attr(not(target_os = "redox"), macro_use)] extern crate nix; #[macro_use] extern crate lazy_static; mod common; mod sys; #[cfg(not(target_os = "redox"))] mod test_dir; mod test_fcntl; #[cfg(any(target_os = "android", target_os = "linux"))] mod test_kmod; #[cfg(target_o...
}
{ let r = chdir(&self.d); if std::thread::panicking() { r.unwrap(); } }
identifier_body
harfbuzz.rs
, priv hb_font: *hb_font_t, priv hb_funcs: *hb_font_funcs_t, } #[unsafe_destructor] impl Drop for Shaper { #[fixed_stack_segment] fn drop(&mut self) { unsafe { assert!(self.hb_face.is_not_null()); hb_face_destroy(self.hb_face); assert!(self.hb_font.is_not_nu...
{ let skinny_font_table_ptr: *FontTable = font_table; // private context let mut blob: *hb_blob_t = null(); do (*skinny_font_table_ptr).with_buffer |buf: *u8
conditional_block
harfbuzz.rs
let x_offset = Shaper::fixed_to_float((*pos_info_i).x_offset); let y_offset = Shaper::fixed_to_float((*pos_info_i).y_offset); let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance); let y_advance = Shaper::fixed_to_float((*pos_info_i).y_advance); le...
unsafe { match (*font).glyph_index(char::from_u32(unicode).unwrap()) { Some(g) => {
random_line_split
harfbuzz.rs
i).x_advance); let y_advance = Shaper::fixed_to_float((*pos_info_i).y_advance); let x_offset = Au::from_frac_px(x_offset); let y_offset = Au::from_frac_px(y_offset); let x_advance = Au::from_frac_px(x_advance); let y_advance = Au::from_frac_px(y_advance); ...
{ let font: *Font = font_data as *Font; assert!(font.is_not_null()); unsafe { match (*font).glyph_index(char::from_u32(unicode).unwrap()) { Some(g) => { *glyph = g as hb_codepoint_t; true as hb_bool_t } None => false as hb_bool_t ...
identifier_body
harfbuzz.rs
{ cluster: uint, codepoint: GlyphIndex, advance: Au, offset: Option<Point2D<Au>>, } impl ShapedGlyphData { #[fixed_stack_segment] pub fn new(buffer: *hb_buffer_t) -> ShapedGlyphData { unsafe { let glyph_count = 0; let glyph_infos = hb_buffer_get_glyph_infos(buff...
ShapedGlyphEntry
identifier_name
text.rs
use std::str; use crate::{ AttributeId, AttributeValue, Document, Node, }; trait StrTrim { fn remove_first(&mut self); fn remove_last(&mut self); } impl StrTrim for String { fn remove_first(&mut self) { self.drain(0..1); } fn remove_last(&mut self) { self.pop(); ...
fn _prepare_text(parent: &Node, nodes: &mut Vec<Node>, parent_xmlspace: XmlSpace) { for mut node in parent.children().filter(|n| n.is_element()) { let xmlspace = get_xmlspace(&mut node, nodes, parent_xmlspace); if let Some(child) = node.first_child() { if child.is_text() { ...
{ // Remember nodes that have 'xml:space' changed. let mut nodes = Vec::new(); _prepare_text(&doc.root(), &mut nodes, XmlSpace::Default); // Remove temporary 'xml:space' attributes created during the text processing. for mut node in nodes { node.remove_attribute(AttributeId::Space); } ...
identifier_body
text.rs
use std::str; use crate::{ AttributeId, AttributeValue, Document, Node, }; trait StrTrim { fn remove_first(&mut self); fn remove_last(&mut self); } impl StrTrim for String { fn remove_first(&mut self) { self.drain(0..1); } fn remove_last(&mut self) { self.pop(); ...
} else if nodes.len() > 1 { // Process element with many text node children. // We manage all text nodes as a single text node // and trying to remove duplicated spaces across nodes. // // For example '<text>Text <tspan> text </tspan> text</text>' // is the same ...
{ // Do nothing when xml:space=preserve. }
conditional_block
text.rs
use std::str; use crate::{ AttributeId, AttributeValue, Document, Node, }; trait StrTrim { fn remove_first(&mut self); fn remove_last(&mut self); } impl StrTrim for String { fn remove_first(&mut self) { self.drain(0..1); } fn remove_last(&mut self) { self.pop(); ...
(text: &str, space: XmlSpace) -> String { let mut s = String::with_capacity(text.len()); let mut prev = '0'; for c in text.chars() { // \r, \n and \t should be converted into spaces. let c = match c { '\r' | '\n' | '\t' =>'', _ => c, }; // Skip conti...
trim
identifier_name
text.rs
use std::str; use crate::{ AttributeId, AttributeValue, Document, Node, }; trait StrTrim { fn remove_first(&mut self); fn remove_last(&mut self); } impl StrTrim for String { fn remove_first(&mut self) { self.drain(0..1); } fn remove_last(&mut self) { self.pop(); ...
} _prepare_text(&node, nodes, xmlspace); } } fn get_xmlspace(node: &mut Node, nodes: &mut Vec<Node>, default: XmlSpace) -> XmlSpace { { let attrs = node.attributes(); let v = attrs.get_value(AttributeId::Space); if let Some(&AttributeValue::String(ref s)) = v { ...
}
random_line_split
effect.rs
// Copyright 2012-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-MI...
fn visit_expr(&mut self, expr: &ast::Expr) { match expr.node { ast::ExprMethodCall(_, _, _) => { let method_call = MethodCall::expr(expr.id); let base_type = (*self.tcx.method_map.borrow())[method_call].ty; debug!("effect: method call case, base ty...
visit::walk_block(self, block); self.unsafe_context = old_unsafe_context }
random_line_split
effect.rs
// Copyright 2012-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-MI...
(&mut self, expr: &ast::Expr) { match expr.node { ast::ExprMethodCall(_, _, _) => { let method_call = MethodCall::expr(expr.id); let base_type = (*self.tcx.method_map.borrow())[method_call].ty; debug!("effect: method call case, base type is {}", ...
visit_expr
identifier_name
day9.rs
use std::collections::{HashSet, HashMap}; use std::hash::Hash; use std::cmp::{min, max}; use std::u32; #[derive(Clone, Debug)] struct Link { start: String, end: String, distance: u32, } fn parse_links(path: &str) -> Vec<Link> { use std::fs::File; use std::io::prelude::*; use std::io::BufReader...
let start = path[i].to_owned(); let end = path[i + 1].to_owned(); let dist = distances.get(&(start, end)) .cloned() .unwrap_or(u32::max_value()); sum += dist; } sum } pub fn permutations<T: Clone + Hash + Eq>(vec: &Vec<T>) ->...
let mut sum: u32 = 0; for i in 0..path.len() - 1 {
random_line_split
day9.rs
use std::collections::{HashSet, HashMap}; use std::hash::Hash; use std::cmp::{min, max}; use std::u32; #[derive(Clone, Debug)] struct Link { start: String, end: String, distance: u32, } fn parse_links(path: &str) -> Vec<Link>
fn distance(distances: &HashMap<(String, String), u32>, path: &Vec<String>) -> u32 { let mut sum: u32 = 0; for i in 0..path.len() - 1 { let start = path[i].to_owned(); let end = path[i + 1].to_owned(); let dist = distances.get(&(start, end)) ...
{ use std::fs::File; use std::io::prelude::*; use std::io::BufReader; let file = File::open(path).unwrap(); let file = BufReader::new(file); let mut links = Vec::new(); for line in file.lines() { let line = line.unwrap(); let words: Vec<_> = line.split(" ").collect(); ...
identifier_body
day9.rs
use std::collections::{HashSet, HashMap}; use std::hash::Hash; use std::cmp::{min, max}; use std::u32; #[derive(Clone, Debug)] struct Link { start: String, end: String, distance: u32, } fn
(path: &str) -> Vec<Link> { use std::fs::File; use std::io::prelude::*; use std::io::BufReader; let file = File::open(path).unwrap(); let file = BufReader::new(file); let mut links = Vec::new(); for line in file.lines() { let line = line.unwrap(); let words: Vec<_> = line.sp...
parse_links
identifier_name
day9.rs
use std::collections::{HashSet, HashMap}; use std::hash::Hash; use std::cmp::{min, max}; use std::u32; #[derive(Clone, Debug)] struct Link { start: String, end: String, distance: u32, } fn parse_links(path: &str) -> Vec<Link> { use std::fs::File; use std::io::prelude::*; use std::io::BufReader...
else { vec.swap(0, n - 1); } } heaps_perms(set, vec, n - 1); } } fn all_cities(links: &Vec<Link>) -> Vec<String> { let mut cities = HashSet::new(); for link in links.iter().cloned() { cities.insert(link.start); cities.insert(link.end); } ...
{ vec.swap(i, n - 1); }
conditional_block
radix_sort.rs
// http://rosettacode.org/wiki/Sorting_algorithms/Radix_sort fn merge(in1: Vec<i32>, in2: Vec<i32>, out: &mut [i32]) { let (left, right) = out.split_at_mut(in1.len()); left.clone_from_slice(in1.as_slice()); right.clone_from_slice(in2.as_slice()); } // least significant digit radix sort fn radix_sort(data:...
#[test] fn test_empty_vector() { check_numbers(&mut []); } #[test] fn test_one_element_vector() { check_numbers(&mut [0i32]); } #[test] fn test_repeat_vector() { check_numbers(&mut [1i32, 1, 1, 1, 1]); } #[test] fn test_already_sorted_vector() { ...
{ check_numbers(&mut [170, 45, 75, -90, -802, 24, 2, 66, -17, 2]); }
identifier_body
radix_sort.rs
// http://rosettacode.org/wiki/Sorting_algorithms/Radix_sort fn merge(in1: Vec<i32>, in2: Vec<i32>, out: &mut [i32]) { let (left, right) = out.split_at_mut(in1.len()); left.clone_from_slice(in1.as_slice()); right.clone_from_slice(in2.as_slice()); } // least significant digit radix sort fn radix_sort(data:...
() { check_numbers(&mut [1i32, 1, 1, 1, 1]); } #[test] fn test_already_sorted_vector() { check_numbers(&mut [-1i32, 0, 3, 6, 99]); } #[test] fn test_random_numbers() { let mut rng = thread_rng(); let mut numbers: Vec<i32> = rng.gen_iter::<i32>().take(500).collec...
test_repeat_vector
identifier_name
radix_sort.rs
// http://rosettacode.org/wiki/Sorting_algorithms/Radix_sort fn merge(in1: Vec<i32>, in2: Vec<i32>, out: &mut [i32]) { let (left, right) = out.split_at_mut(in1.len()); left.clone_from_slice(in1.as_slice()); right.clone_from_slice(in2.as_slice()); } // least significant digit radix sort fn radix_sort(data:...
} #[test] fn test_empty_vector() { check_numbers(&mut []); } #[test] fn test_one_element_vector() { check_numbers(&mut [0i32]); } #[test] fn test_repeat_vector() { check_numbers(&mut [1i32, 1, 1, 1, 1]); } #[test] fn test_already_sorted_vector(...
#[test] fn test_rosetta_vector() { check_numbers(&mut [170, 45, 75, -90, -802, 24, 2, 66, -17, 2]);
random_line_split
lib.rs
pub struct Allergies(u32); impl Allergies { pub fn new(x: u32) -> Allergies
pub fn is_allergic_to(&self, allergen: &Allergen) -> bool { allergen.value() & self.0!= 0 } pub fn allergies(&self) -> Vec<Allergen> { Allergen::all() .into_iter() .filter(|ref a| self.is_allergic_to(&a)) .collect() } } macro_rules! allergens { { ...
{ Allergies(x) }
identifier_body
lib.rs
pub struct Allergies(u32); impl Allergies { pub fn new(x: u32) -> Allergies { Allergies(x) } pub fn is_allergic_to(&self, allergen: &Allergen) -> bool { allergen.value() & self.0!= 0 } pub fn allergies(&self) -> Vec<Allergen> { Allergen::all() .into_iter()
.filter(|ref a| self.is_allergic_to(&a)) .collect() } } macro_rules! allergens { { $( $name:ident => $order:expr ),* } => { #[derive(Debug, PartialEq)] pub enum Allergen { $( $name ),* } impl Allergen { fn value(&self) -> u32 { ...
random_line_split
lib.rs
pub struct
(u32); impl Allergies { pub fn new(x: u32) -> Allergies { Allergies(x) } pub fn is_allergic_to(&self, allergen: &Allergen) -> bool { allergen.value() & self.0!= 0 } pub fn allergies(&self) -> Vec<Allergen> { Allergen::all() .into_iter() .filter(|ref a...
Allergies
identifier_name
fnv.rs
use std::hash::{BuildHasher, Hasher}; ///! This was taken directly from https://github.com/servo/rust-fnv. I needed to make the hasher ///! clonable, and this was faster than actually cloning the repo and making PR. At some point I ///! should probably request the change be added to the main repo. #[derive(Debug, Clo...
() -> FnvHasher { FnvHasher(0xcbf29ce484222325) } } impl Hasher for FnvHasher { #[inline] fn finish(&self) -> u64 { self.0 } #[inline] fn write(&mut self, bytes: &[u8]) { let FnvHasher(mut hash) = *self; for byte in bytes.iter() { hash = hash ^ (*byte as u64); h...
default
identifier_name
fnv.rs
use std::hash::{BuildHasher, Hasher}; ///! This was taken directly from https://github.com/servo/rust-fnv. I needed to make the hasher ///! clonable, and this was faster than actually cloning the repo and making PR. At some point I ///! should probably request the change be added to the main repo. #[derive(Debug, Clo...
pub struct FnvHashState; impl BuildHasher for FnvHashState { type Hasher = FnvHasher; fn build_hasher(&self) -> FnvHasher { FnvHasher::default() } } #[derive(Debug, Copy, Clone)] pub struct FnvHasher(u64); impl Default for FnvHasher { #[inline] fn default() -> FnvHasher { FnvHasher(0xcbf...
random_line_split
changes.rs
//! Turn a query into a changefeed, an infinite stream of objects //! representing changes to the query's results as they occur //! //! A changefeed may return changes to a table or an individual document //! (a "point" changefeed). Commands such as `filter` or `map` may be used //! before the `changes` command to tran...
/// `true`: When multiple changes to the same document occur before a /// batch of notifications is sent, the changes are "squashed" into one /// change. The client receives a notification that will bring it fully /// up to date with the server. /// `false`: All changes will be sent to the client ve...
#[non_exhaustive] #[serde(untagged)] pub enum Squash {
random_line_split
changes.rs
//! Turn a query into a changefeed, an infinite stream of objects //! representing changes to the query's results as they occur //! //! A changefeed may return changes to a table or an individual document //! (a "point" changefeed). Commands such as `filter` or `map` may be used //! before the `changes` command to tran...
} impl Arg for Options { fn arg(self) -> cmd::Arg<Options> { ().arg().with_opts(self) } }
{ Command::new(TermType::Changes) .mark_change_feed() .into_arg() }
identifier_body
changes.rs
//! Turn a query into a changefeed, an infinite stream of objects //! representing changes to the query's results as they occur //! //! A changefeed may return changes to a table or an individual document //! (a "point" changefeed). Commands such as `filter` or `map` may be used //! before the `changes` command to tran...
(self) -> cmd::Arg<Options> { Command::new(TermType::Changes) .mark_change_feed() .into_arg() } } impl Arg for Options { fn arg(self) -> cmd::Arg<Options> { ().arg().with_opts(self) } }
arg
identifier_name
log.rs
// Copyright © 2017-2018 Mozilla Foundation // // This program is made available under an ISC-style license. See the // accompanying file LICENSE for details. #[macro_export] macro_rules! cubeb_log_internal { ($level: expr, $msg: expr) => { #[allow(unused_unsafe)] unsafe { if $level <=...
} } }; (__INTERNAL__ $msg: expr) => { if let Some(log_callback) = $crate::ffi::g_cubeb_log_callback { let cstr = ::std::ffi::CString::new(format!("{}:{}: {}\n", file!(), line!(), $msg)).unwrap(); log_callback(cstr.as_ptr()); } } } #[macro_export] ...
if $level <= $crate::ffi::g_cubeb_log_level.into() { cubeb_log_internal!(__INTERNAL__ format!($fmt, $($arg),*));
random_line_split
log.rs
// Copyright © 2017-2018 Mozilla Foundation // // This program is made available under an ISC-style license. See the // accompanying file LICENSE for details. #[macro_export] macro_rules! cubeb_log_internal { ($level: expr, $msg: expr) => { #[allow(unused_unsafe)] unsafe { if $level <=...
}
cubeb_logv!("This is a log at verbose level"); cubeb_logv!("{} Formatted log", 1); cubeb_logv!("{} Formatted {} log {}", 1, 2, 3); }
identifier_body
log.rs
// Copyright © 2017-2018 Mozilla Foundation // // This program is made available under an ISC-style license. See the // accompanying file LICENSE for details. #[macro_export] macro_rules! cubeb_log_internal { ($level: expr, $msg: expr) => { #[allow(unused_unsafe)] unsafe { if $level <=...
) { cubeb_log!("This is log at normal level"); cubeb_log!("{} Formatted log", 1); cubeb_log!("{} Formatted {} log {}", 1, 2, 3); } #[test] fn test_verbose_logging() { cubeb_logv!("This is a log at verbose level"); cubeb_logv!("{} Formatted log", 1); cubeb_log...
est_normal_logging(
identifier_name
r3ipc.rs
/* * Some code in this file has been taken and modifed from * https://github.com/tmerr/i3ipc-rs */ use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; use i3ipc::{reply}; use serde_json as json; use std::error::Error; use std::fmt; use std::io::{Read, Write, self}; use unix_socket::UnixStream; pub const R3...
}; let payload_string = String::from_utf8_lossy(&payload_data).into_owned(); Ok((message_type, payload_string)) } } pub struct R3Msg { stream: UnixStream } impl R3Msg { pub fn new(socket_path: Option<&str>) -> Result<Self, io::Error> { let socket_path = socket_path.unwrap...
random_line_split
r3ipc.rs
/* * Some code in this file has been taken and modifed from * https://github.com/tmerr/i3ipc-rs */ use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; use i3ipc::{reply}; use serde_json as json; use std::error::Error; use std::fmt; use std::io::{Read, Write, self}; use unix_socket::UnixStream; pub const R3...
(&self) -> Option<&Error> { match *self { MessageError::Send(ref e) => Some(e), MessageError::Receive(ref e) => Some(e), MessageError::JsonCouldntParse(ref e) => Some(e), } } } impl fmt::Display for MessageError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt:...
cause
identifier_name
r3ipc.rs
/* * Some code in this file has been taken and modifed from * https://github.com/tmerr/i3ipc-rs */ use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; use i3ipc::{reply}; use serde_json as json; use std::error::Error; use std::fmt; use std::io::{Read, Write, self}; use unix_socket::UnixStream; pub const R3...
= commands.iter() .map(|c| c.as_object().unwrap()) .map(|c| reply::CommandOutcome { success: c.get("success").unwrap().as_bool().unwrap(), error: match c.get("error") { Some(val) => Some(val.as_str().un...
{ if let Err(e) = self.stream.send_i3_message(msgtype, payload) { return Err(MessageError::Send(e)); } // could check that msgtype is REPLY let payload = match self.stream.receive_i3_message() { Ok((_, payload)) => payload, Err(e) => { return Err(Mes...
identifier_body
r3ipc.rs
/* * Some code in this file has been taken and modifed from * https://github.com/tmerr/i3ipc-rs */ use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; use i3ipc::{reply}; use serde_json as json; use std::error::Error; use std::fmt; use std::io::{Read, Write, self}; use unix_socket::UnixStream; pub const R3...
; let payload_string = String::from_utf8_lossy(&payload_data).into_owned(); Ok((message_type, payload_string)) } } pub struct R3Msg { stream: UnixStream } impl R3Msg { pub fn new(socket_path: Option<&str>) -> Result<Self, io::Error> { let socket_path = socket_path.unwrap_or(R3_UN...
{ return Err(e); }
conditional_block
mod.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...
pub mod parser; pub mod rfb;
pub mod logger;
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(box_syntax)] #![feature(conservative_impl_trait)] #![feature(const_fn)] #![feature(core_intrinsics)] #!...
extern crate html5ever; #[macro_use] extern crate html5ever_atoms; #[macro_use] extern crate hyper; extern crate hyper_serde; extern crate image; extern crate ipc_channel; #[macro_use] extern crate js; #[macro_use] extern crate jstraceable_derive; extern crate libc; #[macro_use] extern crate log; #[macro_use] extern cr...
extern crate fnv; extern crate gfx_traits; extern crate heapsize; #[macro_use] extern crate heapsize_derive;
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(box_syntax)] #![feature(conservative_impl_trait)] #![feature(const_fn)] #![feature(core_intrinsics)] #!...
rlim.rlim_max } else { MAX_FILE_LIMIT } } }; match libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) { 0 => (), _ => warn!("Failed...
{ use std::mem; // 4096 is default max on many linux systems const MAX_FILE_LIMIT: libc::rlim_t = 4096; // Bump up our number of file descriptors to save us from impending doom caused by an onslaught // of iframes. unsafe { let mut rlim: libc::rlimit = mem::uninitialized(); matc...
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(box_syntax)] #![feature(conservative_impl_trait)] #![feature(const_fn)] #![feature(core_intrinsics)] #!...
() { use std::mem; // 4096 is default max on many linux systems const MAX_FILE_LIMIT: libc::rlim_t = 4096; // Bump up our number of file descriptors to save us from impending doom caused by an onslaught // of iframes. unsafe { let mut rlim: libc::rlimit = mem::uninitialized(); m...
perform_platform_specific_initialization
identifier_name
mod.rs
//! types/mod.rs - Unlike other modules for compiler passes, //! the type inference compiler pass is defined in types/typechecker.rs //! rather than the mod.rs file here. Instead, this file defines //! the representation of `Type`s - which represent any Type in ante's //! type system - and `TypeInfo`s - which hold more...
(pub usize); /// The initial LetBindingLevel used in nameresolution and typechecking. /// This must be at least 1 since typechecker::infer_ast will set the CURRENT_LEVEL /// to INITIAL_LEVEL - 1 when finishing type checking main to differentiate between /// traits used within main and traits propagated up into main's ...
LetBindingLevel
identifier_name
mod.rs
//! types/mod.rs - Unlike other modules for compiler passes, //! the type inference compiler pass is defined in types/typechecker.rs //! rather than the mod.rs file here. Instead, this file defines //! the representation of `Type`s - which represent any Type in ante's //! type system - and `TypeInfo`s - which hold more...
pub enum PrimitiveType { IntegerType(IntegerKind), // : * FloatType, // : * CharType, // : * BooleanType, // : * UnitType, // : * Ptr, // : * -> * } /// Any type in ante. Note that a trait is not a type. Traits are...
/// enum forms a tree, then these are the leaf nodes. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)]
random_line_split
build.rs
use std::env; use std::fs::{self, File}; use std::path::{MAIN_SEPARATOR, Path}; use j4rs; use j4rs::{Jvm, JvmBuilder, LocalJarArtifact, MavenArtifact}; fn main() { let ui_jar = "rust-keylock-ui-java-0.14.0.jar"; let desktop_ui_jar_in_java_target = format!("../java/target/{}", ui_jar); println!("cargo:reru...
maven("org.openjfx:javafx-fxml:13.0.2", &jvm); maven(&format!("org.openjfx:javafx-fxml:13.0.2:{}", target_os), &jvm); maven("org.openjfx:javafx-graphics:13.0.2", &jvm); maven(&format!("org.openjfx:javafx-graphics:13.0.2:{}", target_os), &jvm); maven("org.openjfx:javafx-media:13.0.2", &jvm); mave...
maven("org.openjfx:javafx-base:13.0.2", &jvm); maven(&format!("org.openjfx:javafx-base:13.0.2:{}", target_os), &jvm); maven("org.openjfx:javafx-controls:13.0.2", &jvm); maven(&format!("org.openjfx:javafx-controls:13.0.2:{}", target_os), &jvm);
random_line_split
build.rs
use std::env; use std::fs::{self, File}; use std::path::{MAIN_SEPARATOR, Path}; use j4rs; use j4rs::{Jvm, JvmBuilder, LocalJarArtifact, MavenArtifact}; fn main() { let ui_jar = "rust-keylock-ui-java-0.14.0.jar"; let desktop_ui_jar_in_java_target = format!("../java/target/{}", ui_jar); println!("cargo:reru...
{ if File::open(desktop_ui_jar_in_java_target).is_ok() { let home = env::var("CARGO_MANIFEST_DIR").unwrap(); let javaassets_path_buf = Path::new(&home).join("javaassets"); let javaassets_path = javaassets_path_buf.to_str().unwrap().to_owned(); let _ = fs_extra::remove_items(vec![jav...
identifier_body
build.rs
use std::env; use std::fs::{self, File}; use std::path::{MAIN_SEPARATOR, Path}; use j4rs; use j4rs::{Jvm, JvmBuilder, LocalJarArtifact, MavenArtifact}; fn main() { let ui_jar = "rust-keylock-ui-java-0.14.0.jar"; let desktop_ui_jar_in_java_target = format!("../java/target/{}", ui_jar); println!("cargo:reru...
(s: &str, jvm: &Jvm) { let artifact = MavenArtifact::from(s); let _ = jvm.deploy_artifact(&artifact).map_err(|error| { println!("cargo:warning=Could not download Maven artifact {}: {:?}", s, error); }); } fn copy_from_java(desktop_ui_jar_in_java_target: &str) { if File::open(desktop_ui_jar_in_j...
maven
identifier_name
main.rs
extern crate hyper; mod credentials; mod error; mod http; use std::process; use std::thread; use std::time::Duration; use credentials::Credentials; use http::Client; use error::Error; fn main() { let credentials = credentials(); let client = Client::new(credentials); let interval = Duration::from_secs(5...
else { Err(Error::Request { status: response.status }) } }
{ Ok(()) }
conditional_block
main.rs
extern crate hyper; mod credentials; mod error; mod http; use std::process; use std::thread; use std::time::Duration; use credentials::Credentials; use http::Client; use error::Error; fn main() { let credentials = credentials(); let client = Client::new(credentials); let interval = Duration::from_secs(5...
Ok(val) => val, Err(e) => { println!("{}", e); process::exit(1); } } } fn run(client: &Client) -> Result<(), Error> { let response = try!(client.put("https://api.github.com/notifications", "{}")); if response.status.is_success() { Ok(()) } else {...
} } fn credentials() -> Credentials { match credentials::from_env() {
random_line_split
main.rs
extern crate hyper; mod credentials; mod error; mod http; use std::process; use std::thread; use std::time::Duration; use credentials::Credentials; use http::Client; use error::Error; fn main() { let credentials = credentials(); let client = Client::new(credentials); let interval = Duration::from_secs(5...
(client: &Client) -> Result<(), Error> { let response = try!(client.put("https://api.github.com/notifications", "{}")); if response.status.is_success() { Ok(()) } else { Err(Error::Request { status: response.status }) } }
run
identifier_name
main.rs
extern crate hyper; mod credentials; mod error; mod http; use std::process; use std::thread; use std::time::Duration; use credentials::Credentials; use http::Client; use error::Error; fn main()
fn credentials() -> Credentials { match credentials::from_env() { Ok(val) => val, Err(e) => { println!("{}", e); process::exit(1); } } } fn run(client: &Client) -> Result<(), Error> { let response = try!(client.put("https://api.github.com/notifications", "{...
{ let credentials = credentials(); let client = Client::new(credentials); let interval = Duration::from_secs(5); loop { let result = run(&client); if result.is_err() { println!("{}", result.unwrap_err()); } thread::sleep(interval); } }
identifier_body
length_of_longest_substring.rs
pub fn
(s: String) -> i32 { let mut m = std::collections::HashMap::new(); let mut ans = 0; let mut i = 0; // 字串的开始位置。 for (j, c) in s.chars().enumerate() { if let Some(idx) = m.get(&c) { // 有重复的字符 i = i.max(*idx); } ans = ans.max(j - i + 1); // [i, j] 是想要的子串 ...
length_of_longest_substring
identifier_name
length_of_longest_substring.rs
pub fn length_of_longest_substring(s: String) -> i32
th_of_longest_substring; #[test] fn test_length_of_longest_substring() { assert_eq!(length_of_longest_substring("abcabcbb".to_string()), 3); assert_eq!(length_of_longest_substring("bbbbb".to_string()), 1); assert_eq!(length_of_longest_substring("pwwkew".to_string()), 3); assert_...
{ let mut m = std::collections::HashMap::new(); let mut ans = 0; let mut i = 0; // 字串的开始位置。 for (j, c) in s.chars().enumerate() { if let Some(idx) = m.get(&c) { // 有重复的字符 i = i.max(*idx); } ans = ans.max(j - i + 1); // [i, j] 是想要的子串 m.insert(c, j +...
identifier_body
length_of_longest_substring.rs
pub fn length_of_longest_substring(s: String) -> i32 { let mut m = std::collections::HashMap::new(); let mut ans = 0; let mut i = 0; // 字串的开始位置。 for (j, c) in s.chars().enumerate() { if let Some(idx) = m.get(&c) { // 有重复的字符 i = i.max(*idx); } ans = ans.max...
assert_eq!(length_of_longest_substring("pwwkew".to_string()), 3); assert_eq!(length_of_longest_substring("abba".to_string()), 2); } }
#[test] fn test_length_of_longest_substring() { assert_eq!(length_of_longest_substring("abcabcbb".to_string()), 3); assert_eq!(length_of_longest_substring("bbbbb".to_string()), 1);
random_line_split
length_of_longest_substring.rs
pub fn length_of_longest_substring(s: String) -> i32 { let mut m = std::collections::HashMap::new(); let mut ans = 0; let mut i = 0; // 字串的开始位置。 for (j, c) in s.chars().enumerate() { if let Some(idx) = m.get(&c) { //
+ 1); // [i, j] 是想要的子串 m.insert(c, j + 1); // 如果出现了重复的 c,那么 i 跳到 j+1 的位置。 } ans as i32 } #[cfg(test)] mod test { use crate::length_of_longest_substring::length_of_longest_substring; #[test] fn test_length_of_longest_substring() { assert_eq!(length_of_longest_substring("abcabcbb".t...
有重复的字符 i = i.max(*idx); } ans = ans.max(j - i
conditional_block
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/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
(token: String) { let (unprivileged_content_sender, unprivileged_content_receiver) = ipc::channel::<UnprivilegedPipelineContent>().unwrap(); let connection_bootstrap: IpcSender<IpcSender<UnprivilegedPipelineContent>> = IpcSender::connect(token).unwrap(); connection_bootstrap.send(unprivilege...
run_content_process
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/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
} fn create_compositor_channel(event_loop_waker: Box<compositor_thread::EventLoopWaker>) -> (CompositorProxy, CompositorReceiver) { let (sender, receiver) = channel(); (CompositorProxy { sender: sender, event_loop_waker: event_loop_waker, }, CompositorReceiver { rec...
{ let constellation_chan = self.constellation_chan.clone(); log::set_logger(|max_log_level| { let env_logger = EnvLogger::new(); let con_logger = FromCompositorLogger::new(constellation_chan); let filter = max(env_logger.filter(), con_logger.filter()); let...
identifier_body
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/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
pub fn setup_logging(&self) { let constellation_chan = self.constellation_chan.clone(); log::set_logger(|max_log_level| { let env_logger = EnvLogger::new(); let con_logger = FromCompositorLogger::new(constellation_chan); let filter = max(env_logger.filter(), con_l...
pub fn pinch_zoom_level(&self) -> f32 { self.compositor.pinch_zoom_level() }
random_line_split
pc.rs
use ::{Decryptor, Encryptor}; use std::io::Cursor; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; /// A struct for encrypting and decrypting using the PC and Dreamcast /// cryptography algorithm. pub struct PcCipher { keys: Vec<u32>, pos: usize, seed: u32 } impl PcCipher { /// Create a n...
(seed: u32) -> Self { PcCipher { keys: gen_keys(seed), pos: 56, seed: seed } } fn get_next_key(&mut self) -> u32 { let re: u32; if self.pos == 56 { mix_keys(&mut self.keys); self.pos = 1; } re = self.key...
new
identifier_name
pc.rs
use ::{Decryptor, Encryptor}; use std::io::Cursor; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; /// A struct for encrypting and decrypting using the PC and Dreamcast /// cryptography algorithm. pub struct PcCipher { keys: Vec<u32>, pos: usize, seed: u32 } impl PcCipher { /// Create a n...
else { break } } Ok(()) } pub fn seed(&self) -> u32 { self.seed } } impl Encryptor for PcCipher { fn encrypt(&mut self, input: &[u8], output: &mut [u8]) -> Result<(), String> { self.process(input, output) } } impl Decryptor for PcCipher { fn de...
{ if let Err(e) = co.write_u32::<LittleEndian>(num ^ self.get_next_key()) { return Err(e.to_string()) } }
conditional_block
pc.rs
use ::{Decryptor, Encryptor}; use std::io::Cursor; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; /// A struct for encrypting and decrypting using the PC and Dreamcast /// cryptography algorithm. pub struct PcCipher { keys: Vec<u32>, pos: usize, seed: u32 } impl PcCipher { /// Create a n...
} impl Encryptor for PcCipher { fn encrypt(&mut self, input: &[u8], output: &mut [u8]) -> Result<(), String> { self.process(input, output) } } impl Decryptor for PcCipher { fn decrypt(&mut self, input: &[u8], output: &mut [u8]) -> Result<(), String> { self.process(input, output) } } ...
{ self.seed }
identifier_body
pc.rs
use ::{Decryptor, Encryptor}; use std::io::Cursor; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; /// A struct for encrypting and decrypting using the PC and Dreamcast /// cryptography algorithm. pub struct PcCipher { keys: Vec<u32>, pos: usize, seed: u32 } impl PcCipher { /// Create a n...
let mut co = Cursor::new(output); loop { if let Ok(num) = ci.read_u32::<LittleEndian>() { if let Err(e) = co.write_u32::<LittleEndian>(num ^ self.get_next_key()) { return Err(e.to_string()) } } else { break ...
} fn process(&mut self, input: &[u8], output: &mut [u8]) -> Result<(), String> { let mut ci = Cursor::new(input);
random_line_split
main.rs
/* Aurélien DESBRIÈRES aurelien(at)hackers(dot)camp License GNU GPL latest */ // Rust experimentations ───────────────┐
#[derive(Debug)] pub enum MathError { DivisionByZero, NonPositiveLogarithm, NegativeSquareRoot, } pub type MathResult = Result<f64, MathError>; pub fn div(x: f64, y: f64) -> MathResult { if y == 0.0 { // this operation would `fail`, instead let's return ...
// Std Library Result ──────────────────┘ mod checked { // Mathematical "errors" we want to catch
random_line_split
main.rs
/* Aurélien DESBRIÈRES aurelien(at)hackers(dot)camp License GNU GPL latest */ // Rust experimentations ───────────────┐ // Std Library Result ──────────────────┘ mod checked { // Mathematical "errors" we want to catch #[derive(Debug)] pub enum MathError { DivisionByZero, NonPositiveLogarit...
::NonPositiveLogarithm) } else { Ok(x.ln()) } } } // `op(x, y)` == `sqrt(ln(x / y))` fn op(x: f64, y: f64) -> f64 { // This is a three level match pyramid! match checked::div(x, y) { Err(why) => panic!("{:?}", why), Ok(ratio) => match checked::ln(ratio) { ...
or
identifier_name
main.rs
/* Aurélien DESBRIÈRES aurelien(at)hackers(dot)camp License GNU GPL latest */ // Rust experimentations ───────────────┐ // Std Library Result ──────────────────┘ mod checked { // Mathematical "errors" we want to catch #[derive(Debug)] pub enum MathError { DivisionByZero, NonPositiveLogarit...
identifier_body
borrowck-preserve-box-in-moved-value.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 ...
{ g: int } fn lend(x: @Foo) -> int { let y = &x.f.g; free(x); // specifically here, if x is not rooted, it will be freed *y } pub fn main() { assert_eq!(lend(@Foo {f: @Bar {g: 22}}), 22); }
Bar
identifier_name
borrowck-preserve-box-in-moved-value.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 lend(x: @Foo) -> int { let y = &x.f.g; free(x); // specifically here, if x is not rooted, it will be freed *y } pub fn main() { assert_eq!(lend(@Foo {f: @Bar {g: 22}}), 22); }
f: @Bar } struct Bar { g: int
random_line_split
col.rs
use std::fmt; use ascii; use Errors; use SET_ORIGIN_COLUMN_LETTERS; #[derive(PartialEq, PartialOrd, Debug, Copy, Clone)] /// 100km grid square column letters /// /// Repeats every third zone with sets: 'ABCDEFGH', 'JKLMNPQR', 'STUVWXYZ' pub enum ColLetter { A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U...
_ => panic!("Invalid e100k set"), } } pub fn from_set_and_index(set: u8, index: u8) -> Self { use self::ColLetter::{A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U, V, W, X, Y, Z}; // columns in zone 1 are A-H, zone 2 J-R, zone 3 S-Z, then repeating every 3rd zone ...
}, 2 => match *self { S => 0, T => 1, U => 2, V => 3, W => 4, X => 5, Y => 6, Z => 7, _ => panic!("Invalid e100k letter for set 3") },
random_line_split
col.rs
use std::fmt; use ascii; use Errors; use SET_ORIGIN_COLUMN_LETTERS; #[derive(PartialEq, PartialOrd, Debug, Copy, Clone)] /// 100km grid square column letters /// /// Repeats every third zone with sets: 'ABCDEFGH', 'JKLMNPQR', 'STUVWXYZ' pub enum ColLetter { A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U...
pub fn from_set_and_index(set: u8, index: u8) -> Self { use self::ColLetter::{A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U, V, W, X, Y, Z}; // columns in zone 1 are A-H, zone 2 J-R, zone 3 S-Z, then repeating every 3rd zone match set { 0 => { match in...
{ use self::ColLetter::{A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U, V, W, X, Y, Z}; match set { 0 => match *self { A => 0, B => 1, C => 2, D => 3, E => 4, F => 5, G => 6, H => 7, _ => panic!("Invalid e100k letter for set 1") }, ...
identifier_body
col.rs
use std::fmt; use ascii; use Errors; use SET_ORIGIN_COLUMN_LETTERS; #[derive(PartialEq, PartialOrd, Debug, Copy, Clone)] /// 100km grid square column letters /// /// Repeats every third zone with sets: 'ABCDEFGH', 'JKLMNPQR', 'STUVWXYZ' pub enum ColLetter { A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U...
(s: &str) -> Result<Self, Self::Err> { use self::ColLetter::{A, B, C, D, E, F, G, H, J, K, L, M, N, P, Q, R, S, T, U, V, W, X, Y, Z}; let z = s.as_bytes()[0]; match z { b'A' | b'a' => Ok(A), b'B' | b'b' => Ok(B), b'C' | b'c' => Ok(C), b'D' | b'd' => Ok(D), b'E' | b'e' => ...
from_str
identifier_name
_env.rs
pub fn env() { consts_module(); functions(); } use std::env; fn consts_module() { println!("ARCH: {}", env::consts::ARCH); println!("DLL_EXTENSION: {}", env::consts::DLL_EXTENSION); println!("DLL_PREFIX: {}", env::consts::DLL_PREFIX); println!("DLL_SUFFIX: {}", env::consts::DLL_SUFFIX); pr...
let key = "KEY"; env::set_var(key, "VALUE"); assert_eq!(env::var(key), Ok("VALUE".to_string())); env::remove_var(key); // there is var_os too assert!(env::var(key).is_err()); use std::path::Path; let root = Path::new("/"); // assert!(env::set_current_dir(&root).is_ok()); pri...
{ let mut paths = env::split_paths(&path).collect::<Vec<_>>(); paths.push(PathBuf::from("/home/cajetan/bin")); let new_path = env::join_paths(paths).unwrap(); println!("new path is: {:?}", new_path); }
conditional_block
_env.rs
pub fn env() { consts_module(); functions(); } use std::env; fn
() { println!("ARCH: {}", env::consts::ARCH); println!("DLL_EXTENSION: {}", env::consts::DLL_EXTENSION); println!("DLL_PREFIX: {}", env::consts::DLL_PREFIX); println!("DLL_SUFFIX: {}", env::consts::DLL_SUFFIX); println!("EXE_EXTENSION: {}", env::consts::EXE_EXTENSION); println!("EXE_SUFFIX: {}",...
consts_module
identifier_name
_env.rs
pub fn env() { consts_module(); functions(); } use std::env; fn consts_module() { println!("ARCH: {}", env::consts::ARCH); println!("DLL_EXTENSION: {}", env::consts::DLL_EXTENSION); println!("DLL_PREFIX: {}", env::consts::DLL_PREFIX); println!("DLL_SUFFIX: {}", env::consts::DLL_SUFFIX); pr...
let f = File::create(dir); // all env variables of the current process for (key, value) in env::vars() { println!("{}: {}", key, value); } // vars_os too }
let mut dir = env::temp_dir(); dir.push("foo.txt");
random_line_split
_env.rs
pub fn env() { consts_module(); functions(); } use std::env; fn consts_module() { println!("ARCH: {}", env::consts::ARCH); println!("DLL_EXTENSION: {}", env::consts::DLL_EXTENSION); println!("DLL_PREFIX: {}", env::consts::DLL_PREFIX); println!("DLL_SUFFIX: {}", env::consts::DLL_SUFFIX); pr...
println!("new path is: {:?}", new_path); } let key = "KEY"; env::set_var(key, "VALUE"); assert_eq!(env::var(key), Ok("VALUE".to_string())); env::remove_var(key); // there is var_os too assert!(env::var(key).is_err()); use std::path::Path; let root = Path::new("/"); //...
{ for i in env::args() { println!("{}", i); } for i in env::args_os() { println!("{:?}", i); } println!("Current dir is: {}", env::current_dir().unwrap().display()); println!("{:?}", env::current_exe()); println!("home dir: {:?}", env::home_dir()); use std::path::Path...
identifier_body
server.rs
use std::future::Future; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use crate::jsonrpc::futures::channel::mpsc; use crate::jsonrpc::{middleware, MetaIoHandler, Metadata, Middleware}; use crate::meta::{MetaExtractor, NoopExtractor, RequestContext}; use crate::select_with_weak::SelectWithWeak...
); Ok(()) } futures::future::Either::Right(_) => Err("timed out"), } }) .unwrap(); } #[test] fn runs_with_security_attributes() { let path = "/tmp/test-ipc-9001"; let io = MetaIoHandler::<Arc<()>>::default(); ServerBuilder::with_meta_extractor(io, NoopExtractor) .set_security_attri...
"Connection to the closed socket should fail"
random_line_split
server.rs
use std::future::Future; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use crate::jsonrpc::futures::channel::mpsc; use crate::jsonrpc::{middleware, MetaIoHandler, Metadata, Middleware}; use crate::meta::{MetaExtractor, NoopExtractor, RequestContext}; use crate::select_with_weak::SelectWithWeak...
fn huge_response_test_json() -> String { let mut result = String::from("{\"jsonrpc\":\"2.0\",\"result\":\""); result.push_str(&huge_response_test_str()); result.push_str("\",\"id\":1}"); result } #[test] fn test_huge_response() { crate::logger::init_log(); let path = "/tmp/test-ipc-60000"; let mu...
{ let mut result = String::from("begin_hello"); result.push_str("begin_hello"); for _ in 0..16384 { result.push(' '); } result.push_str("end_hello"); result }
identifier_body
server.rs
use std::future::Future; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use crate::jsonrpc::futures::channel::mpsc; use crate::jsonrpc::{middleware, MetaIoHandler, Metadata, Middleware}; use crate::meta::{MetaExtractor, NoopExtractor, RequestContext}; use crate::select_with_weak::SelectWithWeak...
futures::future::Either::Right(_) => Err("timed out"), } }) .unwrap(); } #[test] fn runs_with_security_attributes() { let path = "/tmp/test-ipc-9001"; let io = MetaIoHandler::<Arc<()>>::default(); ServerBuilder::with_meta_extractor(io, NoopExtractor) .set_security_attributes(SecurityAttributes:...
{ assert!(result.is_ok(), "Rx failed"); assert_eq!(result, Ok(true), "Wait timeout exceeded"); assert!( UnixStream::connect(path).is_err(), "Connection to the closed socket should fail" ); Ok(()) }
conditional_block
server.rs
use std::future::Future; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use crate::jsonrpc::futures::channel::mpsc; use crate::jsonrpc::{middleware, MetaIoHandler, Metadata, Middleware}; use crate::meta::{MetaExtractor, NoopExtractor, RequestContext}; use crate::select_with_weak::SelectWithWeak...
() { crate::logger::init_log(); let path = "/tmp/test-ipc-70000"; let server = run(path); let close_handle = server.close_handle(); let (tx, rx) = oneshot::channel(); thread::spawn(move || { thread::sleep(time::Duration::from_millis(100)); close_handle.close(); }); thread::spawn(move || { serv...
close_when_waiting
identifier_name
struct-literal-in-for.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 ...
// compile-flags: -Z parse-only struct Foo { x: isize, } impl Foo { fn hi(&self) -> bool { true } } fn main() { for x in Foo { x: 3 //~ ERROR expected type, found `3` }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` println!("yo"); }...
random_line_split
struct-literal-in-for.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() { for x in Foo { x: 3 //~ ERROR expected type, found `3` }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` println!("yo"); } }
{ true }
identifier_body
struct-literal-in-for.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> bool { true } } fn main() { for x in Foo { x: 3 //~ ERROR expected type, found `3` }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` println!("yo"); } }
hi
identifier_name
session.rs
// Copyright 2012-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-MI...
(&self) -> bool { self.debugging_opt(no_prepopulate_passes) } pub fn no_vectorize_loops(&self) -> bool { self.debugging_opt(no_vectorize_loops) } pub fn no_vectorize_slp(&self) -> bool { self.debugging_opt(no_vectorize_slp) } pub fn gen_crate_map(&self) -> bool { ...
no_prepopulate_passes
identifier_name
session.rs
// Copyright 2012-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-MI...
("extra-debug-info", "Extra debugging info (experimental)", extra_debug_info), ("debug-info", "Produce debug info (experimental)", debug_info), ("no-debug-borrows", "do not show where borrow checks fail", no_debug_borrows), ("lint-llvm", "Run the LLVM lint pass on the pre-opt...
("meta-stats", "gather metadata statistics", meta_stats), ("no-opt", "do not optimize, even if -O is passed", no_opt), ("print-link-args", "Print the arguments passed to the linker", print_link_args), ("gc", "Garbage collect shared data (experimental)", gc),
random_line_split
session.rs
// Copyright 2012-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-MI...
pub fn err_count(&self) -> uint { self.span_diagnostic.handler().err_count() } pub fn has_errors(&self) -> bool { self.span_diagnostic.handler().has_errors() } pub fn abort_if_errors(&self) { self.span_diagnostic.handler().abort_if_errors() } pub fn span_warn(&self, ...
{ self.span_diagnostic.handler().err(msg) }
identifier_body
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/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
impl<Window> Browser<Window> where Window: WindowMethods +'static { pub fn new(window: Rc<Window>) -> Browser<Window> { // Global configuration options, parsed from the command line. let opts = opts::get(); // Make sure the gl context is made current. window.prepare_for_composite(0...
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
private_resource_threads: private_resource_threads, time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, supports_clipboard: supports_clipboard, webrender_api_sender: webrender_api_sender, }; let (constellation_chan, from_swmanager_sender) = ...
{ let bluetooth_thread: IpcSender<BluetoothRequest> = BluetoothThreadFactory::new(); let (public_resource_threads, private_resource_threads) = new_resource_threads(user_agent, devtools_chan.clone(), time_profiler_chan.clone(), ...
identifier_body
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/. */ //! Servo, the mighty web browser engine from the future. //! //! This is a very simple library that wires all of ...
(constellation_chan: IpcSender<ScriptMsg>) { log::set_logger(|max_log_level| { let env_logger = EnvLogger::new(); let con_logger = FromScriptLogger::new(constellation_chan); let filter = max(env_logger.filter(), con_logger.filter()); let logger = BothLogger(env_logger, con_logger); ...
set_logger
identifier_name
shared_vec.rs
use std::borrow::Borrow; use std::hash::{Hash, Hasher}; use std::ops::{Index, IndexMut, Range, RangeFrom, RangeTo}; use super::{SharedMemory, open_shared}; use utils::round_to_pages; #[allow(dead_code)] // FIXME: While WIP pub struct SharedVec<T: Sized +'static> { vec: Vec<T>, shared: SharedMemory<T>, modi...
}
{ self.modified = true; self.vec.index_mut(index) }
identifier_body
shared_vec.rs
use std::borrow::Borrow; use std::hash::{Hash, Hasher}; use std::ops::{Index, IndexMut, Range, RangeFrom, RangeTo}; use super::{SharedMemory, open_shared}; use utils::round_to_pages; #[allow(dead_code)] // FIXME: While WIP pub struct SharedVec<T: Sized +'static> { vec: Vec<T>, shared: SharedMemory<T>, modi...
fn index(&self, index: RangeTo<usize>) -> &[T] { self.vec.index(index) } } impl<T: Sized +'static> Index<RangeFrom<usize>> for SharedVec<T> { type Output = [T]; fn index(&self, index: RangeFrom<usize>) -> &[T] { self.vec.index(index) } } impl<T: Sized +'static> IndexMut<usize> for ...
impl<T: Sized + 'static> Index<RangeTo<usize>> for SharedVec<T> { type Output = [T];
random_line_split
shared_vec.rs
use std::borrow::Borrow; use std::hash::{Hash, Hasher}; use std::ops::{Index, IndexMut, Range, RangeFrom, RangeTo}; use super::{SharedMemory, open_shared}; use utils::round_to_pages; #[allow(dead_code)] // FIXME: While WIP pub struct SharedVec<T: Sized +'static> { vec: Vec<T>, shared: SharedMemory<T>, modi...
(&mut self, index: usize) -> &mut T { self.modified = true; self.vec.index_mut(index) } }
index_mut
identifier_name
terr-sorts.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 ...
//~| expected struct `foo` //~| found box } fn main() {}
want_foo(b); //~ ERROR mismatched types //~| expected `foo` //~| found `Box<foo>`
random_line_split
terr-sorts.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 ...
(b: bar) { want_foo(b); //~ ERROR mismatched types //~| expected `foo` //~| found `Box<foo>` //~| expected struct `foo` //~| found box } fn main() {}
have_bar
identifier_name