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
simdty.rs
// Copyright 2016 chacha20-poly1305-aead Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed exce...
} unsafe impl<T: Safe> Safe for Simd4<T> {} unsafe impl<T: Safe> Safe for Simd8<T> {} unsafe impl<T: Safe> Safe for Simd16<T> {}
{ Simd4(e0, e1, e2, e3) }
identifier_body
filter.rs
use htslib::bam::record::Record; pub trait RecordCheck { fn valid(&self, rec: &Record) -> bool; fn vir_pos(&self, rec: &Record) -> i32; } pub struct SingleChecker { pub tail_edge: bool, pub exact_length: bool, pub read_length: usize, pub min_quality: u8, } fn vir_pos_common(read_length: usize...
(&self, record: &Record) -> bool { !record.is_unmapped() && (!self.exact_length || record.seq().len() == self.read_length) && record.mapq() >= self.min_quality } fn vir_pos(&self, rec: &Record) -> i32 { vir_pos_common(self.read_length, self.tail_edge, self.exact_length, rec) } } #[derive(Co...
valid
identifier_name
filter.rs
use htslib::bam::record::Record; pub trait RecordCheck { fn valid(&self, rec: &Record) -> bool; fn vir_pos(&self, rec: &Record) -> i32; } pub struct SingleChecker { pub tail_edge: bool, pub exact_length: bool, pub read_length: usize, pub min_quality: u8, } fn vir_pos_common(read_length: usize...
return false; } } // filter for specific pair in paired reads match self.select_pair { Some( side ) => { match side { PairPosition::First => { if!record.is_first_in_template() { ...
let dist = (record.pos() - record.mpos()).abs() + self.read_length as i32; // TODO FIX! if dist < self.min_dist || dist > self.max_dist {
random_line_split
metrics.rs
use memmap::{Protection, Mmap}; use std::fs::File; use std::io::{ErrorKind, Error}; use std::fmt::{self, Display, Formatter}; use std::str::Chars; use text::style::{Style, StyleFlags}; use text::default::{DefaultMetrics, character_to_default}; // Each glyph takes up to 9x9 pixels. #[derive(Debug, Copy, Clone, Eq, Par...
// Incoming: an ASCII width from 0 to 8. pub fn from_default_width(width: u8) -> Self { if width == 0 { GlyphSize::empty() } else { GlyphSize::new(0, (width * 2) - 1) } } /// Returns the left side of the glyph, the X position of the leftmost column of pixels. This is from 0 to 15. pub fn left(&self...
GlyphSize((left << 4) | (right & 15)) }
random_line_split
metrics.rs
use memmap::{Protection, Mmap}; use std::fs::File; use std::io::{ErrorKind, Error}; use std::fmt::{self, Display, Formatter}; use std::str::Chars; use text::style::{Style, StyleFlags}; use text::default::{DefaultMetrics, character_to_default}; // Each glyph takes up to 9x9 pixels. #[derive(Debug, Copy, Clone, Eq, Par...
/// Returns the advance width of the specified character in this font. The advance is the distance from the leftmost point to the rightmost point on the character's baseline. /// In MC fonts, this is 0.0 to 9.0. /// Note that this function returns the exact advance after rendering, while Minecraft char sizing may...
{ self.right() + 1 - self.left() }
identifier_body
metrics.rs
use memmap::{Protection, Mmap}; use std::fs::File; use std::io::{ErrorKind, Error}; use std::fmt::{self, Display, Formatter}; use std::str::Chars; use text::style::{Style, StyleFlags}; use text::default::{DefaultMetrics, character_to_default}; // Each glyph takes up to 9x9 pixels. #[derive(Debug, Copy, Clone, Eq, Par...
(self) -> Option<usize> { let mut accumulator = 0; for adv in self { accumulator += match adv { Some(advance) => advance as usize, None => return None }; } Some(accumulator) } } impl<'a, I> Iterator for AdvanceRun<'a, I> where I: Iterator<Item=char> { type Item = Option<u8>; fn next(&m...
total
identifier_name
metrics.rs
use memmap::{Protection, Mmap}; use std::fs::File; use std::io::{ErrorKind, Error}; use std::fmt::{self, Display, Formatter}; use std::str::Chars; use text::style::{Style, StyleFlags}; use text::default::{DefaultMetrics, character_to_default}; // Each glyph takes up to 9x9 pixels. #[derive(Debug, Copy, Clone, Eq, Par...
, TryNext::Retry => (), TryNext::Inner(inner) => return Some(inner) } } } } pub struct AdvanceRun<'a, I> where I: Iterator<Item=char> { iter: I, bold: bool, metrics: &'a Metrics } impl<'a, I> AdvanceRun<'a, I> where I: Iterator<Item=char> { pub fn total(self) -> Option<usize> { let mut accumulator...
{self.current = None; return None}
conditional_block
seal.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
{ /// Ethereum seal. #[serde(rename="ethereum")] Ethereum(Ethereum), /// Generic seal. #[serde(rename="generic")] Generic(Generic), } #[cfg(test)] mod tests { use serde_json; use spec::Seal; #[test] fn builtin_deserialization() { let s = r#"[{ "ethereum": { "nonce": "0x0000000000000042", "mixH...
Seal
identifier_name
seal.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
//! Spec seal deserialization. use hash::{H64, H256}; use bytes::Bytes; /// Ethereum seal. #[derive(Debug, PartialEq, Deserialize)] pub struct Ethereum { /// Seal nonce. pub nonce: H64, /// Seal mix hash. #[serde(rename="mixHash")] pub mix_hash: H256, } /// Generic seal. #[derive(Debug, PartialEq, Deserialize)...
// You should have received a copy of the GNU General Public License // along with Parity. If not, see <http://www.gnu.org/licenses/>.
random_line_split
seal.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
}
{ let s = r#"[{ "ethereum": { "nonce": "0x0000000000000042", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" } },{ "generic": { "fields": 1, "rlp": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa" } }]"#; let _deserialized: Vec<Seal...
identifier_body
issue-2190-1.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
}) } pub fn main() { spawn(child_no(0)); }
{ spawn(child_no(x+1)); }
conditional_block
issue-2190-1.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
if x < generations { spawn(child_no(x+1)); } }) } pub fn main() { spawn(child_no(0)); }
random_line_split
issue-2190-1.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ spawn(child_no(0)); }
identifier_body
issue-2190-1.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(mut f: Box<FnMut() +'static + Send>) { Builder::new().stack_size(32 * 1024).spawn(move|| f()); } fn child_no(x: usize) -> Box<FnMut() +'static + Send> { Box::new(move|| { if x < generations { spawn(child_no(x+1)); } }) } pub fn main() { spawn(child_no(0)); }
spawn
identifier_name
lazy.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 ...
} else { Some((*ptr).clone()) } } } unsafe fn init(&'static self) -> Arc<T> { // If we successfully register an at exit handler, then we cache the // `Arc` allocation in our own internal box (it will get deallocated by // the at exit handl...
random_line_split
lazy.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 ...
else if ptr as usize == 1 { None } else { Some((*ptr).clone()) } } } unsafe fn init(&'static self) -> Arc<T> { // If we successfully register an at exit handler, then we cache the // `Arc` allocation in our own internal box (it wi...
{ Some(self.init()) }
conditional_block
lazy.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 ...
(&'static self) -> Arc<T> { // If we successfully register an at exit handler, then we cache the // `Arc` allocation in our own internal box (it will get deallocated by // the at exit handler). Otherwise we just return the freshly allocated // `Arc`. let registered = rt::at_exit(...
init
identifier_name
lazy.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 ...
unsafe fn init(&'static self) -> Arc<T> { // If we successfully register an at exit handler, then we cache the // `Arc` allocation in our own internal box (it will get deallocated by // the at exit handler). Otherwise we just return the freshly allocated // `Arc`. let regis...
{ let _g = self.lock.lock(); unsafe { let ptr = *self.ptr.get(); if ptr.is_null() { Some(self.init()) } else if ptr as usize == 1 { None } else { Some((*ptr).clone()) } } }
identifier_body
x86stdcall2.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 ...
() { }
main
identifier_name
x86stdcall2.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.
// option. This file may not be copied, modified, or distributed // except according to those terms. pub type HANDLE = u32; pub type DWORD = u32; pub type SIZE_T = u32; pub type LPVOID = uint; pub type BOOL = u8; #[cfg(windows)] mod kernel32 { use super::{HANDLE, DWORD, SIZE_T, LPVOID, BOOL}; extern "system"...
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
x86stdcall2.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 ...
{ }
identifier_body
main.rs
mod graph; mod index_type; use std::io::{BufReader, BufRead}; use std::fs::File; use std::str::FromStr; use std::fmt::Debug; use std::result::Result; use graph::{MDGraph, WeightType, Unweighted}; use index_type::{IndexType, NodeIndex, EdgeIndex, DefIndex}; fn read_sgf<NodeWt, EdgeWt, NodeIx, EdgeIx, R, I>(rd: &mut R)...
} // // Some("u") => { // false // } // _ => { panic!("Invalid format"); } }; let num_nodes: usize = match m.next() { Some(ns) => { ...
{ let mut meta: Option<(bool, usize, usize)> = None; let mut graph = MDGraph::new(); for line in rd.lines() { let line = line.unwrap(); let line = line.trim(); if line.starts_with("#") { // skip comment continue; } if meta.is_none() { ...
identifier_body
main.rs
mod graph; mod index_type; use std::io::{BufReader, BufRead}; use std::fs::File; use std::str::FromStr; use std::fmt::Debug; use std::result::Result; use graph::{MDGraph, WeightType, Unweighted}; use index_type::{IndexType, NodeIndex, EdgeIndex, DefIndex}; fn
<NodeWt, EdgeWt, NodeIx, EdgeIx, R, I>(rd: &mut R) -> MDGraph<NodeWt, EdgeWt, NodeIx, EdgeIx> where NodeWt: WeightType + FromStr<Err = I>, EdgeWt: WeightType + FromStr<Err = I>, NodeIx: IndexType, EdgeIx: IndexType, I: Debug, ...
read_sgf
identifier_name
main.rs
mod graph; mod index_type; use std::io::{BufReader, BufRead}; use std::fs::File; use std::str::FromStr; use std::fmt::Debug; use std::result::Result; use graph::{MDGraph, WeightType, Unweighted}; use index_type::{IndexType, NodeIndex, EdgeIndex, DefIndex}; fn read_sgf<NodeWt, EdgeWt, NodeIx, EdgeIx, R, I>(rd: &mut R)...
_ => { panic!("Invalid format"); } }; if let Some(nw) = node_weight { *graph.get_node_weight_mut(NodeIndex::new(node_id)) = nw; } let edge_s = i.next().unwrap(); for es in edge_s.split(',') ...
{ let mut it = ns.splitn(2, ":"); let node_id: usize = it.next().unwrap().parse().unwrap(); let node_weight: Option<NodeWt> = it.next().map(|s| s.parse().unwrap()); (node_id, node_weight) }
conditional_block
main.rs
mod graph; mod index_type; use std::io::{BufReader, BufRead}; use std::fs::File; use std::str::FromStr; use std::fmt::Debug; use std::result::Result; use graph::{MDGraph, WeightType, Unweighted}; use index_type::{IndexType, NodeIndex, EdgeIndex, DefIndex}; fn read_sgf<NodeWt, EdgeWt, NodeIx, EdgeIx, R, I>(rd: &mut R)...
} if meta.is_none() { // First line is meta let mut m = line.split_whitespace(); let directed = match m.next() { Some("d") => { true } // // Some("u") => { // false ...
let line = line.trim(); if line.starts_with("#") { // skip comment continue;
random_line_split
saddle-points.rs
extern crate saddle_points; use saddle_points::*; #[test] fn test_identify_single_saddle_point() { let input = vec![vec![9, 8, 7], vec![5, 3, 2], vec![6, 6, 7]]; assert_eq!(vec![(1, 0)], find_saddle_points(&input)); } #[test] #[ignore] fn
() { let input = vec![vec![], vec![], vec![]]; let expected: Vec<(usize, usize)> = Vec::new(); assert_eq!(expected, find_saddle_points(&input)); } #[test] #[ignore] fn test_identify_lack_of_saddle_point() { let input = vec![vec![1, 2, 3], vec![3, 1, 2], vec![2, 3, 1]]; let expected: Vec<(usize, usi...
test_identify_empty_matrix
identifier_name
saddle-points.rs
extern crate saddle_points; use saddle_points::*; #[test] fn test_identify_single_saddle_point() { let input = vec![vec![9, 8, 7], vec![5, 3, 2], vec![6, 6, 7]]; assert_eq!(vec![(1, 0)], find_saddle_points(&input)); } #[test] #[ignore] fn test_identify_empty_matrix() { let input = vec![vec![], vec![], ve...
#[test] #[ignore] fn test_vector_matrix() { let input = vec![vec![1], vec![3], vec![2], vec![3]]; assert_eq!(vec![(0, 0)], find_saddle_points(&input)); }
{ let input = vec![vec![8, 7, 10, 7, 9], vec![8, 7, 13, 7, 9]]; assert_eq!(vec![(0, 2)], find_saddle_points(&input)); }
identifier_body
saddle-points.rs
extern crate saddle_points; use saddle_points::*; #[test] fn test_identify_single_saddle_point() { let input = vec![vec![9, 8, 7], vec![5, 3, 2], vec![6, 6, 7]]; assert_eq!(vec![(1, 0)], find_saddle_points(&input)); } #[test] #[ignore] fn test_identify_empty_matrix() { let input = vec![vec![], vec![], ve...
} #[test] #[ignore] fn test_identify_bottom_right_saddle_point() { let input = vec![vec![8, 7, 9], vec![6, 7, 6], vec![3, 2, 5]]; assert_eq!(vec![(2, 2)], find_saddle_points(&input)); } #[test] #[ignore] fn test_non_square_matrix_high() { let input = vec![vec![1, 5], vec![3, 6], vec![2, 7], vec![3, 8]]; ...
fn test_multiple_saddle_point() { let input = vec![vec![4, 5, 4], vec![3, 5, 5], vec![1, 5, 4]]; assert_eq!(vec![(0, 1), (1, 1), (2, 1)], find_saddle_points(&input));
random_line_split
closure.rs
important that we be able to locate the closure data *without // knowing the kind of data that is being bound*. This can be tricky // because the alignment requirements of the bound data affects the // alignment requires of the closure_data struct as a whole. However, // right now this is a non-issue in any case, be...
None => {} } let function_type = ty::mk_unboxed_closure(ccx.tcx(), closure_id, ty::ReStatic); let symbol = ccx.tcx().map.with_path(closure_id.node, |path| { mangle_internal_name_by_path_and_seq(pa...
{ debug!("get_or_create_declaration_if_unboxed_closure(): found \ closure"); return Some(*llfn) }
conditional_block
closure.rs
important that we be able to locate the closure data *without // knowing the kind of data that is being bound*. This can be tricky // because the alignment requirements of the bound data affects the // alignment requires of the closure_data struct as a whole. However, // right now this is a non-issue in any case, be...
(&self, ccx: &CrateContext) -> String { format!("{}({})", self.action, self.datum.to_string(ccx)) } } // Given a closure ty, emits a corresponding tuple ty pub fn mk_closure_tys(tcx: &ty::ctxt, bound_values: &[EnvValue]) -> ty::t { // determine the types of the ...
to_string
identifier_name
closure.rs
important that we be able to locate the closure data *without // knowing the kind of data that is being bound*. This can be tricky // because the alignment requirements of the bound data affects the // alignment requires of the closure_data struct as a whole. However, // right now this is a non-issue in any case, be...
fn tuplify_box_ty(tcx: &ty::ctxt, t: ty::t) -> ty::t { let ptr = ty::mk_imm_ptr(tcx, ty::mk_i8()); ty::mk_tup(tcx, vec!(ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t)) } fn allocate_cbox<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, store: ty::TraitStore, cda...
{ // determine the types of the values in the env. Note that this // is the actual types that will be stored in the map, not the // logical types as the user sees them, so by-ref upvars must be // converted to ptrs. let bound_tys = bound_values.iter().map(|bv| { match bv.action { ...
identifier_body
closure.rs
// // But sometimes, such as when cloning or freeing a closure, we need // to know the full information. That is where the type descriptor // that defines the closure comes in handy. We can use its take and // drop glue functions to allocate/free data as needed. // // ## Subtleties concerning alignment ## // // It is...
// by ptr. The routine Type::at_box().ptr_to() returns an appropriate // type for such an opaque closure; it allows access to the box fields, // but not the closure_data itself.
random_line_split
gdl90.rs
9D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C...
buf[0] = 0x14; buf[1] = match e.addr.1 { AddressType::ADSBICAO | AddressType::ADSRICAO => 0, AddressType::ADSBOther | AddressType::ADSROther => 1, AddressType::TISBICAO => 2, AddressType::TISBOther => 3, _ => 3, // unknown }; ...
} } fn generate_traffic(e: &Target, clock: Instant, pres_alt_valid: bool) -> Payload { let mut buf = [0_u8; 28 + 2]; // incl CRC field
random_line_split
gdl90.rs
D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C,...
(mut d: f32) -> (u8, u8, u8) { d /= LON_LAT_RESOLUTION; let wk = d.round() as i32; ( ((wk & 0xFF0000) >> 16) as u8, ((wk & 0x00FF00) >> 8) as u8, (wk & 0x0000FF) as u8, ) } fn alt_to_gdl90(mut a: f32) -> u16 { if a < -1000_f32 || a > 101350_f32 { 0xFFF } else
latlon_to_gdl90
identifier_name
gdl90.rs
D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C,...
} } impl GDL90 { fn generate_heartbeat(&self, utc: &Tm) -> Payload { let mut buf = [0_u8; 7 + 2]; // incl CRC field buf[0] = 0x00; // type = heartbeat buf[1] = 0x11; // UAT Initialized + ATC Services talkback if self.ownship_valid { buf[1] |= 0x80; } ...
{ self.heartbeat_counter = 0; let utc = handle.get_utc(); handle.push_data(self.generate_heartbeat(&utc)); handle.push_data(GDL90::generate_foreflight_id()); }
conditional_block
gdl90.rs
D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C,...
if *b == 0x7E || *b == 0x7D { tmp.push(0x7D); tmp.push(*b ^ 0x20); } else { tmp.push(*b); } } tmp.push(0x7E); tmp } } impl GDL90 { pub fn new() -> Box<Protocol> { Box::new(GDL90 { ...
{ let len = buf.len() - 2; let crc = buf.iter() .take(len) .scan(0_u16, |crc, b| { *crc = CRC16_TABLE[(*crc >> 8) as usize] ^ (*crc << 8) ^ (*b as u16); Some(*crc) }) .last() .unwrap(); buf[len] = (crc ...
identifier_body
unique-send-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let mut actual = 0u; for uint::range(0u, n) |_i| { let j = p.recv(); actual += *j; } assert!(expected == actual); }
random_line_split
unique-send-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let (p, ch) = stream(); let ch = SharedChan(ch); let n = 100u; let mut expected = 0u; for uint::range(0u, n) |i| { let ch = ch.clone(); task::spawn(|| child(&ch, i) ); expected += i; } let mut actual = 0u; for uint::range(0u, n) |_i| { let j = p.recv...
main
identifier_name
unique-send-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let (p, ch) = stream(); let ch = SharedChan(ch); let n = 100u; let mut expected = 0u; for uint::range(0u, n) |i| { let ch = ch.clone(); task::spawn(|| child(&ch, i) ); expected += i; } let mut actual = 0u; for uint::range(0u, n) |_i| { l...
{ c.send(~i); }
identifier_body
lib.rs
// ================================================================= // // * WARNING * // // This file is generated! // // Changes made to this file will be overwritten. If changes are // required to the generated code, the service_crategen project // must be updated to g...
mod custom; mod generated; pub use custom::*; pub use generated::*;
)] //! <p>AWS Cloud Map lets you configure public DNS, private DNS, or HTTP namespaces that your microservice applications run in. When an instance of the service becomes available, you can call the AWS Cloud Map API to register the instance with AWS Cloud Map. For public or private DNS namespaces, AWS Cloud Map automa...
random_line_split
storage.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/. */ use dom::bindings::codegen::Bindings::StorageBinding; use dom::bindings::codegen::Bindings::StorageBinding::Storag...
(&self, name: DOMString, value: DOMString) { self.SetItem(name, value); } fn NamedDeleter(&self, name: DOMString) { self.RemoveItem(name); } fn SupportedPropertyNames(&self) -> Vec<DOMString> { // FIXME: unimplemented (https://github.com/servo/servo/issues/7273) vec![] ...
NamedCreator
identifier_name
storage.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/. */ use dom::bindings::codegen::Bindings::StorageBinding; use dom::bindings::codegen::Bindings::StorageBinding::Storag...
reflect_dom_object(box Storage::new_inherited(global, storage_type), *global, StorageBinding::Wrap) } fn get_url(&self) -> Url { let global_root = self.global.root(); let global_ref = global_root.r(); global_ref.get_url() } fn get_storage_task(&self) -> StorageTask { ...
pub fn new(global: &GlobalRef, storage_type: StorageType) -> Root<Storage> {
random_line_split
storage.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/. */ use dom::bindings::codegen::Bindings::StorageBinding; use dom::bindings::codegen::Bindings::StorageBinding::Storag...
} // https://html.spec.whatwg.org/multipage/#dom-storage-clear fn Clear(&self) { let (sender, receiver) = ipc::channel().unwrap(); self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap(); if receiver.recv().unwrap() { sel...
{ self.broadcast_change_notification(Some(name), Some(old_value), None); }
conditional_block
storage.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/. */ use dom::bindings::codegen::Bindings::StorageBinding; use dom::bindings::codegen::Bindings::StorageBinding::Storag...
// https://html.spec.whatwg.org/multipage/#dom-storage-clear fn Clear(&self) { let (sender, receiver) = ipc::channel().unwrap(); self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap(); if receiver.recv().unwrap() { self.broa...
{ let (sender, receiver) = ipc::channel().unwrap(); let msg = StorageTaskMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone()); self.get_storage_task().send(msg).unwrap(); if let Some(old_value) = receiver.recv().unwrap() { self.broadcast_change_notificati...
identifier_body
tree.rs
/// Async server-side trees use std::{ops, fmt, mem}; use dbus::tree::{Factory, Tree, MethodType, DataType, MTFn, Method, MethodInfo, MethodErr}; use dbus::{Member, Message, Connection}; use std::marker::PhantomData; use std::cell::RefCell; use futures::{IntoFuture, Future, Poll, Stream, Async}; use std::ffi::CString;...
() -> Self { Default::default() } fn push(&self, a: AMethodResult) { let mut z = self.0.borrow_mut(); assert!(z.is_none(), "Same message handled twice"); *z = Some(a); } } impl<D: ADataType> DataType for ATree<D> { type Tree = ATree<D>; type ObjectPath = D::ObjectPath; type ...
new
identifier_name
tree.rs
/// Async server-side trees use std::{ops, fmt, mem}; use dbus::tree::{Factory, Tree, MethodType, DataType, MTFn, Method, MethodInfo, MethodErr}; use dbus::{Member, Message, Connection}; use std::marker::PhantomData; use std::cell::RefCell; use futures::{IntoFuture, Future, Poll, Stream, Async}; use std::ffi::CString;...
else { return Ok(Async::Ready(Some(m))) } } else { return z } } } }
{ self.spawn_method_results(m); for msg in v { self.conn.send(msg)?; } // We consumed the message. Poll again }
conditional_block
tree.rs
/// Async server-side trees use std::{ops, fmt, mem}; use dbus::tree::{Factory, Tree, MethodType, DataType, MTFn, Method, MethodInfo, MethodErr}; use dbus::{Member, Message, Connection}; use std::marker::PhantomData; use std::cell::RefCell; use futures::{IntoFuture, Future, Poll, Stream, Async}; use std::ffi::CString;
type ObjectPath: fmt::Debug; type Property: fmt::Debug; type Interface: fmt::Debug + Default; type Method: fmt::Debug + Default; type Signal: fmt::Debug; } #[derive(Debug, Default)] /// A Tree that allows both synchronous and asynchronous methods. pub struct ATree<D: ADataType>(RefCell<Option<A...
pub trait ADataType: fmt::Debug + Sized + Default {
random_line_split
env.rs
use std::cell::RefCell; use analysis; use config::Config; use config::gobjects::GStatus; use library::*; use version::Version; pub struct
{ pub library: Library, pub config: Config, pub namespaces: analysis::namespaces::Info, pub symbols: RefCell<analysis::symbols::Info>, pub class_hierarchy: analysis::class_hierarchy::Info, } impl Env { #[inline] pub fn type_(&self, tid: TypeId) -> &Type { self.library.type_(tid) ...
Env
identifier_name
env.rs
use std::cell::RefCell; use analysis; use config::Config; use config::gobjects::GStatus;
pub library: Library, pub config: Config, pub namespaces: analysis::namespaces::Info, pub symbols: RefCell<analysis::symbols::Info>, pub class_hierarchy: analysis::class_hierarchy::Info, } impl Env { #[inline] pub fn type_(&self, tid: TypeId) -> &Type { self.library.type_(tid) }...
use library::*; use version::Version; pub struct Env {
random_line_split
env.rs
use std::cell::RefCell; use analysis; use config::Config; use config::gobjects::GStatus; use library::*; use version::Version; pub struct Env { pub library: Library, pub config: Config, pub namespaces: analysis::namespaces::Info, pub symbols: RefCell<analysis::symbols::Info>, pub class_hierarchy: ...
pub fn type_status_sys(&self, name: &str) -> GStatus { self.config.objects.get(name).map(|o| o.status) .unwrap_or(GStatus::Generate) } pub fn is_totally_deprecated(&self, deprecated_version: Option<Version>) -> bool { match deprecated_version { Some(version) if versi...
{ self.config.objects.get(name).map(|o| o.status) .unwrap_or(Default::default()) }
identifier_body
hamming_numbers_alt.rs
// Implements http://rosettacode.org/wiki/Hamming_numbers // alternate version: uses a more efficient representation of Hamming numbers: // instead of storing them as BigUint directly, it stores the three exponents // i, j and k for 2^i * 3^j * 5 ^k and the logarithm of the number for comparisons #![allow(unused_attri...
(&self) -> HammingTriple { *self } } impl PartialEq for HammingTriple { fn eq(&self, other: &HammingTriple) -> bool { self.pow_2 == other.pow_2 && self.pow_3 == other.pow_3 && self.pow_5 == other.pow_5 } } impl Eq for HammingTriple {} impl PartialOrd for HammingTriple { fn partial...
clone
identifier_name
hamming_numbers_alt.rs
// Implements http://rosettacode.org/wiki/Hamming_numbers // alternate version: uses a more efficient representation of Hamming numbers: // instead of storing them as BigUint directly, it stores the three exponents // i, j and k for 2^i * 3^j * 5 ^k and the logarithm of the number for comparisons #![allow(unused_attri...
} impl HammingTriple { fn new(pow_2: usize, pow_3: usize, pow_5: usize) -> HammingTriple { HammingTriple { pow_2: pow_2, pow_3: pow_3, pow_5: pow_5, ln: (pow_2 as f64) * LN_2 + (pow_3 as f64) * LN_3 + (pow_5 as f64) * LN_5 } } } impl Clone for H...
{ Some(pow(2u8.to_biguint().unwrap(), self.pow_2) * pow(3u8.to_biguint().unwrap(), self.pow_3) * pow(5u8.to_biguint().unwrap(), self.pow_5)) }
identifier_body
hamming_numbers_alt.rs
// Implements http://rosettacode.org/wiki/Hamming_numbers // alternate version: uses a more efficient representation of Hamming numbers: // instead of storing them as BigUint directly, it stores the three exponents // i, j and k for 2^i * 3^j * 5 ^k and the logarithm of the number for comparisons #![allow(unused_attri...
} } impl One for HammingTriple { // 1 as an HammingNumber is 2^0 * 3^0 * 5^0 // ln(1) = 0 fn one() -> HammingTriple { HammingTriple::new(0, 0, 0) } } impl HammingNumber for HammingTriple { fn multipliers() -> (HammingTriple, HammingTriple, HammingTriple) { (HammingTriple { pow_...
pow_3: self.pow_3 + other.pow_3, pow_5: self.pow_5 + other.pow_5, ln: self.ln + other.ln }
random_line_split
unboxed-closures-wrong-trait.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let z: int = 7; assert_eq!(c(|&mut: x: int, y| x + y + z), 10); //~^ ERROR not implemented }
main
identifier_name
unboxed-closures-wrong-trait.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.
// option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(lang_items, overloaded_calls, unboxed_closures)] fn c<F:Fn(int, int) -> int>(f: F) -> int { f(5, 6) } fn main() { let z: int = 7; assert_eq!(c(|&mut: x: int, y| x + y + z), 10); //~^ ERROR ...
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
unboxed-closures-wrong-trait.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 main() { let z: int = 7; assert_eq!(c(|&mut: x: int, y| x + y + z), 10); //~^ ERROR not implemented }
{ f(5, 6) }
identifier_body
bench_acquire.rs
//! Benchmark the overhead that the synchronization of `OnceCell::get` causes. //! We do some other operations that write to memory to get an imprecise but somewhat realistic //! measurement. use once_cell::sync::OnceCell; use std::sync::atomic::{AtomicUsize, Ordering}; const N_THREADS: usize = 16; const N_ROUNDS: us...
*j = (*j).wrapping_add(accum); accum = accum.wrapping_add(k); } } }
for j in data.iter_mut() {
random_line_split
bench_acquire.rs
//! Benchmark the overhead that the synchronization of `OnceCell::get` causes. //! We do some other operations that write to memory to get an imprecise but somewhat realistic //! measurement. use once_cell::sync::OnceCell; use std::sync::atomic::{AtomicUsize, Ordering}; const N_THREADS: usize = 16; const N_ROUNDS: us...
{ // The operations we do here don't really matter, as long as we do multiple writes, and // everything is messy enough to prevent the compiler from optimizing the loop away. let mut data = [i; 128]; let mut accum = 0usize; for _ in 0..N_ROUNDS { let _value = CELL.get_or_init(|| i + 1); ...
identifier_body
bench_acquire.rs
//! Benchmark the overhead that the synchronization of `OnceCell::get` causes. //! We do some other operations that write to memory to get an imprecise but somewhat realistic //! measurement. use once_cell::sync::OnceCell; use std::sync::atomic::{AtomicUsize, Ordering}; const N_THREADS: usize = 16; const N_ROUNDS: us...
(i: usize) { // The operations we do here don't really matter, as long as we do multiple writes, and // everything is messy enough to prevent the compiler from optimizing the loop away. let mut data = [i; 128]; let mut accum = 0usize; for _ in 0..N_ROUNDS { let _value = CELL.get_or_init(|| i...
thread_main
identifier_name
comments.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
curr_line.push(rdr.curr.unwrap()); if rdr.curr_is('/') && rdr.nextch_is('*') { rdr.bump(); rdr.bump(); curr_line.push('*'); level += 1; } else { if rdr.curr_is('*') && rdr....
curr_line, col); curr_line = String::new(); rdr.bump(); } else {
random_line_split
comments.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
while i < j && lines[i].trim().is_empty() { i += 1; } // like the first, a last line of all stars should be omitted if j > i && lines[j - 1] .chars() .skip(1) .all(|c| c == '*') { j -= 1; ...
{ i += 1; }
conditional_block
comments.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn read_shebang_comment(rdr: &mut StringReader, code_to_the_left: bool, comments: &mut Vec<Comment>) { debug!(">>> shebang comment"); let p = rdr.last_pos; debug!("<<< shebang comment"); comments.push(Comment { style: if code_to_the_left { Trailing } else { Isolated },...
{ while is_whitespace(rdr.curr) && !rdr.is_eof() { if rdr.col == CharPos(0) && rdr.curr_is('\n') { push_blank_line_comment(rdr, &mut *comments); } rdr.bump(); } }
identifier_body
comments.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let comment = "/**\n let a: *i32;\n *a = 5;\n*/"; let stripped = strip_doc_comment_decoration(comment); assert_eq!(stripped, " let a: *i32;\n *a = 5;"); } #[test] fn test_block_doc_comment_4() { let comment = "/*******************\n test\n *********************/"; l...
test_block_doc_comment_3
identifier_name
q_sigma.rs
use crate::{ domains::Transition, fa::StateActionUpdate, policies::EnumerablePolicy, utils::argmaxima, Enumerable, Function, Handler, Parameterised, }; use rand::thread_rng; use std::{collections::VecDeque, ops::Index}; struct BackupEntry<S> { pub s: S, pub a: usize, pub q:...
pub fn push(&mut self, entry: BackupEntry<S>) { self.entries.push_back(entry); } pub fn clear(&mut self) { self.entries.clear(); } pub fn propagate(&self, gamma: f64) -> (f64, f64) { let mut g = self.entries[0].q; let mut z = 1.0; let mut isr = 1.0; for k in 0..self.n_ste...
pub fn len(&self) -> usize { self.entries.len() } pub fn pop(&mut self) -> Option<BackupEntry<S>> { self.entries.pop_front() }
random_line_split
q_sigma.rs
use crate::{ domains::Transition, fa::StateActionUpdate, policies::EnumerablePolicy, utils::argmaxima, Enumerable, Function, Handler, Parameterised, }; use rand::thread_rng; use std::{collections::VecDeque, ops::Index}; struct BackupEntry<S> { pub s: S, pub a: usize, pub q:...
; let mu = self.policy.evaluate((ns, na)); let residual = t.reward + self.gamma * (self.sigma * nqsna + (1.0 - self.sigma) * exp_nqs) - qa; self.update_backup(BackupEntry { s: s.clone(), a: t.action, q: qa, ...
{ 0.0 }
conditional_block
q_sigma.rs
use crate::{ domains::Transition, fa::StateActionUpdate, policies::EnumerablePolicy, utils::argmaxima, Enumerable, Function, Handler, Parameterised, }; use rand::thread_rng; use std::{collections::VecDeque, ops::Index}; struct
<S> { pub s: S, pub a: usize, pub q: f64, pub residual: f64, pub sigma: f64, pub pi: f64, pub mu: f64, } struct Backup<S> { n_steps: usize, entries: VecDeque<BackupEntry<S>>, } impl<S> Backup<S> { pub fn new(n_steps: usize) -> Backup<S> { Backup { n_steps,...
BackupEntry
identifier_name
q_sigma.rs
use crate::{ domains::Transition, fa::StateActionUpdate, policies::EnumerablePolicy, utils::argmaxima, Enumerable, Function, Handler, Parameterised, }; use rand::thread_rng; use std::{collections::VecDeque, ops::Index}; struct BackupEntry<S> { pub s: S, pub a: usize, pub q:...
pub fn clear(&mut self) { self.entries.clear(); } pub fn propagate(&self, gamma: f64) -> (f64, f64) { let mut g = self.entries[0].q; let mut z = 1.0; let mut isr = 1.0; for k in 0..self.n_steps { let b1 = &self.entries[k]; let b2 = &self.entries[k + 1]...
{ self.entries.push_back(entry); }
identifier_body
lib.rs
#![warn(missing_docs)] //! A `Pinboard` is a shared, mutable, eventually consistent, lock-free data-structure. This //! allows multiple threads to communicate in a decoupled way by publishing data to the pinboard //! which other threads can then read in an eventually consistent way. //! //! This is not a silver bulle...
#[test] fn single_producer_multi_consumer() { let t = Pinboard::<u32>::new(0); crossbeam::scope(|scope| { scope.spawn(|_| produce(&t)); scope.spawn(|_| consume(&t)); scope.spawn(|_| consume(&t)); scope.spawn(|_| consume(&t)); }).unwrap()...
{ let t = Pinboard::<u32>::new(0); crossbeam::scope(|scope| { scope.spawn(|_| produce(&t)); scope.spawn(|_| produce(&t)); scope.spawn(|_| produce(&t)); scope.spawn(|_| consume(&t)); }).unwrap(); }
identifier_body
lib.rs
#![warn(missing_docs)] //! A `Pinboard` is a shared, mutable, eventually consistent, lock-free data-structure. This //! allows multiple threads to communicate in a decoupled way by publishing data to the pinboard //! which other threads can then read in an eventually consistent way. //! //! This is not a silver bulle...
use std::sync::atomic::Ordering::*; /// An instance of a `Pinboard`, holds a shared, mutable, eventually-consistent reference to a `T`. pub struct Pinboard<T: Clone +'static>(Atomic<T>); impl<T: Clone +'static> Pinboard<T> { /// Create a new `Pinboard` instance holding the given value. pub fn new(t: T) -> Pin...
extern crate crossbeam_epoch as epoch; use epoch::{Atomic, Owned, Shared, pin};
random_line_split
lib.rs
#![warn(missing_docs)] //! A `Pinboard` is a shared, mutable, eventually consistent, lock-free data-structure. This //! allows multiple threads to communicate in a decoupled way by publishing data to the pinboard //! which other threads can then read in an eventually consistent way. //! //! This is not a silver bulle...
<T: Clone + Display>(t: &Pinboard<T>) { loop { match t.read() { Some(_) => {} None => break, } std::thread::sleep(std::time::Duration::from_millis(1)); } } fn produce(t: &Pinboard<u32>) { for i in 1..100 { t...
consume
identifier_name
htmllabelelement.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/. */ use dom::activation::{Activatable, ActivationSource, synthetic_click_activation}; use dom::bindings::codegen::Bind...
fn canceled_activation(&self) { } // https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { if let Some(e) = self.GetControl() { let elem = e.upcast::<Element>(); synthetic_click_acti...
// https://html.spec.whatwg.org/multipage/#run-canceled-activation-steps
random_line_split
htmllabelelement.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/. */ use dom::activation::{Activatable, ActivationSource, synthetic_click_activation}; use dom::bindings::codegen::Bind...
// https://html.spec.whatwg.org/multipage/#implicit-submission fn implicit_submission(&self, _ctrlKey: bool, _shiftKey: bool, _altKey: bool, _metaKey: bool) { //FIXME: Investigate and implement implicit submission for label elements // Issue filed at https://github.com/servo/servo/issues/8263 ...
{ if let Some(e) = self.GetControl() { let elem = e.upcast::<Element>(); synthetic_click_activation(elem, false, false, false, false...
identifier_body
htmllabelelement.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/. */ use dom::activation::{Activatable, ActivationSource, synthetic_click_activation}; use dom::bindings::codegen::Bind...
(&self) -> Option<Root<HTMLFormElement>> { self.form_owner() } // https://html.spec.whatwg.org/multipage/#dom-label-htmlfor make_getter!(HtmlFor, "for"); // https://html.spec.whatwg.org/multipage/#dom-label-htmlfor make_atomic_setter!(SetHtmlFor, "for"); // https://html.spec.whatwg.or...
GetForm
identifier_name
htmltitleelement.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/. */ use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding; use crate::dom::bindings::codegen::Bindings:...
let node = self.upcast::<Node>(); if tree_in_doc { node.owner_doc().title_changed(); } } }
{ s.bind_to_tree(tree_in_doc); }
conditional_block
htmltitleelement.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/. */ use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding; use crate::dom::bindings::codegen::Bindings:...
(&self, mutation: &ChildrenMutation) { if let Some(ref s) = self.super_type() { s.children_changed(mutation); } let node = self.upcast::<Node>(); if node.is_in_doc() { node.owner_doc().title_changed(); } } fn bind_to_tree(&self, tree_in_doc: bool)...
children_changed
identifier_name
htmltitleelement.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/. */ use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding; use crate::dom::bindings::codegen::Bindings:...
use crate::dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTitleElement { htmlelement: HTMLElement, } impl HTMLTitleElement { fn new_inherited( local_name: LocalName, prefix: Option<Prefix>, document: &Do...
use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::{ChildrenMutation, Node};
random_line_split
htmltitleelement.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/. */ use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding; use crate::dom::bindings::codegen::Bindings:...
} impl HTMLTitleElementMethods for HTMLTitleElement { // https://html.spec.whatwg.org/multipage/#dom-title-text fn Text(&self) -> DOMString { self.upcast::<Node>().child_text_content() } // https://html.spec.whatwg.org/multipage/#dom-title-text fn SetText(&self, value: DOMString) { ...
{ Node::reflect_node( Box::new(HTMLTitleElement::new_inherited( local_name, prefix, document, )), document, HTMLTitleElementBinding::Wrap, ) }
identifier_body
vec.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let a = [1, 2, 3]; let b = &[4, 5, 6]; let c = @[7, 8, 9]; let d = ~[10, 11, 12]; let _z = 0; }
main
identifier_name
vec.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let a = [1, 2, 3]; let b = &[4, 5, 6]; let c = @[7, 8, 9]; let d = ~[10, 11, 12]; let _z = 0; }
identifier_body
vec.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
random_line_split
main.rs
use itertools::Itertools; use std::fs; use std::io::{Read, Write}; use std::str; const PHF_SRC: &str = "\ // A stripped down `phf` crate fork. // // https://github.com/sfackler/rust-phf struct Map<V:'static> { pub key: u64, pub disps: &'static [(u32, u32)], pub entries: &'static[(&'static str, V)], } im...
(name: &str) -> String { let mut change_case = false; let mut s = String::with_capacity(name.len()); for (idx, c) in name.chars().enumerate() { if idx == 0 { if c.is_digit(10) { s.push('N'); s.push(c); } else { s.push(c.to_upper...
to_enum_name
identifier_name
main.rs
use itertools::Itertools; use std::fs; use std::io::{Read, Write}; use std::str; const PHF_SRC: &str = "\ // A stripped down `phf` crate fork. // // https://github.com/sfackler/rust-phf struct Map<V:'static> { pub key: u64, pub disps: &'static [(u32, u32)], pub entries: &'static[(&'static str, V)], } im...
} s }
{ s.push(c); }
conditional_block
main.rs
use itertools::Itertools; use std::fs; use std::io::{Read, Write}; use std::str; const PHF_SRC: &str = "\ // A stripped down `phf` crate fork. // // https://github.com/sfackler/rust-phf struct Map<V:'static> { pub key: u64, pub disps: &'static [(u32, u32)], pub entries: &'static[(&'static str, V)], } im...
#[inline] fn hash(x: &str, key: u64) -> u64 { use std::hash::Hasher; let mut hasher = siphasher::sip::SipHasher13::new_with_keys(0, key); hasher.write(x.as_bytes()); hasher.finish() } #[inline] fn get_index(hash: u64, disps: &[(u32, u32)], len: usize) -> u32 { let (g, f1, f2) = split(hash); le...
random_line_split
main.rs
use itertools::Itertools; use std::fs; use std::io::{Read, Write}; use std::str; const PHF_SRC: &str = "\ // A stripped down `phf` crate fork. // // https://github.com/sfackler/rust-phf struct Map<V:'static> { pub key: u64, pub disps: &'static [(u32, u32)], pub entries: &'static[(&'static str, V)], } im...
"List of all SVG attributes.", f, )?; writeln!(f, "{}", PHF_SRC)?; Ok(()) } fn gen_map( spec_path: &str, enum_name: &str, map_name: &str, doc: &str, f: &mut fs::File, ) -> Result<(), Box<dyn std::error::Error>> { let mut spec = String::new(); fs::File::open(sp...
{ let f = &mut fs::File::create("../src/names.rs")?; writeln!(f, "// This file is autogenerated. Do not edit it!")?; writeln!(f, "// See ./codegen for details.\n")?; writeln!(f, "use std::fmt;\n")?; gen_map( "elements.txt", "ElementId", "ELEMENTS", "List of all SVG...
identifier_body
marisa-build.rs
// Copyright (c) 2010-2013, Susumu Yata // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // - Redistributions of source code must retain the above copyright notice, this // list of conditi...
read_keys(input_file, &keyset); } catch (const marisa::Exception &ex) { std::cerr << ex.what() << ": failed to read keys" << std::endl; return 12; } marisa::Trie trie; try { trie.build(keyset, param_num_tries | param_tail_mode | param_node_order | param_cache_level); } catch (const m...
{ std::cerr << "error: failed to open: " << args[i] << std::endl; return 11; }
conditional_block
marisa-build.rs
// Copyright (c) 2010-2013, Susumu Yata // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // - Redistributions of source code must retain the above copyright notice, this // list of conditi...
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL ...
random_line_split
trait-inheritance-overloading-simple.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, other: &MyInt) -> bool {!self.eq(other) } } impl MyNum for MyInt {} fn f<T:MyNum>(x: T, y: T) -> bool { return x == y; } fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); assert!(x!= y); assert_eq!(x, z); }
ne
identifier_name
trait-inheritance-overloading-simple.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 mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); assert!(x!= y); assert_eq!(x, z); }
{ return x == y; }
identifier_body
trait-inheritance-overloading-simple.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.
// except according to those terms. use std::cmp::Eq; trait MyNum : Eq { } #[deriving(Show)] struct MyInt { val: int } impl Eq for MyInt { fn eq(&self, other: &MyInt) -> bool { self.val == other.val } fn ne(&self, other: &MyInt) -> bool {!self.eq(other) } } impl MyNum for MyInt {} fn f<T:MyNum>(x: T, y: T...
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed
random_line_split
exponent.rs
use crate::digit_table::*; use core::ptr; #[cfg_attr(feature = "no-panic", inline)] pub unsafe fn write_exponent3(mut k: isize, mut result: *mut u8) -> usize { let sign = k < 0; if sign { *result = b'-'; result = result.offset(1); k = -k; } debug_assert!(k < 1000); if k >= ...
{ let sign = k < 0; if sign { *result = b'-'; result = result.offset(1); k = -k; } debug_assert!(k < 100); if k >= 10 { let d = DIGIT_TABLE.get_unchecked(k as usize * 2); ptr::copy_nonoverlapping(d, result, 2); sign as usize + 2 } else { *...
identifier_body
exponent.rs
use crate::digit_table::*; use core::ptr; #[cfg_attr(feature = "no-panic", inline)] pub unsafe fn write_exponent3(mut k: isize, mut result: *mut u8) -> usize { let sign = k < 0; if sign { *result = b'-'; result = result.offset(1); k = -k; } debug_assert!(k < 1000); if k >= ...
else { *result = b'0' + k as u8; sign as usize + 1 } }
{ let d = DIGIT_TABLE.get_unchecked(k as usize * 2); ptr::copy_nonoverlapping(d, result, 2); sign as usize + 2 }
conditional_block
exponent.rs
use crate::digit_table::*; use core::ptr; #[cfg_attr(feature = "no-panic", inline)] pub unsafe fn write_exponent3(mut k: isize, mut result: *mut u8) -> usize { let sign = k < 0; if sign { *result = b'-'; result = result.offset(1); k = -k; } debug_assert!(k < 1000); if k >= ...
} else { *result = b'0' + k as u8; sign as usize + 1 } }
let d = DIGIT_TABLE.get_unchecked(k as usize * 2); ptr::copy_nonoverlapping(d, result, 2); sign as usize + 2
random_line_split
exponent.rs
use crate::digit_table::*; use core::ptr; #[cfg_attr(feature = "no-panic", inline)] pub unsafe fn write_exponent3(mut k: isize, mut result: *mut u8) -> usize { let sign = k < 0; if sign { *result = b'-'; result = result.offset(1); k = -k; } debug_assert!(k < 1000); if k >= ...
(mut k: isize, mut result: *mut u8) -> usize { let sign = k < 0; if sign { *result = b'-'; result = result.offset(1); k = -k; } debug_assert!(k < 100); if k >= 10 { let d = DIGIT_TABLE.get_unchecked(k as usize * 2); ptr::copy_nonoverlapping(d, result, 2); ...
write_exponent2
identifier_name
ai.rs
// See LICENSE file for copyright and license details. use common::types::{Size2, ZInt, PlayerId, MapPos}; use game_state::{GameState}; use map::{distance}; use pathfinder::{MapPath, Pathfinder}; use dir::{Dir}; use unit::{Unit}; use db::{Db}; use core::{CoreEvent, Command, MoveMode, los}; pub struct Ai { id: Pla...
} } } // vim: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab:
random_line_split
ai.rs
// See LICENSE file for copyright and license details. use common::types::{Size2, ZInt, PlayerId, MapPos}; use game_state::{GameState}; use map::{distance}; use pathfinder::{MapPath, Pathfinder}; use dir::{Dir}; use unit::{Unit}; use db::{Db}; use core::{CoreEvent, Command, MoveMode, los}; pub struct Ai { id: Pla...
} } best_pos } fn truncate_path(&self, path: MapPath, move_points: ZInt) -> MapPath { if path.total_cost().n <= move_points { return path; } let len = path.nodes().len(); for i in 1.. len { let cost = &path.nodes()[i].cost; ...
{ best_cost = Some(cost); best_pos = Some(destination.clone()); }
conditional_block
ai.rs
// See LICENSE file for copyright and license details. use common::types::{Size2, ZInt, PlayerId, MapPos}; use game_state::{GameState}; use map::{distance}; use pathfinder::{MapPath, Pathfinder}; use dir::{Dir}; use unit::{Unit}; use db::{Db}; use core::{CoreEvent, Command, MoveMode, los}; pub struct
{ id: PlayerId, state: GameState, pathfinder: Pathfinder, } impl Ai { pub fn new(id: &PlayerId, map_size: &Size2) -> Ai { Ai { id: id.clone(), state: GameState::new(map_size, id), pathfinder: Pathfinder::new(map_size), } } pub fn apply_event...
Ai
identifier_name
ai.rs
// See LICENSE file for copyright and license details. use common::types::{Size2, ZInt, PlayerId, MapPos}; use game_state::{GameState}; use map::{distance}; use pathfinder::{MapPath, Pathfinder}; use dir::{Dir}; use unit::{Unit}; use db::{Db}; use core::{CoreEvent, Command, MoveMode, los}; pub struct Ai { id: Pla...
} // vim: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab:
{ if let Some(cmd) = self.try_get_move_command(db) { cmd } else if let Some(cmd) = self.try_get_attack_command(db) { cmd } else { Command::EndTurn } }
identifier_body
main.rs
mod tokenizer; mod executor; use tokenizer::*; use executor::{execute, Numeric}; use std::collections::HashMap; use std::io::prelude::*; use std::io; fn main() { // contain all program variables let mut variables: HashMap<String, executor::Numeric> = HashMap::new(); // string to execute let mut buffer ...
// split string to tokens let data = tokenizer::tokenize(buffer.trim()); // execute operation (check by exit flag) if execute(&mut variables, &data) { break; } // clean string buffer.clear(); } }
.expect( "[error] Can't read line from stdin!" ); // ignore null strings if buffer.trim().len() == 0 { continue; }
random_line_split
main.rs
mod tokenizer; mod executor; use tokenizer::*; use executor::{execute, Numeric}; use std::collections::HashMap; use std::io::prelude::*; use std::io; fn
() { // contain all program variables let mut variables: HashMap<String, executor::Numeric> = HashMap::new(); // string to execute let mut buffer = String::new(); loop { print!(">> "); io::stdout().flush() .ok() .expect( "[error] Can't flush to stdout!" ); ...
main
identifier_name
main.rs
mod tokenizer; mod executor; use tokenizer::*; use executor::{execute, Numeric}; use std::collections::HashMap; use std::io::prelude::*; use std::io; fn main()
if execute(&mut variables, &data) { break; } // clean string buffer.clear(); } }
{ // contain all program variables let mut variables: HashMap<String, executor::Numeric> = HashMap::new(); // string to execute let mut buffer = String::new(); loop { print!(">> "); io::stdout().flush() .ok() .expect( "[error] Can't flush to stdout!" ); ...
identifier_body