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
window.rs
use error::Result; use glium_sdl2::{DisplayBuild, SDL2Facade}; use glium::{Frame, Surface}; use platform; use sdl2; use sdl2::Sdl; use sdl2::video::GLProfile; const WINDOW_TITLE: &'static str = "Rusty Doom v0.0.7"; const OPENGL_DEPTH_SIZE: u8 = 24; pub struct Window { facade: SDL2Facade, width: u32, hei...
(&self) -> Frame { let mut frame = self.facade.draw(); frame.clear_all_srgb((0.06, 0.07, 0.09, 0.0), 1.0, 0); frame } pub fn facade(&self) -> &SDL2Facade { &self.facade } }
draw
identifier_name
window.rs
use error::Result; use glium_sdl2::{DisplayBuild, SDL2Facade}; use glium::{Frame, Surface}; use platform; use sdl2; use sdl2::Sdl; use sdl2::video::GLProfile; const WINDOW_TITLE: &'static str = "Rusty Doom v0.0.7"; const OPENGL_DEPTH_SIZE: u8 = 24; pub struct Window { facade: SDL2Facade, width: u32, hei...
} pub fn aspect_ratio(&self) -> f32 { self.width as f32 / self.height as f32 } pub fn draw(&self) -> Frame { let mut frame = self.facade.draw(); frame.clear_all_srgb((0.06, 0.07, 0.09, 0.0), 1.0, 0); frame } pub fn facade(&self) -> &SDL2Facade { &self.f...
self.height
random_line_split
window.rs
use error::Result; use glium_sdl2::{DisplayBuild, SDL2Facade}; use glium::{Frame, Surface}; use platform; use sdl2; use sdl2::Sdl; use sdl2::video::GLProfile; const WINDOW_TITLE: &'static str = "Rusty Doom v0.0.7"; const OPENGL_DEPTH_SIZE: u8 = 24; pub struct Window { facade: SDL2Facade, width: u32, hei...
pub fn height(&self) -> u32 { self.height } pub fn aspect_ratio(&self) -> f32 { self.width as f32 / self.height as f32 } pub fn draw(&self) -> Frame { let mut frame = self.facade.draw(); frame.clear_all_srgb((0.06, 0.07, 0.09, 0.0), 1.0, 0); frame } ...
{ self.width }
identifier_body
mod.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T> where F: FnMut(io::Result<&SocketAddr>) -> io::Result<T> { let addrs = match addr.to_socket_addrs() { Ok(addrs) => addrs, Err(e) => return f(Err(e)) }; let mut last_err = None; for addr in addrs { matc...
{ I::from_be(i) }
identifier_body
mod.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 ...
<I: NetInt>(i: I) -> I { i.to_be() } fn ntoh<I: NetInt>(i: I) -> I { I::from_be(i) } fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T> where F: FnMut(io::Result<&SocketAddr>) -> io::Result<T> { let addrs = match addr.to_socket_addrs() { Ok(addrs) => addrs, Err(e) => retur...
hton
identifier_name
mod.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 ...
#[stable(feature = "rust1", since = "1.0.0")] Write, /// Both the reading and the writing portions of the [`TcpStream`] should be shut down. /// /// See [`Shutdown::Read`] and [`Shutdown::Write`] for more information. /// /// [`TcpStream`]:../../std/net/struct.TcpStream.html /// [`Shutdo...
/// All currently blocked and future [writes] will return an error. /// /// [`TcpStream`]: ../../std/net/struct.TcpStream.html /// [writes]: ../../std/io/trait.Write.html
random_line_split
rsold.rs
extern crate time; use std::io::File; use std::io::BufferedReader; use time::precise_time_ns; #[deriving(Clone, Show)] struct Route{ dest: i32, cost: i32 } #[deriving(Clone, Show)] struct Node { neighbours: Vec<Route> } fn read_places(num_nodes: &mut uint) ->Vec<Node>{ let path = Path::new("agraph"); let ...
max = dist; } } } unsafe{ let newAddr: uint = (visited as uint) + (uintID as uint); let newAddrP: *mut bool = newAddr as *mut bool; *newAddrP = false; } max } fn main(){ let mut num_nodes = 0; let nodes = read_places(&mut num_nodes); let mut visited: Vec<bool> = Vec::from...
{ let uintID = nodeID.to_uint().expect("Error, something had a negative node id"); unsafe{ let newAddr: uint = (visited as uint) + (uintID as uint); let newAddrP: *mut bool = newAddr as *mut bool; *newAddrP = true; } let mut dist: i32; let mut max: i32 = 0; for neighbour in nodes.get(uintID).n...
identifier_body
rsold.rs
extern crate time; use std::io::File; use std::io::BufferedReader; use time::precise_time_ns; #[deriving(Clone, Show)] struct Route{ dest: i32, cost: i32 } #[deriving(Clone, Show)] struct Node { neighbours: Vec<Route> } fn read_places(num_nodes: &mut uint) ->Vec<Node>{ let path = Path::new("agraph"); let ...
} } unsafe{ let newAddr: uint = (visited as uint) + (uintID as uint); let newAddrP: *mut bool = newAddr as *mut bool; *newAddrP = false; } max } fn main(){ let mut num_nodes = 0; let nodes = read_places(&mut num_nodes); let mut visited: Vec<bool> = Vec::from_fn(num_nodes, |_| fa...
{ max = dist; }
conditional_block
rsold.rs
extern crate time; use std::io::File; use std::io::BufferedReader; use time::precise_time_ns; #[deriving(Clone, Show)] struct Route{ dest: i32, cost: i32 } #[deriving(Clone, Show)] struct Node { neighbours: Vec<Route> } fn read_places(num_nodes: &mut uint) ->Vec<Node>{ let path = Path::new("agraph"); let ...
for i in range(0u, *num_nodes){ newnodes.push(if i == node{ newnode.clone()} else {nodes.get(i).clone()}); } nodes = newnodes; } nodes } fn get_longest_path(nodes: &Vec<Node>, nodeID: i32, visited: *bool) -> i32{ let uintID = nodeID.to_uint().expect("Error, something had a negative node id"); ...
let neighbour: i32 = from_str(*nums.get(1)).expect("Error: neighbour id was not an int"); let cost: i32 = from_str(*nums.get(2)).expect("Error: route cost was not an int"); let mut newnode = nodes.get(node).clone(); newnode.neighbours.push(Route{dest: neighbour, cost: cost}); let mut newnodes = Vec:...
random_line_split
rsold.rs
extern crate time; use std::io::File; use std::io::BufferedReader; use time::precise_time_ns; #[deriving(Clone, Show)] struct Route{ dest: i32, cost: i32 } #[deriving(Clone, Show)] struct Node { neighbours: Vec<Route> } fn read_places(num_nodes: &mut uint) ->Vec<Node>{ let path = Path::new("agraph"); let ...
(){ let mut num_nodes = 0; let nodes = read_places(&mut num_nodes); let mut visited: Vec<bool> = Vec::from_fn(num_nodes, |_| false); let startTime = precise_time_ns(); let path = get_longest_path(&nodes, 0, &visited[0] as *bool); let duration = (precise_time_ns() - startTime) / 1000000; println!("{...
main
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(box_syntax)] #![feature(iter_cmp)] #![feature(slice_bytes)] #![feature(vec_push_all)] #![feature(plugin)] #![plugin(plugins)] #![deny(unsafe_code)] #[macro_use] extern crate log; #[macro_use] extern crate profile_traits; #[macro_use] extern crate util; extern crate azure; extern crate canvas; extern crate ...
random_line_split
hook_configuration.rs
#[derive(Clone)] #[derive(RustcDecodable)] pub struct HookConfiguration { pub hooks: Vec<HookConfig>, pub slack: Option<SlackConfiguration>, } #[derive(Clone)] #[derive(RustcDecodable)] pub struct SlackConfiguration { pub webhook_url: String, pub channel: String, pub username: String, pub icon...
{ pub name: String, pub branch: Option<String>, pub action: HookAction, } impl HookConfig { pub fn worker_name(&self) -> String { let b = self.branch.clone().unwrap_or("all".to_string()); format!("{}-{}", self.name, b) } } #[derive(Clone)] #[derive(RustcDecodable)] pub struct Hook...
HookConfig
identifier_name
hook_configuration.rs
#[derive(Clone)] #[derive(RustcDecodable)] pub struct HookConfiguration { pub hooks: Vec<HookConfig>, pub slack: Option<SlackConfiguration>, } #[derive(Clone)] #[derive(RustcDecodable)] pub struct SlackConfiguration { pub webhook_url: String, pub channel: String, pub username: String, pub icon...
} #[derive(Clone)] #[derive(RustcDecodable)] pub struct HookAction { pub cmd: String, pub parms: Vec<String>, pub pwd: String, }
{ let b = self.branch.clone().unwrap_or("all".to_string()); format!("{}-{}", self.name, b) }
identifier_body
hook_configuration.rs
#[derive(Clone)]
#[derive(Clone)] #[derive(RustcDecodable)] pub struct SlackConfiguration { pub webhook_url: String, pub channel: String, pub username: String, pub icon_url: Option<String>, pub icon_emoji: Option<String>, } #[derive(Clone)] #[derive(RustcDecodable)] pub struct HookConfig { pub name: String, ...
#[derive(RustcDecodable)] pub struct HookConfiguration { pub hooks: Vec<HookConfig>, pub slack: Option<SlackConfiguration>, }
random_line_split
interpret.rs
extern crate builtins; use std::slice::Iter; use std::borrow::Cow; type CmdLine<'a> = Vec<Param<'a>>; pub fn read(command_line: &str) { match tokenize(command_line) { Ok(token_list) => { let mut token_iter = token_list.iter(); match generate_tree(&mut token_iter) { Ok(ref tree) => execute_command(tree),...
(&'a self) -> Cow<'a, str> { match self { &Param::Cmd(ref subcmd) => execute_subcommand(subcmd), &Param::Arg(arg_str) => Cow::Borrowed(arg_str), } } } #[cfg(test)] mod tests { use super::tokenize; use super::Token::*; #[test] fn empty_command() { assert_eq!( [LeftParen, RightParen], tokenize("(...
as_arg
identifier_name
interpret.rs
extern crate builtins; use std::slice::Iter; use std::borrow::Cow; type CmdLine<'a> = Vec<Param<'a>>; pub fn read(command_line: &str) { match tokenize(command_line) { Ok(token_list) => { let mut token_iter = token_list.iter(); match generate_tree(&mut token_iter) { Ok(ref tree) => execute_command(tree),...
enum TokenMachineState { Start, SeparateWs, StrWord(usize), WordFirstQuote, QuotedWord(usize), } #[derive(PartialEq, Debug)] // used for tests enum Token<'a> { LeftParen, RightParen, Word(&'a str), } fn tokenize(command_line: &str) -> Result<Vec<Token>, &'static str> { use self::TokenMachineState::*; use se...
} #[derive(Copy, Clone)] // this enum takes only 1B more than usize so copying it is no big deal
random_line_split
issue-2216.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 x = 0; 'foo: loop { 'bar: loop { 'quux: loop { if 1 == 2 { break 'foo; } else { break 'bar; } } continue 'foo; } x = 42; break...
main
identifier_name
issue-2216.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 ...
'bar: loop { 'quux: loop { if 1 == 2 { break 'foo; } else { break 'bar; } } continue 'foo; } x = 42; break; } error!("{:?}", x); assert...
let mut x = 0; 'foo: loop {
random_line_split
issue-2216.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 ...
else { break 'bar; } } continue 'foo; } x = 42; break; } error!("{:?}", x); assert_eq!(x, 42); }
{ break 'foo; }
conditional_block
issue-2216.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(x, 42); }
{ let mut x = 0; 'foo: loop { 'bar: loop { 'quux: loop { if 1 == 2 { break 'foo; } else { break 'bar; } } continue 'foo; } x = 42; break; ...
identifier_body
lib.rs
//! The fast sweeping method for the computation of the signed distance function in 2D in 3D. //! //! Based on [1]. //! //! ## Usage //! //! Add the following to your `Cargo.toml` //! //! ```toml //! [dependencies.fast_sweeping] //! git = "https://github.com/rekka/fast_sweeping.git" //! ``` //! //! At the top of your c...
fn prop(ta: f64) -> bool { let n = 17; let ta = (ta - ta.floor()) * 2. * ::std::f64::consts::PI; let (gy, gx) = ta.sin_cos(); let c = -(gx + gy) * 0.5; let xs = Array::linspace(0., 1., n); let ys = Array::linspace(0., 1., n); let u_arr...
lines() {
identifier_name
lib.rs
//! The fast sweeping method for the computation of the signed distance function in 2D in 3D. //! //! Based on [1]. //! //! ## Usage //! //! Add the following to your `Cargo.toml` //! //! ```toml //! [dependencies.fast_sweeping] //! git = "https://github.com/rekka/fast_sweeping.git" //! ``` //! //! At the top of your c...
t)] mod tests { use super::*; extern crate quickcheck; use self::ndarray::prelude::*; use self::quickcheck::quickcheck; use ndarray::s; fn check_line(gx: f64, gy: f64, c: f64, dim: (usize, usize), tol: f64, print: bool) -> bool { let (nx, ny) = dim; let xs = Array::linspace(0., ...
} } #[cfg(tes
conditional_block
lib.rs
//! The fast sweeping method for the computation of the signed distance function in 2D in 3D. //! //! Based on [1]. //! //! ## Usage //! //! Add the following to your `Cargo.toml` //! //! ```toml //! [dependencies.fast_sweeping] //! git = "https://github.com/rekka/fast_sweeping.git" //! ``` //! //! At the top of your c...
d.all_close(&u_array, tol) } #[test] fn it_works_for_x_axis_line() { fn prop(y: f64) -> bool { check_line( 0., 1., -((y - y.floor()) * 0.9 + 0.05), (9, 17), 0.00001, false, ...
println!("{}", u_array); println!("{}", d); }
random_line_split
lib.rs
//! The fast sweeping method for the computation of the signed distance function in 2D in 3D. //! //! Based on [1]. //! //! ## Usage //! //! Add the following to your `Cargo.toml` //! //! ```toml //! [dependencies.fast_sweeping] //! git = "https://github.com/rekka/fast_sweeping.git" //! ``` //! //! At the top of your c...
] mod tests { use super::*; extern crate quickcheck; use self::ndarray::prelude::*; use self::quickcheck::quickcheck; use ndarray::s; fn check_line(gx: f64, gy: f64, c: f64, dim: (usize, usize), tol: f64, print: bool) -> bool { let (nx, ny) = dim; let xs = Array::linspace(0., 1....
y { y } else { x } } #[cfg(test)
identifier_body
ipv6_loopback.rs
use ipaddress::IPAddress; use num::bigint::BigUint; use num_traits::One; /// The loopback address is a unicast localhost address. If an /// application in a host sends packets to this address, the IPv6 stack /// will loop these packets back on the same virtual interface. /// /// Loopback addresses are expressed...
/// /// ip = IPAddress::IPv6::Loopback.new /// /// ip.to_string /// /// "::1/128" /// /// or by using the wrapper: /// /// ip = IPAddress "::1" /// /// ip.to_string /// /// "::1/128" /// /// Checking if an address is loopback is easy with the IPv6/// loopback? /// method: /// /// ip.loopba...
/// ::1/128 /// /// As for the unspecified addresses, IPv6 loopbacks can be created with /// IPAddress calling their own class:
random_line_split
ipv6_loopback.rs
use ipaddress::IPAddress; use num::bigint::BigUint; use num_traits::One; /// The loopback address is a unicast localhost address. If an /// application in a host sends packets to this address, the IPv6 stack /// will loop these packets back on the same virtual interface. /// /// Loopback addresses are expresse...
{ return ::ipv6::from_int(BigUint::one(), 128).unwrap(); }
identifier_body
ipv6_loopback.rs
use ipaddress::IPAddress; use num::bigint::BigUint; use num_traits::One; /// The loopback address is a unicast localhost address. If an /// application in a host sends packets to this address, the IPv6 stack /// will loop these packets back on the same virtual interface. /// /// Loopback addresses are expresse...
() -> IPAddress { return ::ipv6::from_int(BigUint::one(), 128).unwrap(); }
new
identifier_name
timing.rs
use std::{thread, time::{Duration, Instant}}; /// How long to wait for an Ack after we ping const PING_TIMING_DEFAULT_MS: u64 = 1000; /// How long to wait for an Ack after we PingReq - should be at least 2x the PING_TIMING_DEFAULT_MS const PINGREQ_TIMING_DEFAULT_MS: u64 = 2100; /// How many ...
ping: Duration, pingreq: Duration, confirm: Duration, departure: Duration, gossip_interval: Duration, swim_probe_interval: Duration, } impl Default for Timing { fn default() -> Timing { let swim_interval_ms = PING_TIMING_DEFAULT_MS + PINGREQ_TIMING_DEFAULT_MS; ...
random_line_split
timing.rs
use std::{thread, time::{Duration, Instant}}; /// How long to wait for an Ack after we ping const PING_TIMING_DEFAULT_MS: u64 = 1000; /// How long to wait for an Ack after we PingReq - should be at least 2x the PING_TIMING_DEFAULT_MS const PINGREQ_TIMING_DEFAULT_MS: u64 = 2100; /// How many ...
}
{ thread::sleep(amount) }
conditional_block
timing.rs
use std::{thread, time::{Duration, Instant}}; /// How long to wait for an Ack after we ping const PING_TIMING_DEFAULT_MS: u64 = 1000; /// How long to wait for an Ack after we PingReq - should be at least 2x the PING_TIMING_DEFAULT_MS const PINGREQ_TIMING_DEFAULT_MS: u64 = 2100; /// How many ...
(&self, starting_point: Instant) { maybe_sleep(starting_point, self.swim_probe_interval) } } /// If the amount of time elapsed from `start` is less than `timeout`, /// sleep for the difference. fn maybe_sleep(start: Instant, timeout: Duration) { if let Some(amount) = timeout.checked_sub(start.elapsed()...
sleep_for_remaining_swim_protocol_interval
identifier_name
timing.rs
use std::{thread, time::{Duration, Instant}}; /// How long to wait for an Ack after we ping const PING_TIMING_DEFAULT_MS: u64 = 1000; /// How long to wait for an Ack after we PingReq - should be at least 2x the PING_TIMING_DEFAULT_MS const PINGREQ_TIMING_DEFAULT_MS: u64 = 2100; /// How many ...
/// If the amount of time since `starting_point` is less than a /// SWIM protocol probe interval, sleep for the remainder of that /// interval. pub fn sleep_for_remaining_swim_protocol_interval(&self, starting_point: Instant) { maybe_sleep(starting_point, self.swim_probe_interval) } } ///...
{ maybe_sleep(starting_point, self.gossip_interval) }
identifier_body
build.rs
use protobuf_provider::PROTOBUF_BIN_PATH; use std::env; use std::fs::File; use std::io::{Read, Write}; use std::path::Path; fn main() { println!("cargo:rerun-if-changed=src/proto.proto"); let out_dir = env::var("OUT_DIR").unwrap(); protoc_rust::Codegen::new() .protoc_path(Path::new(PROTOBUF_BIN_PAT...
.expect("protoc"); // Work around // https://github.com/stepancheg/rust-protobuf/issues/117 // https://github.com/rust-lang/rust/issues/18810. // We open the file, add'mod proto { }' around the contents and write it back. This allows us // to include! the file in lib.rs and have a proper pro...
.out_dir(&out_dir) .input("src/proto.proto") .run()
random_line_split
build.rs
use protobuf_provider::PROTOBUF_BIN_PATH; use std::env; use std::fs::File; use std::io::{Read, Write}; use std::path::Path; fn main()
.read_to_string(&mut contents) .unwrap(); let new_contents = format!( "#[rustfmt::skip]\npub mod proto {{\n{}\n}}", contents.replace("#![rustfmt::skip]\n", "") ); File::create(&proto_path) .unwrap() .write_all(new_contents.as_bytes()) .unwrap(); }
{ println!("cargo:rerun-if-changed=src/proto.proto"); let out_dir = env::var("OUT_DIR").unwrap(); protoc_rust::Codegen::new() .protoc_path(Path::new(PROTOBUF_BIN_PATH).join("protoc")) .out_dir(&out_dir) .input("src/proto.proto") .run() .expect("protoc"); // Work...
identifier_body
build.rs
use protobuf_provider::PROTOBUF_BIN_PATH; use std::env; use std::fs::File; use std::io::{Read, Write}; use std::path::Path; fn
() { println!("cargo:rerun-if-changed=src/proto.proto"); let out_dir = env::var("OUT_DIR").unwrap(); protoc_rust::Codegen::new() .protoc_path(Path::new(PROTOBUF_BIN_PATH).join("protoc")) .out_dir(&out_dir) .input("src/proto.proto") .run() .expect("protoc"); // Work a...
main
identifier_name
_match.rs
prints an error. if!types_unify { return; } // Now that we know the types can be unified we find the unified type and use // it to type the entire expression. let common_type = fcx.infcx().resolve_type_vars_if_possible(&lhs_ty); ...
ast::PatQPath(ref qself, ref path) => { let self_ty = fcx.to_ty(&qself.ty); let path_res = if let Some(&d) = tcx.def_map.borrow().get(&pat.id) { d } else if qself.position == 0 { def::PathResolution { // This is just a sent...
{ let subpats = subpats.as_ref().map(|v| &v[..]); check_pat_enum(pcx, pat, path, subpats, expected); }
conditional_block
_match.rs
_ty = fcx.infcx().next_ty_var(); let pat_ty = match expected_ty.sty { ty::TyArray(_, size) => tcx.mk_array(inner_ty, { let min_len = before.len() + after.len(); match *slice { Some(_) => cmp::max(min_len, size), ...
} }
random_line_split
_match.rs
prints an error. if!types_unify { return; } // Now that we know the types can be unified we find the unified type and use // it to type the entire expression. let common_type = fcx.infcx().resolve_type_vars_if_possible(&lhs_ty); ...
(pcx: &pat_ctxt, def: def::Def, span: Span) -> bool { match def { def::DefAssociatedConst(..) => true, def::DefMethod(..) => { span_err!(pcx.fcx.ccx.tcx.sess, span, E0327, "associated items in match patterns must be constants"); false } _...
check_assoc_item_is_const
identifier_name
_match.rs
.position == 0 { def::PathResolution { // This is just a sentinel for finish_resolving_def_to_ty. base_def: def::DefMod(ast_util::local_def(ast::CRATE_NODE_ID)), last_private: LastMod(AllPublic), depth: path.segments.len() ...
{ // Typecheck the path. let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; let path_res = *tcx.def_map.borrow().get(&pat.id).unwrap(); let (opt_ty, segments, def) = match resolve_ty_and_def_ufcs(fcx, path_res, None, path, ...
identifier_body
trait-inheritance-num2.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-M...
<T:FloatExt>(n: T) { println!("{}", n < n) } pub fn main() { test_float_ext(1f32); }
test_float_ext
identifier_name
trait-inheritance-num2.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...
impl NumExt for uint {} impl NumExt for i8 {} impl NumExt for i16 {} impl NumExt for i32 {} impl NumExt for i64 {} impl NumExt for int {} impl NumExt for f32 {} impl NumExt for f64 {} pub trait UnSignedExt: NumExt {} impl UnSignedExt for u8 {} impl UnSignedExt for u16 {} impl UnSignedExt for u32 {} impl UnSignedEx...
impl NumExt for u8 {} impl NumExt for u16 {} impl NumExt for u32 {} impl NumExt for u64 {}
random_line_split
trait-inheritance-num2.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-M...
pub fn main() { test_float_ext(1f32); }
{ println!("{}", n < n) }
identifier_body
last-use-in-block.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 ...
<T>(s: StrBuf, f: |StrBuf| -> T) -> T {f(s)} g(s, |v| { let r = f(v); r }) } pub fn main() {}
g
identifier_name
last-use-in-block.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
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Issue #1818 fn lp<T>(s: StrBuf, f: |StrBuf| -> T) -> T { while false { let r = f(s); return (r); } fail!(); } fn apply<T>...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
random_line_split
last-use-in-block.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 ...
g(s, |v| { let r = f(v); r }) } pub fn main() {}
{f(s)}
identifier_body
pip.rs
use std::old_io::BufferedReader; use std::old_io::EndOfFile; use std::old_io::fs::File; use super::super::context::{BuildContext}; use super::super::packages; use super::generic::{run_command_at_env, capture_command}; pub fn scan_features(ver: u8, pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec...
"-m".to_string(), "pip".to_string(), "install".to_string(), "--ignore-installed".to_string(), ); if ctx.pip_settings.index_urls.len() > 0 { let mut indexes = ctx.pip_settings.index_urls.iter(); if let Some(ref lnk) = indexes.next() { args.push(format!("--i...
(if ver == 2 { "python2" } else { "python3" }).to_string(),
random_line_split
pip.rs
use std::old_io::BufferedReader; use std::old_io::EndOfFile; use std::old_io::fs::File; use super::super::context::{BuildContext}; use super::super::packages; use super::generic::{run_command_at_env, capture_command}; pub fn scan_features(ver: u8, pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec...
for name in pkgs.iter() { if name.as_slice().starts_with("git+") { res.push(packages::Git); } else if name.as_slice().starts_with("hg+") { res.push(packages::Mercurial); } } return res; } fn pip_args(ctx: &mut BuildContext, ver: u8) -> Vec<String> { let ...
{ res.push(packages::Python3); res.push(packages::Python3Dev); res.push(packages::PipPy3); }
conditional_block
pip.rs
use std::old_io::BufferedReader; use std::old_io::EndOfFile; use std::old_io::fs::File; use super::super::context::{BuildContext}; use super::super::packages; use super::generic::{run_command_at_env, capture_command}; pub fn
(ver: u8, pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec!(); res.push(packages::BuildEssential); if ver == 2 { res.push(packages::Python2); res.push(packages::Python2Dev); res.push(packages::PipPy2); } else { res.push(packages::Python3); res.pus...
scan_features
identifier_name
pip.rs
use std::old_io::BufferedReader; use std::old_io::EndOfFile; use std::old_io::fs::File; use super::super::context::{BuildContext}; use super::super::packages; use super::generic::{run_command_at_env, capture_command}; pub fn scan_features(ver: u8, pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec...
"pip".to_string(), "freeze".to_string(), ], &[("PYTHONPATH", "/tmp/non-existent:/tmp/pip-install")]) .and_then(|out| { File::create("/vagga/container/pip3-freeze.txt") .and_then(|mut f| f.write_all(&out)) .map_err(|e| f...
{ use std::fs::File; // TODO(tailhook) migrate whole module use std::io::Write; // TODO(tailhook) migrate whole module if ctx.featured_packages.contains(&packages::PipPy2) { try!(capture_command(ctx, &[ "python2".to_string(), "-m".to_string(), "pip"....
identifier_body
webgluniformlocation.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings:...
impl WebGLUniformLocation { fn new_inherited( id: i32, program_id: WebGLProgramId, link_generation: u64, size: Option<i32>, type_: u32, ) -> Self { Self { reflector_: Reflector::new(), id, program_id, link_generation...
link_generation: u64, size: Option<i32>, type_: u32, }
random_line_split
webgluniformlocation.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings:...
(&self) -> i32 { self.id } pub fn program_id(&self) -> WebGLProgramId { self.program_id } pub fn link_generation(&self) -> u64 { self.link_generation } pub fn size(&self) -> Option<i32> { self.size } pub fn type_(&self) -> u32 { self.type_ ...
id
identifier_name
webgluniformlocation.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings:...
pub fn size(&self) -> Option<i32> { self.size } pub fn type_(&self) -> u32 { self.type_ } }
{ self.link_generation }
identifier_body
emulator.rs
use mmu::Memory; use cart::SaveFile; use cpu::Cpu; use graphics; use timer; #[derive(Clone, Copy)] pub enum DeviceMode { GameBoy, SuperGameBoy, GameBoyColor, } pub struct Emulator { pub mem: Memory, pub cpu: Cpu, cycles: i32,
Emulator { mem: Memory::new(), cpu: Cpu::new(), cycles: 0, } } pub fn load_cart(&mut self, data: &[u8], save_file: Option<Box<SaveFile>>) { self.mem.cart.load(data, save_file); } /// Initialise the emulator with the expected startup values ...
} impl Emulator { pub fn new() -> Emulator {
random_line_split
emulator.rs
use mmu::Memory; use cart::SaveFile; use cpu::Cpu; use graphics; use timer; #[derive(Clone, Copy)] pub enum DeviceMode { GameBoy, SuperGameBoy, GameBoyColor, } pub struct
{ pub mem: Memory, pub cpu: Cpu, cycles: i32, } impl Emulator { pub fn new() -> Emulator { Emulator { mem: Memory::new(), cpu: Cpu::new(), cycles: 0, } } pub fn load_cart(&mut self, data: &[u8], save_file: Option<Box<SaveFile>>) { se...
Emulator
identifier_name
emulator.rs
use mmu::Memory; use cart::SaveFile; use cpu::Cpu; use graphics; use timer; #[derive(Clone, Copy)] pub enum DeviceMode { GameBoy, SuperGameBoy, GameBoyColor, } pub struct Emulator { pub mem: Memory, pub cpu: Cpu, cycles: i32, } impl Emulator { pub fn new() -> Emulator { Emulator {...
/// Run the emulator for one frame. To emulate the Game Boy system realistically this should be /// called at 60 Hz pub fn frame<F, G>(&mut self, mut on_tick: F, mut on_vblank: G) where F: FnMut(&mut Cpu, &mut Memory), G: FnMut(&mut Cpu, &mut Memory) { if self.mem.crashed...
{ self.cpu.start_up(); self.mem.start_up(DeviceMode::GameBoy); }
identifier_body
emulator.rs
use mmu::Memory; use cart::SaveFile; use cpu::Cpu; use graphics; use timer; #[derive(Clone, Copy)] pub enum DeviceMode { GameBoy, SuperGameBoy, GameBoyColor, } pub struct Emulator { pub mem: Memory, pub cpu: Cpu, cycles: i32, } impl Emulator { pub fn new() -> Emulator { Emulator {...
while self.cycles <= graphics::timings::FULL_FRAME as i32 { on_tick(&mut self.cpu, &mut self.mem); let instruction_time = self.cpu.step(&mut self.mem); timer::step(&mut self.mem, instruction_time); graphics::step(&mut self.mem, instruction_time); if...
{ return; }
conditional_block
identifier.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
(&self) -> Ident { use syn::Item::*; match self { Const(item) => item.ident.clone(), Enum(item) => item.ident.clone(), ExternCrate(item) => item.ident.clone(), Fn(item) => item.sig.ident.clone(), ForeignMod(_) => panic!("[bug] `ForeignMod` has no identifier (please report this issu...
ident
identifier_name
identifier.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
fn ident(&self) -> Ident; } impl ItemIdent for syn::Item { fn ident(&self) -> Ident { use syn::Item::*; match self { Const(item) => item.ident.clone(), Enum(item) => item.ident.clone(), ExternCrate(item) => item.ident.clone(), Fn(item) => item.sig.ident.clone(), ForeignMod(_) ...
pub use proc_macro2::{Ident,Span}; pub trait ItemIdent {
random_line_split
identifier.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
_ => panic!("[bug] non exhaustive case in ItemIdent for syn::Item (please report this issue)."), } } } impl ItemIdent for syn::ItemFn { fn ident(&self) -> Ident { self.sig.ident.clone() } }
{ use syn::Item::*; match self { Const(item) => item.ident.clone(), Enum(item) => item.ident.clone(), ExternCrate(item) => item.ident.clone(), Fn(item) => item.sig.ident.clone(), ForeignMod(_) => panic!("[bug] `ForeignMod` has no identifier (please report this issue)."), Impl...
identifier_body
cstore.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 hash(&self) -> Svh { decoder::get_crate_hash(self.data()) } } impl MetadataBlob { pub fn as_slice<'a>(&'a self) -> &'a [u8] { match *self { MetadataVec(ref vec) => vec.as_slice(), MetadataArchive(ref ar) => ar.as_slice(), } } }
{ decoder::get_crate_name(self.data()) }
identifier_body
cstore.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...
<'a>(&'a self) -> &'a RefCell<Vec<(String, NativeLibaryKind)> > { &self.used_libraries } pub fn add_used_link_args(&self, args: &str) { for s in args.split(' ').filter(|s|!s.is_empty()) { self.used_link_args.borrow_mut().push(s.to_string()); } ...
get_used_libraries
identifier_name
cstore.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...
self.metas.borrow().get(&cnum).clone() } pub fn get_crate_hash(&self, cnum: ast::CrateNum) -> Svh { let cdata = self.get_crate_data(cnum); decoder::get_crate_hash(cdata.data()) } pub fn set_crate_data(&self, cnum: ast::CrateNum, data: Rc<crate_metadata>) { self.metas.bo...
pub fn get_crate_data(&self, cnum: ast::CrateNum) -> Rc<crate_metadata> {
random_line_split
derive-struct.rs
/// Test crate for derive(FieldByField). extern crate field_by_field; #[macro_use] extern crate field_by_field_derive; use field_by_field::EqualFieldByField; #[derive(FieldByField, Debug)] struct Something { hello: String, val: i8, val2: i8, val3: i8, } fn noteq() -> (Something, Something) { (So...
() { let (one, two) = eq(); one.assert_equal_field_by_field(&two); }
assert_allows_identical
identifier_name
derive-struct.rs
/// Test crate for derive(FieldByField). extern crate field_by_field; #[macro_use] extern crate field_by_field_derive; use field_by_field::EqualFieldByField; #[derive(FieldByField, Debug)] struct Something { hello: String, val: i8, val2: i8, val3: i8,
fn noteq() -> (Something, Something) { (Something { hello: "one".into(), val: 1, val2: 5, val3: 3 }, Something { hello: "two".into(), val: 1, val2: 2, val3: 3 }) } fn eq() -> (Something, Something) { (Something { hello: "one".into(), val: 1, val2: 2, val3: 3 }, Something { hello: "one".into(), val: ...
}
random_line_split
derive-struct.rs
/// Test crate for derive(FieldByField). extern crate field_by_field; #[macro_use] extern crate field_by_field_derive; use field_by_field::EqualFieldByField; #[derive(FieldByField, Debug)] struct Something { hello: String, val: i8, val2: i8, val3: i8, } fn noteq() -> (Something, Something) { (So...
#[test] fn assert_allows_identical() { let (one, two) = eq(); one.assert_equal_field_by_field(&two); }
{ let (one, two) = eq(); assert_eq!(one.fields_not_equal(&two).len(), 0); }
identifier_body
main.rs
extern crate rustc_serialize; extern crate docopt; extern crate slp_sequence_hlsl_to_cl; use std::io::Read; use std::io::Write; use std::fs::File; use std::thread; use std::path::Path; use std::path::PathBuf; use docopt::Docopt; use slp_sequence_hlsl_to_cl::*; #[cfg_attr(rustfmt, rustfmt_skip)] const USAGE: &'static...
{ flag_entry_point: String, flag_o: Option<String>, flag_I: Vec<String>, arg_source_file: String, } struct FileLoader { include_paths: Vec<PathBuf>, } impl IncludeHandler for FileLoader { fn load(&mut self, file_name: &str) -> Result<String, ()> { let file_path = Path::new(file_name);...
Args
identifier_name
main.rs
extern crate rustc_serialize; extern crate docopt; extern crate slp_sequence_hlsl_to_cl; use std::io::Read; use std::io::Write; use std::fs::File; use std::thread; use std::path::Path; use std::path::PathBuf; use docopt::Docopt; use slp_sequence_hlsl_to_cl::*; #[cfg_attr(rustfmt, rustfmt_skip)] const USAGE: &'static ...
Ok(file) => file, Err(_) => { println!("Failed to open output file {}", output_file); return; } }; match file.write(output.code.to_string().as_bytes()) ...
Ok(output) => { match flag_output_file { Some(output_file) => { let mut file = match File::create(&output_file) {
random_line_split
main.rs
extern crate rustc_serialize; extern crate docopt; extern crate slp_sequence_hlsl_to_cl; use std::io::Read; use std::io::Write; use std::fs::File; use std::thread; use std::path::Path; use std::path::PathBuf; use docopt::Docopt; use slp_sequence_hlsl_to_cl::*; #[cfg_attr(rustfmt, rustfmt_skip)] const USAGE: &'static...
return; } }; let paths = flag_include_paths.iter().map(|s| PathBuf::from(s)).collect::<Vec<_>>(); for path in &paths { if!path.is_dir() { let s = match path.to_str() { Some(s) => s, None => "<invalid>", }; print...
{ let args: Args = Docopt::new(USAGE).and_then(|d| d.decode()).unwrap_or_else(|e| e.exit()); let Args { flag_entry_point, flag_o: flag_output_file, flag_I: flag_include_paths, arg_source_file } = args; let mut source_file = match File::open(&arg_source_file) { ...
identifier_body
table_colgroup.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/. */ //! CSS table formatting contexts. #![deny(unsafe_code)] use app_units::Au; use context::LayoutContext; use disp...
fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au> { panic!("Table column groups can't be containing blocks!") } fn iterate_through_fragment_border_boxes(&self, _: &mut FragmentBorderBoxIterator, ...
{ Overflow::new() }
identifier_body
table_colgroup.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/. */ //! CSS table formatting contexts. #![deny(unsafe_code)] use app_units::Au; use context::LayoutContext; use disp...
fn mutate_fragments(&mut self, _: &mut FnMut(&mut Fragment)) {} } impl fmt::Debug for TableColGroupFlow { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.fragment { Some(ref rb) => write!(f, "TableColGroupFlow: {:?}", rb), None => write!(f, "TableColGroupFlow"...
_: i32, _: &Point2D<Au>) {}
random_line_split
table_colgroup.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/. */ //! CSS table formatting contexts. #![deny(unsafe_code)] use app_units::Au; use context::LayoutContext; use disp...
(&mut self) { let _scope = layout_debug_scope!("table_colgroup::bubble_inline_sizes {:x}", self.base.debug_id()); for fragment in &self.cols { // Retrieve the specified value from the appropriate CSS property. let inline_size = fragmen...
bubble_inline_sizes
identifier_name
config_error.rs
// Copyright 2015-2020 Benjamin Fry <benjaminfry@me.com> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed...
} } impl From<ErrorKind> for Error { fn from(kind: ErrorKind) -> Error { Error { kind, backtrack: trace!(), } } } impl From<io::Error> for Error { fn from(e: io::Error) -> Error { ErrorKind::from(e).into() } } impl From<toml::de::Error> for Error {...
{ fmt::Display::fmt(&self.kind, f) }
conditional_block
config_error.rs
// Copyright 2015-2020 Benjamin Fry <benjaminfry@me.com> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed...
/// The error type for errors that get returned in the crate #[derive(Debug)] pub struct Error { kind: ErrorKind, backtrack: Option<ExtBacktrace>, } impl Error { /// Get the kind of the error pub fn kind(&self) -> &ErrorKind { &self.kind } } impl fmt::Display for Error { fn fmt(&self,...
/// An error occurred while decoding toml data #[error("toml decode error: {0}")] TomlDecode(#[from] toml::de::Error), }
random_line_split
config_error.rs
// Copyright 2015-2020 Benjamin Fry <benjaminfry@me.com> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed...
{ kind: ErrorKind, backtrack: Option<ExtBacktrace>, } impl Error { /// Get the kind of the error pub fn kind(&self) -> &ErrorKind { &self.kind } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(ref backtrace) = self.backtrack {...
Error
identifier_name
config_error.rs
// Copyright 2015-2020 Benjamin Fry <benjaminfry@me.com> // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed...
} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(ref backtrace) = self.backtrack { fmt::Display::fmt(&self.kind, f)?; fmt::Debug::fmt(backtrace, f) } else { fmt::Display::fmt(&self.kind, f) } } } imp...
{ &self.kind }
identifier_body
args.rs
/* Copyright (c) 2020, R. Ou <rqou@robertou.com> and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list o...
(&self, tokens: &mut proc_macro2::TokenStream) { self._ident.to_tokens(tokens); self._eq.to_tokens(tokens); self.ty.to_tokens(tokens); } } #[derive(Debug)] pub struct ArgWithLitStr { _ident: Ident, _eq: syn::token::Eq, pub litstr: LitStr, } impl Parse for ArgWithLitStr { fn...
to_tokens
identifier_name
args.rs
/* Copyright (c) 2020, R. Ou <rqou@robertou.com> and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list o...
syn::custom_keyword!(inner_frag_variant); syn::custom_keyword!(encode_extra_type); syn::custom_keyword!(decode_extra_type); } #[derive(Debug)] pub struct ArgWithExpr { pub ident: Ident, _eq: syn::token::Eq, pub expr: Expr, } impl Parse for ArgWithExpr { fn parse(input: ParseStream) -> syn:...
syn::custom_keyword!(pat_variant); syn::custom_keyword!(dimensions); syn::custom_keyword!(outer_frag_variant);
random_line_split
text_viewer.rs
//! # Toolbar, Scrollable Text View and File Chooser //! //! A simple text file viewer extern crate gtk; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use gtk::traits::*; use gtk::signal::Inhibit; fn main()
toolbar.add(&open_button); let scroll = gtk::ScrolledWindow::new(None, None).unwrap(); scroll.set_policy(gtk::PolicyType::Automatic, gtk::PolicyType::Automatic); scroll.add(&text_view); let vbox = gtk::Box::new(gtk::Orientation::Vertical, 0).unwrap(); vbox.pack_start(&toolbar, false, true, 0);...
{ if gtk::init().is_err() { println!("Failed to initialize GTK."); return; } let window = gtk::Window::new(gtk::WindowType::Toplevel).unwrap(); window.set_title("Text File Viewer"); window.set_window_position(gtk::WindowPosition::Center); window.set_default_size(400, 300); ...
identifier_body
text_viewer.rs
//! # Toolbar, Scrollable Text View and File Chooser //! //! A simple text file viewer extern crate gtk; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use gtk::traits::*; use gtk::signal::Inhibit; fn main() { if gtk::init().is_err()
let window = gtk::Window::new(gtk::WindowType::Toplevel).unwrap(); window.set_title("Text File Viewer"); window.set_window_position(gtk::WindowPosition::Center); window.set_default_size(400, 300); let toolbar = gtk::Toolbar::new().unwrap(); let open_icon = gtk::Image::new_from_icon_name("doc...
{ println!("Failed to initialize GTK."); return; }
conditional_block
text_viewer.rs
//! # Toolbar, Scrollable Text View and File Chooser //! //! A simple text file viewer extern crate gtk; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use gtk::traits::*; use gtk::signal::Inhibit; fn main() { if gtk::init().is_err() { println!("Failed to initialize GTK."); ...
toolbar.add(&open_button); let scroll = gtk::ScrolledWindow::new(None, None).unwrap(); scroll.set_policy(gtk::PolicyType::Automatic, gtk::PolicyType::Automatic); scroll.add(&text_view); let vbox = gtk::Box::new(gtk::Orientation::Vertical, 0).unwrap(); vbox.pack_start(&toolbar, false, true, 0);...
let open_button = gtk::ToolButton::new::<gtk::Image>(Some(&open_icon), Some("Open")).unwrap(); open_button.set_is_important(true);
random_line_split
text_viewer.rs
//! # Toolbar, Scrollable Text View and File Chooser //! //! A simple text file viewer extern crate gtk; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use gtk::traits::*; use gtk::signal::Inhibit; fn
() { if gtk::init().is_err() { println!("Failed to initialize GTK."); return; } let window = gtk::Window::new(gtk::WindowType::Toplevel).unwrap(); window.set_title("Text File Viewer"); window.set_window_position(gtk::WindowPosition::Center); window.set_default_size(400, 300); ...
main
identifier_name
mod.rs
//! HTTP Client //! //! The HTTP `Client` uses asynchronous IO, and utilizes the `Handler` trait //! to convey when IO events are available for a given request. use std::cell::RefCell; use std::fmt; use std::io; use std::marker::PhantomData; use std::rc::Rc; use std::time::Duration; use futures::{future, Poll, Async,...
impl Future for FutureResponse { type Item = Response; type Error = ::Error; fn poll(&mut self) -> Poll<Self::Item, Self::Error> { self.0.poll() } } impl<C, B> Service for Client<C, B> where C: Connect, B: Stream<Error=::Error> +'static, B::Item: AsRef<[u8]>, { type Request = ...
random_line_split
mod.rs
//! HTTP Client //! //! The HTTP `Client` uses asynchronous IO, and utilizes the `Handler` trait //! to convey when IO events are available for a given request. use std::cell::RefCell; use std::fmt; use std::io; use std::marker::PhantomData; use std::rc::Rc; use std::time::Duration; use futures::{future, Poll, Async,...
(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Future<Response>") } } impl Future for FutureResponse { type Item = Response; type Error = ::Error; fn poll(&mut self) -> Poll<Self::Item, Self::Error> { self.0.poll() } } impl<C, B> Service for Client<C, B> where C: Connect,...
fmt
identifier_name
mod.rs
//! HTTP Client //! //! The HTTP `Client` uses asynchronous IO, and utilizes the `Handler` trait //! to convey when IO events are available for a given request. use std::cell::RefCell; use std::fmt; use std::io; use std::marker::PhantomData; use std::rc::Rc; use std::time::Duration; use futures::{future, Poll, Async,...
} impl<C: Clone, B> Clone for Config<C, B> { fn clone(&self) -> Config<C, B> { Config { _body_type: PhantomData::<B>, connector: self.connector.clone(), keep_alive: self.keep_alive, keep_alive_timeout: self.keep_alive_timeout, max_idle: self.max_...
{ f.debug_struct("Config") .field("keep_alive", &self.keep_alive) .field("keep_alive_timeout", &self.keep_alive_timeout) .field("max_idle", &self.max_idle) .finish() }
identifier_body
mod.rs
pub type c_long = i32; pub type c_ulong = u32; pub type nlink_t = u32; pub type blksize_t = ::c_long; pub type __u64 = ::c_ulonglong; s! { pub struct pthread_attr_t { __size: [u32; 9] } pub struct sigset_t { __val: [::c_ulong; 32], } pub struct msghdr { pub msg_name: *mut ...
pub gid: ::gid_t, pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::mode_t, pub __seq: ::c_int, __unused1: ::c_long, __unused2: ::c_long } } pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; pub const __SIZEOF_PTHREAD_RWLOCK_T: usi...
} pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t,
random_line_split
mod.rs
//! Represents an OpenGL context and the window or environment around it. pub mod events; pub mod prelude { pub use super::events::{Event, WindowEvent}; pub use super::system::{EventListener, EventListenerHandle}; pub use super::WindowParams; } mod backends; mod system; use self::ins::{ctx, CTX}; use sel...
drop(Box::from_raw(CTX as *mut WindowSystem)); CTX = std::ptr::null(); } /// Adds a event listener. pub fn attach<T: EventListener +'static>(lis: T) -> EventListenerHandle { ctx().add_event_listener(lis) } /// Removes a event listener from window. pub fn detach(handle: EventListenerHandle) { ctx().r...
{ return; }
conditional_block
mod.rs
//! Represents an OpenGL context and the window or environment around it. pub mod events; pub mod prelude { pub use super::events::{Event, WindowEvent}; pub use super::system::{EventListener, EventListenerHandle}; pub use super::WindowParams; } mod backends; mod system; use self::ins::{ctx, CTX}; use sel...
() -> f32 { ctx().device_pixel_ratio() } mod ins { use super::system::WindowSystem; pub static mut CTX: *const WindowSystem = std::ptr::null(); #[inline] pub fn ctx() -> &'static WindowSystem { unsafe { debug_assert!( !CTX.is_null(), "window syst...
device_pixel_ratio
identifier_name
mod.rs
//! Represents an OpenGL context and the window or environment around it. pub mod events; pub mod prelude { pub use super::events::{Event, WindowEvent}; pub use super::system::{EventListener, EventListenerHandle}; pub use super::WindowParams; } mod backends; mod system; use self::ins::{ctx, CTX}; use sel...
/// Discard the window system. pub(crate) unsafe fn discard() { if CTX.is_null() { return; } drop(Box::from_raw(CTX as *mut WindowSystem)); CTX = std::ptr::null(); } /// Adds a event listener. pub fn attach<T: EventListener +'static>(lis: T) -> EventListenerHandle { ctx().add_event_liste...
{ ctx().resize(dimensions); }
identifier_body
mod.rs
//! Represents an OpenGL context and the window or environment around it. pub mod events; pub mod prelude { pub use super::events::{Event, WindowEvent}; pub use super::system::{EventListener, EventListenerHandle}; pub use super::WindowParams; } mod backends;
use self::ins::{ctx, CTX}; use self::system::{EventListener, EventListenerHandle, WindowSystem}; use crate::errors::*; use crate::math::prelude::Vector2; #[derive(Debug, Clone)] pub struct WindowParams { /// Sets the title of window. pub title: String, /// Sets the size in *points* of the client area of t...
mod system;
random_line_split
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
#![doc( html_logo_url = "https://raw.githubusercontent.com/rusoto/rusoto/master/assets/logo-square.png" )] //! <p><fullname>Amazon Simple Email Service</fullname> <p> This document contains reference information for the <a href="https://aws.amazon.com/ses/">Amazon Simple Email Service</a> (Amazon SES) API, version ...
// must be updated to generate the changes. // // =================================================================
random_line_split
day_2.rs
pub use tdd_kata::map_kata::day_2::Map; #[test] fn it_should_create_an_empty_map() { let map = Map::new(10); assert_eq!(map.len(), 0); assert!(map.is_empty()); } #[test] fn it_should_increase_map_size_when_put() { let mut map = Map::new(10); let old_size = map.len(); map.put(1, 1); asse...
}
assert_eq!(map.len(), old_size);
random_line_split
day_2.rs
pub use tdd_kata::map_kata::day_2::Map; #[test] fn
() { let map = Map::new(10); assert_eq!(map.len(), 0); assert!(map.is_empty()); } #[test] fn it_should_increase_map_size_when_put() { let mut map = Map::new(10); let old_size = map.len(); map.put(1, 1); assert_eq!(map.len(), old_size + 1); } #[test] fn it_should_decrease_map_size_when_r...
it_should_create_an_empty_map
identifier_name
day_2.rs
pub use tdd_kata::map_kata::day_2::Map; #[test] fn it_should_create_an_empty_map() { let map = Map::new(10); assert_eq!(map.len(), 0); assert!(map.is_empty()); } #[test] fn it_should_increase_map_size_when_put() { let mut map = Map::new(10); let old_size = map.len(); map.put(1, 1); asse...
#[test] #[ignore] fn it_should_not_increase_map_size_when_put_same_key() { let mut map = Map::new(10); map.put(1, 1); let old_size = map.len(); map.put(1, 2); assert_eq!(map.len(), old_size); }
{ let mut map = Map::new(10); map.put(1, 1); let old_size = map.len(); map.remove(1); assert_eq!(map.len(), old_size - 1); }
identifier_body
closure.rs
// (and the referenced type descriptors) will be allocated in the // exchange heap. For a fn, the closure is allocated in the task heap // and is reference counted. For a block, the closure is allocated on // the stack. // // ## Opaque closures and the embedded type descriptor ## // // One interesting part of closure...
} pub fn make_opaque_cbox_take_glue( bcx: block, sigil: ast::Sigil, cboxptr: ValueRef) // ptr to ptr to the opaque closure -> block { // Easy cases: let _icx = push_ctxt("closure::make_opaque_cbox_take_glue"); match sigil { ast::BorrowedSigil => { return bcx; ...
let closure_ty = ty::mk_opaque_closure_ptr(tcx, sigil); glue_fn(bcx, box_cell_v, closure_ty) } } }
random_line_split
closure.rs
(and the referenced type descriptors) will be allocated in the // exchange heap. For a fn, the closure is allocated in the task heap // and is reference counted. For a block, the closure is allocated on // the stack. // // ## Opaque closures and the embedded type descriptor ## // // One interesting part of closures ...
(bcx: block, llbox: ValueRef) { let _icx = push_ctxt("closure::nuke_ref_count"); // Initialize ref count to arbitrary value for debugging: let ccx = bcx.ccx(); let llbox = PointerCast(bcx, llbox, Type::opaque_box(ccx).ptr_to()); let ref_cnt = GEPi(bcx, llbox, [0u, abi::box_field_...
nuke_ref_count
identifier_name
repositories.rs
// Low-level database access traits. // Each repository is responsible for a single entity and // its relationships. Related entities are only referenced // by their id and never modified or loaded by another // repository. use super::{entities::*, error::RepoError, util::time::Timestamp}; type Result<T> = std::resul...
( &self, ratings: Vec<Rating>, ) -> Result<Vec<(Rating, Vec<Comment>)>> { let mut results = Vec::with_capacity(ratings.len()); for rating in ratings { debug_assert!(rating.archived.is_none()); let comments = self.load_comments_of_rating(&rating.id)?; ...
zip_ratings_with_comments
identifier_name
repositories.rs
// Low-level database access traits. // Each repository is responsible for a single entity and // its relationships. Related entities are only referenced // by their id and never modified or loaded by another // repository. use super::{entities::*, error::RepoError, util::time::Timestamp}; type Result<T> = std::resul...
fn archive_comments(&self, ids: &[&str], archived: Timestamp) -> Result<usize>; fn archive_comments_of_ratings( &self, rating_ids: &[&str], archived: Timestamp, ) -> Result<usize>; fn archive_comments_of_entries(&self, entry_ids: &[&str], archived: Timestamp) -> Result<...
{ let mut results = Vec::with_capacity(ratings.len()); for rating in ratings { debug_assert!(rating.archived.is_none()); let comments = self.load_comments_of_rating(&rating.id)?; results.push((rating, comments)); } Ok(results) }
identifier_body
repositories.rs
// Low-level database access traits. // Each repository is responsible for a single entity and // its relationships. Related entities are only referenced // by their id and never modified or loaded by another // repository. use super::{entities::*, error::RepoError, util::time::Timestamp}; type Result<T> = std::resul...
// Only unarchived ratings without comments fn load_rating(&self, id: &str) -> Result<Rating>; fn load_ratings(&self, ids: &[&str]) -> Result<Vec<Rating>>; fn load_ratings_of_entry(&self, entry_id: &str) -> Result<Vec<Rating>>; fn archive_ratings(&self, ids: &[&str], archived: Timestamp) -> Result<...
fn create_rating(&self, rating: Rating) -> Result<()>;
random_line_split
config.rs
use std::collections::HashMap; use std::rc::Rc; use serde::de::{Deserialize, Deserializer}; use serde_derive::Deserialize; use toml::value; use crate::errors; use crate::icons::Icons; use crate::protocol::i3bar_event::MouseButton; use crate::themes::Theme; #[derive(Debug)] pub struct SharedConfig { pub theme: Rc...
(&mut self, overrides: HashMap<String, String>) { let mut icons = self.icons.as_ref().clone(); icons.0.extend(overrides); self.icons = Rc::new(icons); } pub fn get_icon(&self, icon: &str) -> crate::errors::Result<String> { use crate::errors::OptionExt; Ok(self.icons_form...
icons_override
identifier_name
config.rs
use std::collections::HashMap; use std::rc::Rc; use serde::de::{Deserialize, Deserializer}; use serde_derive::Deserialize; use toml::value; use crate::errors; use crate::icons::Icons; use crate::protocol::i3bar_event::MouseButton; use crate::themes::Theme; #[derive(Debug)] pub struct SharedConfig { pub theme: Rc...
impl Default for Config { fn default() -> Self { Config { icons: Icons::default(), theme: Theme::default(), icons_format: Config::default_icons_format(), scrolling: Scrolling::default(), blocks: Vec::new(), } } } #[derive(Deserialize, ...
}
random_line_split
config.rs
use std::collections::HashMap; use std::rc::Rc; use serde::de::{Deserialize, Deserializer}; use serde_derive::Deserialize; use toml::value; use crate::errors; use crate::icons::Icons; use crate::protocol::i3bar_event::MouseButton; use crate::themes::Theme; #[derive(Debug)] pub struct SharedConfig { pub theme: Rc...
pub fn get_icon(&self, icon: &str) -> crate::errors::Result<String> { use crate::errors::OptionExt; Ok(self.icons_format.clone().replace( "{icon}", self.icons .0 .get(icon) .internal_error("get_icon()", &format!("icon '{}' not fo...
{ let mut icons = self.icons.as_ref().clone(); icons.0.extend(overrides); self.icons = Rc::new(icons); }
identifier_body