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
angle.rs
/* Copyright (c) 2015, 2016 Saurav Sachidanand 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 limitation the rights to use, copy, modify, merge, publish, di...
* `deg`: Angle in degrees with decimals **/ #[inline] pub fn hms_frm_deg(deg: f64) -> (i64, i64, f64) { let hours = deg / 15.0; let hour = hours as i64; let minutes = (hours - (hour as f64)) * 60.0; let minute = minutes as i64; let seconds = (minutes - (minute as f64)) * 60.0; (hour, minute, ...
random_line_split
angle.rs
/* Copyright (c) 2015, 2016 Saurav Sachidanand 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 limitation the rights to use, copy, modify, merge, publish, di...
(angl: f64) -> f64 { let n = (angl / 360.0) as i64; let limited_angl = angl - (360.0 * (n as f64)); if limited_angl < 0.0 { limited_angl + 360.0 } else { limited_angl } } /** Computes the equivalent angle in [0, 2Ο€] radian range # Arguments * `angl`: Angle *| in radians* **/ #[inlin...
limit_to_360
identifier_name
writer.rs
//! Writer traits. pub use genet_abi::writer::{Metadata, Worker, Writer}; #[doc(hidden)] pub use genet_abi::writer::WriterBox; /// Registers writer entries. #[macro_export] macro_rules! genet_writers { ( $( $x:expr ), * ) => { thread_local! { static WRITERS: Vec<genet_sdk::writer::WriterBox> ...
} d.as_ptr() }) } }; }
WRITERS.with(|d| { unsafe { *len = d.len() as u64;
random_line_split
fmt.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...
r<'a> { fn write(&mut self, b: &[u8]) -> io::IoResult<()> { match (*self).write(b) { Ok(()) => Ok(()), Err(WriteError) => Err(io::standard_error(io::OtherIoError)) } } }
Writer::new(); let _ = write!(&mut output, "{}", args); string::String::from_utf8(output.unwrap()).unwrap() } impl<'a> Writer for Formatte
identifier_body
fmt.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...
/// /// # Example /// /// ```rust /// use std::fmt; /// /// let s = format_args!(fmt::format, "Hello, {}!", "world"); /// assert_eq!(s, "Hello, world!".to_string()); /// ``` pub fn format(args: &Arguments) -> string::String{ let mut output = io::MemWriter::new(); let _ = write!(&mut output, "{}", args); str...
/// /// * args - a structure of arguments generated via the `format_args!` macro. /// Because this structure can only be safely generated at /// compile-time, this function is safe.
random_line_split
fmt.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...
oResult<()> { match (*self).write(b) { Ok(()) => Ok(()), Err(WriteError) => Err(io::standard_error(io::OtherIoError)) } } }
io::I
identifier_name
step.rs
use std::io::{Write, Result as IoResult}; use std::iter::repeat; use crate::syntax::ast; use super::{ Scope, Item, Expr, Shape, ValueId, Ctxt, Process, ProcessInfo, ProcessChain, MatchSet, Type }; use super::{ on_expr_message, value, pattern_match, rexpr }; use super::process::resolve_process; pub type Message = ...
Process::Token(ref message) => writeln!(f, "{} Token: {:?}", i, message)?, Process::Seq(ref step) => { writeln!(f, "{} Seq:", i)?; step.write_tree(f, indent+2)?; } Proc...
Step::Process(ref processes) => { writeln!(f, "{}Process:", i)?; for p in &processes.processes { match p.process {
random_line_split
step.rs
use std::io::{Write, Result as IoResult}; use std::iter::repeat; use crate::syntax::ast; use super::{ Scope, Item, Expr, Shape, ValueId, Ctxt, Process, ProcessInfo, ProcessChain, MatchSet, Type }; use super::{ on_expr_message, value, pattern_match, rexpr }; use super::process::resolve_process; pub type Message = ...
let step = resolve_seq(sb.with_scope(&body_scope), block); sb.foreach(count.unwrap_or(0) as u32, inner_vars, step) } ast::Action::Alt(ref expr, ref arms) => { let r = rexpr(sb.scope, expr); let v = arms.iter().map(|arm| { let mut body_s...
{ let mut body_scope = sb.scope.child(); let mut count = None; let mut inner_vars = Vec::with_capacity(pairs.len()); for &(ref name, ref expr) in pairs { let e = value(sb.scope, expr); let t = e.get_type(); let dir = e.dir(...
conditional_block
step.rs
use std::io::{Write, Result as IoResult}; use std::iter::repeat; use crate::syntax::ast; use super::{ Scope, Item, Expr, Shape, ValueId, Ctxt, Process, ProcessInfo, ProcessChain, MatchSet, Type }; use super::{ on_expr_message, value, pattern_match, rexpr }; use super::process::resolve_process; pub type Message = ...
(&self, length: u32, vars: Vec<(ValueId, Expr)>, inner: StepInfo) -> StepInfo { //TODO: check that inner followlast and first are non-overlapping StepInfo { first: inner.first.clone(), step: Step::Foreach(length, vars, Box::new(inner)) } } fn alt(&self, opts: Ve...
foreach
identifier_name
step.rs
use std::io::{Write, Result as IoResult}; use std::iter::repeat; use crate::syntax::ast; use super::{ Scope, Item, Expr, Shape, ValueId, Ctxt, Process, ProcessInfo, ProcessChain, MatchSet, Type }; use super::{ on_expr_message, value, pattern_match, rexpr }; use super::process::resolve_process; pub type Message = ...
StepInfo { first: MatchSet::join(&bottom_first, &top_first), step: Step::Process(p) } } fn token_top(&self, message: Message, inner: StepInfo) -> StepInfo { StepInfo { first: MatchSet::upper(message.clone()).followed_by(inner.first.clone()), ...
{ if p.processes.len() == 1 { if let Process::Seq(_) = p.processes[0].process { match p.processes.into_iter().next().unwrap().process { Process::Seq(s) => return s, _ => unreachable!() } } } fn proce...
identifier_body
record-pat.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 ...
(input: t3) -> int { match input { t3::c(T2 {x: t1::a(m),..}, _) => { return m; } t3::c(T2 {x: t1::b(m), y: y}, z) => { return ((m + z) as int) + y; } } } pub fn main() { assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4u)), 10); assert_eq!(m(t3::c(T2 {x: t1::b(10u), y: 5}, 4u)), 19); }
m
identifier_name
record-pat.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 ...
t3::c(T2 {x: t1::b(m), y: y}, z) => { return ((m + z) as int) + y; } } } pub fn main() { assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4u)), 10); assert_eq!(m(t3::c(T2 {x: t1::b(10u), y: 5}, 4u)), 19); }
{ return m; }
conditional_block
record-pat.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 ...
t3::c(T2 {x: t1::b(m), y: y}, z) => { return ((m + z) as int) + y; } } } pub fn main() { assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4u)), 10); assert_eq!(m(t3::c(T2 {x: t1::b(10u), y: 5}, 4u)), 19); }
fn m(input: t3) -> int { match input { t3::c(T2 {x: t1::a(m), ..}, _) => { return m; }
random_line_split
record-pat.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!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4u)), 10); assert_eq!(m(t3::c(T2 {x: t1::b(10u), y: 5}, 4u)), 19); }
identifier_body
kleisli.rs
use std::mem::transmute; use std::marker::PhantomData; use std::collections::VecDeque; use super::instr::Instr; use super::{Program, point}; /// The Kleisli arrow from `A` to `Program<I, B>`. pub struct Kleisli<'a, I: Instr<Return=A>, A, B> { phan: PhantomData<(A, B)>, deque: VecDeque<Box<Fn(Box<()>) -> Progr...
(mut self, a: A) -> Program<'a, I, B> { unsafe { let mut r = transmute::<Program<'a, I, A>, Program<'a, I, ()>>(point(a)); loop { match self.deque.pop_front() { None => return transmute(r), Some(f) => r = r.and_then_boxed(move |a| (...
run
identifier_name
kleisli.rs
use std::mem::transmute; use std::marker::PhantomData; use std::collections::VecDeque; use super::instr::Instr; use super::{Program, point}; /// The Kleisli arrow from `A` to `Program<I, B>`. pub struct Kleisli<'a, I: Instr<Return=A>, A, B> { phan: PhantomData<(A, B)>, deque: VecDeque<Box<Fn(Box<()>) -> Progr...
match self.deque.pop_front() { None => return transmute(r), Some(f) => r = r.and_then_boxed(move |a| (*f)(a)) } } } } } #[test] fn kleisli_run_plus_one() { use super::instr::Identity; let k: Kleisli<Identity<i32>, ...
let mut r = transmute::<Program<'a, I, A>, Program<'a, I, ()>>(point(a)); loop {
random_line_split
kleisli.rs
use std::mem::transmute; use std::marker::PhantomData; use std::collections::VecDeque; use super::instr::Instr; use super::{Program, point}; /// The Kleisli arrow from `A` to `Program<I, B>`. pub struct Kleisli<'a, I: Instr<Return=A>, A, B> { phan: PhantomData<(A, B)>, deque: VecDeque<Box<Fn(Box<()>) -> Progr...
impl<'a, I: 'a + Instr<Return=A>, A, B> Kleisli<'a, I, A, B> { /// Appends the given function to the tail of the arrow. /// This corresponds to closure composition at the codomain (post-composition). /// /// # Example /// /// ```rust /// use operational::{Kleisli, point}; /// use oper...
{ k.deque.push_back(unsafe { fn_transmute(f) }); Kleisli { phan: PhantomData, deque: k.deque } }
identifier_body
emulator.rs
use arch::Arch; use error::Error; use stack; use std::collections::HashMap; use unicorn; #[derive(Debug)] pub struct MemMap { pub addr: u64, pub size: u64, pub flags: unicorn::unicorn_const::Protection, pub name: Option<String>, } pub type MemMaps = HashMap<String, MemMap>; /// Main struct to manage ...
// Memory operation. /// Create a new memory map in the emulator from `mapping`. It will be /// possible to read and write the emulator memory afterward. pub fn mem_map(&mut self, mapping: MemMap) -> Result<(), Error> { let map_key = match mapping.name { Some(ref name) => name.clon...
{ stack::Stack::new(self) }
identifier_body
emulator.rs
use arch::Arch; use error::Error; use stack; use std::collections::HashMap; use unicorn; #[derive(Debug)] pub struct MemMap { pub addr: u64, pub size: u64, pub flags: unicorn::unicorn_const::Protection, pub name: Option<String>, }
arch: Arch, uc: unicorn::Unicorn, } impl Emulator { /// Create a new emulator instance for a given architecture from /// `arch_info`. pub fn new(arch: Arch) -> Result<Emulator, Error> { let uc = try!(unicorn::Unicorn::new(arch.arch, arch.mode)); Ok(Emulator { mappings: D...
pub type MemMaps = HashMap<String, MemMap>; /// Main struct to manage and run emulation. pub struct Emulator { mappings: MemMaps,
random_line_split
emulator.rs
use arch::Arch; use error::Error; use stack; use std::collections::HashMap; use unicorn; #[derive(Debug)] pub struct
{ pub addr: u64, pub size: u64, pub flags: unicorn::unicorn_const::Protection, pub name: Option<String>, } pub type MemMaps = HashMap<String, MemMap>; /// Main struct to manage and run emulation. pub struct Emulator { mappings: MemMaps, arch: Arch, uc: unicorn::Unicorn, } impl Emulator {...
MemMap
identifier_name
day_6.rs
pub use tdd_kata::string_calc_kata::iter_2::day_6::evaluate;
describe! string_calculator { it "should evaluate float number" { expect!(evaluate("4354.5405478")).to(be_ok().value(4354.5405478)); } it "should evaluate add operation" { expect!(evaluate("43654.45+32432.42")).to(be_ok().value(76086.87)); } it "should evaluate sub operation" { ...
pub use expectest::prelude::be_ok;
random_line_split
fib.rs
extern crate llvm; use llvm::*; use llvm::Attribute::*; fn main() { let ctx = Context::new(); let module = Module::new("simple", &ctx); let func = module.add_function("fib", Type::get::<fn(u64) -> u64>(&ctx)); func.add_attributes(&[NoUnwind, ReadNone]); let value = &func[0]; let entry = func.app...
let a = builder.build_sub(value, one); let b = builder.build_sub(value, two); let fa = builder.build_tail_call(func, &[a]); let fb = builder.build_tail_call(func, &[b]); builder.build_ret(builder.build_add(fa, fb)); module.verify().unwrap(); let ee = JitEngine::new(&module, JitOptions {opt_l...
builder.build_ret(zero); builder.position_at_end(on_one); builder.build_ret(one); builder.position_at_end(default); let two = 2u64.compile(&ctx);
random_line_split
fib.rs
extern crate llvm; use llvm::*; use llvm::Attribute::*; fn
() { let ctx = Context::new(); let module = Module::new("simple", &ctx); let func = module.add_function("fib", Type::get::<fn(u64) -> u64>(&ctx)); func.add_attributes(&[NoUnwind, ReadNone]); let value = &func[0]; let entry = func.append("entry"); let on_zero = func.append("on_zero"); let...
main
identifier_name
fib.rs
extern crate llvm; use llvm::*; use llvm::Attribute::*; fn main()
builder.position_at_end(on_one); builder.build_ret(one); builder.position_at_end(default); let two = 2u64.compile(&ctx); let a = builder.build_sub(value, one); let b = builder.build_sub(value, two); let fa = builder.build_tail_call(func, &[a]); let fb = builder.build_tail_call(func, &[b]...
{ let ctx = Context::new(); let module = Module::new("simple", &ctx); let func = module.add_function("fib", Type::get::<fn(u64) -> u64>(&ctx)); func.add_attributes(&[NoUnwind, ReadNone]); let value = &func[0]; let entry = func.append("entry"); let on_zero = func.append("on_zero"); let on...
identifier_body
stdio.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
/// /// Care should be taken when creating multiple handles to an output stream for /// a single process. While usage is still safe, the output may be surprising if /// no synchronization is performed to ensure a sane output. pub fn stdout() -> LineBufferedWriter<StdWriter> { LineBufferedWriter::new(stdout_raw()) }...
/// /// Note that this is a fairly expensive operation in that at least one memory /// allocation is performed. Additionally, this must be called from a runtime /// task context because the stream returned will be a non-blocking object using /// the local scheduler to perform the I/O.
random_line_split
stdio.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(s: &str) { with_task_stdout(|io| io.write(s.as_bytes())) } /// Prints a string to the stdout of the current process. A literal /// `\n` character is printed to the console after the string. pub fn println(s: &str) { with_task_stdout(|io| { io.write(s.as_bytes()).and_then(|()| io.write([b'\n'])) })...
print
identifier_name
stdio.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
/// Flushes the local task's stdout handle. /// /// By default, this stream is a line-buffering stream, so flushing may be /// necessary to ensure that all output is printed to the screen (if there are /// no newlines printed). /// /// Note that logging macros do not use this stream. Using the logging macros /// will...
{ let result = if Local::exists(None::<Task>) { let mut my_stdout = local_stdout.replace(None).unwrap_or_else(|| { box stdout() as Box<Writer + Send> }); let result = f(&mut *my_stdout); local_stdout.replace(Some(my_stdout)); result } else { let mut io...
identifier_body
utils.rs
use std::fmt; use std::path::{Path, PathBuf}; use std::fs; use rustc_serialize::{Encodable, Encoder}; use url::Url; use git2::{self, ObjectType}; use core::GitReference; use util::{CargoResult, ChainError, human, ToUrl, internal}; #[derive(PartialEq, Clone, Debug)] pub struct GitRevision(git2::Oid); impl fmt::Displ...
try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None)); Ok(()) }) }
cb.credentials(|a, b, c| f(a, b, c)); let mut remote = try!(repo.remote_anonymous(&url, Some(refspec))); try!(remote.add_fetch("refs/tags/*:refs/tags/*")); remote.set_callbacks(&mut cb);
random_line_split
utils.rs
use std::fmt; use std::path::{Path, PathBuf}; use std::fs; use rustc_serialize::{Encodable, Encoder}; use url::Url; use git2::{self, ObjectType}; use core::GitReference; use util::{CargoResult, ChainError, human, ToUrl, internal}; #[derive(PartialEq, Clone, Debug)] pub struct GitRevision(git2::Oid); impl fmt::Displ...
GitReference::Rev(ref s) => { let obj = try!(self.repo.revparse_single(s)); obj.id() } }; Ok(GitRevision(id)) } pub fn has_ref(&self, reference: &str) -> CargoResult<()> { try!(self.repo.revparse_single(reference)); Ok(())...
{ try!((|| { let b = try!(self.repo.find_branch(s, git2::BranchType::Local)); b.get().target().chain_error(|| { human(format!("branch `{}` did not have a target", s)) }) }).chain_error(|| { ...
conditional_block
utils.rs
use std::fmt; use std::path::{Path, PathBuf}; use std::fs; use rustc_serialize::{Encodable, Encoder}; use url::Url; use git2::{self, ObjectType}; use core::GitReference; use util::{CargoResult, ChainError, human, ToUrl, internal}; #[derive(PartialEq, Clone, Debug)] pub struct GitRevision(git2::Oid); impl fmt::Displ...
(&self) -> &Url { &self.url } pub fn rev_for(&self, path: &Path, reference: &GitReference) -> CargoResult<GitRevision> { let db = try!(self.db_at(path)); db.rev_for(reference) } pub fn checkout(&self, into: &Path) -> CargoResult<GitDatabase> { let rep...
url
identifier_name
utils.rs
use std::fmt; use std::path::{Path, PathBuf}; use std::fs; use rustc_serialize::{Encodable, Encoder}; use url::Url; use git2::{self, ObjectType}; use core::GitReference; use util::{CargoResult, ChainError, human, ToUrl, internal}; #[derive(PartialEq, Clone, Debug)] pub struct GitRevision(git2::Oid); impl fmt::Displ...
let head_and_repo = child.open().and_then(|repo| { let target = try!(repo.head()).target(); Ok((target, repo)) }); let repo = match head_and_repo { Ok((head, repo)) => { if child.head_id()...
{ info!("update submodules for: {:?}", repo.workdir().unwrap()); for mut child in try!(repo.submodules()).into_iter() { try!(child.init(false)); let url = try!(child.url().chain_error(|| { internal("non-utf8 url for submodule") ...
identifier_body
source_util.rs
// Copyright 2012-2013 The Rust Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
base::check_zero_tts(cx, sp, tts, "line!"); let topmost = topmost_expn_info(cx.backtrace().get()); let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); base::MRExpr(mk_uint(cx, topmost.call_site, loc.line)) } /* col!(): expands to the current column number */ pub fn expand_col(cx: @ext_ctxt,...
-> base::MacResult {
random_line_split
source_util.rs
// Copyright 2012-2013 The Rust Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
/* file!(): expands to the current filename */ /* The filemap (`loc.file`) contains a bunch more information we could spit * out if we wanted. */ pub fn expand_file(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "file!"); let topmost = topmost_ex...
{ base::check_zero_tts(cx, sp, tts, "col!"); let topmost = topmost_expn_info(cx.backtrace().get()); let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); base::MRExpr(mk_uint(cx, topmost.call_site, loc.col.to_uint())) }
identifier_body
source_util.rs
// Copyright 2012-2013 The Rust Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(cx: @ext_ctxt, sp: codemap::span, arg: &Path) -> Path { // NB: relative paths are resolved relative to the compilation unit if!arg.is_absolute { let cu = Path(cx.codemap().span_to_filename(sp)); cu.dir_path().push_many(arg.components) } else { copy *arg } } // // Local Variable...
res_rel_file
identifier_name
source_util.rs
// Copyright 2012-2013 The Rust Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} base::MRExpr(mk_base_str(cx, sp, result::unwrap(res))) } pub fn expand_include_bin(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include_bin!"); match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) { result...
{ cx.parse_sess().span_diagnostic.handler().fatal((*e)); }
conditional_block
reader.rs
use rustc_serialize::json::{Json, Object}; use std::fs::File; use super::responses::Responses; use super::outcome::Outcome; pub struct Phase { pub operation: Responses, pub outcome: Outcome, } impl Phase { fn from_json(object: &Object) -> Result<Phase, String> { let operation = val_or_err!(object...
Ok(Phase{ operation: operation, outcome: outcome }) } } pub struct Suite { pub uri: String, pub phases: Vec<Phase>, } fn get_phases(object: &Object) -> Result<Vec<Phase>, String> { let array = val_or_err!(object.get("phases"), Some(&Json::Array(ref array)) => array....
random_line_split
reader.rs
use rustc_serialize::json::{Json, Object}; use std::fs::File; use super::responses::Responses; use super::outcome::Outcome; pub struct Phase { pub operation: Responses, pub outcome: Outcome, } impl Phase { fn from_json(object: &Object) -> Result<Phase, String> { let operation = val_or_err!(object...
(path: &str) -> Result<Json, String> { let mut file = File::open(path).expect(&format!("Unable to open file: {}", path)); Ok(Json::from_reader(&mut file).expect(&format!("Invalid JSON file: {}", path))) } fn get_suite(&self) -> Result<Suite, String> { let object = val_or_err!(self, ...
from_file
identifier_name
reader.rs
use rustc_serialize::json::{Json, Object}; use std::fs::File; use super::responses::Responses; use super::outcome::Outcome; pub struct Phase { pub operation: Responses, pub outcome: Outcome, } impl Phase { fn from_json(object: &Object) -> Result<Phase, String> { let operation = val_or_err!(object...
Ok(phases) } pub trait SuiteContainer: Sized { fn from_file(path: &str) -> Result<Self, String>; fn get_suite(&self) -> Result<Suite, String>; } impl SuiteContainer for Json { fn from_file(path: &str) -> Result<Json, String> { let mut file = File::open(path).expect(&format!("Unable to open fi...
{ let array = val_or_err!(object.get("phases"), Some(&Json::Array(ref array)) => array.clone(), "No `phases` array found"); let mut phases = vec![]; for json in array { let obj = val_or_err!(json, Json::Object(re...
identifier_body
mod.rs
extern crate rand; extern crate clap; extern crate log; use clap::{Arg, App, SubCommand, ArgMatches}; use rand::Rng; pub fn define_subcommand<'a>() -> App<'a, 'a>
pub fn exec<'a>(matches: &ArgMatches<'a>) { println!("Manage!"); println!("{}", generate_password(50)); } fn generate_password(length: usize) -> String { rand::thread_rng() .gen_ascii_chars() .take(length) .collect() } // TESTING #[test] fn test_generate_password() { let pwd0 = generate_password(0);...
{ SubCommand::with_name("manage") .about("Manage a site") .version("0.1") .arg(Arg::with_name("SITE") .required(true) .index(1) .help("Site to manage")) }
identifier_body
mod.rs
extern crate rand; extern crate clap; extern crate log; use clap::{Arg, App, SubCommand, ArgMatches}; use rand::Rng; pub fn define_subcommand<'a>() -> App<'a, 'a> { SubCommand::with_name("manage") .about("Manage a site") .version("0.1") .arg(Arg::with_name("SITE") .required(true) ...
<'a>(matches: &ArgMatches<'a>) { println!("Manage!"); println!("{}", generate_password(50)); } fn generate_password(length: usize) -> String { rand::thread_rng() .gen_ascii_chars() .take(length) .collect() } // TESTING #[test] fn test_generate_password() { let pwd0 = generate_password(0); assert_eq!(...
exec
identifier_name
mod.rs
extern crate rand; extern crate clap; extern crate log; use clap::{Arg, App, SubCommand, ArgMatches}; use rand::Rng;
.required(true) .index(1) .help("Site to manage")) } pub fn exec<'a>(matches: &ArgMatches<'a>) { println!("Manage!"); println!("{}", generate_password(50)); } fn generate_password(length: usize) -> String { rand::thread_rng() .gen_ascii_chars() .take(length) .collect() ...
pub fn define_subcommand<'a>() -> App<'a, 'a> { SubCommand::with_name("manage") .about("Manage a site") .version("0.1") .arg(Arg::with_name("SITE")
random_line_split
mod.rs
// Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
mod lifeguard; use std::borrow::Cow; use primitives::field::Value; /// Creates the objects that may be needed for parsing /// /// When parsing AMQP "fields", some values may require dynamic allocation-- at least the /// ones can't just reference into the byte-string (Table and List rather than &str or &[u8]). /// ///...
// <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. #[cfg(not(feature = "lifeguard"))]
random_line_split
mod.rs
// Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according...
} /// Creates objects as needed (no pools, no configuration, no attributes) pub struct NoParserPool; impl ParserPool for NoParserPool { fn new_values_vec(&mut self, _: &[u8]) -> Vec<Value<'static>> { Vec::with_capacity(10) } fn new_table_entries_vec(&mut self, _: &[u8]) -> Vec<(Cow<'static, str>,...
{}
identifier_body
mod.rs
// Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according...
(&mut self, _: &[u8]) -> Vec<Value<'static>> { Vec::with_capacity(10) } fn new_table_entries_vec(&mut self, _: &[u8]) -> Vec<(Cow<'static, str>, Value<'static>)> { Vec::with_capacity(10) } }
new_values_vec
identifier_name
len.rs
use std::iter::{AdditiveIterator}; use {Data, Packet, Record, Question}; pub fn packet(p: &Packet) -> usize { let mut len = 12; // Header size for q in &p.question { len += question(q); } for r in &p.answer { len += record(r); } for r in &p.authority { len += record(r); } for r in &p.ad...
fn rp(mbox: &str, txt: &str) -> usize { domain_name(mbox) + domain_name(txt) } fn txt(s: &[String]) -> usize { s.iter().map(|v| character_string(v)).sum() } fn domain_name(s: &str) -> usize { let mut len = 0; for part in s.split('.') { len += 1 + part.len(); } len += 1; len } fn...
{ domain_name(domain) }
identifier_body
len.rs
use std::iter::{AdditiveIterator}; use {Data, Packet, Record, Question}; pub fn packet(p: &Packet) -> usize { let mut len = 12; // Header size for q in &p.question { len += question(q); } for r in &p.answer { len += record(r); } for r in &p.authority { len += record(r); } for r in &p.ad...
s.iter().map(|v| character_string(v)).sum() } fn domain_name(s: &str) -> usize { let mut len = 0; for part in s.split('.') { len += 1 + part.len(); } len += 1; len } fn character_string(s: &str) -> usize { 1 + s.len() }
} fn txt(s: &[String]) -> usize {
random_line_split
len.rs
use std::iter::{AdditiveIterator}; use {Data, Packet, Record, Question}; pub fn packet(p: &Packet) -> usize { let mut len = 12; // Header size for q in &p.question { len += question(q); } for r in &p.answer { len += record(r); } for r in &p.authority { len += record(r); } for r in &p.ad...
(r: &Record) -> usize { domain_name(&r.name) + 2 + 2 + 4 + 2 + data(&r.data) } pub fn data(d: &Data) -> usize { match *d { Data::A(..) => a(), Data::Aaaa(..) => aaaa(), Data::Mx(_, ref domain) => mx(domain), Data::Ptr(ref domain) => ptr(dom...
record
identifier_name
size_of.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::size_of; // pub fn size_of<T>() -> usize; macro_rules! size_of_test { ($T:ty, $size:expr) => ({ let size: usize = unsafe { size_of::<$T>() }; assert_eq!(size, $size); }) } #[test] ...
#[test] fn size_of_test2() { size_of_test!( u8, 1 ); size_of_test!( u16, 2 ); size_of_test!( u32, 4 ); size_of_test!( u64, 8 ); size_of_test!( i8, 1 ); size_of_test!( i16, 2 ); size_of_test!( i32, 4 ); size_of_test!( i64, 8 ); size_of_test!( f32, 4 ); size_of_test!( f64, 8 ); size_of_test!( [u8; ...
{ struct A; size_of_test!( A, 0 ); }
identifier_body
size_of.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::size_of; // pub fn size_of<T>() -> usize; macro_rules! size_of_test { ($T:ty, $size:expr) => ({ let size: usize = unsafe { size_of::<$T>() }; assert_eq!(size, $size); }) } #[test] ...
} }
random_line_split
size_of.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::size_of; // pub fn size_of<T>() -> usize; macro_rules! size_of_test { ($T:ty, $size:expr) => ({ let size: usize = unsafe { size_of::<$T>() }; assert_eq!(size, $size); }) } #[test] ...
() { size_of_test!( u8, 1 ); size_of_test!( u16, 2 ); size_of_test!( u32, 4 ); size_of_test!( u64, 8 ); size_of_test!( i8, 1 ); size_of_test!( i16, 2 ); size_of_test!( i32, 4 ); size_of_test!( i64, 8 ); size_of_test!( f32, 4 ); size_of_test!( f64, 8 ); size_of_test!( [u8; 0], 0 ); size_of_test!( [u8; 68],...
size_of_test2
identifier_name
regions-blk.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name
regions-blk.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ }
identifier_body
regions-blk.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn foo(cond: boo...
random_line_split
regions-blk.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() { }
{ let w: &'blk int = &x; z = w; }
conditional_block
textencoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::TextEncoderBinding; use dom::bindings::codegen::Bindings::TextEncoderBinding...
(global: GlobalRef, label: DOMString) -> Fallible<Root<TextEncoder>> { let encoding = match encoding_from_whatwg_label(&label) { Some(enc) => enc, None => { debug!("Encoding Label Not Supported"); return Err(Error::Range("The given e...
Constructor
identifier_name
textencoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::TextEncoderBinding; use dom::bindings::codegen::Bindings::TextEncoderBinding...
#[dom_struct] pub struct TextEncoder { reflector_: Reflector, #[ignore_heap_size_of = "Defined in rust-encoding"] encoder: EncodingRef, } impl TextEncoder { fn new_inherited(encoder: EncodingRef) -> TextEncoder { TextEncoder { reflector_: Reflector::new(), encoder: encod...
use std::borrow::ToOwned; use std::ptr;
random_line_split
textencoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::TextEncoderBinding; use dom::bindings::codegen::Bindings::TextEncoderBinding...
#[allow(unsafe_code)] // https://encoding.spec.whatwg.org/#dom-textencoder-encode fn Encode(&self, cx: *mut JSContext, input: USVString) -> *mut JSObject { unsafe { let encoded = self.encoder.encode(&input.0, EncoderTrap::Strict).unwrap(); let length = encoded.len() as u32;...
{ DOMString::from(self.encoder.name()) }
identifier_body
multimap.rs
use std::collections::btree_map; use std::default::Default; use std::iter::FromIterator; use super::map::{map, Map}; use super::set::Set; pub struct Multimap<K, C: Collection> { map: Map<K, C>, } pub trait Collection: Default { type Item; fn push(&mut self, item: Self::Item); } impl<K: Ord, C: Collecti...
(&self, key: &K) -> Option<&C> { self.map.get(key) } pub fn iter(&self) -> btree_map::Iter<K, C> { self.map.iter() } pub fn into_iter(self) -> btree_map::IntoIter<K, C> { self.map.into_iter() } } impl<K: Ord, C: Collection> IntoIterator for Multimap<K, C> { type Item =...
get
identifier_name
multimap.rs
use std::collections::btree_map; use std::default::Default; use std::iter::FromIterator; use super::map::{map, Map}; use super::set::Set; pub struct Multimap<K, C: Collection> { map: Map<K, C>, } pub trait Collection: Default { type Item; fn push(&mut self, item: Self::Item); } impl<K: Ord, C: Collecti...
} pub fn into_iter(self) -> btree_map::IntoIter<K, C> { self.map.into_iter() } } impl<K: Ord, C: Collection> IntoIterator for Multimap<K, C> { type Item = (K, C); type IntoIter = btree_map::IntoIter<K, C>; fn into_iter(self) -> btree_map::IntoIter<K, C> { self.into_iter() }...
pub fn iter(&self) -> btree_map::Iter<K, C> { self.map.iter()
random_line_split
multimap.rs
use std::collections::btree_map; use std::default::Default; use std::iter::FromIterator; use super::map::{map, Map}; use super::set::Set; pub struct Multimap<K, C: Collection> { map: Map<K, C>, } pub trait Collection: Default { type Item; fn push(&mut self, item: Self::Item); } impl<K: Ord, C: Collecti...
pub fn into_iter(self) -> btree_map::IntoIter<K, C> { self.map.into_iter() } } impl<K: Ord, C: Collection> IntoIterator for Multimap<K, C> { type Item = (K, C); type IntoIter = btree_map::IntoIter<K, C>; fn into_iter(self) -> btree_map::IntoIter<K, C> { self.into_iter() } } i...
{ self.map.iter() }
identifier_body
cmp-default.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 ...
} struct Int(isize); impl PartialEq for Int { fn eq(&self, other: &Int) -> bool { let Int(this) = *self; let Int(other) = *other; this == other } } impl PartialOrd for Int { fn partial_cmp(&self, other: &Int) -> Option<Ordering> { let Int(this) = *self; let Int(ot...
{ let Fool(this) = *self; let Fool(other) = *other; this != other }
identifier_body
cmp-default.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self, other: &RevInt) -> bool { let RevInt(this) = *self; let RevInt(other) = *other; this == other } } impl PartialOrd for RevInt { fn partial_cmp(&self, other: &RevInt) -> Option<Ordering> { let RevInt(this) = *self; let RevInt(other) = *other; other.partial_...
eq
identifier_name
cmp-default.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 ...
impl PartialEq for Fool { fn eq(&self, other: &Fool) -> bool { let Fool(this) = *self; let Fool(other) = *other; this!= other } } struct Int(isize); impl PartialEq for Int { fn eq(&self, other: &Int) -> bool { let Int(this) = *self; let Int(other) = *other; ...
random_line_split
starting_hand.rs
use crate::core::{Card, Hand, Suit, Value}; /// Enum to represent how the suits of a hand correspond to each other. /// `Suitedness::Suited` will mean that all cards have the same suit /// `Suitedness::OffSuit` will mean that all cards have the different suit /// `Suitedness::Any` makes no promises. #[derive(Debug, Eq...
(value_one: Value, value_two: Value, suited: Suitedness) -> Self { Self::Def(Default { value_one, value_two, suited, }) } /// Create a new StartingHand with the second card being a range. pub fn single_range(value_one: Value, start: Value, end: Value, sui...
default
identifier_name
starting_hand.rs
use crate::core::{Card, Hand, Suit, Value}; /// Enum to represent how the suits of a hand correspond to each other. /// `Suitedness::Suited` will mean that all cards have the same suit /// `Suitedness::OffSuit` will mean that all cards have the different suit /// `Suitedness::Any` makes no promises. #[derive(Debug, Eq...
value: self.value_one, suit: *suit_two, }, Card { value: self.value_two, suit: *suit_one, }, ])); } ...
{ let suits = Suit::suits(); for (i, suit_one) in suits.iter().enumerate() { for suit_two in &suits[i + 1..] { // Push the hands in. hands.push(Hand::new_with_cards(vec![ Card { value: self.value_one, ...
identifier_body
starting_hand.rs
use crate::core::{Card, Hand, Suit, Value}; /// Enum to represent how the suits of a hand correspond to each other. /// `Suitedness::Suited` will mean that all cards have the same suit /// `Suitedness::OffSuit` will mean that all cards have the different suit /// `Suitedness::Any` makes no promises. #[derive(Debug, Eq...
} } hands } /// Get all the possible starting hands represented by the /// two values of this starting hand. fn possible_hands(&self) -> Vec<Hand> { match self.suited { Suitedness::Suited => self.create_suited(), Suitedness::OffSuit => self.c...
{ hands.push(Hand::new_with_cards(vec![ Card { value: self.value_one, suit: *suit_two, }, Card { value: self.value_two, ...
conditional_block
starting_hand.rs
use crate::core::{Card, Hand, Suit, Value}; /// Enum to represent how the suits of a hand correspond to each other. /// `Suitedness::Suited` will mean that all cards have the same suit /// `Suitedness::OffSuit` will mean that all cards have the different suit /// `Suitedness::Any` makes no promises. #[derive(Debug, Eq...
} /// Create every possible unique StartingHand. pub fn all() -> Vec<Self> { let mut hands = Vec::with_capacity(169); let values = Value::values(); for (i, value_one) in values.iter().enumerate() { for value_two in &values[i..] { hands.push(Self::Def(Defa...
start, end, suited, })
random_line_split
extern-fn-reachable.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// xfail-fast // xfail-linux apparently dlsym doesn't work on program symbols? // xfail-android apparently dlsym doesn't work on program symbols? // xfail-freebsd apparently dlsym doesn't work on program symbols? use std::unstable::dynamic_lib::DynamicLibrary; #[no_mangle] pub extern "C" fn fun1() {} #[no_mangle] ex...
random_line_split
extern-fn-reachable.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { unsafe { let a = DynamicLibrary::open(None).unwrap(); assert!(a.symbol::<int>("fun1").is_ok()); assert!(a.symbol::<int>("fun2").is_err()); assert!(a.symbol::<int>("fun3").is_err()); assert!(a.symbol::<int>("fun4").is_ok()); assert!(a.symbol::<int>("fun5"...
{}
identifier_body
extern-fn-reachable.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() {} } #[no_mangle] pub fn fun5() {} fn main() { unsafe { let a = DynamicLibrary::open(None).unwrap(); assert!(a.symbol::<int>("fun1").is_ok()); assert!(a.symbol::<int>("fun2").is_err()); assert!(a.symbol::<int>("fun3").is_err()); assert!(a.symbol::<int>("fun4").is_ok()); ...
fun4
identifier_name
main.rs
use std::collections::HashSet; use std::io; use std::io::prelude::*; extern crate regex; use regex::Regex; fn replace(rep: (Regex, String), molecule: &String) -> HashSet<String> { let (reg, r) = rep; let mut replacements = HashSet::new(); for (start, end) in reg.find_iter(molecule) { let front = m...
(line: &String) -> (Regex, String) { let rep_re = Regex::new(r"(.*) => (.*)").unwrap(); match rep_re.captures(line) { Some(caps) => (Regex::new(caps.at(1).unwrap()).unwrap(), caps.at(2).unwrap().to_string()), None => panic!("ahh"), } } fn main() { let stdin = io::...
parse_replacement
identifier_name
main.rs
use std::collections::HashSet; use std::io; use std::io::prelude::*; extern crate regex; use regex::Regex; fn replace(rep: (Regex, String), molecule: &String) -> HashSet<String> { let (reg, r) = rep; let mut replacements = HashSet::new(); for (start, end) in reg.find_iter(molecule) { let front = m...
for rep in replacements { let repl = replace(rep, &molecule); derivatives = repl.union(&derivatives).cloned().collect(); } println!("{}", derivatives.len()); }
random_line_split
main.rs
use std::collections::HashSet; use std::io; use std::io::prelude::*; extern crate regex; use regex::Regex; fn replace(rep: (Regex, String), molecule: &String) -> HashSet<String>
fn parse_replacement(line: &String) -> (Regex, String) { let rep_re = Regex::new(r"(.*) => (.*)").unwrap(); match rep_re.captures(line) { Some(caps) => (Regex::new(caps.at(1).unwrap()).unwrap(), caps.at(2).unwrap().to_string()), None => panic!("ahh"), } } fn main() ...
{ let (reg, r) = rep; let mut replacements = HashSet::new(); for (start, end) in reg.find_iter(molecule) { let front = molecule[0..start].to_string(); let back = molecule[end..].to_string(); let repl = front + &r + &back; replacements.insert(repl); } replacements }
identifier_body
const_FRAC_1_PI.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::f32::consts::FRAC_1_PI; // 1.0/pi // pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724_f32; #[test] fn
() { let mut value: f32 = 0.0_f32; unsafe { *(&mut value as *mut f32 as *mut u32) = 0b0_01111101_01000101111100110000011; } assert_eq!(FRAC_1_PI, value); } }
frac_1_pi_test1
identifier_name
const_FRAC_1_PI.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::f32::consts::FRAC_1_PI; // 1.0/pi // pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724_f32; #[test] fn frac_1_pi_test1()
}
{ let mut value: f32 = 0.0_f32; unsafe { *(&mut value as *mut f32 as *mut u32) = 0b0_01111101_01000101111100110000011; } assert_eq!(FRAC_1_PI, value); }
identifier_body
const_FRAC_1_PI.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::f32::consts::FRAC_1_PI; // 1.0/pi // pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724_f32; #[test] fn frac_1_pi_test1() { let mut value: f32 = 0.0_f32; unsafe { *(&mut value as *mut f32 as *mut u32) =...
assert_eq!(FRAC_1_PI, value); } }
random_line_split
rbmtp_cross_crate_lib.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 bigger_region<'b:'a>(self, b: Inv<'b>); } impl<'a> IntoMaybeOwned<'a> for Inv<'a> { fn into_maybe_owned(self) -> MaybeOwned<'a> { panic!() } fn into_inv(self) -> Inv<'a> { panic!() } fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() } }
random_line_split
rbmtp_cross_crate_lib.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 ...
(self) -> Inv<'a> { panic!() } fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() } }
into_inv
identifier_name
html.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/. */ #![allow(unrooted_must_root)] use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateEleme...
} } pub fn end(&mut self) { self.inner.end(); } pub fn url(&self) -> &ServoUrl { &self.inner.sink().sink().base_url } pub fn set_plaintext_state(&mut self) { self.inner.set_plaintext_state(); } } #[allow(unsafe_code)] unsafe impl JSTraceable for HtmlTokeni...
TokenizerResult::Script(script) => Err(Root::from_ref(script.downcast().unwrap())),
random_line_split
html.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/. */ #![allow(unrooted_must_root)] use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateEleme...
, (IncludeNode, NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction)) => { let pi = node.downcast::<ProcessingInstruction>().unwrap(); let data = pi.upcast::<CharacterData>().data(); serializer.write_processing_instruction(&pi.target(), &data...
{ let cdata = node.downcast::<CharacterData>().unwrap(); serializer.write_comment(&cdata.data()) }
conditional_block
html.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/. */ #![allow(unrooted_must_root)] use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateEleme...
(&mut self, input: &mut BufferQueue) -> Result<(), Root<HTMLScriptElement>> { match self.inner.feed(input) { TokenizerResult::Done => Ok(()), TokenizerResult::Script(script) => Err(Root::from_ref(script.downcast().unwrap())), } } pub fn end(&mut self) { self.inne...
feed
identifier_name
html.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/. */ #![allow(unrooted_must_root)] use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateEleme...
} #[allow(unsafe_code)] unsafe impl JSTraceable for HtmlTokenizer<TreeBuilder<JS<Node>, Sink>> { unsafe fn trace(&self, trc: *mut JSTracer) { struct Tracer(*mut JSTracer); let tracer = Tracer(trc); impl HtmlTracer for Tracer { type Handle = JS<Node>; #[allow(unroot...
{ self.inner.set_plaintext_state(); }
identifier_body
shared-generics.rs
// // no-prefer-dynamic // NOTE: We always compile this test with -Copt-level=0 because higher opt-levels // prevent drop-glue from participating in share-generics. // incremental // compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0 #![crate_type="rlib"] // aux-build:shared_generics_aux....
{ //~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_generics.volatile[External] let _ = shared_generics_aux::generic_fn(0u16, 1u16); // This should not generate a monomorphization because it's already // available in `shared_generics_aux`. let _ = shared_gene...
identifier_body
shared-generics.rs
// // no-prefer-dynamic // NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
// incremental // compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0 #![crate_type="rlib"] // aux-build:shared_generics_aux.rs extern crate shared_generics_aux; //~ MONO_ITEM fn foo pub fn foo() { //~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_gen...
// prevent drop-glue from participating in share-generics.
random_line_split
shared-generics.rs
// // no-prefer-dynamic // NOTE: We always compile this test with -Copt-level=0 because higher opt-levels // prevent drop-glue from participating in share-generics. // incremental // compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0 #![crate_type="rlib"] // aux-build:shared_generics_aux....
() { //~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_generics.volatile[External] let _ = shared_generics_aux::generic_fn(0u16, 1u16); // This should not generate a monomorphization because it's already // available in `shared_generics_aux`. let _ = shared_g...
foo
identifier_name
cli.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/. */ extern crate geometrify; extern crate image; extern crate clap; extern crate pbr; use clap::{Arg, App, AppSet...
() -> PbrProgressReporter { PbrProgressReporter { bar: None } } } impl ProgressReporter for PbrProgressReporter { fn init(&mut self, steps: u64) { let mut progress = ProgressBar::new(steps); progress.format("|#--|"); self.bar = Some(progress); } fn step(&mut self) { ...
new
identifier_name
cli.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/. */ extern crate geometrify; extern crate image; extern crate clap; extern crate pbr; use clap::{Arg, App, AppSet...
let ref mut bar = self.bar .as_mut() .expect("ProgressReporter was not initialized"); bar.inc(); } fn finish(&mut self) { { let ref mut bar = self.bar .as_mut() .expect("ProgressReporter was not initialized"); b...
random_line_split
cli.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/. */ extern crate geometrify; extern crate image; extern crate clap; extern crate pbr; use clap::{Arg, App, AppSet...
} impl ProgressReporter for PbrProgressReporter { fn init(&mut self, steps: u64) { let mut progress = ProgressBar::new(steps); progress.format("|#--|"); self.bar = Some(progress); } fn step(&mut self) { let ref mut bar = self.bar .as_mut() .expect("Pr...
{ PbrProgressReporter { bar: None } }
identifier_body
replays.rs
use std::fs; use std::path::PathBuf; use std::cmp::Ordering; use chrono::{Local, DateTime}; use pf_sandbox_lib::files; use pf_sandbox_lib::input::ControllerInput; use pf_sandbox_lib::package::Package; use pf_sandbox_lib::stage::Stage; use crate::game::{Game, PlayerSetup}; use crate::input::Input; use crate::player::P...
(package: &Package, name: &str) -> PathBuf { let mut replay_path = get_replays_dir_path(package); replay_path.push(format!("{}.zip", name)); replay_path } pub fn load_replay(name: &str, package: &Package) -> Result<Replay, String> { let replay_path = get_replay_path(package, name); files::load_stru...
get_replay_path
identifier_name
replays.rs
use std::fs; use std::path::PathBuf; use std::cmp::Ordering; use chrono::{Local, DateTime}; use pf_sandbox_lib::files; use pf_sandbox_lib::input::ControllerInput; use pf_sandbox_lib::package::Package; use pf_sandbox_lib::stage::Stage; use crate::game::{Game, PlayerSetup}; use crate::input::Input; use crate::player::P...
fn get_replay_path(package: &Package, name: &str) -> PathBuf { let mut replay_path = get_replays_dir_path(package); replay_path.push(format!("{}.zip", name)); replay_path } pub fn load_replay(name: &str, package: &Package) -> Result<Replay, String> { let replay_path = get_replay_path(package, name); ...
{ let mut replays_path = files::get_path(); replays_path.push("replays"); replays_path.push(package.file_name()); replays_path }
identifier_body
replays.rs
use std::fs; use std::path::PathBuf; use std::cmp::Ordering; use chrono::{Local, DateTime}; use pf_sandbox_lib::files; use pf_sandbox_lib::input::ControllerInput; use pf_sandbox_lib::package::Package; use pf_sandbox_lib::stage::Stage; use crate::game::{Game, PlayerSetup}; use crate::input::Input; use crate::player::P...
fn get_replays_dir_path(package: &Package) -> PathBuf { let mut replays_path = files::get_path(); replays_path.push("replays"); replays_path.push(package.file_name()); replays_path } fn get_replay_path(package: &Package, name: &str) -> PathBuf { let mut replay_path = get_replays_dir_path(package);...
result }
random_line_split
replays.rs
use std::fs; use std::path::PathBuf; use std::cmp::Ordering; use chrono::{Local, DateTime}; use pf_sandbox_lib::files; use pf_sandbox_lib::input::ControllerInput; use pf_sandbox_lib::package::Package; use pf_sandbox_lib::stage::Stage; use crate::game::{Game, PlayerSetup}; use crate::input::Input; use crate::player::P...
} } ); result } fn get_replays_dir_path(package: &Package) -> PathBuf { let mut replays_path = files::get_path(); replays_path.push("replays"); replays_path.push(package.file_name()); replays_path } fn get_replay_path(package: &Package, name: &str) -> PathBuf { let mut...
{ Ordering::Greater }
conditional_block
script_msg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use AnimationState; use DocumentState; use IFrameLoadInfo; use MouseButton; use MouseEventType; use MozBrowserEven...
} /// Messages from the script to the constellation. #[derive(Deserialize, Serialize)] pub enum ScriptMsg { /// Indicates whether this pipeline is currently running animations. ChangeRunningAnimationsState(PipelineId, AnimationState), /// Requests that a new 2D canvas thread be created. (This is done in th...
random_line_split
script_msg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use AnimationState; use DocumentState; use IFrameLoadInfo; use MouseButton; use MouseEventType; use MozBrowserEven...
{ /// script resource url pub script_url: Url, /// pipeline which requested the activation pub pipeline_id: PipelineId, /// network load origin of the resource pub worker_load_origin: WorkerScriptLoadOrigin, /// base resources required to create worker global scopes pub init: WorkerGlob...
ScopeThings
identifier_name
krpc.rs
// Copyright 2014 Dmitry "Divius" Tantsur <divius.inside@gmail.com> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, ...
() { let n = test::new_node_with_port(42, 8009); let s = KRpcService::new_default(n.clone()).unwrap(); assert_eq!(n.id, s.this_node.id); let nt = s.node_table_lock().read().unwrap(); assert_eq!(0, nt.find(&test::usize_to_id(1), 1).len()); } }
test_new_default
identifier_name
krpc.rs
// Copyright 2014 Dmitry "Divius" Tantsur <divius.inside@gmail.com> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, ...
#[test] fn test_new_default() { let n = test::new_node_with_port(42, 8009); let s = KRpcService::new_default(n.clone()).unwrap(); assert_eq!(n.id, s.this_node.id); let nt = s.node_table_lock().read().unwrap(); assert_eq!(0, nt.find(&test::usize_to_id(1), 1).len()); ...
{ let n = test::new_node_with_port(42, 8007); let sock = DummySocketWrapper { last_package: None, last_node: None }; let s = KRpcService::new(n.clone(), DummyNodeTable { last_node: None }, sock).unwrap(); assert_eq!(n.id, ...
identifier_body
krpc.rs
// Copyright 2014 Dmitry "Divius" Tantsur <divius.inside@gmail.com> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, ...
Drop for KRpcService<TNodeTable, TSocket> { fn drop(&mut self) { *self.active.write().unwrap() = false; } } #[cfg(test)] mod test { use std::old_io::IoResult; use std::old_io::net::ip; use num::traits::ToPrimitive; use num; use super::super::super::base::{self, GenericNodeTable}; ...
#[unsafe_destructor] impl<TNodeTable: base::GenericNodeTable, TSocket: udpwrapper::GenericSocketWrapper>
random_line_split
borrowck-loan-rcvr.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct point { x: int, y: int } trait methods { fn impurem(&self); fn blockm(&self, f: &fn()); } impl methods for point { fn impurem(&self) ...
random_line_split
borrowck-loan-rcvr.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 p = point {x: 3, y: 4}; // Here: it's ok to call even though receiver is mutable, because we // can loan it out. p.impurem(); // But in this case we do not honor the loan: do p.blockm { p.x = 10; //~ ERROR cannot assign } } fn b() { let mut p = point {x: 3, y: 4};...
a
identifier_name
borrowck-loan-rcvr.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn b() { let mut p = point {x: 3, y: 4}; // Here I create an outstanding loan and check that we get conflicts: let l = &mut p; p.impurem(); //~ ERROR cannot borrow l.x += 1; } fn c() { // Loaning @mut as & is considered legal due to dynamic checks... let q = @mut point {x: 3, y: 4}; ...
{ let mut p = point {x: 3, y: 4}; // Here: it's ok to call even though receiver is mutable, because we // can loan it out. p.impurem(); // But in this case we do not honor the loan: do p.blockm { p.x = 10; //~ ERROR cannot assign } }
identifier_body