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
regions-out-of-scope-slice.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...
// compile-flags: -Z parse-only fn foo(cond: bool) { // Here we will infer a type that uses the // region of the if stmt then block, but in the scope: let mut x; if cond { x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` } } fn main() {}
// option. This file may not be copied, modified, or distributed // except according to those terms. // blk region isn't supported in the front-end
random_line_split
regions-out-of-scope-slice.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 main() {}
{ x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` }
conditional_block
regions-out-of-scope-slice.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...
(cond: bool) { // Here we will infer a type that uses the // region of the if stmt then block, but in the scope: let mut x; if cond { x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` } } fn main() {}
foo
identifier_name
regions-out-of-scope-slice.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 main() {}
{ // Here we will infer a type that uses the // region of the if stmt then block, but in the scope: let mut x; if cond { x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` } }
identifier_body
averages_mean_angle.rs
// Implements http://rosettacode.org/wiki/Averages/Mean_angle use std::f64::consts::PI; fn mean_angle(angles: &[f64]) -> f64 { let (sum_cos, sum_sin) = angles.iter() .map(|&x| x * PI / 180.) // We map into a tuple of sin and cos so we ...
#[test] fn basic_tests() { let set1 = [350., 10.]; let set2 = [90., 180., 270., 360.]; let set3 = [10., 20., 30.]; // We need to round the numbers assert_eq!(mean_angle(&set1).round(), 0.); assert_eq!(mean_angle(&set2).round(), -90.); assert_eq!(mean_angle(&set3).round(), 20.); }
{ let set1 = &[350., 10.]; let set2 = &[90., 180., 270., 360.]; let set3 = &[10., 20., 30.]; println!("Mean angle of first set is {} degrees", mean_angle(set1)); println!("Mean angle of second set is {} degrees", mean_angle(set2)); println!("Mean angle of third set is {} degrees", mean_angle(se...
identifier_body
averages_mean_angle.rs
// Implements http://rosettacode.org/wiki/Averages/Mean_angle use std::f64::consts::PI; fn mean_angle(angles: &[f64]) -> f64 { let (sum_cos, sum_sin) = angles.iter() .map(|&x| x * PI / 180.) // We map into a tuple of sin and cos so we ...
} #[test] fn basic_tests() { let set1 = [350., 10.]; let set2 = [90., 180., 270., 360.]; let set3 = [10., 20., 30.]; // We need to round the numbers assert_eq!(mean_angle(&set1).round(), 0.); assert_eq!(mean_angle(&set2).round(), -90.); assert_eq!(mean_angle(&set3).round(), 20.); }
let set3 = &[10., 20., 30.]; println!("Mean angle of first set is {} degrees", mean_angle(set1)); println!("Mean angle of second set is {} degrees", mean_angle(set2)); println!("Mean angle of third set is {} degrees", mean_angle(set3));
random_line_split
averages_mean_angle.rs
// Implements http://rosettacode.org/wiki/Averages/Mean_angle use std::f64::consts::PI; fn
(angles: &[f64]) -> f64 { let (sum_cos, sum_sin) = angles.iter() .map(|&x| x * PI / 180.) // We map into a tuple of sin and cos so we // only need to iterate the slice once. .map...
mean_angle
identifier_name
result.rs
fn main() { let a = String::from("hello"); run1(&a).unwrap(); run2(&a).unwrap(); } fn run1(a: &String) -> Result<(), String> { let b = match foo(a) { Ok(x) => x, Err(x) => return Err(x), }; let c = match bar(a) { Ok(x) => x, Err(x) => return Err(x), }; le...
(s: &String) -> Result<i32, String> { if s.is_empty() { Err(String::from("bar")) } else { Ok(s.len() as i32) } } fn baz(s: &String, i: i32) -> Result<(&String, i32), String> { if s.is_empty() || i == 0 { Err(String::from("baz")) } else { Ok((s, i)) } }
bar
identifier_name
result.rs
fn main() { let a = String::from("hello"); run1(&a).unwrap(); run2(&a).unwrap(); } fn run1(a: &String) -> Result<(), String> { let b = match foo(a) { Ok(x) => x, Err(x) => return Err(x), }; let c = match bar(a) { Ok(x) => x, Err(x) => return Err(x), }; le...
} } fn bar(s: &String) -> Result<i32, String> { if s.is_empty() { Err(String::from("bar")) } else { Ok(s.len() as i32) } } fn baz(s: &String, i: i32) -> Result<(&String, i32), String> { if s.is_empty() || i == 0 { Err(String::from("baz")) } else { Ok((s, i)) ...
fn foo(s: &String) -> Result<&String, String> { if s.is_empty() { Err(String::from("foo")) } else { Ok(s)
random_line_split
result.rs
fn main() { let a = String::from("hello"); run1(&a).unwrap(); run2(&a).unwrap(); } fn run1(a: &String) -> Result<(), String> { let b = match foo(a) { Ok(x) => x, Err(x) => return Err(x), }; let c = match bar(a) { Ok(x) => x, Err(x) => return Err(x), }; le...
fn baz(s: &String, i: i32) -> Result<(&String, i32), String> { if s.is_empty() || i == 0 { Err(String::from("baz")) } else { Ok((s, i)) } }
{ if s.is_empty() { Err(String::from("bar")) } else { Ok(s.len() as i32) } }
identifier_body
array.rs
extern crate rand; use std::usize::MAX; pub trait ArrayUtils<T> { fn swaping(&mut self, a: usize, b: usize) -> bool; fn index_of(&self, search: &T) -> usize; fn chunk(&self, size: usize) -> Vec<Vec<T>>; fn fill_mut(&mut self, value: &T); fn unique(&self) -> Vec...
<T: Copy>(ary: &mut [T], value: &T) { for i in 0..ary.len() { ary[i] = *value; } } pub fn unique<T: Copy + PartialEq>(ary: &[T]) -> Vec<T> { unique_adv(&ary).0 } pub fn unique_adv<T: Copy + PartialEq>(ary: &[T]) -> (Vec<T>, Vec<T>) { let mut res = Vec::<T>::new(); let mut removed...
fill_mut
identifier_name
array.rs
extern crate rand; use std::usize::MAX; pub trait ArrayUtils<T> { fn swaping(&mut self, a: usize, b: usize) -> bool; fn index_of(&self, search: &T) -> usize; fn chunk(&self, size: usize) -> Vec<Vec<T>>; fn fill_mut(&mut self, value: &T); fn unique(&self) -> Vec...
} pub fn index_of<T: Ord + Copy>(ary: &[T], search: &T) -> usize { for i in 0..ary.len() { if &ary[i] == search { return i; } } MAX } pub fn chunk<T: Clone>(ary: &[T], size: usize) -> Vec<Vec<T>> { let mut iter = ary.chunks(size); let mut next = iter.next();...
{ if a > ary.len()-1 || b > ary.len()-1 { return false } else{ let temp = ary[a]; ary[a] = ary[b]; ary[b] = temp; true } }
conditional_block
array.rs
extern crate rand; use std::usize::MAX; pub trait ArrayUtils<T> { fn swaping(&mut self, a: usize, b: usize) -> bool; fn index_of(&self, search: &T) -> usize; fn chunk(&self, size: usize) -> Vec<Vec<T>>; fn fill_mut(&mut self, value: &T);
fn unique_adv(&self) -> (Vec<T>, Vec<T>); } pub fn swaping<T: Ord + Copy>(ary: &mut [T], a: usize, b: usize) -> bool { if a == b { return true } else{ if a > ary.len()-1 || b > ary.len()-1 { return false } else{ let temp = ary[a]; ary[a] = ary[b]; ...
fn unique(&self) -> Vec<T>;
random_line_split
array.rs
extern crate rand; use std::usize::MAX; pub trait ArrayUtils<T> { fn swaping(&mut self, a: usize, b: usize) -> bool; fn index_of(&self, search: &T) -> usize; fn chunk(&self, size: usize) -> Vec<Vec<T>>; fn fill_mut(&mut self, value: &T); fn unique(&self) -> Vec...
pub fn unique<T: Copy + PartialEq>(ary: &[T]) -> Vec<T> { unique_adv(&ary).0 } pub fn unique_adv<T: Copy + PartialEq>(ary: &[T]) -> (Vec<T>, Vec<T>) { let mut res = Vec::<T>::new(); let mut removed = Vec::<T>::new(); 'outer: for i in 0..ary.len() { for j in 0..res.len() { ...
{ for i in 0..ary.len() { ary[i] = *value; } }
identifier_body
basic-example.rs
extern crate compiler; use compiler::{ir,pass}; fn main() { let mut module = self::create_module(); let mut pm = self::create_ir_pass_manager(); println!("Previously:\n\n{}", ir::printable(&module)); module = pm.run(module); module = module.flatten(); println!("\n\nAfterwards:\n\n{}", ir::...
() -> ir::Module { let lhs = ir::Value::new(ir::Expression::i32(23)); let rhs = ir::Value::new(ir::Expression::i32(2)); let global = ir::Global::new("MyGlobal".into(), lhs.clone()); let func2 = { let bb2 = { let inst_add1 = ir::Value::new(ir::Expression::add(lhs.clone(), rhs.clon...
create_module
identifier_name
basic-example.rs
extern crate compiler; use compiler::{ir,pass}; fn main() { let mut module = self::create_module(); let mut pm = self::create_ir_pass_manager(); println!("Previously:\n\n{}", ir::printable(&module)); module = pm.run(module); module = module.flatten(); println!("\n\nAfterwards:\n\n{}", ir::p...
} fn create_module() -> ir::Module { let lhs = ir::Value::new(ir::Expression::i32(23)); let rhs = ir::Value::new(ir::Expression::i32(2)); let global = ir::Global::new("MyGlobal".into(), lhs.clone()); let func2 = { let bb2 = { let inst_add1 = ir::Value::new(ir::Expression::add(lh...
Ok(..) => println!("passed!"), Err(ref msg) => println!("failed: {}", msg), }
random_line_split
basic-example.rs
extern crate compiler; use compiler::{ir,pass}; fn main() { let mut module = self::create_module(); let mut pm = self::create_ir_pass_manager(); println!("Previously:\n\n{}", ir::printable(&module)); module = pm.run(module); module = module.flatten(); println!("\n\nAfterwards:\n\n{}", ir::...
let inst_br = ir::Value::new( ir::Expression::br(ir::Condition::True, ir::Value::new(ir::Expression::block_ref(&bb2))), ); let mut block = ir::Block::empty("entry"); block.append_value(inst_br); block ...
{ let lhs = ir::Value::new(ir::Expression::i32(23)); let rhs = ir::Value::new(ir::Expression::i32(2)); let global = ir::Global::new("MyGlobal".into(), lhs.clone()); let func2 = { let bb2 = { let inst_add1 = ir::Value::new(ir::Expression::add(lhs.clone(), rhs.clone())); ...
identifier_body
header.rs
use packet_type::PacketType; use std::io; use super::qos::QoS; #[derive(Debug, Clone, PartialEq)] pub struct Header { hd: u8, pub typ: PacketType, pub len: usize } impl Header { pub fn
(hd: u8, len: usize) -> io::Result<Header> { Ok(Header { hd: hd, typ: try!(PacketType::from_hd(hd)), len: len }) } #[inline] pub fn dup(&self) -> bool { (self.hd & 0b1000)!= 0 } #[inline] pub fn qos(&self) -> io::Result<QoS> { ...
new
identifier_name
header.rs
use packet_type::PacketType; use std::io; use super::qos::QoS; #[derive(Debug, Clone, PartialEq)] pub struct Header { hd: u8, pub typ: PacketType, pub len: usize } impl Header { pub fn new(hd: u8, len: usize) -> io::Result<Header> { Ok(Header { hd: hd, typ: try!(PacketT...
}
{ (self.hd & 1) != 0 }
identifier_body
header.rs
use packet_type::PacketType; use std::io; use super::qos::QoS; #[derive(Debug, Clone, PartialEq)] pub struct Header { hd: u8, pub typ: PacketType, pub len: usize } impl Header { pub fn new(hd: u8, len: usize) -> io::Result<Header> { Ok(Header {
#[inline] pub fn dup(&self) -> bool { (self.hd & 0b1000)!= 0 } #[inline] pub fn qos(&self) -> io::Result<QoS> { QoS::from_hd(self.hd) } #[inline] pub fn retain(&self) -> bool { (self.hd & 1)!= 0 } }
hd: hd, typ: try!(PacketType::from_hd(hd)), len: len }) }
random_line_split
tcpclient.rs
use std::string::String; use std::vec::Vec; use std::io::TcpStream; pub struct Clients { destinations: Vec<String>, } pub trait ClientFunction { fn new() -> Self; fn add_client(&mut self, ip: String, port: String); fn remove_client(&mut self, index: usize); fn send_message(&mut self, message: Stri...
fn add_client(&mut self, ip: String, port: String) { let mut port_ip = String::new(); port_ip.push_str(ip.as_slice()); port_ip.push_str(":"); port_ip.push_str(port.as_slice()); self.destinations.push(port_ip); } fn remove_client(&mut self, index: usize) { ...
{ return Clients{destinations: Vec::new()}; }
random_line_split
tcpclient.rs
use std::string::String; use std::vec::Vec; use std::io::TcpStream; pub struct Clients { destinations: Vec<String>, } pub trait ClientFunction { fn new() -> Self; fn add_client(&mut self, ip: String, port: String); fn remove_client(&mut self, index: usize); fn send_message(&mut self, message: Stri...
fn remove_client(&mut self, index: usize) { self.destinations.remove(index); } fn send_message(&mut self, message: String) { for dest in self.destinations.iter() { let mut tcp_stream = TcpStream::connect(dest.as_slice()).unwrap(); let _ = tcp_stream...
{ let mut port_ip = String::new(); port_ip.push_str(ip.as_slice()); port_ip.push_str(":"); port_ip.push_str(port.as_slice()); self.destinations.push(port_ip); }
identifier_body
tcpclient.rs
use std::string::String; use std::vec::Vec; use std::io::TcpStream; pub struct Clients { destinations: Vec<String>, } pub trait ClientFunction { fn new() -> Self; fn add_client(&mut self, ip: String, port: String); fn remove_client(&mut self, index: usize); fn send_message(&mut self, message: Stri...
(&mut self, ip: String, port: String) { let mut port_ip = String::new(); port_ip.push_str(ip.as_slice()); port_ip.push_str(":"); port_ip.push_str(port.as_slice()); self.destinations.push(port_ip); } fn remove_client(&mut self, index: usize) { self.destina...
add_client
identifier_name
scrabble-score.rs
extern crate scrabble_score; use scrabble_score::*; #[test] fn a_is_worth_one_point() { assert_eq!(score("a"), 1); } #[test] #[ignore] fn scoring_is_case_insensitive() { assert_eq!(score("A"), 1); } #[test] #[ignore] fn f_is_worth_four()
#[test] #[ignore] fn two_one_point_letters_make_a_two_point_word() { assert_eq!(score("at"), 2); } #[test] #[ignore] fn three_letter_word() { assert_eq!(score("zoo"), 12); } #[test] #[ignore] fn medium_word() { assert_eq!(score("street"), 6); } #[test] #[ignore] fn longer_words_with_valuable_letters() ...
{ assert_eq!(score("f"), 4); }
identifier_body
scrabble-score.rs
extern crate scrabble_score; use scrabble_score::*; #[test] fn a_is_worth_one_point() { assert_eq!(score("a"), 1); } #[test] #[ignore] fn scoring_is_case_insensitive() { assert_eq!(score("A"), 1); } #[test] #[ignore] fn f_is_worth_four() { assert_eq!(score("f"), 4); } #[test] #[ignore] fn two_one_point...
) { assert_eq!(score(""), 0); } #[test] #[ignore] fn all_letters_work() { assert_eq!(score("abcdefghijklmnopqrstuvwxyz"), 87); }
mpty_words_are_worth_zero(
identifier_name
scrabble-score.rs
extern crate scrabble_score; use scrabble_score::*; #[test] fn a_is_worth_one_point() { assert_eq!(score("a"), 1); } #[test]
} #[test] #[ignore] fn f_is_worth_four() { assert_eq!(score("f"), 4); } #[test] #[ignore] fn two_one_point_letters_make_a_two_point_word() { assert_eq!(score("at"), 2); } #[test] #[ignore] fn three_letter_word() { assert_eq!(score("zoo"), 12); } #[test] #[ignore] fn medium_word() { assert_eq!(score(...
#[ignore] fn scoring_is_case_insensitive() { assert_eq!(score("A"), 1);
random_line_split
thread.rs
use alloc::boxed::Box; use core::mem; use system::syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, sys_waitpid, CLONE_VM, CLONE_FS, CLONE_FILES, TimeSpec}; use time::Duration; /// An owned permission to join on a thread (block on its termination). /// /// A `JoinHandle` *detaches* the child th...
<T> { pid: usize, result_ptr: *mut Option<T>, } impl<T> JoinHandle<T> { /// Waits for the associated thread to finish. pub fn join(self) -> Option<T> where T: ::core::fmt::Debug { let mut status = 0; match sys_waitpid(self.pid, &mut status, 0) { Ok(_) => unsafe { *Box::from_...
JoinHandle
identifier_name
thread.rs
use alloc::boxed::Box; use core::mem; use system::syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, sys_waitpid, CLONE_VM, CLONE_FS, CLONE_FILES, TimeSpec}; use time::Duration; /// An owned permission to join on a thread (block on its termination). /// /// A `JoinHandle` *detaches* the child th...
pub fn spawn<F, T>(f: F) -> JoinHandle<T> where F: FnOnce() -> T, F: Send +'static, T: Send +'static { let result_ptr: *mut Option<T> = Box::into_raw(box None); //This must only be used by the child let boxed_f = Box::new(f); match unsafe { sys_clone(CLONE_VM | CLONE_FS | CLONE_...
// TODO: Catch panic
random_line_split
thread.rs
use alloc::boxed::Box; use core::mem; use system::syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, sys_waitpid, CLONE_VM, CLONE_FS, CLONE_FILES, TimeSpec}; use time::Duration; /// An owned permission to join on a thread (block on its termination). /// /// A `JoinHandle` *detaches* the child th...
} } pub fn yield_now() { let _ = sys_yield(); }
{ let result_ptr: *mut Option<T> = Box::into_raw(box None); //This must only be used by the child let boxed_f = Box::new(f); match unsafe { sys_clone(CLONE_VM | CLONE_FS | CLONE_FILES).unwrap() } { 0 => { unsafe { *result_ptr = Some(boxed_f()) }; loop { l...
identifier_body
mod.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
}; if!(is_builtin_trait(tname) || cx.ecfg.enable_custom_derive()) { feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic, "custom_derive", titem.span, ...
{ cx.span_err(titem.span, "malformed `derive` entry"); continue; }
conditional_block
mod.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
"Debug" => show::expand_deriving_show, "Default" => default::expand_deriving_default, "FromPrimitive" => primitive::expand_deriving_from_primitive, "Send" => bounds::expand_deriving_unsafe_bound, "Sync" => bounds::expand_deriving_unsafe_bound, "Copy" => bounds::expand_deriving_copy, // d...
"Rand" => rand::expand_deriving_rand,
random_line_split
mod.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
if!(is_builtin_trait(tname) || cx.ecfg.enable_custom_derive()) { feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic, "custom_derive", titem.span, ...
{ item.map(|mut item| { if mitem.value_str().is_some() { cx.span_err(mitem.span, "unexpected value in `derive`"); } let traits = mitem.meta_item_list().unwrap_or(&[]); if traits.is_empty() { cx.span_warn(mitem.span, "empty trait list in `derive`"); } ...
identifier_body
mod.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(cx: &mut ExtCtxt, span: Span, _: &MetaItem, _: &Item, _: &mut FnMut(P<Item>)) { cx.span_err(span, "`deriving` has been renamed to `derive`"); } fn expand_derive(cx: &mut ExtCtxt, ...
expand_deprecated_deriving
identifier_name
task-comm-3.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...
(ch: &Sender<isize>, message: isize, count: isize) { println!("Starting test00_start"); let mut i: isize = 0; while i < count { println!("Sending Message"); ch.send(message + 0).unwrap(); i = i + 1; } println!("Ending test00_start"); } fn test00() { let number_of_tasks: ...
test00_start
identifier_name
task-comm-3.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...
// ignore-emscripten no threads support use std::thread; use std::sync::mpsc::{channel, Sender}; pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); } fn test00_start(ch: &Sender<isize>, message: isize, count: isize) { println!("Starting test00_start"); let mut i: isize = 0; while i < coun...
#![allow(unused_must_use)]
random_line_split
task-comm-3.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 test00_start(ch: &Sender<isize>, message: isize, count: isize) { println!("Starting test00_start"); let mut i: isize = 0; while i < count { println!("Sending Message"); ch.send(message + 0).unwrap(); i = i + 1; } println!("Ending test00_start"); } fn test00() { let ...
{ println!("===== WITHOUT THREADS ====="); test00(); }
identifier_body
xdg.rs
//! XDG Output advertising capabilities //! //! This protocol is meant for describing outputs in a way //! which is more in line with the concept of an output on desktop oriented systems. use std::{ ops::Deref as _, sync::{Arc, Mutex}, }; use slog::{o, trace}; use wayland_protocols::unstable::xdg_output::v1::...
// No need for wl_output.done() here, it will be called by caller (super::Output::change_current_state) } } } /// Initialize a xdg output manager global. pub fn init_xdg_output_manager<L>(display: &mut Display, logger: L) -> Global<ZxdgOutputManagerV1> where L: Into<Option<::slog::Logger>...
{ instance.done(); }
conditional_block
xdg.rs
//! XDG Output advertising capabilities //! //! This protocol is meant for describing outputs in a way //! which is more in line with the concept of an output on desktop oriented systems. use std::{ ops::Deref as _, sync::{Arc, Mutex}, }; use slog::{o, trace}; use wayland_protocols::unstable::xdg_output::v1::...
// xdg_output.done() is deprecated since version 3 if instance.as_ref().version() < 3 { instance.done(); } // No need for wl_output.done() here, it will be called by caller (super::Output::change_current_state) } } } /// Initialize a xdg out...
instance.logical_position(output.logical_position.x, output.logical_position.y); }
random_line_split
xdg.rs
//! XDG Output advertising capabilities //! //! This protocol is meant for describing outputs in a way //! which is more in line with the concept of an output on desktop oriented systems. use std::{ ops::Deref as _, sync::{Arc, Mutex}, }; use slog::{o, trace}; use wayland_protocols::unstable::xdg_output::v1::...
<L>(display: &mut Display, logger: L) -> Global<ZxdgOutputManagerV1> where L: Into<Option<::slog::Logger>>, { let log = crate::slog_or_fallback(logger).new(o!("smithay_module" => "xdg_output_handler")); display.create_global( 3, Filter::new(move |(manager, _version): (Main<ZxdgOutputManager...
init_xdg_output_manager
identifier_name
io.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...
(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> { // compute offset as signed and clamp to prevent overflow let pos = match seek { io::SeekSet => 0, io::SeekEnd => end, io::SeekCur => cur, } as i64; if offset + pos < 0 { Err(IoError { ki...
combine
identifier_name
io.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...
else { // Make sure the internal buffer is as least as big as where we // currently are let difference = self.pos as i64 - self.buf.len() as i64; if difference > 0 { self.buf.grow(difference as uint, 0); } // Figure out what bytes...
{ self.buf.push_all(buf) }
conditional_block
io.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...
io::SeekEnd => end, io::SeekCur => cur, } as i64; if offset + pos < 0 { Err(IoError { kind: io::InvalidInput, desc: "invalid seek to a negative offset", detail: None }) } else { Ok((offset + pos) as u64) } } /// Writes to an o...
fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> { // compute offset as signed and clamp to prevent overflow let pos = match seek { io::SeekSet => 0,
random_line_split
io.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...
#[bench] fn bench_seekable_mem_writer_100_0100(b: &mut Bencher) { do_bench_seekable_mem_writer(b, 100, 100) } #[bench] fn bench_seekable_mem_writer_100_1000(b: &mut Bencher) { do_bench_seekable_mem_writer(b, 100, 1000) } }
{ do_bench_seekable_mem_writer(b, 100, 10) }
identifier_body
manifest.rs
use std::collections::BTreeMap; use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; use std::process::Command; use chrono::{Datelike, Local}; use chrono::naive::date::NaiveDate; use serde_json; use slug; use toml::{Parser, Value}; use bench::Benchmark; #[derive(Debug, Serialize, Deserialize)] pub...
(manifest_path: &Path) -> Result<BTreeMap<String, Value>, String> { let mut file = try!(File::open(manifest_path).map_err(|e| e.to_string())); let mut toml_string = String::new(); try!(file.read_to_string(&mut toml_string) .map(|_| ()) .map_err(|e| e.to_string()))...
parse_manifest
identifier_name
manifest.rs
use std::collections::BTreeMap; use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; use std::process::Command; use chrono::{Datelike, Local}; use chrono::naive::date::NaiveDate; use serde_json; use slug; use toml::{Parser, Value}; use bench::Benchmark; #[derive(Debug, Serialize, Deserialize)] pub...
.ok_or("Manifest missing meta header.".to_string()) .map(|v| v.as_table())) .ok_or("Meta header missing from manifest.")); let start_date = match meta.get("start").map(|v| v.as_str()) { Some(Some(date_str...
{ let parsed = try!(Self::parse_manifest(Path::new(path))); let mut benchmarks = Vec::new(); if let Some(benches) = parsed.get("benches") { if let Some(benches) = benches.as_table() { for (name, value) in benches.into_iter() { benchmarks.push(tr...
identifier_body
manifest.rs
use std::collections::BTreeMap; use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; use std::process::Command; use chrono::{Datelike, Local}; use chrono::naive::date::NaiveDate; use serde_json; use slug; use toml::{Parser, Value}; use bench::Benchmark; #[derive(Debug, Serialize, Deserialize)] pub...
} dates } fn parse_date(date_str: &str) -> Result<NaiveDate, String> { let mut tokens = date_str.split('-'); let year = try!(try!(tokens.next() .ok_or("Incorrectly formatted start date string!".to_string())) .parse::<i...
let mut current_date = start; while current_date <= end { dates.push(current_date); current_date = current_date.succ();
random_line_split
namednodemap.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::attr::Attr; use dom::bindings::codegen::Bindings::NamedNodeMapBinding; use dom::bindings::codegen::Bindin...
{ reflector_: Reflector, owner: JS<Element>, } impl NamedNodeMap { fn new_inherited(elem: JSRef<Element>) -> NamedNodeMap { NamedNodeMap { reflector_: Reflector::new(), owner: JS::from_rooted(elem), } } pub fn new(window: JSRef<Window>, elem: JSRef<Element>...
NamedNodeMap
identifier_name
namednodemap.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::attr::Attr; use dom::bindings::codegen::Bindings::NamedNodeMapBinding; use dom::bindings::codegen::Bindin...
} impl<'a> NamedNodeMapMethods for JSRef<'a, NamedNodeMap> { fn Length(self) -> u32 { self.owner.root().r().attrs().len() as u32 } fn Item(self, index: u32) -> Option<Temporary<Attr>> { self.owner.root().r().attrs().as_slice().get(index as uint).map(|x| Temporary::new(x.clone())) } ...
{ reflect_dom_object(box NamedNodeMap::new_inherited(elem), GlobalRef::Window(window), NamedNodeMapBinding::Wrap) }
identifier_body
namednodemap.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::attr::Attr; use dom::bindings::codegen::Bindings::NamedNodeMapBinding; use dom::bindings::codegen::Bindin...
} } impl<'a> NamedNodeMapMethods for JSRef<'a, NamedNodeMap> { fn Length(self) -> u32 { self.owner.root().r().attrs().len() as u32 } fn Item(self, index: u32) -> Option<Temporary<Attr>> { self.owner.root().r().attrs().as_slice().get(index as uint).map(|x| Temporary::new(x.clone())) ...
reflect_dom_object(box NamedNodeMap::new_inherited(elem), GlobalRef::Window(window), NamedNodeMapBinding::Wrap)
random_line_split
module_gui.rs
use gui::{button::*, component::*, connect::*, event::*, geom::*, layout, render::*}; use module::*; use futures::executor::ThreadPool; use std::marker::PhantomData; use std::rc::Rc; use std::sync::Arc; use gfx_device_gl as gl; pub struct GuiModuleConfig { pub graph: Arc<flow::Graph>, pub ctx: RenderContext...
; let node = graph.node(ifc.id()).unwrap(); let mut module = T::new(ifc); let ports = module.ports(); // Bounds pos is relative to the window, so we drop it and keep just the size, // for the purposes of the layout solver let mut solver = layout::Layout::new(Box3::new(0....
{ graph.add_node() }
conditional_block
module_gui.rs
use gui::{button::*, component::*, connect::*, event::*, geom::*, layout, render::*}; use module::*; use futures::executor::ThreadPool; use std::marker::PhantomData; use std::rc::Rc; use std::sync::Arc; use gfx_device_gl as gl; pub struct GuiModuleConfig { pub graph: Arc<flow::Graph>, pub ctx: RenderContext...
// for the purposes of the layout solver let mut solver = layout::Layout::new(Box3::new(0.0.into(), bounds.size)); // set up two main areas, for the jacks and the body let jack_area = solver.add_node(); let body_area = solver.add_node(); solver.stack(layout::Axis::Y, &[j...
{ let GuiModuleConfig { bounds, jack_ctx, mut ctx, graph, executor, node_id, } = cfg; let target = TextureTarget::new(ctx.clone(), bounds.size.drop_z()); let ifc = if let Some(id) = node_id { graph.add_no...
identifier_body
module_gui.rs
use gui::{button::*, component::*, connect::*, event::*, geom::*, layout, render::*}; use module::*; use futures::executor::ThreadPool; use std::marker::PhantomData; use std::rc::Rc; use std::sync::Arc; use gfx_device_gl as gl; pub struct GuiModuleConfig { pub graph: Arc<flow::Graph>, pub ctx: RenderContext...
(&mut self, device: &mut gl::Device, ctx: &mut RenderContext) { if self.dirty { self.target.begin_frame(); self.render_self(device); self.delete_button.render(device, self.target.ctx()); self.target.end_frame(device); self.dirty = false; } ...
render
identifier_name
module_gui.rs
use gui::{button::*, component::*, connect::*, event::*, geom::*, layout, render::*}; use module::*; use futures::executor::ThreadPool; use std::marker::PhantomData; use std::rc::Rc; use std::sync::Arc; use gfx_device_gl as gl; pub struct GuiModuleConfig { pub graph: Arc<flow::Graph>, pub ctx: RenderContext...
module.start(executor); GuiModuleWrapper { module, node, target, body, delete_button: Button::new( ctx, "X".into(), Box3 { pos: Pt3::new(bounds.size.x - TITLE_BAR_HEIGHT - BOR...
.map(|(port, layout)| jack_ctx.new_jack(port.clone(), solver.query(layout), bounds.pos)) .collect(); let body = module.new_body(&mut ctx, solver.query(body_area));
random_line_split
transform.rs
// Copyright (C) 2009 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applic...
//rsDebug("Transform checking parent", (int)0); if (parent) { if (parent->changed) { toChild.changed = 1; rsMatrixLoad(globalMat, parent->mat); rsMatrixMultiply(globalMat, localMat); } } else { rsMatrixLoad(globalMat, localMat); } //rs...
{ data->isDirty = 0; toChild.changed = 1; // Reset our local matrix rsMatrixLoadIdentity(localMat); for (int i = 0; i < 16; i ++) { if (data->transformTypes[i] == TRANSFORM_NONE) { break; } //rsDebug("Transform adding transfor...
conditional_block
transform.rs
// Copyright (C) 2009 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applic...
}
random_line_split
test_termios.rs
use std::os::unix::prelude::*; use tempfile::tempfile; use nix::fcntl; use nix::errno::Errno; use nix::pty::openpty; use nix::sys::termios::{self, LocalFlags, OutputFlags, tcgetattr}; use nix::unistd::{read, write, close}; /// Helper function analogous to `std::io::Write::write_all`, but for `RawFd`s fn
(f: RawFd, buf: &[u8]) { let mut len = 0; while len < buf.len() { len += write(f, &buf[len..]).unwrap(); } } // Test tcgetattr on a terminal #[test] fn test_tcgetattr_pty() { // openpty uses ptname(3) internally let _m = crate::PTSNAME_MTX.lock(); let pty = openpty(None, None).expect("...
write_all
identifier_name
test_termios.rs
use std::os::unix::prelude::*; use tempfile::tempfile; use nix::fcntl; use nix::errno::Errno; use nix::pty::openpty; use nix::sys::termios::{self, LocalFlags, OutputFlags, tcgetattr}; use nix::unistd::{read, write, close}; /// Helper function analogous to `std::io::Write::write_all`, but for `RawFd`s fn write_all(f: ...
close(pty.slave).unwrap(); termios }; // Make sure postprocessing '\r' isn't specified by default or this test is useless. assert!(!termios.output_flags.contains(OutputFlags::OPOST | OutputFlags::OCRNL)); // Specify that '\r' characters should be transformed to '\n' // OPOST is spe...
close(pty.master).unwrap();
random_line_split
test_termios.rs
use std::os::unix::prelude::*; use tempfile::tempfile; use nix::fcntl; use nix::errno::Errno; use nix::pty::openpty; use nix::sys::termios::{self, LocalFlags, OutputFlags, tcgetattr}; use nix::unistd::{read, write, close}; /// Helper function analogous to `std::io::Write::write_all`, but for `RawFd`s fn write_all(f: ...
// Test tcgetattr on something that isn't a terminal #[test] fn test_tcgetattr_enotty() { let file = tempfile().unwrap(); assert_eq!(termios::tcgetattr(file.as_raw_fd()).err(), Some(Errno::ENOTTY)); } // Test tcgetattr on an invalid file descriptor #[test] fn test_tcgetattr_ebadf() { asser...
{ // openpty uses ptname(3) internally let _m = crate::PTSNAME_MTX.lock(); let pty = openpty(None, None).expect("openpty failed"); assert!(termios::tcgetattr(pty.slave).is_ok()); close(pty.master).expect("closing the master failed"); close(pty.slave).expect("closing the slave failed"); }
identifier_body
lib.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ #![deny(warnings)] use anyhow::{Error, Result}; use blobrepo::BlobRepo; use blobrepo_hg::BlobRepoHg; use context::CoreContext; use futures...
{ let blobrepo = blobrepo.clone(); let futures = pushrebased_changesets.into_iter().map({ move |p| { let blobrepo = blobrepo.clone(); let ctx = ctx.clone(); async move { let (old, new) = futures::try_join!( blobrepo.get_hg_from_bons...
identifier_body
lib.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ #![deny(warnings)] use anyhow::{Error, Result}; use blobrepo::BlobRepo; use blobrepo_hg::BlobRepoHg; use context::CoreContext; use futures...
let hg_pushrebased_changesets = pushrebased_changesets_to_hg_stream(ctx.clone(), blobrepo, filtered_changesets); let time = DateTime::now(); let mut metadata = vec![MetadataEntry::new("operation", "push")]; if let Some(user) = ctx.metadata().unix_name() { metadata.push(MetadataEntry:...
{ return None; }
conditional_block
lib.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ #![deny(warnings)] use anyhow::{Error, Result}; use blobrepo::BlobRepo; use blobrepo_hg::BlobRepoHg; use context::CoreContext; use futures...
Some(part) } fn pushrebased_changesets_to_hg_stream( ctx: CoreContext, blobrepo: &BlobRepo, pushrebased_changesets: Vec<pushrebase::PushrebaseChangesetPair>, ) -> impl StreamOld<Item = (HgChangesetId, Vec<HgChangesetId>), Error = Error> { let blobrepo = blobrepo.clone(); let futures = pushreba...
let part = parts::obsmarkers_part(hg_pushrebased_changesets, time, metadata);
random_line_split
lib.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ #![deny(warnings)] use anyhow::{Error, Result}; use blobrepo::BlobRepo; use blobrepo_hg::BlobRepoHg; use context::CoreContext; use futures...
( ctx: CoreContext, blobrepo: &BlobRepo, pushrebased_changesets: Vec<pushrebase::PushrebaseChangesetPair>, ) -> Option<Result<PartEncodeBuilder>> { let filtered_changesets: Vec<_> = pushrebased_changesets .into_iter() .filter(|c| c.id_old!= c.id_new) .collect(); if filtered_cha...
pushrebased_changesets_to_obsmarkers_part
identifier_name
infer-from-object-issue-26952.rs
// run-pass #![allow(dead_code)] #![allow(unused_variables)] // Test that when we match a trait reference like `Foo<A>: Foo<_#0t>`, // we unify with `_#0t` with `A`. In this code, if we failed to do // that, then you get an unconstrained type-variable in `call`. // // Also serves as a regression test for issue #26952, ...
fn as_trait<A>(t: &Type<A>) -> &dyn Trait<A> { loop { } } fn want<A,T:Trait<A>+?Sized>(t: &T) { } fn call<A>(p: Type<A>) { let q = as_trait(&p); want(q); // parameter A to `want` *would* be unconstrained } fn main() { }
trait Trait<A> { fn foo(&self); } struct Type<A> { a: PhantomData<A> }
random_line_split
infer-from-object-issue-26952.rs
// run-pass #![allow(dead_code)] #![allow(unused_variables)] // Test that when we match a trait reference like `Foo<A>: Foo<_#0t>`, // we unify with `_#0t` with `A`. In this code, if we failed to do // that, then you get an unconstrained type-variable in `call`. // // Also serves as a regression test for issue #26952, ...
<A>(p: Type<A>) { let q = as_trait(&p); want(q); // parameter A to `want` *would* be unconstrained } fn main() { }
call
identifier_name
infer-from-object-issue-26952.rs
// run-pass #![allow(dead_code)] #![allow(unused_variables)] // Test that when we match a trait reference like `Foo<A>: Foo<_#0t>`, // we unify with `_#0t` with `A`. In this code, if we failed to do // that, then you get an unconstrained type-variable in `call`. // // Also serves as a regression test for issue #26952, ...
{ }
identifier_body
rooting.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/. */ #![cfg(feature = "debugmozjs")] extern crate libc; #[macro_use] extern crate mozjs; use std::ptr; use mozjs::js...
(_: *mut JSContext, _: u32, _: *mut Value) -> bool { true } const METHODS: &'static [JSFunctionSpec] = &[ JSFunctionSpec { name: JSPropertySpec_Name { string_: b"addEventListener\0" as *const u8 as *const libc::c_char, }, call: JSNativeWrapper { op: Some(generic_...
generic_method
identifier_name
rooting.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/. */ #![cfg(feature = "debugmozjs")] extern crate libc; #[macro_use] extern crate mozjs; use std::ptr; use mozjs::js...
define_methods(context, proto.handle(), METHODS).unwrap(); rooted!(in(context) let root: JSVal); assert_eq!(root.get().is_undefined(), true); rooted!(in(context) let root: *mut JSObject); assert_eq!(root.get().is_null(), true); rooted!(in(context) let root: *mut JSStri...
{ let engine = JSEngine::init().unwrap(); let runtime = Runtime::new(engine.handle()); let context = runtime.cx(); let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook; let c_option = RealmOptions::default(); unsafe { JS_SetGCZeal(context, 2, 1); rooted!(in(context) let glo...
identifier_body
rooting.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
#![cfg(feature = "debugmozjs")] extern crate libc; #[macro_use] extern crate mozjs; use std::ptr; use mozjs::jsapi::JSPROP_ENUMERATE; use mozjs::jsapi::{ GetRealmObjectPrototype, JS_NewGlobalObject, JS_NewObjectWithGivenProto, JS_SetGCZeal, }; use mozjs::jsapi::{ JSAutoRealm, JSClass, JSContext, JSFunction, ...
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
random_line_split
tree.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/. */ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency //! between layout and style. use at...
operation: &AttrSelectorOperation<&<Self::Impl as SelectorImpl>::AttrValue>, ) -> bool; fn match_non_ts_pseudo_class<F>( &self, pc: &<Self::Impl as SelectorImpl>::NonTSPseudoClass, context: &mut MatchingContext<Self::Impl>, flags_setter: &mut F, ) -> bool where ...
random_line_split
tree.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/. */ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency //! between layout and style. use at...
(&self) -> Option<Self> { None } fn has_id( &self, id: &<Self::Impl as SelectorImpl>::Identifier, case_sensitivity: CaseSensitivity, ) -> bool; fn has_class( &self, name: &<Self::Impl as SelectorImpl>::ClassName, case_sensitivity: CaseSensitivity...
assigned_slot
identifier_name
tree.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/. */ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency //! between layout and style. use at...
} pub trait Element: Sized + Clone + Debug { type Impl: SelectorImpl; /// Converts self into an opaque representation. fn opaque(&self) -> OpaqueElement; fn parent_element(&self) -> Option<Self>; /// Whether the parent node of this element is a shadow root. fn parent_node_is_shadow_root(&se...
{ unsafe { OpaqueElement(NonNull::new_unchecked( ptr as *const T as *const () as *mut (), )) } }
identifier_body
lib.rs
#![feature(plugin_registrar, macro_rules)] extern crate rustc; extern crate syntax; use std::io::Command; use std::io::fs::PathExtensions; use std::os; use std::str; use std::sync::{Once, ONCE_INIT}; use rustc::plugin::Registry; use syntax::abi; use syntax::ast; use syntax::attr; use syntax::ptr::P; use syntax::code...
impl MacResult for MacItems { fn make_items(self: Box<MacItems>) -> Option<SmallVector<P<ast::Item>>> { Some(self.items.into_iter().collect()) } } // lol hax fn cargo_native_dirs() -> Vec<Path> { match rustc::driver::handle_options(os::args()) { Some(matches) => { matches.opt_...
{ let entry = ecx.expander().fold_expr(parser.parse_expr()); match entry.node { ast::ExprLit(ref lit) => { match lit.node { ast::LitStr(ref s, _) => return Ok((s.to_string(), entry.span)), _ => {} } } _ => {} } ecx.span_err(...
identifier_body
lib.rs
#![feature(plugin_registrar, macro_rules)] extern crate rustc; extern crate syntax; use std::io::Command; use std::io::fs::PathExtensions; use std::os; use std::str; use std::sync::{Once, ONCE_INIT}; use rustc::plugin::Registry; use syntax::abi; use syntax::ast; use syntax::attr; use syntax::ptr::P; use syntax::code...
let args = ecx.meta_name_value(sp, InternedString::new("link_args"), ast::LitStr(l, ast::CookedStr)); ecx.attribute(sp, args) })); let mut attrs = attrs.map(|attr| { attr::mark_used(&attr); attr }); ecx.item(sp, special_idents::inva...
let attrs = attrs.chain(info.locs.iter().map(|l| { let l = token::intern_and_get_ident(format!("-L{}", l.display()).as_slice());
random_line_split
lib.rs
#![feature(plugin_registrar, macro_rules)] extern crate rustc; extern crate syntax; use std::io::Command; use std::io::fs::PathExtensions; use std::os; use std::str; use std::sync::{Once, ONCE_INIT}; use rustc::plugin::Registry; use syntax::abi; use syntax::ast; use syntax::attr; use syntax::ptr::P; use syntax::code...
if stderr.len() > 0 { msg.push_str("\n--- stderr\n"); msg.push_str(stderr); } ecx.span_err(sp, msg.as_slice()); return Err(()) } let mut libs = Vec::new(); let mut locs = Vec::new(); for arg in stdout.split(' ').filter(|l|!l.is_empty()) { ...
{ msg.push_str("\n--- stdout\n"); msg.push_str(stdout); }
conditional_block
lib.rs
#![feature(plugin_registrar, macro_rules)] extern crate rustc; extern crate syntax; use std::io::Command; use std::io::fs::PathExtensions; use std::os; use std::str; use std::sync::{Once, ONCE_INIT}; use rustc::plugin::Registry; use syntax::abi; use syntax::ast; use syntax::attr; use syntax::ptr::P; use syntax::code...
() { static mut DONE: Once = ONCE_INIT; unsafe { DONE.doit(add_cargo_pkg_config_paths) } fn add_cargo_pkg_config_paths() { let path = os::getenv_as_bytes("PKG_CONFIG_PATH").unwrap_or(Vec::new()); let mut pkg_config_path = os::split_paths(path.as_slice()); pkg_config_path.push_all(ca...
add_cargo_pkg_config_paths
identifier_name
contact.rs
use std::mem; use math::{Point, Vect}; /// Geometric description of a contact. #[derive(Debug, PartialEq, Clone, RustcEncodable, RustcDecodable)] pub struct Contact<P: Point> { /// Position of the contact on the first object. The position is expressed in world space. pub world1: P, /// Position of the con...
} } } impl<P: Point> Contact<P> { /// Reverts the contact normal and swaps `world1` and `world2`. #[inline] pub fn flip(&mut self) { mem::swap(&mut self.world1, &mut self.world2); self.normal = -self.normal.clone(); } }
depth: depth
random_line_split
contact.rs
use std::mem; use math::{Point, Vect}; /// Geometric description of a contact. #[derive(Debug, PartialEq, Clone, RustcEncodable, RustcDecodable)] pub struct
<P: Point> { /// Position of the contact on the first object. The position is expressed in world space. pub world1: P, /// Position of the contact on the second object. The position is expressed in world space. pub world2: P, /// Contact normal pub normal: P::Vect, /// Penetration depth ...
Contact
identifier_name
contact.rs
use std::mem; use math::{Point, Vect}; /// Geometric description of a contact. #[derive(Debug, PartialEq, Clone, RustcEncodable, RustcDecodable)] pub struct Contact<P: Point> { /// Position of the contact on the first object. The position is expressed in world space. pub world1: P, /// Position of the con...
} impl<P: Point> Contact<P> { /// Reverts the contact normal and swaps `world1` and `world2`. #[inline] pub fn flip(&mut self) { mem::swap(&mut self.world1, &mut self.world2); self.normal = -self.normal.clone(); } }
{ Contact { world1: world1, world2: world2, normal: normal, depth: depth } }
identifier_body
methods-are-with-self-type.rs
// Currently, all generic functions are instantiated in each codegen unit that // uses them, even those not marked with #[inline], so this test does not make // much sense at the moment. // ignore-test // // We specify incremental here because we want to test the partitioning for // incremental compilation // incremen...
(_: isize, _: *const *const u8) -> isize { //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[1]::method[0]<u32, u64> @@ methods_are_with_self_type.volatile[WeakODR] SomeGenericType(0u32, 0u64).method(); //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[1]::associated_fn[0]<char, &s...
start
identifier_name
methods-are-with-self-type.rs
// Currently, all generic functions are instantiated in each codegen unit that // uses them, even those not marked with #[inline], so this test does not make // much sense at the moment. // ignore-test // // We specify incremental here because we want to test the partitioning for // incremental compilation // incremen...
pub struct Struct; } //~ MONO_ITEM fn methods_are_with_self_type::start[0] #[start] fn start(_: isize, _: *const *const u8) -> isize { //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[1]::method[0]<u32, u64> @@ methods_are_with_self_type.volatile[WeakODR] SomeGenericType(0u32, 0u64).method();...
} mod type2 {
random_line_split
resources.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/. */ use std::path::PathBuf; use std::sync::{Once, RwLock}; lazy_static! { static ref RES: RwLock<Option<Box<dyn ...
path.pop(); } path.push(file); let mut buffer = vec![]; File::open(path) .expect(&format!("Can't find file: {}", file)) .read_to_end(&mut buffer) .expect("Can't read file"); buffer } } ...
{ break; }
conditional_block
resources.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/. */ use std::path::PathBuf; use std::sync::{Once, RwLock}; lazy_static! { static ref RES: RwLock<Option<Box<dyn ...
(&self, file: Resource) -> Vec<u8> { let file = match file { Resource::Preferences => "prefs.json", Resource::BluetoothBlocklist => "gatt_blocklist.txt", Resource::DomainList => "public_domains.txt", Resource::HstsPreloadList => "hsts_preload.j...
read
identifier_name
resources.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/. */ use std::path::PathBuf; use std::sync::{Once, RwLock}; lazy_static! { static ref RES: RwLock<Option<Box<dyn ...
.expect(&format!("Can't find file: {}", file)) .read_to_end(&mut buffer) .expect("Can't read file"); buffer } } Box::new(ResourceReader) }
let mut buffer = vec![]; File::open(path)
random_line_split
v4.rs
extern crate byteorder; extern crate flate2; use self::byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use id3v2::frame::stream::FrameStream; use id3v2::frame::{Frame, Id}; use id3v2::Error; use id3v2::ErrorKind::{UnsupportedFeature, InvalidTag}; use std::io::{self, Read, Write}; use self::flate2::write::ZlibEnco...
if let Id::V4(id_bytes)=frame.id { try!(writer.write(&id_bytes)); } else { panic!("internal error: writing v2.4 frame but frame ID is not v2.4!"); } try!(writer.write(&util::u32_to_bytes(util::synchsafe(content_size)))); try!(writer.write(&frame.flags.to...
{ content_size += 4; }
conditional_block
v4.rs
extern crate byteorder; extern crate flate2; use self::byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use id3v2::frame::stream::FrameStream; use id3v2::frame::{Frame, Id}; use id3v2::Error; use id3v2::ErrorKind::{UnsupportedFeature, InvalidTag}; use std::io::{self, Read, Write}; use self::flate2::write::ZlibEnco...
(writer: &mut Write, frame: &Frame, _: Option<FrameV4>, unsynchronization: bool) -> Result<u32, io::Error> { let mut content_bytes = frame.fields_to_bytes(); let mut content_size = content_bytes.len() as u32; let decompressed_size = content_size; if frame.flags.compression { ...
write
identifier_name
v4.rs
extern crate byteorder; extern crate flate2; use self::byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use id3v2::frame::stream::FrameStream; use id3v2::frame::{Frame, Id}; use id3v2::Error; use id3v2::ErrorKind::{UnsupportedFeature, InvalidTag}; use std::io::{self, Read, Write}; use self::flate2::write::ZlibEnco...
let frameflags = try!(reader.read_u16::<BigEndian>()); frame.flags.tag_alter_preservation = frameflags & 0x4000!= 0; frame.flags.file_alter_preservation = frameflags & 0x2000!= 0; frame.flags.read_only = frameflags & 0x1000!= 0; frame.flags.grouping_identity = frameflags & 0x40!=...
let content_size = util::unsynchsafe(try!(reader.read_u32::<BigEndian>()));
random_line_split
v4.rs
extern crate byteorder; extern crate flate2; use self::byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use id3v2::frame::stream::FrameStream; use id3v2::frame::{Frame, Id}; use id3v2::Error; use id3v2::ErrorKind::{UnsupportedFeature, InvalidTag}; use std::io::{self, Read, Write}; use self::flate2::write::ZlibEnco...
panic!("internal error: writing v2.4 frame but frame ID is not v2.4!"); } try!(writer.write(&util::u32_to_bytes(util::synchsafe(content_size)))); try!(writer.write(&frame.flags.to_bytes(0x4))); if frame.flags.data_length_indicator { debug!("[{:?}] adding data leng...
{ let mut content_bytes = frame.fields_to_bytes(); let mut content_size = content_bytes.len() as u32; let decompressed_size = content_size; if frame.flags.compression { debug!("[{:?}] compressing frame content", frame.id); let mut encoder = ZlibEncoder::new(Vec::...
identifier_body
mod.rs
use std::io::{Cursor, Read}; use serde; use error::ResultE; mod arg_visitor; mod bundle_visitor; mod iter_visitor; mod maybe_skip_comma; mod msg_visitor; mod osc_reader; mod osc_type; mod pkt_deserializer; mod prim_deserializer; pub use self::pkt_deserializer::PktDeserializer as Deserializer; /// Deserialize an OSC ...
<'de, T>(slice: &[u8]) -> ResultE<T> where T: serde::de::Deserialize<'de> { from_read(Cursor::new(slice)) }
from_slice
identifier_name
mod.rs
use std::io::{Cursor, Read}; use serde; use error::ResultE; mod arg_visitor; mod bundle_visitor; mod iter_visitor; mod maybe_skip_comma; mod msg_visitor; mod osc_reader; mod osc_type; mod pkt_deserializer; mod prim_deserializer; pub use self::pkt_deserializer::PktDeserializer as Deserializer; /// Deserialize an OSC ...
}
random_line_split
mod.rs
use std::io::{Cursor, Read}; use serde; use error::ResultE; mod arg_visitor; mod bundle_visitor; mod iter_visitor; mod maybe_skip_comma; mod msg_visitor; mod osc_reader; mod osc_type; mod pkt_deserializer; mod prim_deserializer; pub use self::pkt_deserializer::PktDeserializer as Deserializer; /// Deserialize an OSC ...
{ from_read(Cursor::new(slice)) }
identifier_body
collaborators.rs
use crate::users::User; use crate::Future; use crate::{Error, Github}; use futures::prelude::*; use http::StatusCode; use std::collections::HashMap; use std::fmt; #[derive(Debug)] pub enum Permissions { Admin, Push, Pull, } impl Default for Permissions { fn default() -> Permissions { Permission...
pub fn remove(&self, username: &str) -> Future<()> { self.github.delete(&self.path(&format!("/{}", username))) } }
{ let mut permission_params = HashMap::new(); permission_params.insert("permission", permissions.to_string()); match serde_json::to_string(&permission_params) { Ok(data) => self .github .put::<()>(&self.path(&format!("/{}", username)), data.into_bytes...
identifier_body
collaborators.rs
use crate::users::User; use crate::Future; use crate::{Error, Github}; use futures::prelude::*; use http::StatusCode; use std::collections::HashMap; use std::fmt; #[derive(Debug)] pub enum Permissions { Admin, Push, Pull, } impl Default for Permissions { fn default() -> Permissions { Permission...
{ github: Github, owner: String, repo: String, } impl Collaborators { pub fn new<O, R>(github: Github, owner: O, repo: R) -> Collaborators where O: Into<String>, R: Into<String>, { Collaborators { github, owner: owner.into(), repo: re...
Collaborators
identifier_name
collaborators.rs
use crate::users::User; use crate::Future; use crate::{Error, Github}; use futures::prelude::*; use http::StatusCode; use std::collections::HashMap; use std::fmt; #[derive(Debug)] pub enum Permissions { Admin, Push, Pull, } impl Default for Permissions { fn default() -> Permissions { Permission...
.. } => Ok(false), Error::Codec(_) => Ok(true), otherwise => Err(otherwise), } }), ) } pub fn add(&self, username: &str, permissions: &Permissions) -> Future<()> { ...
.map_ok(|_| true) .or_else(|err| async move { match err { Error::Fault { code: StatusCode::NOT_FOUND,
random_line_split
properties.mako.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/. */ // `data` comes from components/style/properties.mako.rs; see build.rs for more details. <%! from data import...
<F: FnOnce(&Vec<Option<CascadePropertyFn<Self>>>)>(f: F) { CASCADE_PROPERTY.with(|x| f(x)); } % for style_struct in data.style_structs: #[inline] fn clone_${style_struct.trait_name_lower}(&self) -> Arc<Self::Concrete${style_struct.trait_name}> { self.${style_struct.ident}.clone() } ...
do_cascade_property
identifier_name
properties.mako.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/. */ // `data` comes from components/style/properties.mako.rs; see build.rs for more details. <%! from data import...
<% border_style_keyword = Keyword("border-style", "none solid double dotted dashed hidden groove ridge inset outset") %> <% skip_border_longhands = " ".join(["border-{0}-style border-{0}-width ".format(x.ident) for x in SIDES]) %> <%self:impl_trait style_struct_name="Border" ...
{ unsafe { % for side in SIDES: transmute::<_, [u32; ${side.index}]>([1; gecko_style_structs::Side::eSide${side.name} as usize]); % endfor } }
conditional_block
properties.mako.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/. */ // `data` comes from components/style/properties.mako.rs; see build.rs for more details. <%! from data import...
%if style_struct.gecko_ffi_name in "nsStyleBorder nsStylePosition nsStyleDisplay nsStyleList nsStyleBackground "\ "nsStyleFont nsStyleEffects nsStyleSVGReset".split(): impl Debug for ${style_struct.gecko_ffi_name} { // FIXME(bholley): Generate this. fn fmt(&self, f: &mut fmt:...
random_line_split
properties.mako.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/. */ // `data` comes from components/style/properties.mako.rs; see build.rs for more details. <%! from data import...
, % endfor } } fn style_for_child_text_node(parent: &Arc<Self>) -> Arc<Self> { // Gecko expects text nodes to be styled as if they were elements that // matched no rules (that is, inherited style structs are inherited and // non-inherited style structs are set to the...
{ GeckoComputedValues { custom_properties: custom_properties, shareable: shareable, writing_mode: writing_mode, root_font_size: root_font_size, % for style_struct in data.style_structs: ${style_struct.ident}: ${style_struct.ident}
identifier_body
quality_counts.rs
use crate::trust_seq::group::BaseGroup; use std::cmp; use std::f64; pub struct QualityCounts { pub counts: Vec<QualityCount>, } impl QualityCounts { pub fn new() -> QualityCounts { return QualityCounts { counts: Vec::new() }; } pub fn ensure_size(&mut self, len: usize) { if self.counts....
} pub fn add_value(&mut self, idx: usize, ch: u8) { self.ensure_size(idx + 1); self.counts[idx].counts[ch as usize] += 1; self.counts[idx].total_count += 1; } pub fn len(&self) -> usize { return self.counts.len(); } pub fn get_mean(&self, group: &BaseGroup, offse...
{ self.counts.resize(len, QualityCount::new()); }
conditional_block
quality_counts.rs
use crate::trust_seq::group::BaseGroup; use std::cmp; use std::f64; pub struct QualityCounts { pub counts: Vec<QualityCount>, } impl QualityCounts { pub fn new() -> QualityCounts { return QualityCounts { counts: Vec::new() }; } pub fn ensure_size(&mut self, len: usize) { if self.counts....
self.counts[ch as usize] += 1; self.total_count += 1; } pub fn get_mean(&self, offset: u32) -> f64 { let mut total: f64 = 0.0; let mut count: f64 = 0.0; for (idx, c) in self.counts.iter().enumerate() { let cnt = *c as f64; total += cnt * ((idx as f...
pub fn add_value(&mut self, ch: usize) -> () {
random_line_split
quality_counts.rs
use crate::trust_seq::group::BaseGroup; use std::cmp; use std::f64; pub struct QualityCounts { pub counts: Vec<QualityCount>, } impl QualityCounts { pub fn new() -> QualityCounts { return QualityCounts { counts: Vec::new() }; } pub fn ensure_size(&mut self, len: usize) { if self.counts....
pub fn get_percentile(&self, group: &BaseGroup, offset: u32, percentile: u32) -> f64 { let mut count: u32 = 0; let mut total: f64 = 0.0; for i in (group.lower_count - 1)..group.upper_count { if self.counts[i].total_count > 100 { count += 1; total ...
{ let mut count: u32 = 0; let mut total: f64 = 0.0; for i in (group.lower_count - 1)..group.upper_count { count += 1; total += self.counts[i].get_mean(offset); } if count > 0 { total / count as f64 } else { f64::NAN ...
identifier_body