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
authorized.rs
use session::game::{Session, GameState}; use session::game::chunk::{self, Ref}; use protocol::messages::authorized::*; use std::io::Result; use server::SERVER; #[register_handlers] impl Session { pub fn handle_admin_quiet_command_message<'a>(&mut self, chunk: Ref<'a>, ...
Ok(()) } }
}
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // For simd (currently x86_64/aarch64) #![cfg_attr(any(target_os = "linux", target_os = "android", target_os = "wi...
pub mod paint_thread; // Platform-specific implementations. #[allow(unsafe_code)] mod platform; // Text pub mod text;
pub mod font_context; pub mod font_template;
random_line_split
TestNativeDivide.rs
/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by app...
float __attribute__((kernel)) testNativeDivideFloatFloatFloat(float inLeftVector, unsigned int x) { float inRightVector = rsGetElementAt_float(gAllocInRightVector, x); return native_divide(inLeftVector, inRightVector); } float2 __attribute__((kernel)) testNativeDivideFloat2Float2Float2(float2 inLeftVector, un...
#pragma rs java_package_name(android.renderscript.cts) rs_allocation gAllocInRightVector;
random_line_split
pthread.rs
//! Low level threading primitives #[cfg(not(target_os = "redox"))] use crate::errno::Errno; #[cfg(not(target_os = "redox"))] use crate::Result; use libc::{self, pthread_t}; /// Identifies an individual thread. pub type Pthread = pthread_t; /// Obtain ID of the calling thread (see /// [`pthread_self(3)`](https://pub...
Errno::result(res).map(drop) } }
let sig = match signal.into() { Some(s) => s as libc::c_int, None => 0, }; let res = unsafe { libc::pthread_kill(thread, sig) };
random_line_split
pthread.rs
//! Low level threading primitives #[cfg(not(target_os = "redox"))] use crate::errno::Errno; #[cfg(not(target_os = "redox"))] use crate::Result; use libc::{self, pthread_t}; /// Identifies an individual thread. pub type Pthread = pthread_t; /// Obtain ID of the calling thread (see /// [`pthread_self(3)`](https://pub...
feature! { #![feature = "signal"] /// Send a signal to a thread (see [`pthread_kill(3)`]). /// /// If `signal` is `None`, `pthread_kill` will only preform error checking and /// won't send any signal. /// /// [`pthread_kill(3)`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html #[cfg(not(...
{ unsafe { libc::pthread_self() } }
identifier_body
pthread.rs
//! Low level threading primitives #[cfg(not(target_os = "redox"))] use crate::errno::Errno; #[cfg(not(target_os = "redox"))] use crate::Result; use libc::{self, pthread_t}; /// Identifies an individual thread. pub type Pthread = pthread_t; /// Obtain ID of the calling thread (see /// [`pthread_self(3)`](https://pub...
() -> Pthread { unsafe { libc::pthread_self() } } feature! { #![feature = "signal"] /// Send a signal to a thread (see [`pthread_kill(3)`]). /// /// If `signal` is `None`, `pthread_kill` will only preform error checking and /// won't send any signal. /// /// [`pthread_kill(3)`]: https://pubs.opengroup.org/onlinep...
pthread_self
identifier_name
fastq.rs
// Copyright 2014-2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! FastQ reading and writing. //! //! # Example //! //! ``` //! use std::io; //! use bio::io::fastq; //! let reade...
try!(self.reader.read_line(&mut record.qual)); if record.qual.is_empty() { return Err(io::Error::new( io::ErrorKind::Other, "Incomplete record. Each FastQ record has to consist \ of 4 lines: header, sequence, separator ...
try!(self.reader.read_line(&mut record.seq)); try!(self.reader.read_line(&mut self.sep_line));
random_line_split
fastq.rs
// Copyright 2014-2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! FastQ reading and writing. //! //! # Example //! //! ``` //! use std::io; //! use bio::io::fastq; //! let reade...
if!self.qual.is_ascii() { return Err("Non-ascii character found in qualities."); } if self.seq().len()!= self.qual().len() { return Err("Unequal length of sequence an qualities."); } Ok(()) } /// Return the id of the record. pub fn id(&self) ...
return Err("Non-ascii character found in sequence."); }
conditional_block
fastq.rs
// Copyright 2014-2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! FastQ reading and writing. //! //! # Example //! //! ``` //! use std::io; //! use bio::io::fastq; //! let reade...
} /// A FastQ record. #[derive(Debug, Clone, Default)] pub struct Record { id: String, desc: Option<String>, seq: String, qual: String, } impl Record { /// Create a new, empty FastQ record. pub fn new() -> Self { Record { id: String::new(), desc: None, ...
Records { reader: self } }
identifier_body
fastq.rs
// Copyright 2014-2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! FastQ reading and writing. //! //! # Example //! //! ``` //! use std::io; //! use bio::io::fastq; //! let reade...
) { let reader = Reader::new(FASTQ_FILE); let records: Vec<io::Result<Record>> = reader.records().collect(); assert!(records.len() == 1); for res in records { let record = res.ok().unwrap(); assert_eq!(record.check(), Ok(())); assert_eq!(record.id(), "...
est_reader(
identifier_name
http_get.rs
extern crate clap; extern crate fibers; extern crate futures; extern crate miasht; use clap::{App, Arg}; use fibers::{Executor, InPlaceExecutor, Spawn}; use futures::{Future, IntoFuture}; use miasht::{Client, Method}; use miasht::builtin::{FutureExt, IoExt}; fn main()
Client::new() .connect(addr) .and_then(move |connection| connection.build_request(Method::Get, &path).finish()) .and_then(|req| req.read_response()) .and_then(|res| { res.into_body_reader() .into_future() .and_then...
{ let matches = App::new("http_get") .arg(Arg::with_name("HOST").index(1).required(true)) .arg(Arg::with_name("PATH").index(2).required(true)) .arg( Arg::with_name("PORT") .short("p") .takes_value(true) .default_value("80"), ...
identifier_body
http_get.rs
extern crate clap; extern crate fibers; extern crate futures; extern crate miasht; use clap::{App, Arg}; use fibers::{Executor, InPlaceExecutor, Spawn}; use futures::{Future, IntoFuture}; use miasht::{Client, Method}; use miasht::builtin::{FutureExt, IoExt}; fn main() { let matches = App::new("http_get") ....
); match executor.run_fiber(monitor).unwrap() { Ok(s) => println!("{}", s), Err(e) => println!("[ERROR] {:?}", e), } }
.into_future() .and_then(|r| r.read_all_str()) .map(|(_, body)| body) }),
random_line_split
http_get.rs
extern crate clap; extern crate fibers; extern crate futures; extern crate miasht; use clap::{App, Arg}; use fibers::{Executor, InPlaceExecutor, Spawn}; use futures::{Future, IntoFuture}; use miasht::{Client, Method}; use miasht::builtin::{FutureExt, IoExt}; fn
() { let matches = App::new("http_get") .arg(Arg::with_name("HOST").index(1).required(true)) .arg(Arg::with_name("PATH").index(2).required(true)) .arg( Arg::with_name("PORT") .short("p") .takes_value(true) .default_value("80"), ) ...
main
identifier_name
example.rs
extern crate int_range_check; use std::fmt::Display; use std::num::Int; use int_range_check::uncovered_and_overlapped; use int_range_check::IntRange; use int_range_check::IntRange::*; fn main() { example_driver("Example 1", vec![Bound(0i32, 5i32), From(3)]); example_driver("Example 2a", vec![To(5u8), From(2...
println!("{} uncovered ranges: {}", title, uncovered); println!("{} overlapping ranges: {}", title, overlapped); }
println!("{} input ranges: {}", title, ranges);
random_line_split
example.rs
extern crate int_range_check; use std::fmt::Display; use std::num::Int; use int_range_check::uncovered_and_overlapped; use int_range_check::IntRange; use int_range_check::IntRange::*; fn main() { example_driver("Example 1", vec![Bound(0i32, 5i32), From(3)]); example_driver("Example 2a", vec![To(5u8), From(...
<T: Display+Int>(title: &str, ranges: Vec<IntRange<T>>) { let (uncovered, overlapped) = uncovered_and_overlapped(&ranges); println!("{} input ranges: {}", title, ranges); println!("{} uncovered ranges: {}", title, uncovered); println!("{} overlapping ranges: {}", title, overlapped); }
example_driver
identifier_name
example.rs
extern crate int_range_check; use std::fmt::Display; use std::num::Int; use int_range_check::uncovered_and_overlapped; use int_range_check::IntRange; use int_range_check::IntRange::*; fn main()
fn example_driver<T: Display+Int>(title: &str, ranges: Vec<IntRange<T>>) { let (uncovered, overlapped) = uncovered_and_overlapped(&ranges); println!("{} input ranges: {}", title, ranges); println!("{} uncovered ranges: {}", title, uncovered); println!("{} overlapping ranges: {}", title, overla...
{ example_driver("Example 1", vec![Bound(0i32, 5i32), From(3)]); example_driver("Example 2a", vec![To(5u8), From(250)]); example_driver("Example 2b", vec![Bound(0u8, 5), Bound(250, 255)]); }
identifier_body
group_by.rs
use deuterium::*; #[test] fn select_group_by() { let jedi_table = TableDef::new("jedi"); let name = NamedField::<String>::field_of("name", &jedi_table); let side = NamedField::<bool>::field_of("side", &jedi_table); let force_level = NamedField::<i8>::field_of("force_level", &jedi_table); let quer...
() { let jedi_table = TableDef::new("jedi"); let name = NamedField::<String>::field_of("name", &jedi_table); let force_level = NamedField::<i8>::field_of("force_level", &jedi_table); let query = jedi_table.select_2(&name, &force_level.sum()).group_by(&[&name]); assert_sql!(query, "SELECT name, SUM...
select_with_agg
identifier_name
group_by.rs
use deuterium::*; #[test] fn select_group_by() { let jedi_table = TableDef::new("jedi"); let name = NamedField::<String>::field_of("name", &jedi_table); let side = NamedField::<bool>::field_of("side", &jedi_table); let force_level = NamedField::<i8>::field_of("force_level", &jedi_table); let quer...
{ let jedi_table = TableDef::new("jedi"); let name = NamedField::<String>::field_of("name", &jedi_table); let force_level = NamedField::<i8>::field_of("force_level", &jedi_table); let query = jedi_table.select_2(&name, &force_level.sum()).group_by(&[&name]); assert_sql!(query, "SELECT name, SUM(fo...
identifier_body
group_by.rs
use deuterium::*; #[test] fn select_group_by() { let jedi_table = TableDef::new("jedi"); let name = NamedField::<String>::field_of("name", &jedi_table); let side = NamedField::<bool>::field_of("side", &jedi_table); let force_level = NamedField::<i8>::field_of("force_level", &jedi_table); let quer...
} #[test] fn select_with_agg() { let jedi_table = TableDef::new("jedi"); let name = NamedField::<String>::field_of("name", &jedi_table); let force_level = NamedField::<i8>::field_of("force_level", &jedi_table); let query = jedi_table.select_2(&name, &force_level.sum()).group_by(&[&name]); assert_...
let query = jedi_table.select_2(&name, &force_level.sum()).group_by(&[&name]); assert_sql!(query, "SELECT name, SUM(force_level) FROM jedi GROUP BY name;");
random_line_split
worker.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
<Message> { pub work_type: WorkType<Message>, pub token: usize, pub handler_id: HandlerId, pub handler: Arc<IoHandler<Message>>, } /// An IO worker thread /// Sorts them ready for blockchain insertion. pub struct Worker { thread: Option<JoinHandle<()>>, wait: Arc<Condvar>, deleting: Arc<AtomicBool>, wait_mutex...
Work
identifier_name
worker.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
WorkType::Message(message) => { work.handler.message(&IoContext::new(channel, work.handler_id), &message); } } } } impl Drop for Worker { fn drop(&mut self) { trace!(target: "shutdown", "[IoWorker] Closing..."); let _ = self.wait_mutex.lock(); self.deleting.store(true, AtomicOrdering::Release); ...
{ work.handler.timeout(&IoContext::new(channel, work.handler_id), work.token); }
conditional_block
worker.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
} WorkType::Hup => { work.handler.stream_hup(&IoContext::new(channel, work.handler_id), work.token); } WorkType::Timeout => { work.handler.timeout(&IoContext::new(channel, work.handler_id), work.token); } WorkType::Message(message) => { work.handler.message(&IoContext::new(channel, work.ha...
} WorkType::Writable => { work.handler.stream_writable(&IoContext::new(channel, work.handler_id), work.token);
random_line_split
vec-matching-autoslice.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x = [1, 2, 3]; match x { [2, _, _] => panic!(), [1, a, b] => { assert_eq!([a, b], [2, 3]); } [_, _, _] => panic!(), } let y = ([(1, true), (2, false)], 0.5f64); match y { ([(1, a), (b, false)], _) => { assert_eq!(a, true); ...
main
identifier_name
vec-matching-autoslice.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 ...
pub fn main() { let x = [1, 2, 3]; match x { [2, _, _] => panic!(), [1, a, b] => { assert_eq!([a, b], [2, 3]); } [_, _, _] => panic!(), } let y = ([(1, true), (2, false)], 0.5f64); match y { ([(1, a), (b, false)], _) => { assert_eq!(a,...
random_line_split
vec-matching-autoslice.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let x = [1, 2, 3]; match x { [2, _, _] => panic!(), [1, a, b] => { assert_eq!([a, b], [2, 3]); } [_, _, _] => panic!(), } let y = ([(1, true), (2, false)], 0.5f64); match y { ([(1, a), (b, false)], _) => { assert_eq!(a, true); ...
identifier_body
lib.rs
//! Concurrent work-stealing deques. //! //! These data structures are most commonly used in work-stealing schedulers. The typical setup //! involves a number of threads, each having its own FIFO or LIFO queue (*worker*). There is also //! one global FIFO queue (*injector*) and a list of references to *worker* queues t...
//! ) -> Option<T> { //! // Pop a task from the local queue, if not empty. //! local.pop().or_else(|| { //! // Otherwise, we need to look for a task elsewhere. //! iter::repeat_with(|| { //! // Try stealing a batch of tasks from the global queue. //! global.steal_batch_an...
random_line_split
scalar.rs
// mrusty. mruby safe bindings for Rust // Copyright (C) 2016 Dragoș Tiselice // // 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 mrusty::MrubyImpl; use super::...
{ pub value: f32 } impl Scalar { pub fn new(value: f32) -> Scalar { Scalar { value: value } } pub fn set_value(&mut self, value: f32) { self.value = value; } } mrusty_class!(Scalar, { def!("initialize", |v: f64| { Scalar::new(v as f32) }); ...
calar
identifier_name
scalar.rs
// mrusty. mruby safe bindings for Rust // Copyright (C) 2016 Dragoș Tiselice // // 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 mrusty::MrubyImpl; use super::...
}); def!("value=", |mruby, slf: (&mut Scalar), v: f64| { slf.set_value(v as f32); mruby.nil() }); def!("*", |mruby, slf: (&Scalar), vector: (&Vector)| { mruby.obj((*slf).clone() * (*vector).clone()) }); def!("panic", |_slf: Value| { panic!("I always panic."); ...
}); def!("value", |mruby, slf: (&Scalar)| { mruby.float(slf.value as f64)
random_line_split
scalar.rs
// mrusty. mruby safe bindings for Rust // Copyright (C) 2016 Dragoș Tiselice // // 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 mrusty::MrubyImpl; use super::...
} mrusty_class!(Scalar, { def!("initialize", |v: f64| { Scalar::new(v as f32) }); def!("value", |mruby, slf: (&Scalar)| { mruby.float(slf.value as f64) }); def!("value=", |mruby, slf: (&mut Scalar), v: f64| { slf.set_value(v as f32); mruby.nil() }); def!(...
self.value = value; }
identifier_body
lib.rs
//! A simple X11 status bar for use with simple WMs. //! //! Cnx is written to be customisable, simple and fast. Where possible, it //! prefers to asynchronously wait for changes in the underlying data sources //! (and uses [`tokio`] to achieve this), rather than periodically //! calling out to external programs. //! /...
ync fn run_inner(self) -> Result<()> { let mut bar = Bar::new(self.position)?; let mut widgets = StreamMap::with_capacity(self.widgets.len()); for widget in self.widgets { let idx = bar.add_content(Vec::new())?; widgets.insert(idx, widget.into_stream()?); } ...
// Use a single-threaded event loop. We aren't interested in // performance too much, so don't mind if we block the loop // occasionally. We are using events to get woken up as // infrequently as possible (to save battery). let rt = Runtime::new()?; let local = task::LocalSet::...
identifier_body
lib.rs
//! A simple X11 status bar for use with simple WMs. //! //! Cnx is written to be customisable, simple and fast. Where possible, it //! prefers to asynchronously wait for changes in the underlying data sources //! (and uses [`tokio`] to achieve this), rather than periodically //! calling out to external programs. //! /...
//! customizing Cnx are then limited). //! //! Before running Cnx, you'll need to make sure your system has the required //! dependencies, which are described in the [`README`][readme-deps]. //! //! # Built-in widgets //! //! There are currently these widgets available: //! //! - [`crate::widgets::ActiveWindowTitle`] —...
//! A more complex example is given in [`cnx-bin/src/main.rs`] alongside the project. //! (This is the default `[bin]` target for the crate, so you _could_ use it by //! either executing `cargo run` from the crate root, or even running `cargo //! install cnx; cnx`. However, neither of these are recommended as options f...
random_line_split
lib.rs
//! A simple X11 status bar for use with simple WMs. //! //! Cnx is written to be customisable, simple and fast. Where possible, it //! prefers to asynchronously wait for changes in the underlying data sources //! (and uses [`tokio`] to achieve this), rather than periodically //! calling out to external programs. //! /...
self, widget: W) where W: Widget +'static, { self.widgets.push(Box::new(widget)); } /// Runs the Cnx instance. /// /// This method takes ownership of the Cnx instance and runs it until either /// the process is terminated, or an internal error is returned. pub fn run(se...
et<W>(&mut
identifier_name
inherited_table.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("InheritedTable", inherited=True, ...
Ok(()) } } impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; #[inline] fn to_computed_value(&self, context: &Context) -> computed_value::T { let horizontal = self.horizontal.to_computed_value(context); compute...
{ try!(dest.write_str(" ")); vertical.to_css(dest)?; }
conditional_block
inherited_table.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("InheritedTable", inherited=True, ...
} } } pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<SpecifiedValue,ParseError<'i>> { let mut first = None; let mut second = None; match Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes) ...
random_line_split
inherited_table.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("InheritedTable", inherited=True, ...
(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> { Ok(T { horizontal: try!(self.horizontal.add_weighted(&other.horizontal, self_portion, other_portion)), ...
add_weighted
identifier_name
inherited_table.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("InheritedTable", inherited=True, ...
#[inline] fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> { Ok(try!(self.horizontal.compute_squared_distance(&other.horizontal)) + try!(self.vertical.compute_squared_distance(&other.vertical))) } } } #[derive(C...
{ self.compute_squared_distance(other).map(|sd| sd.sqrt()) }
identifier_body
main.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
println!("usage: {} [client | server] ADDRESS", args[0]); }
random_line_split
main.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
{ let args : Vec<String> = ::std::env::args().collect(); if args.len() >= 2 { match &args[1][..] { "client" => return client::main(), "server" => return server::main(), _ => (), } } println!("usage: {} [client | server] ADDRESS", args[0]); }
identifier_body
main.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
() { let args : Vec<String> = ::std::env::args().collect(); if args.len() >= 2 { match &args[1][..] { "client" => return client::main(), "server" => return server::main(), _ => (), } } println!("usage: {} [client | server] ADDRESS", args[0]); }
main
identifier_name
timestamp.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html use crate::define_newtype;
use chrono::prelude::*; use lazy_static::lazy_static; use std::env; use std::time; define_newtype!(TimestampSecs, i64); define_newtype!(TimestampMillis, i64); impl TimestampSecs { pub fn now() -> Self { Self(elapsed().as_secs() as i64) } pub fn zero() -> Self { Self(0) } pub fn e...
random_line_split
timestamp.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html use crate::define_newtype; use chrono::prelude::*; use lazy_static::lazy_static; use std::env; use std::time; define_newtype!(TimestampSecs, i64); define_newtype!(TimestampMillis, i64); im...
{ if *TESTING { // shift clock around rollover time to accomodate Python tests that make bad assumptions. // we should update the tests in the future and remove this hack. let mut elap = time::SystemTime::now() .duration_since(time::SystemTime::UNIX_EPOCH) .unwrap(); ...
identifier_body
timestamp.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html use crate::define_newtype; use chrono::prelude::*; use lazy_static::lazy_static; use std::env; use std::time; define_newtype!(TimestampSecs, i64); define_newtype!(TimestampMillis, i64); im...
else { time::SystemTime::now() .duration_since(time::SystemTime::UNIX_EPOCH) .unwrap() } }
{ // shift clock around rollover time to accomodate Python tests that make bad assumptions. // we should update the tests in the future and remove this hack. let mut elap = time::SystemTime::now() .duration_since(time::SystemTime::UNIX_EPOCH) .unwrap(); let now = ...
conditional_block
timestamp.rs
// Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html use crate::define_newtype; use chrono::prelude::*; use lazy_static::lazy_static; use std::env; use std::time; define_newtype!(TimestampSecs, i64); define_newtype!(TimestampMillis, i64); im...
() -> Self { Self(0) } pub fn elapsed_secs(self) -> u64 { (Self::now().0 - self.0).max(0) as u64 } /// YYYY-mm-dd pub(crate) fn date_string(self, offset: FixedOffset) -> String { offset.timestamp(self.0, 0).format("%Y-%m-%d").to_string() } pub fn local_utc_offset(s...
zero
identifier_name
comm.rs
// -*- rust -*- // 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
// option. This file may not be copied, modified, or distributed // except according to those terms. use core::comm::*; pub fn main() { let (p, ch) = stream(); let t = task::spawn(|| child(&ch) ); let y = p.recv(); error!("received"); error!(y); assert!((y == 10)); } fn child(c: &Chan<int>) {...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
comm.rs
// -*- rust -*- // 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 // ...
(c: &Chan<int>) { error!("sending"); c.send(10); error!("value sent"); }
child
identifier_name
comm.rs
// -*- rust -*- // 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 // ...
fn child(c: &Chan<int>) { error!("sending"); c.send(10); error!("value sent"); }
{ let (p, ch) = stream(); let t = task::spawn(|| child(&ch) ); let y = p.recv(); error!("received"); error!(y); assert!((y == 10)); }
identifier_body
shell.rs
ArgsBuilder, Args}; use kernel::collections::{Vec, String}; use kernel::alloc::Box; use core::fmt::{self, Display}; /* const LOGO: &'static str = " . ;' .. '. .cc. x0kk. .Oo .xc c,;: .OO. xO. .Oo 'dkxoc.d. .o'.clccc. ;' ;...
fn previous(&self) -> Token { self.tokens[self.current - 1] } fn parse(&mut self) -> Result<Expr, ParseError> { self.expression() } fn expression(&mut self) -> Result<Expr, ParseError> { self.term() } fn term(&mut self) -> Result<Expr, ParseError> { let m...
{ self.tokens[self.current] }
identifier_body
shell.rs
::{ArgsBuilder, Args}; use kernel::collections::{Vec, String}; use kernel::alloc::Box; use core::fmt::{self, Display}; /* const LOGO: &'static str = " . ;' .. '. .cc. x0kk. .Oo .xc c,;: .OO. xO. .Oo 'dkxoc.d. .o'.clccc. ;'...
enum ReadError { UnclosedString, } impl Display for ReadError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let msg = match *self { ReadError::UnclosedString => "unclosed string found", }; write!(f, "{}", msg) } } enum Command<'a> { Echo, Clear, ...
const UNAME_HELP: &'static str = "Displays system information"; const EXIT_HELP: &'static str = "Exit the shell"; const HELP_HELP: &'static str = "Display available commands or more information about a certain command";
random_line_split
shell.rs
ArgsBuilder, Args}; use kernel::collections::{Vec, String}; use kernel::alloc::Box; use core::fmt::{self, Display}; /* const LOGO: &'static str = " . ;' .. '. .cc. x0kk. .Oo .xc c,;: .OO. xO. .Oo 'dkxoc.d. .o'.clccc. ;' ;...
else { Err(ParseError::UnmatchedParens) } }, _ => Err(ParseError::UnexpectedToken), } } } enum Expr { Op(Box<Expr>, Operator, Box<Expr>), Val(isize), } impl Expr { fn eval(&self) -> isize { match *self { ...
{ Ok(expr) }
conditional_block
shell.rs
ArgsBuilder, Args}; use kernel::collections::{Vec, String}; use kernel::alloc::Box; use core::fmt::{self, Display}; /* const LOGO: &'static str = " . ;' .. '. .cc. x0kk. .Oo .xc c,;: .OO. xO. .Oo 'dkxoc.d. .o'.clccc. ;' ;...
(&mut self) -> Result<Expr, ParseError> { let mut expr = self.primary()?; while self.matches(Operator::Mul) || self.matches(Operator::Div) { let operator = if let Token::Op(op) = self.previous() { op } else { return Err(ParseError::Inv...
factor
identifier_name
transaction.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...
} /// Signed transaction information. #[derive(Debug, Clone, Eq, PartialEq)] #[cfg_attr(feature = "ipc", binary)] pub struct UnverifiedTransaction { /// Plain Transaction. unsigned: Transaction, /// The V field of the signature; the LS bit described which half of the curve our point falls /// in. The MS bits desc...
{ Self::gas_required_for(match self.action{Action::Create=>true, Action::Call(_)=>false}, &self.data, schedule) }
identifier_body
transaction.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...
() { use ethkey::{Random, Generator}; let key = Random.generate().unwrap(); let t = Transaction { action: Action::Create, nonce: U256::from(42), gas_price: U256::from(3000), gas: U256::from(50_000), value: U256::from(1), data: b"Hello!".to_vec() }.sign(&key.secret(), Some(69)); assert_eq!(Address::from...
should_recover_from_network_specific_signing
identifier_name
transaction.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...
use rlp::*; use util::sha3::Hashable; use util::{H256, Address, U256, Bytes, HeapSizeOf}; use ethkey::{Signature, Secret, Public, recover, public_to_address, Error as EthkeyError}; use error::*; use evm::Schedule; use header::BlockNumber; use ethjson; #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "ipc", ...
random_line_split
transaction.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...
else { Ok(()) } } /// Get the hash of this header (sha3 of the RLP). pub fn hash(&self) -> H256 { self.hash } /// Recovers the public key of the sender. pub fn recover_public(&self) -> Result<Public, Error> { Ok(recover(&self.signature(), &self.unsigned.hash(self.network_id()))?) } /// Do basic val...
{ Err(EthkeyError::InvalidSignature.into()) }
conditional_block
be_true.rs
use matchers::matcher::Matcher; #[derive(Copy, Clone)] pub struct BeTrue { file_line: (&'static str, u32) } impl Matcher<bool> for BeTrue { #[allow(unused_variables)] fn assert_check(&self, expected: bool) -> bool { expected == true } #[allow(unused_variables)] fn msg(&self, expected: bool) -...
(&self, expected: bool) -> String { format!("Expected {} NOT to be true but it was.", stringify!(expected)) } fn get_file_line(&self) -> (&'static str, u32) { self.file_line } } pub fn be_true(file_line: (&'static str, u32)) -> Box<BeTrue> { Box::new(BeTrue { file_line: file_line }) } ...
negated_msg
identifier_name
be_true.rs
use matchers::matcher::Matcher; #[derive(Copy, Clone)] pub struct BeTrue { file_line: (&'static str, u32) }
#[allow(unused_variables)] fn assert_check(&self, expected: bool) -> bool { expected == true } #[allow(unused_variables)] fn msg(&self, expected: bool) -> String { format!("Expected {} to be true but it was not.", stringify!(expected)) } #[allow(unused_variables)] fn negated_msg(&s...
impl Matcher<bool> for BeTrue {
random_line_split
be_true.rs
use matchers::matcher::Matcher; #[derive(Copy, Clone)] pub struct BeTrue { file_line: (&'static str, u32) } impl Matcher<bool> for BeTrue { #[allow(unused_variables)] fn assert_check(&self, expected: bool) -> bool { expected == true } #[allow(unused_variables)] fn msg(&self, expected: bool) -...
fn get_file_line(&self) -> (&'static str, u32) { self.file_line } } pub fn be_true(file_line: (&'static str, u32)) -> Box<BeTrue> { Box::new(BeTrue { file_line: file_line }) } #[macro_export] macro_rules! be_true( () => ( be_true((file!(), expand_line!())) ); );
{ format!("Expected {} NOT to be true but it was.", stringify!(expected)) }
identifier_body
recent_data.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use libc::c_char; use glib::translate::{ToGlib, ToGlibPtr, Stash}; pub struct Recen...
(&self) -> Stash<'a, *mut ffi::GtkRecentData, &'a RecentData> { let display_name = self.display_name.to_glib_none(); let description = self.description.to_glib_none(); let mime_type = self.mime_type.to_glib_none(); let app_name = self.app_name.to_glib_none(); let app_exec...
to_glib_none
identifier_name
recent_data.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use libc::c_char; use glib::translate::{ToGlib, ToGlibPtr, Stash}; pub struct Recen...
} }
{ let display_name = self.display_name.to_glib_none(); let description = self.description.to_glib_none(); let mime_type = self.mime_type.to_glib_none(); let app_name = self.app_name.to_glib_none(); let app_exec = self.app_exec.to_glib_none(); let groups = (&*self.groups)....
identifier_body
recent_data.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use libc::c_char; use glib::translate::{ToGlib, ToGlibPtr, Stash}; pub struct Recen...
mime_type: mime_type.0 as *mut c_char, app_name: app_name.0 as *mut c_char, app_exec: app_exec.0 as *mut c_char, groups: groups.0 as *mut *mut c_char, is_private: self.is_private.to_glib(), }); Stash(&mut *data, (data, [display_name, descripti...
let groups = (&*self.groups).to_glib_none(); let mut data = Box::new(ffi::GtkRecentData { display_name: display_name.0 as *mut c_char, description: description.0 as *mut c_char,
random_line_split
rustoleum.rs
use std::io::{stdin, File}; use std::io::buffered::BufferedReader; use std::str::{from_utf8}; use std::os;
println("Usage: rustoleum [arguments] path/to/input/file"); println("-i (I)nteractive mode"); println("-wpm N Display N words per (m)inute (default: 300)"); println("-wpl N Display N words per (l)ine (default: 1)"); println("-h Display this (h)elp"); } fn get_args_interactive () -> (uint, uint, Path) { let mut r...
fn print_usage () { println("A tool to keep your reading skills bright and shiny.");
random_line_split
rustoleum.rs
use std::io::{stdin, File}; use std::io::buffered::BufferedReader; use std::str::{from_utf8}; use std::os; fn print_usage () { println("A tool to keep your reading skills bright and shiny."); println("Usage: rustoleum [arguments] path/to/input/file"); println("-i (I)nteractive mode"); println("-wpm N Display N wor...
fn main () { if os::args().contains(&~"-h"){ print_usage(); } else { let (WPM, WPL, p) = get_vals(os::args()); print_file(WPM, WPL, p); } }
{ if p.exists(){ let contents = File::open(&p).read_to_end(); let mut string_iter = from_utf8(contents).words(); let string_vec = string_iter.to_owned_vec(); let sleep_time = (60000 / WPM * WPL) as u64; for words in string_vec.chunks(WPL) { println("\x1bc".into_owned().append(words.connect(" "))); std:...
identifier_body
rustoleum.rs
use std::io::{stdin, File}; use std::io::buffered::BufferedReader; use std::str::{from_utf8}; use std::os; fn print_usage () { println("A tool to keep your reading skills bright and shiny."); println("Usage: rustoleum [arguments] path/to/input/file"); println("-i (I)nteractive mode"); println("-wpm N Display N wor...
(args: &~[~str], flag: &~str, default: uint) -> uint { from_str::<uint>(args[1 + args.position_elem(flag).unwrap_or(-1)]).unwrap_or(default) } fn print_file(WPM: uint, WPL: uint, p: Path){ if p.exists(){ let contents = File::open(&p).read_to_end(); let mut string_iter = from_utf8(contents).words(); let string...
get_arg
identifier_name
rustoleum.rs
use std::io::{stdin, File}; use std::io::buffered::BufferedReader; use std::str::{from_utf8}; use std::os; fn print_usage () { println("A tool to keep your reading skills bright and shiny."); println("Usage: rustoleum [arguments] path/to/input/file"); println("-i (I)nteractive mode"); println("-wpm N Display N wor...
} fn get_arg (args: &~[~str], flag: &~str, default: uint) -> uint { from_str::<uint>(args[1 + args.position_elem(flag).unwrap_or(-1)]).unwrap_or(default) } fn print_file(WPM: uint, WPL: uint, p: Path){ if p.exists(){ let contents = File::open(&p).read_to_end(); let mut string_iter = from_utf8(contents).words()...
{ let fallbackfile = &~"data/example.txt"; let path = args.tail().last_opt().unwrap_or(fallbackfile); let p = Path::new(path.as_slice()); let WPM = get_arg(&args, &~"-wpm", 300); let WPL = get_arg(&args, &~"-wpl", 300); (WPM,WPL,p) }
conditional_block
local_image_cache.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/. */ /*! An adapter for ImageCacheTask that does local caching to avoid extra message traffic, it also avoids waiting o...
(&self, url: &Url) { let state = self.get_state(url); if!state.decoded { self.image_cache_task.send(Decode((*url).clone())); state.decoded = true; } } // FIXME: Should return a Future pub fn get_image(&self, url: &Url) -> Port<ImageResponseMsg> { let ...
decode
identifier_name
local_image_cache.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/. */ /*! An adapter for ImageCacheTask that does local caching to avoid extra message traffic, it also avoids waiting o...
} struct ImageState { prefetched: bool, decoded: bool, last_request_round: uint, last_response: ImageResponseMsg } impl LocalImageCache { /// The local cache will only do a single remote request for a given /// URL in each 'round'. Layout should call this each time it begins pub fn next_ro...
pub struct LocalImageCache { priv image_cache_task: ImageCacheTask, priv round_number: uint, priv on_image_available: Option<~fn() -> ~fn(ImageResponseMsg)>, priv state_map: UrlMap<@mut ImageState>
random_line_split
mod.rs
macro_rules! os_required { () => { panic!("mio must be compiled with `os-poll` to run.") }; } mod selector; pub(crate) use self::selector::{event, Event, Events, Selector}; mod waker; pub(crate) use self::waker::Waker; cfg_net! { pub(crate) mod tcp; pub(crate) mod udp; #[cfg(unix)] pu...
pub(crate) struct IoSourceState; impl IoSourceState { pub fn new() -> IoSourceState { IoSourceState } pub fn do_io<T, F, R>(&self, f: F, io: &T) -> io::Result<R> where F: FnOnce(&T) -> io::Result<R>, { // We don't hold state, so we ca...
use crate::{Registry, Token, Interest};
random_line_split
utils.rs
// Copyright 2019 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::mem; use std::sync::Arc; use super::error::*; use crate::usb::xhci::xhci_transfer::{XhciTransfer, XhciTransferState}; use crate::utils::Async...
}); *state = XhciTransferState::Submitted { cancel_callback }; return Ok(()); } } } XhciTransferState::Cancelled => { warn!("Transfer is already cancelled"); ...
{ usb_debug!("fail to cancel: {}", e); }
conditional_block
utils.rs
// Copyright 2019 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::mem; use std::sync::Arc; use super::error::*; use crate::usb::xhci::xhci_transfer::{XhciTransfer, XhciTransferState}; use crate::utils::Async...
} } Ok(()) } /// Helper function to submit usb_transfer to device handle. pub fn submit_transfer( fail_handle: Arc<dyn FailHandle>, job_queue: &Arc<AsyncJobQueue>, xhci_transfer: Arc<XhciTransfer>, device: &mut Device, usb_transfer: Transfer, ) -> Result<()> { let transfer_stat...
{ let status = usb_transfer.status(); let mut state = xhci_transfer.state().lock(); if status == TransferStatus::Cancelled { *state = XhciTransferState::Cancelled; return Ok(()); } match *state { XhciTransferState::Cancelling => { *state = XhciTransferState::Can...
identifier_body
utils.rs
// Copyright 2019 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::mem; use std::sync::Arc; use super::error::*; use crate::usb::xhci::xhci_transfer::{XhciTransfer, XhciTransferState}; use crate::utils::Async...
( fail_handle: Arc<dyn FailHandle>, job_queue: &Arc<AsyncJobQueue>, xhci_transfer: Arc<XhciTransfer>, device: &mut Device, usb_transfer: Transfer, ) -> Result<()> { let transfer_status = { // We need to hold the lock to avoid race condition. // While we are trying to submit the t...
submit_transfer
identifier_name
utils.rs
// Copyright 2019 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::mem; use std::sync::Arc; use super::error::*; use crate::usb::xhci::xhci_transfer::{XhciTransfer, XhciTransferState}; use crate::utils::Async...
// trying to cancel it. // Completed: A completed transfer should not be submitted again. error!("xhci trasfer state is invalid"); return Err(Error::BadXhciTransferState); } } }; // We are holding locks to of backends, we want t...
} _ => { // The transfer could not be in the following states: // Submitted: A transfer should only be submitted once. // Cancelling: Transfer is cancelling only when it's submitted and someone is
random_line_split
xcore.rs
//! Contains xcore-specific types use core::convert::From; use core::{cmp, fmt, slice}; // XXX todo(tmfink): create rusty versions pub use capstone_sys::xcore_insn_group as XcoreInsnGroup; pub use capstone_sys::xcore_insn as XcoreInsn; pub use capstone_sys::xcore_reg as XcoreReg; use capstone_sys::{cs_xcore, cs_xcore...
/// Index register pub fn index(&self) -> RegId { RegId(RegIdInt::from(self.0.index)) } /// Disp value pub fn disp(&self) -> i32 { self.0.disp } /// Direct value pub fn direct(&self) -> i32 { self.0.direct } } impl_PartialEq_repr_fields!(XcoreOpMem; b...
{ RegId(RegIdInt::from(self.0.base)) }
identifier_body
xcore.rs
//! Contains xcore-specific types use core::convert::From; use core::{cmp, fmt, slice}; // XXX todo(tmfink): create rusty versions pub use capstone_sys::xcore_insn_group as XcoreInsnGroup; pub use capstone_sys::xcore_insn as XcoreInsn; pub use capstone_sys::xcore_reg as XcoreReg; use capstone_sys::{cs_xcore, cs_xcore...
/// Invalid Invalid, } impl Default for XcoreOperand { fn default() -> Self { XcoreOperand::Invalid } } /// XCORE memory operand #[derive(Debug, Copy, Clone)] pub struct XcoreOpMem(pub(crate) xcore_op_mem); impl XcoreOpMem { /// Base register pub fn base(&self) -> RegId { RegI...
random_line_split
xcore.rs
//! Contains xcore-specific types use core::convert::From; use core::{cmp, fmt, slice}; // XXX todo(tmfink): create rusty versions pub use capstone_sys::xcore_insn_group as XcoreInsnGroup; pub use capstone_sys::xcore_insn as XcoreInsn; pub use capstone_sys::xcore_reg as XcoreReg; use capstone_sys::{cs_xcore, cs_xcore...
(pub(crate) xcore_op_mem); impl XcoreOpMem { /// Base register pub fn base(&self) -> RegId { RegId(RegIdInt::from(self.0.base)) } /// Index register pub fn index(&self) -> RegId { RegId(RegIdInt::from(self.0.index)) } /// Disp value pub fn disp(&self) -> i32 { ...
XcoreOpMem
identifier_name
deriving-via-extension-struct.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 ...
{ x: isize, y: isize, z: isize, } pub fn main() { let a = Foo { x: 1, y: 2, z: 3 }; let b = Foo { x: 1, y: 2, z: 3 }; assert_eq!(a, b); assert!(!(a!= b)); assert!(a.eq(&b)); assert!(!a.ne(&b)); }
Foo
identifier_name
deriving-via-extension-struct.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!(a, b); assert!(!(a!= b)); assert!(a.eq(&b)); assert!(!a.ne(&b)); }
pub fn main() { let a = Foo { x: 1, y: 2, z: 3 }; let b = Foo { x: 1, y: 2, z: 3 };
random_line_split
dynamic_lib.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(&mut self) { match dl::check_for_errors_in(|| { unsafe { dl::close(self.handle) } }) { Ok(()) => {}, Err(str) => panic!("{}", str) } } } impl DynamicLibrary { // FIXME (#12938): Until DST lands, we cannot decompose &str in...
drop
identifier_name
dynamic_lib.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} } result } pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where F: FnOnce() -> T, { unsafe { SetLastError(0); let result = f(); let error = os::errno(); if 0 == error { Ok(result) ...
unsafe { if use_thread_mode { SetThreadErrorMode(prev_error_mode, ptr::null_mut()); } else { SetErrorMode(prev_error_mode);
random_line_split
dynamic_lib.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
}; unsafe { if use_thread_mode { SetThreadErrorMode(prev_error_mode, ptr::null_mut()); } else { SetErrorMode(prev_error_mode); } } result } pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where ...
{ let mut handle = ptr::null_mut(); let succeeded = unsafe { GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &mut handle) }; if succeeded == libc::FALSE { let errno = os::errno(); Err(os::error_...
conditional_block
multiset.rs
string of length `len` pub fn new(len: usize) -> Subset { let mut sb = SubsetBuilder::new(); sb.pad_to_len(len); sb.build() } /// Mostly for testing. pub fn delete_from_string(&self, s: &str) -> String { let mut result = String::new(); for (b, e) in self.range_i...
transform
identifier_name
multiset.rs
self.push_segment(total_len - cur_len, 0); } } /// Sets the count for a given range. This method must be called with a /// non-empty range with `begin` not before the largest range or segment added /// so far. Gaps will be filled with a 0-count segment. pub fn add_range(&mut self, begin: ...
/// Count the total length of all the segments matching `matcher`. pub fn count(&self, matcher: CountMatcher) -> usize { self.segments.iter().filter(|seg| matcher.matches(seg)).map(|seg| seg.len).sum() } /// Convenience alias for `self.count(CountMatcher::All)` pub fn len(&self) -> usize ...
{ self.count(CountMatcher::Zero) }
identifier_body
multiset.rs
self.push_segment(total_len - cur_len, 0); } } /// Sets the count for a given range. This method must be called with a /// non-empty range with `begin` not before the largest range or segment added /// so far. Gaps will be filled with a 0-count segment. pub fn add_range(&mut self, begin: ...
// consume as much of the segment as possible and necessary let to_consume = cmp::min(cur_seg.len, to_be_consumed); sb.push_segment(to_consume, cur_seg.count); to_be_consumed -= to_consume; cur_seg.len -= to_consume; ...
{ cur_seg = seg_iter .next() .expect("self must cover all 0-regions of other") .clone(); }
conditional_block
multiset.rs
self.push_segment(total_len - cur_len, 0); } } /// Sets the count for a given range. This method must be called with a /// non-empty range with `begin` not before the largest range or segment added /// so far. Gaps will be filled with a 0-count segment. pub fn add_range(&mut self, begin:...
self.segments.push(Segment { len, count }); } pub fn build(self) -> Subset { Subset { segments: self.segments } } } /// Determines which elements of a `Subset` a method applies to /// based on the count of the element. #[derive(Clone, Copy, Debug)] pub enum CountMatcher { Zero, Non...
random_line_split
test_map_reduce.rs
use std::thread; fn main ()
result })); } //Reduce let mut intermediate_sums = vec![]; for child in children { let intermediate_sum = child.join().unwrap(); intermediate_sums.push(intermediate_sum); } let final_result = intermediate_sums.iter().sum::<u32>(); println!("Fin...
{ let data = "86967897737416471853297327050364959 11861322575564723963297542624962850 70856234701860851907960690014725639 38397966707106094172783238747669219 52380795257888236525459303330302837 58495327135744041048897885734297812 69920216438980873548808413720956532 16278424637452...
identifier_body
test_map_reduce.rs
use std::thread; fn
() { let data = "86967897737416471853297327050364959 11861322575564723963297542624962850 70856234701860851907960690014725639 38397966707106094172783238747669219 52380795257888236525459303330302837 58495327135744041048897885734297812 69920216438980873548808413720956532 1627842463...
main
identifier_name
test_map_reduce.rs
use std::thread; fn main () { let data = "86967897737416471853297327050364959 11861322575564723963297542624962850 70856234701860851907960690014725639 38397966707106094172783238747669219 52380795257888236525459303330302837 58495327135744041048897885734297812 69920216438980873548808413...
intermediate_sums.push(intermediate_sum); } let final_result = intermediate_sums.iter().sum::<u32>(); println!("Final sum result: {}", final_result); }
//Reduce let mut intermediate_sums = vec![]; for child in children { let intermediate_sum = child.join().unwrap();
random_line_split
callee.rs
ref_expr.id)) } ast::def_variant(tid, vid) => { // nullary variants are not callable assert!(ty::enum_variant_with_id(bcx.tcx(), tid, ...
~"method call expr wasn't in \ method map") } } }, args, dest, DontAutorefArg) } pub fn trans_lang_call(bcx: block, did: ast::def_id, ...
{ let _icx = in_cx.insn_ctxt("trans_method_call"); trans_call_inner( in_cx, call_ex.info(), node_id_type(in_cx, call_ex.callee_id), expr_ty(in_cx, call_ex), |cx| { match cx.ccx().maps.method_map.find(&call_ex.id) { Some(origin) => { ...
identifier_body
callee.rs
functions if must_monomorphise { // Should be either intra-crate or inlined. assert!(def_id.crate == ast::local_crate); let mut (val, must_cast) = monomorphize::monomorphic_fn(ccx, def_id, type_params, vtables, opt_impl_did, Some(ref_id)...
random_line_split
callee.rs
ref_expr.id)) } ast::def_variant(tid, vid) => { // nullary variants are not callable assert!(ty::enum_variant_with_id(bcx.tcx(), tid, ...
(in_cx: block, call_ex: @ast::expr, rcvr: @ast::expr, args: CallArgs, dest: expr::Dest) -> block { let _icx = in_cx.insn_ctxt("trans_method_call"); trans_call_inner( in_cx, c...
trans_method_call
identifier_name
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] //! Test infrastructure for the Diem VM. //! //! This crate contains helpers for executing tests against the Diem VM. use diem_types::{transaction::TransactionStatus, vm_status::KeptVMStatus}; pub mod account;...
#[macro_export] macro_rules! assert_prologue_parity { ($e1:expr, $e2:expr, $e3:expr) => { assert_eq!($e1.unwrap(), $e3); assert!(transaction_status_eq($e2, &TransactionStatus::Discard($e3))); }; } #[macro_export] macro_rules! assert_prologue_disparity { ($e1:expr => $e2:expr, $e3:expr => $e...
}
random_line_split
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] //! Test infrastructure for the Diem VM. //! //! This crate contains helpers for executing tests against the Diem VM. use diem_types::{transaction::TransactionStatus, vm_status::KeptVMStatus}; pub mod account;...
(t1: &TransactionStatus, t2: &TransactionStatus) -> bool { match (t1, t2) { (TransactionStatus::Discard(s1), TransactionStatus::Discard(s2)) => { assert_eq!(s1, s2); true } (TransactionStatus::Keep(s1), TransactionStatus::Keep(s2)) => { assert_eq!(s1, s2);...
transaction_status_eq
identifier_name
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] //! Test infrastructure for the Diem VM. //! //! This crate contains helpers for executing tests against the Diem VM. use diem_types::{transaction::TransactionStatus, vm_status::KeptVMStatus}; pub mod account;...
#[macro_export] macro_rules! assert_prologue_parity { ($e1:expr, $e2:expr, $e3:expr) => { assert_eq!($e1.unwrap(), $e3); assert!(transaction_status_eq($e2, &TransactionStatus::Discard($e3))); }; } #[macro_export] macro_rules! assert_prologue_disparity { ($e1:expr => $e2:expr, $e3:expr => ...
{ match (t1, t2) { (TransactionStatus::Discard(s1), TransactionStatus::Discard(s2)) => { assert_eq!(s1, s2); true } (TransactionStatus::Keep(s1), TransactionStatus::Keep(s2)) => { assert_eq!(s1, s2); true } _ => false, } }
identifier_body
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] //! Test infrastructure for the Diem VM. //! //! This crate contains helpers for executing tests against the Diem VM. use diem_types::{transaction::TransactionStatus, vm_status::KeptVMStatus}; pub mod account;...
_ => false, } } #[macro_export] macro_rules! assert_prologue_parity { ($e1:expr, $e2:expr, $e3:expr) => { assert_eq!($e1.unwrap(), $e3); assert!(transaction_status_eq($e2, &TransactionStatus::Discard($e3))); }; } #[macro_export] macro_rules! assert_prologue_disparity { ($e1:ex...
{ assert_eq!(s1, s2); true }
conditional_block
utility.rs
use std::sync::Arc;
/// [`ArenaSet`]: struct.ArenaSet.html pub fn string_arena_set() -> ArenaSet<String> { builder().hash().unwrap() } /// Create an [`ArenaSet`] for `Vec<u8>` with a `HashMap` and an ID of `usize`. /// [`ArenaSet`]: struct.ArenaSet.html pub fn byte_arena_set() -> ArenaSet<Vec<u8>> { builder().hash().unwrap() } /...
use builder::builder; use arena_set::{ArenaSet, StadiumSet}; /// Create an [`ArenaSet`] for `String` with a `HashMap` and an ID of `usize`.
random_line_split
utility.rs
use std::sync::Arc; use builder::builder; use arena_set::{ArenaSet, StadiumSet}; /// Create an [`ArenaSet`] for `String` with a `HashMap` and an ID of `usize`. /// [`ArenaSet`]: struct.ArenaSet.html pub fn string_arena_set() -> ArenaSet<String> { builder().hash().unwrap() } /// Create an [`ArenaSet`] for `Vec<u8...
/// Create a [`StadiumSet`] for `Arc<String>` with a `HashMap` and an ID of `usize`. /// [`StadiumSet`]: struct.StadiumSet.html pub fn string_stadium_set() -> StadiumSet<Arc<String>> { builder().stadium_set_hash().unwrap() } /// Create a [`StadiumSet`] for `Arc<Vec<u8>>` with a `HashMap` and an ID of `usize`. //...
{ builder().hash().unwrap() }
identifier_body
utility.rs
use std::sync::Arc; use builder::builder; use arena_set::{ArenaSet, StadiumSet}; /// Create an [`ArenaSet`] for `String` with a `HashMap` and an ID of `usize`. /// [`ArenaSet`]: struct.ArenaSet.html pub fn string_arena_set() -> ArenaSet<String> { builder().hash().unwrap() } /// Create an [`ArenaSet`] for `Vec<u8...
() -> StadiumSet<Arc<Vec<u8>>> { builder().stadium_set_hash().unwrap() }
byte_stadium_set
identifier_name
fps.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang // // 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, c...
() -> Fps { Fps { frames: 0., cur_frames: 0., frame_start: time::precise_time_s() } } } impl PerfHandler for Fps { fn reset(&mut self) -> () { self.frames = 0.; self.cur_frames = 0.; self.frame_start = time::precise_time_s(); } fn frame_begin(&mut self) -> () { } fn frame_end(&mut self)...
new
identifier_name
fps.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang // // 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, c...
fn frame_end(&mut self) -> () { self.cur_frames += 1.; if time::precise_time_s() - self.frame_start >= 1. { self.frame_start = time::precise_time_s(); self.frames = self.cur_frames; self.cur_frames = 0.; } } fn get_value(&self) -> Option<f64> { Some(self.frames) } }
fn frame_begin(&mut self) -> () { }
random_line_split
fps.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang // // 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, c...
} fn get_value(&self) -> Option<f64> { Some(self.frames) } }
{ self.frame_start = time::precise_time_s(); self.frames = self.cur_frames; self.cur_frames = 0.; }
conditional_block
fps.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang // // 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, c...
fn frame_end(&mut self) -> () { self.cur_frames += 1.; if time::precise_time_s() - self.frame_start >= 1. { self.frame_start = time::precise_time_s(); self.frames = self.cur_frames; self.cur_frames = 0.; } } fn get_value(&self) -> Option<f64> { Some(self.frames) } }
{ }
identifier_body