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
generic-tuple-style-enum.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { () }
zzz
identifier_name
compute_squared_distance.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 crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use derive_common::cg; use...
}), quote!(+)); sum }; return quote! { (&#this_pattern, &#other_pattern) => Ok(#sum), }; } #[derive(Default, FromField)] #[darling(attributes(distance), default)] struct DistanceFieldAttrs { field_bound: bool, }
{ quote! { crate::values::distance::ComputeSquaredDistance::compute_squared_distance(#this, #other)? } }
conditional_block
compute_squared_distance.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 crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use derive_common::cg; use...
input.generics.where_clause = where_clause; if needs_catchall_branch { // This ideally shouldn't be needed, but see: // https://github.com/rust-lang/rust/issues/68867 match_body.append_all(quote! { _ => unsafe { debug_unreachable!() } }); } let name = &input.ident; let (imp...
random_line_split
compute_squared_distance.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 crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use derive_common::cg; use...
( variant: &synstructure::VariantInfo, mut where_clause: &mut Option<WhereClause>, ) -> TokenStream { let variant_attrs = cg::parse_variant_attrs_from_ast::<AnimationVariantAttrs>(&variant.ast()); let (this_pattern, this_info) = cg::ref_pattern(&variant, "this"); let (other_pattern, other_info) = cg...
derive_variant_arm
identifier_name
ipv4.rs
use common::get_slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct Ipv4Header { pub ver_hlen: u8, pub services: u8, pub len: n16, pub id: n16, pub flags_fragment: n16, pub ttl: u8, p...
impl FromBytes for Ipv4 { fn from_bytes(bytes: Vec<u8>) -> Option<Self> { if bytes.len() >= mem::size_of::<Ipv4Header>() { unsafe { let header = *(bytes.as_ptr() as *const Ipv4Header); let header_len = ((header.ver_hlen & 0xF) << 2) as usize; retu...
}
random_line_split
ipv4.rs
use common::get_slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct Ipv4Header { pub ver_hlen: u8, pub services: u8, pub len: n16, pub id: n16, pub flags_fragment: n16, pub ttl: u8, p...
None } } impl ToBytes for Ipv4 { fn to_bytes(&self) -> Vec<u8> { unsafe { let header_ptr: *const Ipv4Header = &self.header; let mut ret = Vec::<u8>::from(slice::from_raw_parts(header_ptr as *const u8, mem::...
{ unsafe { let header = *(bytes.as_ptr() as *const Ipv4Header); let header_len = ((header.ver_hlen & 0xF) << 2) as usize; return Some(Ipv4 { header: header, options: bytes.get_slice(Some(mem::size_of::<Ipv4Header>()), S...
conditional_block
ipv4.rs
use common::get_slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct
{ pub ver_hlen: u8, pub services: u8, pub len: n16, pub id: n16, pub flags_fragment: n16, pub ttl: u8, pub proto: u8, pub checksum: Checksum, pub src: Ipv4Addr, pub dst: Ipv4Addr, } pub struct Ipv4 { pub header: Ipv4Header, pub options: Vec<u8>, pub data: Vec<u8>, }...
Ipv4Header
identifier_name
ipv4.rs
use common::get_slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct Ipv4Header { pub ver_hlen: u8, pub services: u8, pub len: n16, pub id: n16, pub flags_fragment: n16, pub ttl: u8, p...
} impl ToBytes for Ipv4 { fn to_bytes(&self) -> Vec<u8> { unsafe { let header_ptr: *const Ipv4Header = &self.header; let mut ret = Vec::<u8>::from(slice::from_raw_parts(header_ptr as *const u8, mem::size_of::<Ipv4Heade...
{ if bytes.len() >= mem::size_of::<Ipv4Header>() { unsafe { let header = *(bytes.as_ptr() as *const Ipv4Header); let header_len = ((header.ver_hlen & 0xF) << 2) as usize; return Some(Ipv4 { header: header, optio...
identifier_body
text.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang (letang.jeremy@gmail.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitati...
{ pub x: i32, pub y: i32, pub text: String, pub attribs: HashMap<String, String>, pub transform: Option<Transform> } impl SVGEntity for Text { fn gen_output(&self) -> String { let mut o = String::new(); o.push_str(format!("<text x=\"{}\" y=\"{}\"", se...
Text
identifier_name
text.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang (letang.jeremy@gmail.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitati...
}
o }
random_line_split
du.rs
use std::fs::{read_dir, symlink_metadata}; use std::path::{PathBuf, Path}; use std::io; use std::env; use std::os::unix::fs::MetadataExt; #[derive(Debug)] pub enum
{ File { size: u64 }, Directory { size: u64, children: Vec<Entry> }, OtherFs, Error(io::Error), Other, } #[derive(Debug)] pub struct Entry(pub PathBuf, pub EntryData); impl Entry { pub fn size(&self) -> u64 { let Entry(_, ref data) = *self; match data { &EntryData...
EntryData
identifier_name
du.rs
use std::fs::{read_dir, symlink_metadata}; use std::path::{PathBuf, Path}; use std::io; use std::env; use std::os::unix::fs::MetadataExt; #[derive(Debug)] pub enum EntryData { File { size: u64 }, Directory { size: u64, children: Vec<Entry> }, OtherFs, Error(io::Error), Other, } #[derive(Debug)] p...
if m.is_file() { return Entry(name, EntryData::File { size: m.len() }); } else if m.is_dir() { let cwd = env::current_dir().unwrap(); if let Err(err) = env::set_current_dir(&name) { return Entry(name, EntryData::Error(err)); } let dir_list = read_dir("."); ...
{ let m = symlink_metadata(name); let name = PathBuf::from(name); if let Err(err) = m { return Entry(name, EntryData::Error(err)); } let m = m.unwrap(); let mdev = m.dev(); let dev = dev.unwrap_or(if xfs { mdev } else { 0 }); if xfs && mdev != dev { return Entry(na...
identifier_body
du.rs
use std::fs::{read_dir, symlink_metadata}; use std::path::{PathBuf, Path}; use std::io; use std::env; use std::os::unix::fs::MetadataExt; #[derive(Debug)] pub enum EntryData { File { size: u64 }, Directory { size: u64, children: Vec<Entry> }, OtherFs, Error(io::Error), Other, } #[derive(Debug)] pu...
match data { &EntryData::File{size} => size, &EntryData::Directory{size,..} => size, _ => 0 } } } pub fn process_entry(name: &Path, xfs: bool, dev: Option<u64>) -> Entry { let m = symlink_metadata(name); let name = PathBuf::from(name); if let Err(...
impl Entry { pub fn size(&self) -> u64 { let Entry(_, ref data) = *self;
random_line_split
du.rs
use std::fs::{read_dir, symlink_metadata}; use std::path::{PathBuf, Path}; use std::io; use std::env; use std::os::unix::fs::MetadataExt; #[derive(Debug)] pub enum EntryData { File { size: u64 }, Directory { size: u64, children: Vec<Entry> }, OtherFs, Error(io::Error), Other, } #[derive(Debug)] p...
}
{ return Entry(name, EntryData::Other); }
conditional_block
lib.rs
#![allow(unknown_lints)] // Allow clippy lints. extern crate alga; extern crate arrayvec; extern crate decorum; #[macro_use] extern crate failure; #[macro_use] extern crate gfx; extern crate gfx_device_gl; extern crate gfx_window_glutin; extern crate glutin; extern crate image; #[macro_use] extern crate lazy_static; e...
<F>(mut self, f: F) -> Self where F: Fn(&T) -> bool, { match self.take() { Some(value) => if f(&value) { Some(value) } else { None }, _ => None, } } }
and_if
identifier_name
lib.rs
#![allow(unknown_lints)] // Allow clippy lints. extern crate alga; extern crate arrayvec; extern crate decorum; #[macro_use] extern crate failure; #[macro_use] extern crate gfx; extern crate gfx_device_gl; extern crate gfx_window_glutin; extern crate glutin; extern crate image; #[macro_use] extern crate lazy_static; e...
Some(value) => if f(&value) { Some(value) } else { None }, _ => None, } } }
fn and_if<F>(mut self, f: F) -> Self where F: Fn(&T) -> bool, { match self.take() {
random_line_split
lib.rs
#![allow(unknown_lints)] // Allow clippy lints. extern crate alga; extern crate arrayvec; extern crate decorum; #[macro_use] extern crate failure; #[macro_use] extern crate gfx; extern crate gfx_device_gl; extern crate gfx_window_glutin; extern crate glutin; extern crate image; #[macro_use] extern crate lazy_static; e...
} pub trait OptionExt<T> { fn and_if<F>(self, f: F) -> Self where F: Fn(&T) -> bool; } impl<T> OptionExt<T> for Option<T> { fn and_if<F>(mut self, f: F) -> Self where F: Fn(&T) -> bool, { match self.take() { Some(value) => if f(&value) { Some(va...
{ if self { Some(some) } else { None } }
identifier_body
reentrant.rs
//! Module to handle reentrant/recursion limits while deserializing. use std::cell::Cell; use std::rc::Rc;
/// not do any synchronization -- it is intended purely for single-threaded use. pub struct ReentrantLimit(Rc<Cell<usize>>); impl ReentrantLimit { /// Create a new reentrant limit. pub fn new(limit: usize) -> Self { ReentrantLimit(Rc::new(Cell::new(limit))) } /// Try to decrease the limit by 1...
use crate::errors::*; /// Sets a limit on the amount of recursion during deserialization. This does
random_line_split
reentrant.rs
//! Module to handle reentrant/recursion limits while deserializing. use std::cell::Cell; use std::rc::Rc; use crate::errors::*; /// Sets a limit on the amount of recursion during deserialization. This does /// not do any synchronization -- it is intended purely for single-threaded use. pub struct ReentrantLimit(Rc<...
(limit: usize) -> Self { ReentrantLimit(Rc::new(Cell::new(limit))) } /// Try to decrease the limit by 1. Return an RAII guard that when freed /// will increase the limit by 1. pub fn acquire<S: Into<String>>(&mut self, kind: S) -> Result<ReentrantGuard> { if self.0.get() == 0 { ...
new
identifier_name
reentrant.rs
//! Module to handle reentrant/recursion limits while deserializing. use std::cell::Cell; use std::rc::Rc; use crate::errors::*; /// Sets a limit on the amount of recursion during deserialization. This does /// not do any synchronization -- it is intended purely for single-threaded use. pub struct ReentrantLimit(Rc<...
self.0.set(self.0.get() - 1); Ok(ReentrantGuard(self.0.clone())) } } /// RAII guard for reentrant limits. pub struct ReentrantGuard(Rc<Cell<usize>>); impl Drop for ReentrantGuard { fn drop(&mut self) { self.0.set(self.0.get() + 1); } }
{ bail!(ErrorKind::DeRecursionLimitExceeded(kind.into())); }
conditional_block
method-on-generic-struct.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} fn main() { let stack = Struct { x: (8888_u32, -8888_i32) }; let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); let owned = box Struct { x: 1234.5f64 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); } fn zzz(...
{ zzz(); // #break arg1 + arg2 }
identifier_body
method-on-generic-struct.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(self: Box<Struct<T>>, arg1: int, arg2: int) -> int { zzz(); // #break arg1 + arg2 } } fn main() { let stack = Struct { x: (8888_u32, -8888_i32) }; let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); let owned = box Struct { x: 1234.5f64 }; let _ = owned.self_...
self_owned
identifier_name
method-on-generic-struct.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// lldb-command:continue // STACK BY VAL // lldb-command:print self // lldb-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) } // lldb-command:print arg1 // lldb-check:[...]$4 = -3 // lldb-command:print arg2 // lldb-check:[...]$5 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self // lldb-c...
// lldb-command:print arg1 // lldb-check:[...]$1 = -1 // lldb-command:print arg2 // lldb-check:[...]$2 = -2
random_line_split
web.rs
use std::io::Read; use std::{thread, time}; use hyper::Client; use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; use hyper::Ok; use kuchiki; use kuchiki::traits::TendrilSink; fn fetch_url(url: &str) -> impl Read
pub fn fetch_html(url: &str) -> kuchiki::NodeRef { let mut response = fetch_url(url); kuchiki::parse_html() .from_utf8() .read_from(&mut response) .unwrap() } pub fn fetch_string(url: &str) -> String { let mut response = fetch_url(url); let mut response_string = String::new(); response.read_to_strin...
{ //we're going to be nice to the maintainers of the donation tracker //to avoid DDOSing them, add a delay between each request let delay_milliseconds = 100; thread::sleep(time::Duration::from_millis(delay_milliseconds)); //perform the request and read the repsonse into a string let ssl = NativeTlsClient::new()....
identifier_body
web.rs
use std::io::Read; use std::{thread, time}; use hyper::Client; use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; use hyper::Ok; use kuchiki; use kuchiki::traits::TendrilSink; fn fetch_url(url: &str) -> impl Read { //we're going to be nice to the maintainers of the donation tracker //to avoid D...
(url: &str) -> String { let mut response = fetch_url(url); let mut response_string = String::new(); response.read_to_string(&mut response_string).unwrap(); response_string }
fetch_string
identifier_name
web.rs
use std::io::Read; use std::{thread, time}; use hyper::Client; use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; use hyper::Ok; use kuchiki; use kuchiki::traits::TendrilSink; fn fetch_url(url: &str) -> impl Read { //we're going to be nice to the maintainers of the donation tracker //to avoid D...
} pub fn fetch_html(url: &str) -> kuchiki::NodeRef { let mut response = fetch_url(url); kuchiki::parse_html() .from_utf8() .read_from(&mut response) .unwrap() } pub fn fetch_string(url: &str) -> String { let mut response = fetch_url(url); let mut response_string = String::new(); response.read_to_stri...
response
random_line_split
mozjs-error.rs
// run-pass #![allow(dead_code)] #![allow(non_upper_case_globals)] struct CustomAutoRooterVFTable { trace: unsafe extern "C" fn(this: *mut i32, trc: *mut u32), } unsafe trait CustomAutoTraceable: Sized { const vftable: CustomAutoRooterVFTable = CustomAutoRooterVFTable { trace: Self::trace, }; ...
fn main() { let _ = <()>::vftable; }
random_line_split
mozjs-error.rs
// run-pass #![allow(dead_code)] #![allow(non_upper_case_globals)] struct CustomAutoRooterVFTable { trace: unsafe extern "C" fn(this: *mut i32, trc: *mut u32), } unsafe trait CustomAutoTraceable: Sized { const vftable: CustomAutoRooterVFTable = CustomAutoRooterVFTable { trace: Self::trace, }; ...
() { let _ = <()>::vftable; }
main
identifier_name
run-pass.rs
// run-pass #![feature(if_let_guard)] enum Foo { Bar, Baz, Qux(u8), } fn bar(x: bool) -> Foo { if x { Foo::Baz } else { Foo::Bar } } fn baz(x: u8) -> Foo { if x % 2 == 0 { Foo::Bar } else { Foo::Baz } } fn qux(x: u8) -> Foo { Foo::Qux(x.rotate_left(1)) } fn main() { match Some((true, 3...
match Some(42) { Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84), _ => panic!(), } }
random_line_split
run-pass.rs
// run-pass #![feature(if_let_guard)] enum Foo { Bar, Baz, Qux(u8), } fn bar(x: bool) -> Foo { if x { Foo::Baz } else { Foo::Bar } } fn baz(x: u8) -> Foo { if x % 2 == 0
else { Foo::Baz } } fn qux(x: u8) -> Foo { Foo::Qux(x.rotate_left(1)) } fn main() { match Some((true, 3)) { Some((x, _)) if let Foo::Bar = bar(x) => panic!(), Some((_, x)) if let Foo::Baz = baz(x) => {}, _ => panic!(), } match Some(42) { Some(x) if let Foo::Qux(y) = qu...
{ Foo::Bar }
conditional_block
run-pass.rs
// run-pass #![feature(if_let_guard)] enum Foo { Bar, Baz, Qux(u8), } fn
(x: bool) -> Foo { if x { Foo::Baz } else { Foo::Bar } } fn baz(x: u8) -> Foo { if x % 2 == 0 { Foo::Bar } else { Foo::Baz } } fn qux(x: u8) -> Foo { Foo::Qux(x.rotate_left(1)) } fn main() { match Some((true, 3)) { Some((x, _)) if let Foo::Bar = bar(x) => panic!(), Some((_, x)) if let...
bar
identifier_name
run-pass.rs
// run-pass #![feature(if_let_guard)] enum Foo { Bar, Baz, Qux(u8), } fn bar(x: bool) -> Foo { if x { Foo::Baz } else { Foo::Bar } } fn baz(x: u8) -> Foo { if x % 2 == 0 { Foo::Bar } else { Foo::Baz } } fn qux(x: u8) -> Foo
fn main() { match Some((true, 3)) { Some((x, _)) if let Foo::Bar = bar(x) => panic!(), Some((_, x)) if let Foo::Baz = baz(x) => {}, _ => panic!(), } match Some(42) { Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84), _ => panic!(), } }
{ Foo::Qux(x.rotate_left(1)) }
identifier_body
errors.rs
use toml; use std::error; use std::fmt::{self, Display}; #[derive(Debug)] pub enum Error { Parsing(Vec<toml::ParserError>), MissingKey(String), ExpectedType(&'static str, String), PackageNotFound(String), TargetNotFound(String), MissingRoot, UnsupportedVersion(String), } impl error::Error...
(&self) -> Option<&error::Error> { None } } impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { use self::Error::*; match *self { Parsing(ref n) => { for e in n { try!(e.fmt(f)); ...
cause
identifier_name
errors.rs
use toml;
use std::error; use std::fmt::{self, Display}; #[derive(Debug)] pub enum Error { Parsing(Vec<toml::ParserError>), MissingKey(String), ExpectedType(&'static str, String), PackageNotFound(String), TargetNotFound(String), MissingRoot, UnsupportedVersion(String), } impl error::Error for Error ...
random_line_split
main.rs
use std::fs; use std::io; use std::io::Read; use clap::{App, Arg}; mod llvm_runner; mod optimizer; mod parser; mod runner; mod structs; #[cfg(feature = "llvm")] use llvm_runner::LlvmState; use parser::parse; use runner::State; use structs::OpStream; fn
() { let app = App::new("BrainRust") .arg( Arg::with_name("dry-run") .short("n") .long("dry-run") .help("Don't actually execute the program"), ) .arg( Arg::with_name("no-optimize") .short("0") .l...
main
identifier_name
main.rs
use std::fs; use std::io; use std::io::Read; use clap::{App, Arg}; mod llvm_runner; mod optimizer; mod parser; mod runner; mod structs; #[cfg(feature = "llvm")] use llvm_runner::LlvmState; use parser::parse; use runner::State; use structs::OpStream; fn main() { let app = App::new("BrainRust") .arg( ...
for filename in matches.values_of("FILES").unwrap() { let buffer = match read_file(filename) { Ok(v) => v, Err(e) => { eprintln!("Error while reading {}: {}", filename, e); continue; } }; let ops = match parse(&buffer) { ...
random_line_split
main.rs
use std::fs; use std::io; use std::io::Read; use clap::{App, Arg}; mod llvm_runner; mod optimizer; mod parser; mod runner; mod structs; #[cfg(feature = "llvm")] use llvm_runner::LlvmState; use parser::parse; use runner::State; use structs::OpStream; fn main()
.long("llvm") .help("Execute using LLVM JIT"), ); let matches = app.get_matches(); let dry_run = matches.is_present("dryrun"); let no_optimize = matches.is_present("no-optimize"); let use_llvm = cfg!(feature = "llvm") && matches.is_present("llvm"); for filename in matche...
{ let app = App::new("BrainRust") .arg( Arg::with_name("dry-run") .short("n") .long("dry-run") .help("Don't actually execute the program"), ) .arg( Arg::with_name("no-optimize") .short("0") ...
identifier_body
main.rs
use std::fs; use std::io; use std::io::Read; use clap::{App, Arg}; mod llvm_runner; mod optimizer; mod parser; mod runner; mod structs; #[cfg(feature = "llvm")] use llvm_runner::LlvmState; use parser::parse; use runner::State; use structs::OpStream; fn main() { let app = App::new("BrainRust") .arg( ...
}; let mut opstream = OpStream { ops }; if!(use_llvm || no_optimize) { opstream.optimize(); } if!dry_run { if use_llvm { #[cfg(feature = "llvm")] LlvmState::new(&mut io::stdin(), &mut io::stdout(),!no_optimize) ...
{ eprintln!("Error while parsing {}: {}", filename, e); continue; }
conditional_block
text_renderer.rs
use std::default::Default; use gfx::{ BlendPreset, BufferHandle, BufferUsage, Device, DeviceExt, DrawState, Frame, Graphics, Mesh, PrimitiveType, ProgramError, ProgramHandle, Resources, Slice, SliceKind, VertexCount, TextureHandle, }; use gfx::tex::{...
struct Vertex { position: [f32; 2], texcoords: [f32; 2], world_position: [f32; 3], screen_relative: i32, color: [f32; 4], } #[shader_param] struct TextShaderParams<R: Resources> { u_model_view_proj: [[f32; 4]; 4], u_screen_size: [f32; 2], u_tex_font: TextureParam<R>, }
#[derive(Copy)] #[derive(Clone)] #[derive(Debug)]
random_line_split
text_renderer.rs
use std::default::Default; use gfx::{ BlendPreset, BufferHandle, BufferUsage, Device, DeviceExt, DrawState, Frame, Graphics, Mesh, PrimitiveType, ProgramError, ProgramHandle, Resources, Slice, SliceKind, VertexCount, TextureHandle, }; use gfx::tex::{...
(&mut self, width: u32, height: u32) { self.params.u_screen_size = [width as f32, height as f32]; } pub fn draw_text_at_position( &mut self, text: &str, world_position: [f32; 3], color: [f32; 4], ) { self.draw_text(text, [0, 0], world_position, 0, color); ...
resize
identifier_name
http.rs
extern crate websocket; extern crate hyper; extern crate serde_json; use std::thread; use self::hyper::header::{ContentLength, ContentType}; use self::hyper::mime::{Mime, TopLevel, SubLevel}; use self::hyper::server::{Request, Response}; use self::hyper::status::StatusCode; use self::hyper::uri::RequestUri; const HEA...
}; res.headers_mut() .set(ContentLength(get_response.len() as u64)); res.send(get_response).unwrap(); }) .unwrap(); }) } pub fn port() -> i32 { 8080 }
{ *res.status_mut() = StatusCode::MethodNotAllowed; b"502" }
conditional_block
http.rs
extern crate websocket; extern crate hyper; extern crate serde_json; use std::thread; use self::hyper::header::{ContentLength, ContentType}; use self::hyper::mime::{Mime, TopLevel, SubLevel}; use self::hyper::server::{Request, Response}; use self::hyper::status::StatusCode; use self::hyper::uri::RequestUri; const HEA...
() -> thread::JoinHandle<()> { thread::spawn(|| { let addr = format!("0.0.0.0:{}", port()); let server = hyper::Server::http(addr).unwrap(); let index = format!("{}<script>{}</script>", HEADER, SCRIPT); server .handle(move |req: Request, mut res: Response| { ...
start_thread
identifier_name
http.rs
extern crate websocket; extern crate hyper; extern crate serde_json; use std::thread; use self::hyper::header::{ContentLength, ContentType}; use self::hyper::mime::{Mime, TopLevel, SubLevel}; use self::hyper::server::{Request, Response}; use self::hyper::status::StatusCode; use self::hyper::uri::RequestUri; const HEA...
{ 8080 }
identifier_body
http.rs
extern crate websocket; extern crate hyper; extern crate serde_json; use std::thread; use self::hyper::header::{ContentLength, ContentType}; use self::hyper::mime::{Mime, TopLevel, SubLevel}; use self::hyper::server::{Request, Response}; use self::hyper::status::StatusCode; use self::hyper::uri::RequestUri; const HEA...
vec![]))); include_bytes!("html/favicon.ico") } _ => { *res.status_mut() = StatusCode::NotFound; b"404" ...
.set(ContentType(Mime(TopLevel::Image, SubLevel::Ext("x-icon".to_string()),
random_line_split
compositor_thread.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/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::CompositingReason; use eucli...
(&mut self) -> Option<Msg> { self.try_recv().ok() } fn recv_compositor_msg(&mut self) -> Msg { self.recv().unwrap() } } pub trait RenderListener { fn recomposite(&mut self, reason: CompositingReason); } impl RenderListener for Box<CompositorProxy +'static> { fn recomposite(&mut sel...
try_recv_compositor_msg
identifier_name
compositor_thread.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/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::CompositingReason; use eucli...
CreatePng(IpcSender<Option<Image>>), /// Alerts the compositor that the viewport has been constrained in some manner ViewportConstrained(PipelineId, ViewportConstraints), /// A reply to the compositor asking if the output image is stable. IsReadyToSaveImageReply(bool), /// A favicon was detected...
random_line_split
vec-res-add.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 ...
{ i:int } fn r(i:int) -> r { r { i: i } } impl Drop for r { fn drop(&mut self) {} } fn main() { // This can't make sense as it would copy the classes let i = vec!(r(0)); let j = vec!(r(1)); let k = i + j; //~^ ERROR not implemented println!("{}", j); //~^ ERROR not implemented }
r
identifier_name
vec-res-add.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 ...
}
random_line_split
vec-res-add.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 ...
{ // This can't make sense as it would copy the classes let i = vec!(r(0)); let j = vec!(r(1)); let k = i + j; //~^ ERROR not implemented println!("{}", j); //~^ ERROR not implemented }
identifier_body
function-arg-initialization.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// lldb-command:print b // lldb-check:[...]$9 = 23 // lldb-command:print c // lldb-check:[...]$10 = 24.5 // lldb-command:continue // FUNCTION CALL // lldb-command:print x // lldb-check:[...]$11 = 25 // lldb-command:print y // lldb-check:[...]$12 = 26 // lldb-command:print z // lldb-check:[...]$13 = 27.5 // lldb-comman...
// lldb-command:print a // lldb-check:[...]$8 = 22
random_line_split
function-arg-initialization.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(a: int, b: bool, c: f64) { ::std::old_io::print("") // #break } struct BigStruct { a: u64, b: u64, c: u64, d: u64, e: u64, f: u64, g: u64, h: u64 } fn non_immediate_args(a: BigStruct, b: BigStruct) { ::std::old_io::print("") // #break } fn binding(a: i64, b: u64, c: f64) { ...
immediate_args
identifier_name
function-arg-initialization.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
f: 16, g: 17, h: 18 } ); binding(19, 20, 21.5); assignment(22, 23, 24.5); function_call(25, 26, 27.5); identifier(28, 29, 30.5); return_expr(31, 32, 33.5); arithmetic_expr(34, 35, 36.5); if_expr(37, 38, 39.5); while_expr(40, 41, 42); l...
{ immediate_args(1, true, 2.5); non_immediate_args( BigStruct { a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10 }, BigStruct { a: 11, b: 12, c: 13, ...
identifier_body
function-arg-initialization.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} fn while_expr(mut x: u64, y: u64, z: u64) -> u64 { while x + y > 1000 { // #break x += z } return x; } fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 { loop { // #break x += z; if x + y > 1000 { return x; } } } fn main() { immediate_args(1, tru...
{ y }
conditional_block
lib.rs
#[macro_use] extern crate lazy_static; extern crate regex; extern crate rusqlite; pub mod weblog; use regex::Regex; use weblog::Weblog; use rusqlite::Connection; // Take an unprocessed string representing a single line of an Apache log, // attempt to match the various components of the string, and generate a Weblog ...
\"(.+)\" ").expect("Unable to compile Regex"); } // This used to print to stdout before returning None, but the calling // program should do the printing. let cap = match RE.captures(line) { Some(x) => x, None => { return None; } }; le...
\"(\\S+)\"\\s
random_line_split
lib.rs
#[macro_use] extern crate lazy_static; extern crate regex; extern crate rusqlite; pub mod weblog; use regex::Regex; use weblog::Weblog; use rusqlite::Connection; // Take an unprocessed string representing a single line of an Apache log, // attempt to match the various components of the string, and generate a Weblog ...
return None; } }; let logline = Weblog::new( cap[1].to_string(), cap[4].to_string(), cap[5].to_string(), cap[6].parse::<i32>().unwrap_or(0), cap[7].parse::<i32>().unwrap_or(0), cap[8].to_string(), cap[9].to_string() ); Some(logl...
{ lazy_static! { static ref RE: Regex = Regex::new("(?x) (\\S+)\\s (\\S+)\\s (\\S+)\\s \\[(\\d{2}/\\w+/\\d{4}:\\d{2}:\\d{2}:\\d{2}\\s+.+?)\\]\\s \"(\\w+\\s\\S+\\s\\w+/\\d+\\.\\d+)\"\\s (\\d+)\\s (\\d+)\\s \"(\\S+...
identifier_body
lib.rs
#[macro_use] extern crate lazy_static; extern crate regex; extern crate rusqlite; pub mod weblog; use regex::Regex; use weblog::Weblog; use rusqlite::Connection; // Take an unprocessed string representing a single line of an Apache log, // attempt to match the various components of the string, and generate a Weblog ...
(count: i32) -> Vec<Weblog> { let conn = Connection::open("test.db").expect("Cannot open database?"); let mut stmt = conn.prepare("SELECT * FROM weblogs LIMIT (?)") .expect("Unable to prepare SELECT statement"); let log_iter = stmt.query_map(&[&count], |row| { Weblog { ip: row.get...
fetch
identifier_name
compile.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
Rep(x, ZeroMore, g) => { let j1 = self.insts.len(); let split = self.empty_split(); let j2 = self.insts.len(); self.compile(*x); let jmp = self.empty_jump(); let j3 = self.insts.len(); self.set_...
{ let split = self.empty_split(); let j1 = self.insts.len(); self.compile(*x); let j2 = self.insts.len(); if g.is_greedy() { self.set_split(split, j1, j2); } else { self.set_split(spl...
conditional_block
compile.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
EmptyEnd(Flags), // Matches a word boundary (\w on one side and \W \A or \z on the other), // and consumes no character. // The flags indicate whether this matches a word boundary or something // that isn't a word boundary. EmptyWordBoundary(Flags), // Saves the current position in the inp...
EmptyBegin(Flags), // Matches the end of the string, consumes no characters. // The flags indicate whether it matches if the proceeding character // is a new line.
random_line_split
compile.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
/// Appends an *empty* `Jump` instruction to the program and returns the /// index of that instruction. #[inline] fn empty_jump(&mut self) -> InstIdx { self.insts.push(Jump(0)); self.insts.len() - 1 } /// Sets the location of a `Jump` instruction at index `i` to `pc`. /// ...
{ let split = self.insts.get_mut(i); match *split { Split(_, _) => *split = Split(pc1, pc2), _ => fail!("BUG: Invalid split index."), } }
identifier_body
compile.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self, i: InstIdx, pc1: InstIdx, pc2: InstIdx) { let split = self.insts.get_mut(i); match *split { Split(_, _) => *split = Split(pc1, pc2), _ => fail!("BUG: Invalid split index."), } } /// Appends an *empty* `Jump` instruction to the program and returns the ...
set_split
identifier_name
ring_buffer.rs
use common::*; use libc::{self, c_void, ftruncate, mmap, munmap, shm_open, shm_unlink}; use std::cmp::min; use std::ffi::CString; use std::io; use std::io::Write; use std::ptr; use std::slice; use uuid::*; /// A ring buffer which can be used to insert and read ordered data. pub struct RingBuffer { /// Head, signif...
/// Produce an immutable slice at an offset. The nice thing about our implementation is that we can produce slices /// despite using a circular ring buffer. #[inline] fn slice_at_offset(&self, offset: usize, len: usize) -> &[u8] { if len >= self.size { panic!("slice beyond buffer l...
{ unsafe { RingBuffer::allocate(pages) } }
identifier_body
ring_buffer.rs
use common::*; use libc::{self, c_void, ftruncate, mmap, munmap, shm_open, shm_unlink}; use std::cmp::min; use std::ffi::CString; use std::io; use std::io::Write; use std::ptr; use std::slice; use uuid::*; /// A ring buffer which can be used to insert and read ordered data. pub struct RingBuffer { /// Head, signif...
/// Length of the ring buffer. #[inline] pub fn len(&self) -> usize { self.size } /// In cases with out-of-order data this allows the write head (and hence the amount of available data) to be /// progressed without writing anything. #[inline] pub fn seek_tail(&mut self, incremen...
random_line_split
ring_buffer.rs
use common::*; use libc::{self, c_void, ftruncate, mmap, munmap, shm_open, shm_unlink}; use std::cmp::min; use std::ffi::CString; use std::io; use std::io::Write; use std::ptr; use std::slice; use uuid::*; /// A ring buffer which can be used to insert and read ordered data. pub struct RingBuffer { /// Head, signif...
(&mut self, increment_by: usize) { self.tail = self.tail.wrapping_add(increment_by); } #[inline] pub fn clear(&mut self) { self.head = 0; self.tail = 0; } }
seek_tail
identifier_name
ring_buffer.rs
use common::*; use libc::{self, c_void, ftruncate, mmap, munmap, shm_open, shm_unlink}; use std::cmp::min; use std::ffi::CString; use std::io; use std::io::Write; use std::ptr; use std::slice; use uuid::*; /// A ring buffer which can be used to insert and read ordered data. pub struct RingBuffer { /// Head, signif...
// First get a big enough chunk of virtual memory. Fortunately for us this does not actually commit any physical // pages. We allocate twice as much memory so as to mirror the ring buffer. let address = mmap(ptr::null_mut(), alloc_bytes, li...
{ libc::close(fd); shm_unlink(name.as_ptr()); return Err(io::Error::last_os_error()).chain_err(|| ErrorKind::RingAllocationFailure); }
conditional_block
fileref.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
(&mut self) { VPE::cur().files().remove(self.fd); } } impl Deref for FileRef { type Target = FileHandle; fn deref(&self) -> &FileHandle { &self.file } } impl Read for FileRef { fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> { self.file.borrow_mut().read(buf) ...
drop
identifier_name
fileref.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
} impl Map for FileRef { fn map(&self, pager: &Pager, virt: goff, off: usize, len: usize, prot: kif::Perm) -> Result<(), Error> { self.file.borrow().map(pager, virt, off, len, prot) } } impl fmt::Debug for FileRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileRef...
{ self.file.borrow_mut().seek(off, whence) }
identifier_body
fileref.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
self.file.borrow().map(pager, virt, off, len, prot) } } impl fmt::Debug for FileRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileRef[fd={}, file={:?}]", self.fd, self.file.borrow()) } }
impl Map for FileRef { fn map(&self, pager: &Pager, virt: goff, off: usize, len: usize, prot: kif::Perm) -> Result<(), Error> {
random_line_split
factor.rs
#![crate_name = "uu_factor"] /* * This file is part of the uutils coreutils package. * * (c) T. Jameson Little <t.jameson.little@gmail.com> * (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com> * 20150223 added Pollard rho method implementation * (c) kwantam <kwantam@gmail.com> * 20150429 sped up trial division ...
(mut num: u64, factors: &mut Vec<u64>) { if num < 2 { return; } while num % 2 == 0 { num /= 2; factors.push(2); } if num == 1 { return; } if is_prime(num) { factors.push(num); return; } for &(prime, inv, ceil) in P_INVS_U64 { if...
table_division
identifier_name
factor.rs
#![crate_name = "uu_factor"] /* * This file is part of the uutils coreutils package. * * (c) T. Jameson Little <t.jameson.little@gmail.com> * (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com> * 20150223 added Pollard rho method implementation * (c) kwantam <kwantam@gmail.com> * 20150429 sped up trial division ...
else { big_add(big_mul(a, big_mul(x, x, num), num), b, num) } } fn gcd(mut a: u64, mut b: u64) -> u64 { while b > 0 { a %= b; swap(&mut a, &mut b); } a } fn rho_pollard_find_divisor(num: u64) -> u64 { let range = Range::new(1, num); let mut rng = rand::weak_rng(); ...
{ (sm_mul(a, sm_mul(x, x, num), num) + b) % num }
conditional_block
factor.rs
#![crate_name = "uu_factor"] /* * This file is part of the uutils coreutils package. * * (c) T. Jameson Little <t.jameson.little@gmail.com> * (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com> * 20150223 added Pollard rho method implementation * (c) kwantam <kwantam@gmail.com> * 20150429 sped up trial division ...
// inv = prime^-1 mod 2^64 // ceil = floor((2^64-1) / prime) // if (num * inv) mod 2^64 <= ceil, then prime divides num // See http://math.stackexchange.com/questions/1251327/ // for a nice explanation. loop { let Wrapping(x) = Wrapping(num) * Wrapping(inv); ...
{ if num < 2 { return; } while num % 2 == 0 { num /= 2; factors.push(2); } if num == 1 { return; } if is_prime(num) { factors.push(num); return; } for &(prime, inv, ceil) in P_INVS_U64 { if num == 1 { break; ...
identifier_body
factor.rs
#![crate_name = "uu_factor"] /* * This file is part of the uutils coreutils package. * * (c) T. Jameson Little <t.jameson.little@gmail.com> * (c) Wiktor Kuropatwa <wiktor.kuropatwa@gmail.com> * 20150223 added Pollard rho method implementation * (c) kwantam <kwantam@gmail.com> * 20150429 sped up trial division ...
} } } else { for num_str in &matches.free { print_factors_str(num_str); } } 0 }
for line in BufReader::new(stdin()).lines() { for number in line.unwrap().split_whitespace() { print_factors_str(number);
random_line_split
gen_sample.rs
use async_trait::*; use futures::channel::mpsc::{channel, Receiver, Sender}; use futures::executor::LocalPool; use futures::sink::SinkExt; use futures::stream::StreamExt; use futures::task::LocalSpawnExt; use macro_test::gen_sample::*; use pasta_core::Scriptor; use std::collections::HashSet; use std::ops::Range; struc...
let (mut s, mut rx) = TestScriptor::new(); spawner .spawn_local(async move { s.tags_mut().insert("通常トーク".to_owned()); s.tags_mut().insert("お昼過ぎ".to_owned()); walk(&mut s, JT::START).await; }) .unwrap(); let left = pool.run_until(async move { rx.nex...
_mut().insert("お昼過ぎ".to_owned()); let jump = walk_one(&mut s, JT::START).await; let jump = walk_one(&mut s, jump).await; walk_one(&mut s, jump).await; }) .unwrap(); let act = pool.run_until(async move { rx.next().await.unwrap() }); let mut right: String = Def...
identifier_body
gen_sample.rs
use async_trait::*; use futures::channel::mpsc::{channel, Receiver, Sender}; use futures::executor::LocalPool; use futures::sink::SinkExt; use futures::stream::StreamExt; use futures::task::LocalSpawnExt; use macro_test::gen_sample::*; use pasta_core::Scriptor; use std::collections::HashSet; use std::ops::Range; struc...
impl TestScriptor { pub fn new() -> (Self, Receiver<String>) { let (tx, rx) = channel(0); ( Self { tags: Default::default(), talk: Default::default(), tx: tx, }, rx, ) } } #[async_trait] impl Scriptor f...
random_line_split
gen_sample.rs
use async_trait::*; use futures::channel::mpsc::{channel, Receiver, Sender}; use futures::executor::LocalPool; use futures::sink::SinkExt; use futures::stream::StreamExt; use futures::task::LocalSpawnExt; use macro_test::gen_sample::*; use pasta_core::Scriptor; use std::collections::HashSet; use std::ops::Range; struc...
{ tags: HashSet<String>, talk: String, tx: Sender<String>, } impl TestScriptor { pub fn new() -> (Self, Receiver<String>) { let (tx, rx) = channel(0); ( Self { tags: Default::default(), talk: Default::default(), tx: tx, ...
TestScriptor
identifier_name
main.rs
use std::env; fn first_factor(product: u64) -> u64 { let mut primes = Vec::new(); for i in 2..(product + 1) { if!primes.iter().any(|p| i % p == 0) { // is prime if product % i == 0 { return i; } primes.push(i); } } 1 } fn largest_p...
fn main() { match env::args().nth(1) { None => println!("Needs a first argument"), Some(string) => match string.parse::<u64>() { Ok(product) => println!("{}", largest_prime(product)), Err(_) => println!("First argument must be an int"), } } }
{ let mut remaining = product; let mut primes = Vec::new(); loop { let factor = first_factor(remaining); primes.push(factor); remaining = remaining / factor; if factor == 1 { break; } } let mut max_prime = 1; for p in primes { if p > m...
identifier_body
main.rs
use std::env; fn first_factor(product: u64) -> u64 { let mut primes = Vec::new(); for i in 2..(product + 1) { if!primes.iter().any(|p| i % p == 0) { // is prime if product % i == 0 { return i; } primes.push(i); } } 1 } fn
(product: u64) -> u64 { let mut remaining = product; let mut primes = Vec::new(); loop { let factor = first_factor(remaining); primes.push(factor); remaining = remaining / factor; if factor == 1 { break; } } let mut max_prime = 1; for p in pri...
largest_prime
identifier_name
main.rs
use std::env; fn first_factor(product: u64) -> u64 { let mut primes = Vec::new(); for i in 2..(product + 1) { if!primes.iter().any(|p| i % p == 0) { // is prime if product % i == 0 { return i; } primes.push(i); } } 1 } fn largest_p...
let mut remaining = product; let mut primes = Vec::new(); loop { let factor = first_factor(remaining); primes.push(factor); remaining = remaining / factor; if factor == 1 { break; } } let mut max_prime = 1; for p in primes { if p > max...
random_line_split
limited-debuginfo.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(a: int, b: int) { let some_variable = Struct { a: 11, b: 22 }; let some_other_variable = 23i; zzz(); // #break } fn some_other_function(a: int, b: int) -> bool { true }
some_function
identifier_name
limited-debuginfo.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn zzz() {()} fn some_function(a: int, b: int) { let some_variable = Struct { a: 11, b: 22 }; let some_other_variable = 23i; zzz(); // #break } fn some_other_function(a: int, b: int) -> bool { true }
{ some_function(101, 202); some_other_function(1, 2); }
identifier_body
limited-debuginfo.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// Make sure there is no information about locals // gdb-command:info locals // gdb-check:No locals. // gdb-command:continue #![allow(unused_variables)] struct Struct { a: i64, b: i32 } fn main() { some_function(101, 202); some_other_function(1, 2); } fn zzz() {()} fn some_function(a: int, b: int...
// gdb-check:[...]void[...]some_other_function([...]); // gdb-check:[...]void[...]zzz([...]); // gdb-command:run
random_line_split
informant.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
let mut write_report = self.report.write(); let report = self.client.report(); let paint = |c: Style, t: String| match self.with_color && stdout_isatty() { true => format!("{}", c.paint(t)), false => t, }; info!(target: "import", "{} {} {} {}", match importing { true => match snapshot_sync {...
random_line_split
informant.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
( client: Arc<Client>, sync: Option<Arc<SyncProvider>>, net: Option<Arc<ManageNetwork>>, snapshot: Option<Arc<SnapshotService>>, rpc_stats: Option<Arc<RpcStats>>, with_color: bool, ) -> Self { Informant { report: RwLock::new(None), last_tick: RwLock::new(Instant::now()), with_color: with_color, ...
new
identifier_name
informant.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
} impl Informant { /// Make a new instance potentially `with_color` output. pub fn new( client: Arc<Client>, sync: Option<Arc<SyncProvider>>, net: Option<Arc<ManageNetwork>>, snapshot: Option<Arc<SnapshotService>>, rpc_stats: Option<Arc<RpcStats>>, with_color: bool, ) -> Self { Informant { report:...
{ self.as_secs() * 1000 + self.subsec_nanos() as u64 / 1_000_000 }
identifier_body
operator-multidispatch.rs
// run-pass // Test that we can overload the `+` operator for points so that two // points can be added, and a point can be added to an integer. use std::ops; #[derive(Debug,PartialEq,Eq)] struct Point { x: isize, y: isize } impl ops::Add for Point { type Output = Point; fn add(self, other: Point) -...
{ let mut p = Point {x: 10, y: 20}; p = p + Point {x: 101, y: 102}; assert_eq!(p, Point {x: 111, y: 122}); p = p + 1; assert_eq!(p, Point {x: 112, y: 123}); }
identifier_body
operator-multidispatch.rs
// run-pass // Test that we can overload the `+` operator for points so that two // points can be added, and a point can be added to an integer. use std::ops; #[derive(Debug,PartialEq,Eq)] struct Point { x: isize, y: isize } impl ops::Add for Point { type Output = Point; fn add(self, other: Point) -...
(self, other: isize) -> Point { Point {x: self.x + other, y: self.y + other} } } pub fn main() { let mut p = Point {x: 10, y: 20}; p = p + Point {x: 101, y: 102}; assert_eq!(p, Point {x: 111, y: 122}); p = p + 1; assert_eq!(p, Point {x: 112, y: 123}); }
add
identifier_name
operator-multidispatch.rs
// run-pass // Test that we can overload the `+` operator for points so that two // points can be added, and a point can be added to an integer. use std::ops; #[derive(Debug,PartialEq,Eq)] struct Point { x: isize, y: isize } impl ops::Add for Point { type Output = Point; fn add(self, other: Point) -...
assert_eq!(p, Point {x: 112, y: 123}); }
p = p + Point {x: 101, y: 102}; assert_eq!(p, Point {x: 111, y: 122}); p = p + 1;
random_line_split
hostname.rs
#![crate_name = "uu_hostname"] /* * This file is part of the uutils coreutils package. * * (c) Alan Andrade <alan.andradec@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Synced with: * * https://www.opensource.appl...
fn xgethostname() -> String { let namelen = 256usize; let mut name : Vec<u8> = repeat(0).take(namelen).collect(); let err = unsafe { gethostname (name.as_mut_ptr() as *mut libc::c_char, namelen as libc::size_t) }; if err!= 0 { panic!("Cannot...
{ version(); println!(""); println!("Usage:"); println!(" {} [OPTION]... [HOSTNAME]", program); println!(""); print!("{}", options.usage("Print or set the system's host name.")); }
identifier_body
hostname.rs
#![crate_name = "uu_hostname"] /* * This file is part of the uutils coreutils package. * * (c) Alan Andrade <alan.andradec@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Synced with: * * https://www.opensource.appl...
() -> String { let namelen = 256usize; let mut name : Vec<u8> = repeat(0).take(namelen).collect(); let err = unsafe { gethostname (name.as_mut_ptr() as *mut libc::c_char, namelen as libc::size_t) }; if err!= 0 { panic!("Cannot determine hostna...
xgethostname
identifier_name
hostname.rs
#![crate_name = "uu_hostname"] /* * This file is part of the uutils coreutils package. * * (c) Alan Andrade <alan.andradec@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Synced with: * * https://www.opensource.appl...
show_error!("{}", f); return 1; } } } else { if matches.opt_present("s") { let mut it = hostname.char_indices().filter(|&ci| ci.1 == '.'); let ci = it.next(); ...
if len > 0 { println!("{}", &output[0 .. len - 1]); } } Err(f) => {
random_line_split
issue-2149.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<B>(&self, f: |A| -> Vec<B> ) { let mut r = fail!(); for elt in self.iter() { r = r + f(*elt); } //~^ ERROR the type of this value must be known } } fn main() { ["hi"].bind(|x| [x] ); //~^ ERROR type `[&str,..1]` does not implement any method in scope named `bind` }
bind
identifier_name
issue-2149.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 ...
{ ["hi"].bind(|x| [x] ); //~^ ERROR type `[&str, ..1]` does not implement any method in scope named `bind` }
identifier_body
issue-2149.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 r = fail!(); for elt in self.iter() { r = r + f(*elt); } //~^ ERROR the type of this value must be known } } fn main() { ["hi"].bind(|x| [x] ); //~^ ERROR type `[&str,..1]` does not implement any method in scope named `bind` }
random_line_split
log_syntax-trace_macros-macro-locations.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { // statements trace_macros!(false); log_syntax!(); // expressions (trace_macros!(false), log_syntax!()); }
random_line_split
log_syntax-trace_macros-macro-locations.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { // statements trace_macros!(false); log_syntax!(); // expressions (trace_macros!(false), log_syntax!()); }
main
identifier_name
log_syntax-trace_macros-macro-locations.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ // statements trace_macros!(false); log_syntax!(); // expressions (trace_macros!(false), log_syntax!()); }
identifier_body
error.rs
use std::path::PathBuf; use std::error::Error; use std::fmt; use super::Environment; use self::ConfigError::*; use term_painter::Color::White; use term_painter::ToStyle; /// The type of a configuration parsing error. #[derive(Debug, PartialEq, Clone)] pub struct ParsingError { /// Start and end byte indices into...
} } /// Whether this error is of `NotFound` variant. #[inline(always)] pub fn is_not_found(&self) -> bool { match *self { NotFound => true, _ => false } } } impl fmt::Display for ConfigError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result...
{ error!("environment variable '{}={}' could not be parsed", White.paint(key), White.paint(value)); info_!("value for {:?} must be {}", White.paint(key), White.paint(expected)) }
conditional_block
error.rs
use std::path::PathBuf; use std::error::Error; use std::fmt; use super::Environment; use self::ConfigError::*; use term_painter::Color::White; use term_painter::ToStyle; /// The type of a configuration parsing error. #[derive(Debug, PartialEq, Clone)] pub struct ParsingError { /// Start and end byte indices into...
(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { BadCWD => write!(f, "couldn't get current working directory"), NotFound => write!(f, "config file was not found"), IOError => write!(f, "I/O error while reading the config file"), BadFilePath(ref p, _)...
fmt
identifier_name
error.rs
use std::path::PathBuf; use std::error::Error; use std::fmt; use super::Environment; use self::ConfigError::*; use term_painter::Color::White; use term_painter::ToStyle; /// The type of a configuration parsing error. #[derive(Debug, PartialEq, Clone)] pub struct ParsingError { /// Start and end byte indices into...
error!("configuration file path '{:?}' is invalid", path); info_!("{}", reason); } BadEntry(ref name, ref filename) => { let valid_entries = format!("{}, and global", valid_envs); error!("[{}] is not a known configuration environmen...
NotFound => error!("config file was not found"), IOError => error!("failed reading the config file: IO error"), BadFilePath(ref path, reason) => {
random_line_split
mode.rs
use state::State; use std::marker::PhantomData; use typeahead::Parse; pub trait Transition<K> where K: Ord, K: Copy, K: Parse, { fn name(&self) -> &'static str; fn transition(&self, state: &mut State<K>) -> Mode<K>; } #[derive(Clone, Copy, Debug)] pub struct NormalMode<K> { t: PhantomData<K>, ...
<K> { Normal(NormalMode<K>), Pending(PendingMode<K>), Insert(InsertMode<K>), } pub fn normal<K>() -> Mode<K> { Mode::Normal(NormalMode::<K> { t: PhantomData::<K> {} }) } pub fn recast_normal<K>(orig: &NormalMode<K>) -> Mode<K> { Mode::Normal(NormalMode::<K> { t: PhantomData::<K> {} }) } pub fn pe...
Mode
identifier_name
mode.rs
use state::State; use std::marker::PhantomData; use typeahead::Parse; pub trait Transition<K> where K: Ord, K: Copy,
{ fn name(&self) -> &'static str; fn transition(&self, state: &mut State<K>) -> Mode<K>; } #[derive(Clone, Copy, Debug)] pub struct NormalMode<K> { t: PhantomData<K>, } /// Used by `PendingMode` to remember what mode to transition to next. #[derive(Clone, Copy, Debug)] pub enum NextMode { Normal, ...
K: Parse,
random_line_split