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 |
|---|---|---|---|---|
app_chooser.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... |
}
fn get_content_info(&self) -> Option<String> {
unsafe {
FromGlibPtr::borrow(
ffi::gtk_app_chooser_get_content_type(GTK_APP_CHOOSER(self.unwrap_widget())))
}
}
fn refresh(&self) -> () {
unsafe { ffi::gtk_app_chooser_refresh(GTK_APP_CHOOSER(self.unw... | {
Some(gtk::FFIWidget::wrap_widget(tmp_pointer as *mut ffi::C_GtkWidget))
} | conditional_block |
app_chooser.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | (&self) -> Option<String> {
unsafe {
FromGlibPtr::borrow(
ffi::gtk_app_chooser_get_content_type(GTK_APP_CHOOSER(self.unwrap_widget())))
}
}
fn refresh(&self) -> () {
unsafe { ffi::gtk_app_chooser_refresh(GTK_APP_CHOOSER(self.unwrap_widget())) }
}
} | get_content_info | identifier_name |
macros.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/. */
//! Various macro helpers.
macro_rules! trivial_to_computed_value {
($name:ty) => {
impl $crate::valu... | ) -> Result<$name, ::style_traits::ParseError<'i>> {
try_match_ident_ignore_ascii_case! { input,
$( $css => Ok($name::$variant), )+
}
}
}
impl ::style_traits::values::ToCss for $name {
fn to_css<W>(&self, dest: &mut... | impl $crate::parser::Parse for $name {
fn parse<'i, 't>(
_context: &$crate::parser::ParserContext,
input: &mut ::cssparser::Parser<'i, 't>, | random_line_split |
auto-dedup.rs | // run-pass
#![allow(unused_assignments)]
// Test that duplicate auto trait bounds in trait objects don't create new types.
#[allow(unused_assignments)]
use std::marker::Send as SendAlias;
// A dummy trait for the non-auto trait.
trait Trait {}
// A dummy struct to implement `Trait` and `Send`.
struct Struct;
impl... | (_: Box<dyn Trait + Send + SendAlias>) {}
impl dyn Trait + Send + Send {
fn do_nothing(&self) {}
}
fn main() {
// 1. Moving into a variable with more `Send`s and back.
let mut dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
let dyn_trait_send_send: Box<dyn Trait + Send + Send> = dyn_trait_... | takes_dyn_trait_send_sendalias | identifier_name |
auto-dedup.rs | // run-pass
#![allow(unused_assignments)]
// Test that duplicate auto trait bounds in trait objects don't create new types.
#[allow(unused_assignments)]
use std::marker::Send as SendAlias;
// A dummy trait for the non-auto trait.
trait Trait {}
// A dummy struct to implement `Trait` and `Send`.
struct Struct;
impl... |
fn takes_dyn_trait_send_send(_: Box<dyn Trait + Send + Send>) {}
fn takes_dyn_trait_send_sendalias(_: Box<dyn Trait + Send + SendAlias>) {}
impl dyn Trait + Send + Send {
fn do_nothing(&self) {}
}
fn main() {
// 1. Moving into a variable with more `Send`s and back.
let mut dyn_trait_send = Box::new(Struc... | {} | identifier_body |
auto-dedup.rs | // run-pass
#![allow(unused_assignments)]
// Test that duplicate auto trait bounds in trait objects don't create new types.
#[allow(unused_assignments)]
use std::marker::Send as SendAlias;
// A dummy trait for the non-auto trait.
trait Trait {} | impl Trait for Struct {}
// These three functions should be equivalent.
fn takes_dyn_trait_send(_: Box<dyn Trait + Send>) {}
fn takes_dyn_trait_send_send(_: Box<dyn Trait + Send + Send>) {}
fn takes_dyn_trait_send_sendalias(_: Box<dyn Trait + Send + SendAlias>) {}
impl dyn Trait + Send + Send {
fn do_nothing(&sel... |
// A dummy struct to implement `Trait` and `Send`.
struct Struct;
| random_line_split |
endpoint.rs | // Copyright 2015, 2016 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 la... | pub host: String,
pub port: u16,
pub using_dapps_domains: bool,
}
#[derive(Debug, PartialEq, Clone)]
pub struct EndpointInfo {
pub name: String,
pub description: String,
pub version: String,
pub author: String,
pub icon_url: String,
}
pub type Endpoints = BTreeMap<String, Box<Endpoint>>;
pub type Handler = se... | use std::collections::BTreeMap;
#[derive(Debug, PartialEq, Default, Clone)]
pub struct EndpointPath {
pub app_id: String, | random_line_split |
endpoint.rs | // Copyright 2015, 2016 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 la... | (&self, path: EndpointPath, _control: hyper::Control) -> Box<Handler> {
self.to_handler(path)
}
}
| to_async_handler | identifier_name |
main.rs | #[macro_use] extern crate libeuler;
use libeuler::prime::SieveOfAtkin;
/// The first two consecutive numbers to have two distinct prime factors are:
///
/// 14 = 2 × 7
/// 15 = 3 × 5
///
/// The first three consecutive numbers to have three distinct prime factors are:
///
/// 644 = 2² × 7 × 23
/// 645 = 3 × 5 × 43
///... | return first;
}
}
None
}
}
}
| utions! {
inputs: (num: usize = 4)
sol naive {
let sieve = SieveOfAtkin::new(1_000_000);
let mut first = None;
let mut count = 0;
for i in 0..1_000_000 {
if sieve.factors(i).len() == num {
first = match first {
... | identifier_body |
main.rs | #[macro_use] extern crate libeuler;
use libeuler::prime::SieveOfAtkin;
/// The first two consecutive numbers to have two distinct prime factors are:
///
/// 14 = 2 × 7
/// 15 = 3 × 5
///
/// The first three consecutive numbers to have three distinct prime factors are:
///
/// 644 = 2² × 7 × 23
/// 645 = 3 × 5 × 43
///... | if count == num {
return first;
}
}
None
}
}
} | random_line_split | |
main.rs | #[macro_use] extern crate libeuler;
use libeuler::prime::SieveOfAtkin;
/// The first two consecutive numbers to have two distinct prime factors are:
///
/// 14 = 2 × 7
/// 15 = 3 × 5
///
/// The first three consecutive numbers to have three distinct prime factors are:
///
/// 644 = 2² × 7 × 23
/// 645 = 3 × 5 × 43
///... | solutions! {
inputs: (num: usize = 4)
sol naive {
let sieve = SieveOfAtkin::new(1_000_000);
let mut first = None;
let mut count = 0;
for i in 0..1_000_000 {
if sieve.factors(i).len() == num {
first = match first {
... | identifier_name | |
image_texture.rs | use image;
use image::{
GenericImage,
Rgba,
Rgb,
};
use texture::{
Pixel,
Texture,
};
impl<P: Pixel + image::Pixel, I: GenericImage<Pixel=P>> Texture for I {
type Pixel = I::Pixel;
fn width(&self) -> u32 {
self.dimensions().0
}
fn height(&self) -> u32 {
self.dimen... | else {
None
}
}
fn set(&mut self, x: u32, y: u32, val: I::Pixel) {
self.put_pixel(x, y, val);
}
}
impl Pixel for Rgba<u8> {
fn is_transparent(&self) -> bool {
self[3] == 0
}
fn transparency() -> Option<Rgba<u8>> {
Some(Rgba([0; 4]))
}
fn o... | {
Some(self.get_pixel(x, y))
} | conditional_block |
image_texture.rs | use image;
use image::{
GenericImage,
Rgba,
Rgb,
};
use texture::{
Pixel,
Texture,
};
impl<P: Pixel + image::Pixel, I: GenericImage<Pixel=P>> Texture for I {
type Pixel = I::Pixel;
fn width(&self) -> u32 {
self.dimensions().0
}
fn height(&self) -> u32 {
self.dimen... | fn set(&mut self, x: u32, y: u32, val: I::Pixel) {
self.put_pixel(x, y, val);
}
}
impl Pixel for Rgba<u8> {
fn is_transparent(&self) -> bool {
self[3] == 0
}
fn transparency() -> Option<Rgba<u8>> {
Some(Rgba([0; 4]))
}
fn outline() -> Rgba<u8> {
Rgba([255, ... | random_line_split | |
image_texture.rs | use image;
use image::{
GenericImage,
Rgba,
Rgb,
};
use texture::{
Pixel,
Texture,
};
impl<P: Pixel + image::Pixel, I: GenericImage<Pixel=P>> Texture for I {
type Pixel = I::Pixel;
fn width(&self) -> u32 {
self.dimensions().0
}
fn height(&self) -> u32 |
fn get(&self, x: u32, y: u32) -> Option<I::Pixel> {
if self.in_bounds(x, y) {
Some(self.get_pixel(x, y))
} else {
None
}
}
fn set(&mut self, x: u32, y: u32, val: I::Pixel) {
self.put_pixel(x, y, val);
}
}
impl Pixel for Rgba<u8> {
fn is_tra... | {
self.dimensions().1
} | identifier_body |
image_texture.rs | use image;
use image::{
GenericImage,
Rgba,
Rgb,
};
use texture::{
Pixel,
Texture,
};
impl<P: Pixel + image::Pixel, I: GenericImage<Pixel=P>> Texture for I {
type Pixel = I::Pixel;
fn width(&self) -> u32 {
self.dimensions().0
}
fn height(&self) -> u32 {
self.dimen... | () -> Rgb<u8> {
Rgb([255, 0, 0])
}
}
| outline | identifier_name |
backup.rs | // id number A unique number used to identify and reference
// a specific image.
// name string The display name of the image. This is shown in
// the web UI and is generally a descriptive title for the image in question.
// type string The kind of image, describing ... |
}
| { "backup".into() } | identifier_body |
backup.rs | // id number A unique number used to identify and reference
// a specific image.
// name string The display name of the image. This is shown in
// the web UI and is generally a descriptive title for the image in question.
// type string The kind of image, describing ... | {
pub id: f64,
pub name: String,
#[serde(rename = "type")]
pub b_type: String,
pub distribution: String,
pub slug: Option<String>,
pub public: bool,
pub regions: Vec<String>,
pub min_disk_size: f64,
}
impl response::NotArray for Backup {}
impl fmt::Display for Backup {
fn fmt(... | Backup | identifier_name |
backup.rs | // id number A unique number used to identify and reference
// a specific image.
// name string The display name of the image. This is shown in
// the web UI and is generally a descriptive title for the image in question.
// type string The kind of image, describing ... | // how long the image is stored. This is one of "snapshot", "temporary" or
// "backup".
// distribution string The base distribution used for this image.
// slug nullable string A uniquely identifying string that is
// associated with each of the DigitalOcean-provided public images. These can
// be... | random_line_split | |
msgsend-pipes.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 ... |
enum request {
get_count,
bytes(uint),
stop
}
fn server(requests: &Port<request>, responses: &Chan<uint>) {
let mut count: uint = 0;
let mut done = false;
while!done {
match requests.try_recv() {
Some(get_count) => { responses.send(count.clone()); }
Some(bytes(b)) ... | {} | identifier_body |
msgsend-pipes.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 args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"8"]
} else if args.len() <= 1u {
~[~"", ~"10000", ~"4"]
} else {
args.clone()
};
info!("%?", args);
run(args);
}
| main | identifier_name |
msgsend-pipes.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 ... |
}
}
responses.send(count);
//error!("server exiting");
}
fn run(args: &[~str]) {
let (from_child, to_parent) = stream();
let (from_parent, to_child) = stream();
let to_child = SharedChan::new(to_child);
let size = from_str::<uint>(args[1]).unwrap();
let workers = from_str::<ui... | { } | conditional_block |
msgsend-pipes.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.
// | // except according to those terms.
// A port of the simplistic benchmark from
//
// http://github.com/PaulKeeble/ScalaVErlangAgents
//
// I *think* it's the same, more or less.
extern mod extra;
use std::comm::{SharedChan, Chan, stream};
use std::io;
use std::os;
use std::task;
use std::uint;
fn move_out<T>(_x:... | // 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 | random_line_split |
exchanger.rs | use std::collections::VecDeque;
use std::mem;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::atomic::Ordering::{Acquire, Release};
use std::thread;
use std::time::Instant; | use select::handle::{self, Handle};
use util::Backoff;
/// Waiting strategy in an exchange operation.
enum Wait {
/// Yield once and then time out.
YieldOnce,
/// Wait until an optional deadline.
Until(Option<Instant>),
}
/// Enumeration of possible exchange errors.
pub enum ExchangeError<T> {
//... |
use parking_lot::Mutex;
use select::CaseId; | random_line_split |
exchanger.rs | use std::collections::VecDeque;
use std::mem;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::atomic::Ordering::{Acquire, Release};
use std::thread;
use std::time::Instant;
use parking_lot::Mutex;
use select::CaseId;
use select::handle::{self, Handle};
use util::Backoff;
/// Wait... |
}
/// Returns `true` if the exchanger is closed.
pub fn is_closed(&self) -> bool {
self.inner.lock().closed
}
}
/// One side of an exchanger.
pub struct Side<'a, T: 'a> {
/// The index is 0 or 1.
index: usize,
/// A reference to the parent exchanger.
exchanger: &'a Exchanger<... | {
inner.closed = true;
inner.wait_queues[0].abort_all();
inner.wait_queues[1].abort_all();
true
} | conditional_block |
exchanger.rs | use std::collections::VecDeque;
use std::mem;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::atomic::Ordering::{Acquire, Release};
use std::thread;
use std::time::Instant;
use parking_lot::Mutex;
use select::CaseId;
use select::handle::{self, Handle};
use util::Backoff;
/// Wait... | (self) -> T {
self.msg.try_lock().unwrap().take().unwrap()
}
/// Spin-waits until the packet becomes ready.
fn wait(&self) {
let mut backoff = Backoff::new();
while!self.ready.load(Acquire) {
backoff.step();
}
}
}
| into_inner | identifier_name |
exchanger.rs | use std::collections::VecDeque;
use std::mem;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::atomic::Ordering::{Acquire, Release};
use std::thread;
use std::time::Instant;
use parking_lot::Mutex;
use select::CaseId;
use select::handle::{self, Handle};
use util::Backoff;
/// Wait... |
/// Fulfills the previously made promise.
pub fn fulfill(&self, msg: T) -> T {
finish_exchange(msg, self.exchanger)
}
/// Exchanges `msg` if there is an offer or promise on the opposite side.
pub fn try_exchange(
&self,
msg: T,
case_id: CaseId,
) -> Result<T, E... | {
self.exchanger.inner.lock().wait_queues[self.index].revoke(case_id);
} | identifier_body |
filters.rs | use color::Color;
use utils::datastructures::Matrix;
use scene::ScreenPoint;
use super::{Image, Pixel};
use super::samplers::Sample;
use super::utils::from_uniform;
use super::config::{FilterConfig, FilterFunctionConfig};
pub struct Filter {
extent: ScreenPoint,
resolution: Pixel,
weight: Box<Fn(f64, f64)... |
fn neighbours(&self, point: ScreenPoint) -> Vec<Pixel> {
let discretize_range = |lower: f64, upper: f64| {
assert!(lower <= upper);
lower.ceil() as i32..upper.floor() as i32 + 1
};
let ok_pixel = |x, y| {
0 <= x && x < self.resolution[0] as i32 &&
... | {
let mut image = Image::fill(self.resolution, Color::new(0.0, 0.0, 0.0));
let mut weights = Matrix::<f64>::fill(self.resolution, 0.0);
for &(sample, radiance) in samples.iter() {
for pixel in self.neighbours(sample.pixel) {
let diff = ScreenPoint::from(pixel) - from_... | identifier_body |
filters.rs | use color::Color;
use utils::datastructures::Matrix;
use scene::ScreenPoint;
use super::{Image, Pixel};
use super::samplers::Sample;
use super::utils::from_uniform;
use super::config::{FilterConfig, FilterFunctionConfig};
pub struct Filter {
extent: ScreenPoint,
resolution: Pixel,
weight: Box<Fn(f64, f64)... |
}
}
result
}
}
| {
result.push([x as u32, y as u32]);
} | conditional_block |
filters.rs | use color::Color;
use utils::datastructures::Matrix;
use scene::ScreenPoint;
use super::{Image, Pixel};
use super::samplers::Sample;
use super::utils::from_uniform;
use super::config::{FilterConfig, FilterFunctionConfig};
pub struct Filter {
extent: ScreenPoint,
resolution: Pixel,
weight: Box<Fn(f64, f64)... | (&self, point: ScreenPoint) -> Vec<Pixel> {
let discretize_range = |lower: f64, upper: f64| {
assert!(lower <= upper);
lower.ceil() as i32..upper.floor() as i32 + 1
};
let ok_pixel = |x, y| {
0 <= x && x < self.resolution[0] as i32 &&
0 <= y &... | neighbours | identifier_name |
filters.rs | use color::Color;
use utils::datastructures::Matrix;
use scene::ScreenPoint;
use super::{Image, Pixel};
use super::samplers::Sample;
use super::utils::from_uniform;
use super::config::{FilterConfig, FilterFunctionConfig};
pub struct Filter {
extent: ScreenPoint,
resolution: Pixel,
weight: Box<Fn(f64, f64)... | image[i] = image[i] / weight;
}
}
image
}
fn neighbours(&self, point: ScreenPoint) -> Vec<Pixel> {
let discretize_range = |lower: f64, upper: f64| {
assert!(lower <= upper);
lower.ceil() as i32..upper.floor() as i32 + 1
};
... | if weight != 0.0 { | random_line_split |
main.rs | extern crate argparse;
extern crate iron;
use argparse::{ArgumentParser, StoreTrue, Store};
use iron::prelude::*;
fn http_server(_: &mut Request) -> IronResult<Response> |
static HTTP_ADDR: &'static str = "localhost:4242";
fn main() {
let mut size: usize = 20;
let mut reverse: bool = false;
let mut server_mode: bool = false;
let mut skin = "███".to_string();
let padding = vec![" ", " ", "", " ", " ", " ", " ", " "];
{
// this block limits scop... | {
Ok(Response::with((iron::status::Ok, "Rust server")))
} | identifier_body |
main.rs | extern crate argparse;
extern crate iron;
use argparse::{ArgumentParser, StoreTrue, Store};
use iron::prelude::*;
fn http_server(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((iron::status::Ok, "Rust server")))
}
static HTTP_ADDR: &'static str = "localhost:4242";
fn main() {
let mut size: usi... | // this block limits scope of borrows by ap.refer() method
let mut ap = ArgumentParser::new();
ap.set_description("Print a beautiful millipede (written in rust)");
ap.refer(&mut size)
.add_option(&["-w", "--width"], Store, "millipede width");
ap.refer(&mut skin)
... |
{ | random_line_split |
main.rs | extern crate argparse;
extern crate iron;
use argparse::{ArgumentParser, StoreTrue, Store};
use iron::prelude::*;
fn http_server(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((iron::status::Ok, "Rust server")))
}
static HTTP_ADDR: &'static str = "localhost:4242";
fn | () {
let mut size: usize = 20;
let mut reverse: bool = false;
let mut server_mode: bool = false;
let mut skin = "███".to_string();
let padding = vec![" ", " ", "", " ", " ", " ", " ", " "];
{
// this block limits scope of borrows by ap.refer() method
let mut ap = Argume... | main | identifier_name |
main.rs | extern crate argparse;
extern crate iron;
use argparse::{ArgumentParser, StoreTrue, Store};
use iron::prelude::*;
fn http_server(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((iron::status::Ok, "Rust server")))
}
static HTTP_ADDR: &'static str = "localhost:4242";
fn main() {
let mut size: usi... | t i: usize = size;
while i > 0 {
println!("{}╔═({})═╗", padding[i % 8], skin);
i = i - 1;
}
println!(" ╔⊙ ⊙╗");
}
}
| let mut i: usize = 0;
println!(" ╚⊙ ⊙╝");
while i < size {
println!("{}╚═({})═╝", padding[i % 8], skin);
i = i + 1;
}
} else {
let mu | conditional_block |
pipe.rs | use gfx;
use gfx_phase;
use gfx_scene;
use std::cmp::Ordering;
/// Custom ordering function to draw opaque objects first in a
/// front-to-back order, and transparent objects on top in a
/// back-to-front order.
pub fn | <S: PartialOrd, R: gfx::Resources>(
a: &gfx_phase::Object<S, super::Kernel, super::param::Struct<R>>,
b: &gfx_phase::Object<S, super::Kernel, super::param::Struct<R>>)
-> Ordering {
use ::Transparency::*;
match (a.kernel.transparency, b.kernel.transparency) {
(Blen... | order | identifier_name |
pipe.rs | use gfx;
use gfx_phase; | use gfx_scene;
use std::cmp::Ordering;
/// Custom ordering function to draw opaque objects first in a
/// front-to-back order, and transparent objects on top in a
/// back-to-front order.
pub fn order<S: PartialOrd, R: gfx::Resources>(
a: &gfx_phase::Object<S, super::Kernel, super::param::Struct<R>>,
... | random_line_split | |
pipe.rs | use gfx;
use gfx_phase;
use gfx_scene;
use std::cmp::Ordering;
/// Custom ordering function to draw opaque objects first in a
/// front-to-back order, and transparent objects on top in a
/// back-to-front order.
pub fn order<S: PartialOrd, R: gfx::Resources>(
a: &gfx_phase::Object<S, super::Kernel, super... |
}
| {
// prepare
self.phase.technique.update(stream);
// clear
if let Some(color) = self.background {
stream.clear(gfx::ClearData {
color: color,
depth: 1.0,
stencil: 0,
});
}
// draw
scene.draw(&... | identifier_body |
lib.rs |
use net_traits::image_cache::ImageCache;
use net_traits::storage_thread::StorageType;
use profile_traits::mem;
use profile_traits::time as profile_time;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use servo_atoms::Atom;
use servo_url::ImmutableOrigin;
use servo_url::ServoUrl;
use std::collections::H... | (url: ServoUrl,
creator_pipeline_id: Option<PipelineId>,
referrer_policy: Option<ReferrerPolicy>,
referrer_url: Option<ServoUrl>)
-> LoadData {
LoadData {
url: url,
creator_pipeline_id: creator_pipeline_id,
method: M... | new | identifier_name |
lib.rs | ;
use net_traits::image_cache::ImageCache;
use net_traits::storage_thread::StorageType;
use profile_traits::mem;
use profile_traits::time as profile_time;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use servo_atoms::Atom;
use servo_url::ImmutableOrigin;
use servo_url::ServoUrl;
use std::collections::... | DispatchIFrameLoadEvent {
/// The frame that has been marked as loaded.
target: BrowsingContextId,
/// The pipeline that contains a frame loading the target pipeline.
parent: PipelineId,
/// The pipeline that has completed loading.
child: PipelineId,
},
/// Ca... | /// Cause a `load` event to be dispatched at the appropriate iframe element. | random_line_split |
doco.rs | use std::fmt::{Display, Formatter, Result as FmtResult, Write};
use hoedown::{Markdown, Render};
use hoedown::renderer::html::{Html, Flags};
pub struct Item<T>(pub T);
impl<T: AsRef<str>> Display for Item<T> {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
preprocess(self.0.as_ref(), "///", fmt)
}... |
fn prefix(input: &str, pre: &str, fmt: &mut Formatter) -> FmtResult {
for (i, line) in input.lines().enumerate() {
if i > 0 {
fmt.write_char('\n')?;
}
if line.len() == 0 {
write!(fmt, "{}", pre)?;
} else {
write!(fmt, "{} {}", pre, line.trim())?;... | {
// fix up problems in AWS docs
let escaped_1 = input.replace("<code>\\</code>", "<code>\</code>");
let escaped_2 = escaped_1.replace("\"</p>\"", "</p>");
// parse and render markdown
let markdown = Markdown::new(&escaped_2);
let mut html_renderer = Html::new(Flags::empty(), 0);
let b... | identifier_body |
doco.rs | use std::fmt::{Display, Formatter, Result as FmtResult, Write};
use hoedown::{Markdown, Render};
use hoedown::renderer::html::{Html, Flags};
pub struct Item<T>(pub T);
impl<T: AsRef<str>> Display for Item<T> {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
preprocess(self.0.as_ref(), "///", fmt)
}... |
}
Ok(())
}
| {
write!(fmt, "{} {}", pre, line.trim())?;
} | conditional_block |
doco.rs | use std::fmt::{Display, Formatter, Result as FmtResult, Write};
use hoedown::{Markdown, Render};
use hoedown::renderer::html::{Html, Flags};
pub struct Item<T>(pub T);
impl<T: AsRef<str>> Display for Item<T> {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
preprocess(self.0.as_ref(), "///", fmt)
}... | if i > 0 {
fmt.write_char('\n')?;
}
if line.len() == 0 {
write!(fmt, "{}", pre)?;
} else {
write!(fmt, "{} {}", pre, line.trim())?;
}
}
Ok(())
} | random_line_split | |
doco.rs | use std::fmt::{Display, Formatter, Result as FmtResult, Write};
use hoedown::{Markdown, Render};
use hoedown::renderer::html::{Html, Flags};
pub struct | <T>(pub T);
impl<T: AsRef<str>> Display for Item<T> {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
preprocess(self.0.as_ref(), "///", fmt)
}
}
pub struct Module<T>(pub T);
impl<T: AsRef<str>> Display for Module<T> {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
preprocess(self.0.... | Item | identifier_name |
main.rs | extern crate rand;
extern crate walkdir;
use walkdir::WalkDir;
use rand::{Rng, thread_rng};
use std::env;
use std::fs::{self, OpenOptions};
use std::io::prelude::*;
use std::io::{Error, SeekFrom};
use std::cmp;
use std::path::Path;
fn | () {
let mut recursive: bool = false;
let mut file: String = String::from("");
for argument in env::args().skip(1) {
if argument.to_lowercase() == "--help" || argument.to_lowercase() == "-help" {
help();
return;
} else if argument.to_lowercase() == "--v" || argument.... | main | identifier_name |
main.rs | extern crate rand;
extern crate walkdir;
use walkdir::WalkDir;
use rand::{Rng, thread_rng};
use std::env;
use std::fs::{self, OpenOptions};
use std::io::prelude::*;
use std::io::{Error, SeekFrom};
use std::cmp;
use std::path::Path;
fn main() {
let mut recursive: bool = false;
let mut file: String = String::fr... | file = get_path(&file);
if recursive {
for entry in WalkDir::new(file) {
let entry = entry.unwrap();
trumpify_file(entry.path());
}
} else {
trumpify_file(file)
}
}
fn get_path2(file: &str) -> Result<String, Error> {
let path = try!(fs::canonicalize(... | random_line_split | |
main.rs | extern crate rand;
extern crate walkdir;
use walkdir::WalkDir;
use rand::{Rng, thread_rng};
use std::env;
use std::fs::{self, OpenOptions};
use std::io::prelude::*;
use std::io::{Error, SeekFrom};
use std::cmp;
use std::path::Path;
fn main() {
let mut recursive: bool = false;
let mut file: String = String::fr... |
fn get_path(file: &str) -> String {
get_path2(file).unwrap_or(file.to_owned())
}
fn version() {
println!("\x1b[32mVersion:");
println!("\x1b[0m trump-0.1.0");
println!("\x1b[32mWebsite:");
println!("\x1b[0m https://github.com/x13machine/trump/");
println!("\x1b[32mCreator:");
printl... | {
let path = try!(fs::canonicalize(file));
Ok(path.display().to_string())
} | identifier_body |
args.rs | use ::structopt::StructOpt;
///
/// The structure of the commands for the app.
///
/// A large amount of this is generated by StructOpt.
/// See that project for how to write large amounts of this.
///
/// The gist however is that we make a struct that will hold
/// all of our arguments. Commands are then parsed, and ... |
///
/// Builds a new args from the main arguments given.
///
pub fn new_from_args() -> Args {
return Args::from_args();
}
} | pub path: String,
}
impl Args { | random_line_split |
args.rs |
use ::structopt::StructOpt;
///
/// The structure of the commands for the app.
///
/// A large amount of this is generated by StructOpt.
/// See that project for how to write large amounts of this.
///
/// The gist however is that we make a struct that will hold
/// all of our arguments. Commands are then parsed, and... | {
/// Enable logging, use multiple `v`s to increase verbosity.
#[structopt(short = "a", long = "all", help = "Set to show all hidden files and directories.")]
pub all: bool,
/// Set the minimum width of the directory column.
#[structopt(default_value = "0", short = "d", long = "directory-width", ... | Args | identifier_name |
abstractworker.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::DomObject;
use crate::script_... |
}
| {
SimpleWorkerErrorHandler { addr: addr }
} | identifier_body |
abstractworker.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::DomObject;
use crate::script_... | (addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> {
SimpleWorkerErrorHandler { addr: addr }
}
}
| new | identifier_name |
abstractworker.rs | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::DomObject;
use crate::script_runtime::CommonScriptMsg;
use script_traits::StructuredSerializedData;
use servo_url::ImmutableOrigin;
/// Messages used to control the worke... | /* 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 | random_line_split | |
dice.rs |
use error::DiceParseError;
use generator::Generator;
use regex::Regex;
lazy_static! {
static ref DICE_CMD_PATTERN: Regex = Regex::new(r"^\d+(d\d+)?$").unwrap();
}
/// `Dice` describes a set of dice of the same type that can be "rolled" all at once, i.e. "2d6"
#[derive(Debug, Eq, PartialEq)]
pub struct Dice {
... | use std::str; | random_line_split | |
dice.rs | use std::str;
use error::DiceParseError;
use generator::Generator;
use regex::Regex;
lazy_static! {
static ref DICE_CMD_PATTERN: Regex = Regex::new(r"^\d+(d\d+)?$").unwrap();
}
/// `Dice` describes a set of dice of the same type that can be "rolled" all at once, i.e. "2d6"
#[derive(Debug, Eq, PartialEq)]
pub str... | <T: Generator>(&self, generator: &mut T) -> <T as Generator>::Output {
generator.generate(&self)
}
}
impl str::FromStr for Dice {
type Err = DiceParseError;
fn from_str(s: &str) -> Result<Dice, Self::Err> {
if!DICE_CMD_PATTERN.is_match(s) {
return Err(DiceParseError::InvalidExp... | gen_result | identifier_name |
dice.rs | use std::str;
use error::DiceParseError;
use generator::Generator;
use regex::Regex;
lazy_static! {
static ref DICE_CMD_PATTERN: Regex = Regex::new(r"^\d+(d\d+)?$").unwrap();
}
/// `Dice` describes a set of dice of the same type that can be "rolled" all at once, i.e. "2d6"
#[derive(Debug, Eq, PartialEq)]
pub str... |
/// Generates the result of a dice roll for a given `Dice` value
pub fn gen_result<T: Generator>(&self, generator: &mut T) -> <T as Generator>::Output {
generator.generate(&self)
}
}
impl str::FromStr for Dice {
type Err = DiceParseError;
fn from_str(s: &str) -> Result<Dice, Self::Err> {... | {
Dice {
count: count,
range: range,
}
} | identifier_body |
weird-exprs.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 ... | punch_card();
} | union();
special_characters(); | random_line_split |
weird-exprs.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 ... | () {
loop { if break { } }
let mut i = 0;
loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } }
break; }
}
fn evil_lincoln() { let _evil = println!("lincoln"); }
fn dots() {
assert_eq!(String::from(".................................................."),
for... | angrydome | identifier_name |
weird-exprs.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 ... |
break; }
}
fn evil_lincoln() { let _evil = println!("lincoln"); }
fn dots() {
assert_eq!(String::from(".................................................."),
format!("{:?}",..........................
........................));
}
fn u8(u8: u8) {
if u8!= 0u8 ... | { match (continue) { 1 => { }, _ => panic!("wat") } } | conditional_block |
weird-exprs.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 what() {
fn the(x: &Cell<bool>) {
return while!x.get() { x.set(true); };
}
let i = &Cell::new(false);
let dont = {||the(i)};
dont();
assert!((i.get()));
}
fn zombiejesus() {
loop {
while (return) {
if (return) {
match (return) {
... | {
fn f(_x: ()) { }
f(return);
} | identifier_body |
type-referenced-by-whitelisted-function.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct dl_phdr_info {
pub x: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_dl_phdr_info() | stringify!(x)
)
);
}
extern "C" {
pub fn dl_iterate_phdr(arg1: *mut dl_phdr_info) -> ::std::os::raw::c_int;
}
| {
assert_eq!(
::std::mem::size_of::<dl_phdr_info>(),
4usize,
concat!("Size of: ", stringify!(dl_phdr_info))
);
assert_eq!(
::std::mem::align_of::<dl_phdr_info>(),
4usize,
concat!("Alignment of ", stringify!(dl_phdr_info))
);
assert_eq!(
unsafe ... | identifier_body |
type-referenced-by-whitelisted-function.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct | {
pub x: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_dl_phdr_info() {
assert_eq!(
::std::mem::size_of::<dl_phdr_info>(),
4usize,
concat!("Size of: ", stringify!(dl_phdr_info))
);
assert_eq!(
::std::mem::align_of::<dl_phdr_info>(),
4usize,
conc... | dl_phdr_info | identifier_name |
type-referenced-by-whitelisted-function.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct dl_phdr_info {
pub x: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_dl_phdr_info() {
assert_... | 4usize,
concat!("Alignment of ", stringify!(dl_phdr_info))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<dl_phdr_info>())).x as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(dl_phdr_info),
":... | concat!("Size of: ", stringify!(dl_phdr_info))
);
assert_eq!(
::std::mem::align_of::<dl_phdr_info>(), | random_line_split |
point.rs | //! A 2d point type.
use num::{Num, NumCast};
use std::ops::{Add, AddAssign, Sub, SubAssign};
/// A 2d point.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Point<T> {
/// x-coordinate.
pub x: T,
/// y-coordinate.
pub y: T,
}
impl<T> Point<T> {
/// Construct a point at (x, y).
pub fn... | #[derive(Debug, Copy, Clone, PartialEq)]
pub(crate) struct Line {
a: f64,
b: f64,
c: f64,
}
impl Line {
/// Returns the `Line` that passes through p and q.
pub fn from_points(p: Point<f64>, q: Point<f64>) -> Line {
let a = p.y - q.y;
let b = q.x - p.x;
let c = p.x * q.y - q.... | random_line_split | |
point.rs | //! A 2d point type.
use num::{Num, NumCast};
use std::ops::{Add, AddAssign, Sub, SubAssign};
/// A 2d point.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Point<T> {
/// x-coordinate.
pub x: T,
/// y-coordinate.
pub y: T,
}
impl<T> Point<T> {
/// Construct a point at (x, y).
pub fn... | {
sin_theta: f64,
cos_theta: f64,
}
impl Rotation {
/// A rotation of `theta` radians.
pub(crate) fn new(theta: f64) -> Rotation {
let (sin_theta, cos_theta) = theta.sin_cos();
Rotation {
sin_theta,
cos_theta,
}
}
}
impl Point<f64> {
/// Rotates... | Rotation | identifier_name |
point.rs | //! A 2d point type.
use num::{Num, NumCast};
use std::ops::{Add, AddAssign, Sub, SubAssign};
/// A 2d point.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Point<T> {
/// x-coordinate.
pub x: T,
/// y-coordinate.
pub y: T,
}
impl<T> Point<T> {
/// Construct a point at (x, y).
pub fn... |
/// Returns the square of the Euclidean distance between two points.
pub(crate) fn distance_sq<T: NumCast>(p: Point<T>, q: Point<T>) -> f64 {
let p = p.to_f64();
let q = q.to_f64();
(p.x - q.x).powf(2.0) + (p.y - q.y).powf(2.0)
}
/// A fixed rotation. This struct exists solely to cache the values of `sin... | {
distance_sq(p, q).sqrt()
} | identifier_body |
printer.rs | use std::collections::HashMap;
/// Module allowing to display an AST of 'MalValue'.
use std::fmt;
use super::types::MalType::*;
use super::types::{new_str, MalHashContainer, MalValue};
lazy_static! {
static ref STR_ESCAPED_CHARS_MAP: HashMap<char, &'static str> = {
let mut m = HashMap::new();
m.in... |
fn pr_hash(
hash: &MalHashContainer,
print_readably: bool,
start: &str,
end: &str,
sep: &str,
) -> String {
let list: Vec<MalValue> = hash
.iter()
.flat_map(|(k, v)| vec![new_str(k.clone()), v.clone()])
.collect();
pr_seq(&list, print_readably, start, end, sep)
}
| {
let mut string = String::new();
string.push_str(start);
let mut first = true;
for value in seq {
if first {
first = false;
} else {
string.push_str(sep);
}
string.push_str(&value.pr_str(print_readably)[..])
}
string.push_str(end);
s... | identifier_body |
printer.rs | use std::collections::HashMap;
/// Module allowing to display an AST of 'MalValue'.
use std::fmt;
use super::types::MalType::*;
use super::types::{new_str, MalHashContainer, MalValue};
lazy_static! {
static ref STR_ESCAPED_CHARS_MAP: HashMap<char, &'static str> = {
let mut m = HashMap::new();
m.in... | }
string.push_str(&value.pr_str(print_readably)[..])
}
string.push_str(end);
string
}
fn pr_hash(
hash: &MalHashContainer,
print_readably: bool,
start: &str,
end: &str,
sep: &str,
) -> String {
let list: Vec<MalValue> = hash
.iter()
.flat_map(|(k, v)| ... | string.push_str(sep); | random_line_split |
printer.rs | use std::collections::HashMap;
/// Module allowing to display an AST of 'MalValue'.
use std::fmt;
use super::types::MalType::*;
use super::types::{new_str, MalHashContainer, MalValue};
lazy_static! {
static ref STR_ESCAPED_CHARS_MAP: HashMap<char, &'static str> = {
let mut m = HashMap::new();
m.in... | else {
string.push_str(sep);
}
string.push_str(&value.pr_str(print_readably)[..])
}
string.push_str(end);
string
}
fn pr_hash(
hash: &MalHashContainer,
print_readably: bool,
start: &str,
end: &str,
sep: &str,
) -> String {
let list: Vec<MalValue> = hash... | {
first = false;
} | conditional_block |
printer.rs | use std::collections::HashMap;
/// Module allowing to display an AST of 'MalValue'.
use std::fmt;
use super::types::MalType::*;
use super::types::{new_str, MalHashContainer, MalValue};
lazy_static! {
static ref STR_ESCAPED_CHARS_MAP: HashMap<char, &'static str> = {
let mut m = HashMap::new();
m.in... | (&self, print_readably: bool) -> String {
match *self {
Nil => "nil".to_string(),
True => "true".to_string(),
False => "false".to_string(),
Integer(integer) => integer.to_string(),
Str(ref string) => {
if print_readably {
... | pr_str | identifier_name |
dependency_queue.rs | //! A graph-like structure used to represent a set of dependencies and in what
//! order they should be built.
//!
//! This structure is used to store the dependency graph and dynamically update
//! it to figure out when a dependency should be built.
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::... | (&self) -> usize {
self.dep_map.len() + self.pending.len()
}
/// Indicate that a package has been built.
///
/// This function will update the dependency queue with this information,
/// possibly allowing the next invocation of `dequeue` to return a package.
pub fn finish(&mut self, key... | len | identifier_name |
dependency_queue.rs | //! A graph-like structure used to represent a set of dependencies and in what
//! order they should be built.
//!
//! This structure is used to store the dependency graph and dynamically update
//! it to figure out when a dependency should be built.
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::... | match *self { Fresh => other, Dirty => Dirty }
}
}
impl<K: Dependency, V> DependencyQueue<K, V> {
/// Creates a new dependency queue with 0 packages.
pub fn new() -> DependencyQueue<K, V> {
DependencyQueue {
dep_map: HashMap::new(),
reverse_dep_map: HashMap::new(),
... |
impl Freshness {
pub fn combine(&self, other: Freshness) -> Freshness { | random_line_split |
mod.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 ... | output: ty::mk_nil()
}
});
require_same_types(tcx, None, false, main_span, main_t, se_ty,
|| fmt!("main function expects type: `%s`",
ppaux::ty_to_str(ccx.tcx, se_ty)));
}
_ => {
tcx.sess.spa... | sig: ty::FnSig {
bound_lifetime_names: opt_vec::Empty,
inputs: ~[], | random_line_split |
mod.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 ... |
}
pub type vtable_map = @mut HashMap<ast::node_id, vtable_res>;
pub struct CrateCtxt {
// A mapping from method call sites to traits that have that method.
trait_map: resolve::TraitMap,
method_map: method_map,
vtable_map: vtable_map,
coherence_info: coherence::CoherenceInfo,
tcx: ty::ctxt
}
... | {
match *self {
vtable_static(def_id, ref tys, ref vtable_res) => {
fmt!("vtable_static(%?:%s, %s, %s)",
def_id,
ty::item_path_str(tcx, def_id),
tys.repr(tcx),
vtable_res.repr(tcx))
}
... | identifier_body |
mod.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 ... | (ccx: &CrateCtxt) {
let tcx = ccx.tcx;
if!*tcx.sess.building_library {
match *tcx.sess.entry_fn {
Some((id, sp)) => match *tcx.sess.entry_type {
Some(session::EntryMain) => check_main_fn_ty(ccx, id, sp),
Some(session::EntryStart) => check_start_fn_ty(ccx, id, sp),
... | check_for_entry_fn | identifier_name |
unquote.rs | /* Copyright (C) 2015-2016 Yutaka Kamei */
use std::string::FromUtf8Error;
const OFFSET : usize = 6;
const DIGIT : &'static [u8] = b"0123456789ABCDEFabcdef";
/// Replaces %xx escapes by their single-character equivalent.
///
/// # Examples
///
/// ```
/// use urlparse::unquote;
///
/// let s = unquote("ABC%3D123%21%... |
fn to_digit(n1: u8, n2: u8) -> Option<u8> {
let mut byte : u8 = 0;
match DIGIT.binary_search(&n1) {
Ok(_n1) => byte += if _n1 < 16 {_n1 as u8 * 16} else {(_n1 - OFFSET) as u8 * 16},
Err(_) => return None,
}
match DIGIT.binary_search(&n2) {
Ok(_n2) => byte += if _n2 < 16 {_n2 ... | {
let _s = s.as_ref().replace("+", " ");
return unquote(_s);
} | identifier_body |
unquote.rs | /* Copyright (C) 2015-2016 Yutaka Kamei */ |
const OFFSET : usize = 6;
const DIGIT : &'static [u8] = b"0123456789ABCDEFabcdef";
/// Replaces %xx escapes by their single-character equivalent.
///
/// # Examples
///
/// ```
/// use urlparse::unquote;
///
/// let s = unquote("ABC%3D123%21%20DEF%3D%23%23");
/// assert_eq!(s.ok().unwrap(), "ABC=123! DEF=##");
/// ``... |
use std::string::FromUtf8Error; | random_line_split |
unquote.rs | /* Copyright (C) 2015-2016 Yutaka Kamei */
use std::string::FromUtf8Error;
const OFFSET : usize = 6;
const DIGIT : &'static [u8] = b"0123456789ABCDEFabcdef";
/// Replaces %xx escapes by their single-character equivalent.
///
/// # Examples
///
/// ```
/// use urlparse::unquote;
///
/// let s = unquote("ABC%3D123%21%... | ,
Err(_) => return None,
}
return Some(byte);
}
#[test]
fn test_to_digit() {
assert_eq!(to_digit(b'1', b'2'), Some(0x12));
assert_eq!(to_digit(b'e', b'a'), Some(0xEA));
assert_eq!(to_digit(b'E', b'A'), Some(0xEA));
assert_eq!(to_digit(b'F', b'F'), Some(0xFF));
assert_eq!(to_digit(... | {(_n2 - OFFSET) as u8} | conditional_block |
unquote.rs | /* Copyright (C) 2015-2016 Yutaka Kamei */
use std::string::FromUtf8Error;
const OFFSET : usize = 6;
const DIGIT : &'static [u8] = b"0123456789ABCDEFabcdef";
/// Replaces %xx escapes by their single-character equivalent.
///
/// # Examples
///
/// ```
/// use urlparse::unquote;
///
/// let s = unquote("ABC%3D123%21%... | <S: AsRef<str>>(s: S) -> Result<String, FromUtf8Error> {
let _s = s.as_ref().replace("+", " ");
return unquote(_s);
}
fn to_digit(n1: u8, n2: u8) -> Option<u8> {
let mut byte : u8 = 0;
match DIGIT.binary_search(&n1) {
Ok(_n1) => byte += if _n1 < 16 {_n1 as u8 * 16} else {(_n1 - OFFSET) as u8 *... | unquote_plus | identifier_name |
mean.rs | //! Functions for calculating mean
use std::f64::NAN;
/// Calculates arithmetic mean (AM) of data set `slice`.
///
/// # Arguments
///
/// * `slice` - collection of values
///
/// # Example
///
/// ```
/// use math::mean;
///
/// let slice = [8., 16.];
/// assert_eq!(mean::arithmetic(&slice), 12.);
/// ```
pub fn | (slice: &[f64]) -> f64 {
slice.iter().fold(0., |a, b| a + b) / slice.len() as f64
}
/// Calculate geometric mean (GM) of data set `slice`.
///
/// If the result would be imaginary, function returns `NAN`.
///
/// # Arguments
///
/// * `slice` - collection of values
///
/// # Example
///
/// ```
/// use math::mean;
//... | arithmetic | identifier_name |
mean.rs | //! Functions for calculating mean
use std::f64::NAN;
/// Calculates arithmetic mean (AM) of data set `slice`.
///
/// # Arguments
///
/// * `slice` - collection of values
///
/// # Example
///
/// ```
/// use math::mean;
///
/// let slice = [8., 16.];
/// assert_eq!(mean::arithmetic(&slice), 12.);
/// ```
pub fn arit... | geometric_8: (&[NEG_INFINITY, 1., 2., 3., 4.], NAN),
geometric_9: (&[1., 2., 3., 4., INFINITY], INFINITY),
]}
test_mean! { super::harmonic [
harmonic_1: (&[-7., -4., 1., 3., 8.], 4.692737),
harmonic_2: (&[-4., 1., 3., 8., 12.], 3.870968),
harmonic_3: (&[0., 0., 0., 0., 0.], 0.),
harmonic_4: (&[0., 4., 7.... | geometric_4: (&[0., 4., 7., 9., 17.], 0.),
geometric_5: (&[1., 2., 6., 4., 13.], 3.622738),
geometric_6: (&[1., 5., 10., 20., 25.], 7.578583),
geometric_7: (&[2., 3., 5., 7., 11.], 4.706764), | random_line_split |
mean.rs | //! Functions for calculating mean
use std::f64::NAN;
/// Calculates arithmetic mean (AM) of data set `slice`.
///
/// # Arguments
///
/// * `slice` - collection of values
///
/// # Example
///
/// ```
/// use math::mean;
///
/// let slice = [8., 16.];
/// assert_eq!(mean::arithmetic(&slice), 12.);
/// ```
pub fn arit... |
/// Calculate geometric mean (GM) of data set `slice`.
///
/// If the result would be imaginary, function returns `NAN`.
///
/// # Arguments
///
/// * `slice` - collection of values
///
/// # Example
///
/// ```
/// use math::mean;
///
/// let slice = [9., 16.];
/// assert_eq!(mean::geometric(&slice), 12.);
/// ```
p... | {
slice.iter().fold(0., |a, b| a + b) / slice.len() as f64
} | identifier_body |
window.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/. */
//! A windowing implementation using GLUT.
use compositing::compositor_task::{mod, CompositorProxy, CompositorRec... | key!(TLS_KEY: Rc<Window>)
fn install_local_window(window: Rc<Window>) {
TLS_KEY.replace(Some(window));
}
fn drop_local_window() {
TLS_KEY.replace(None);
}
fn local_window() -> Rc<Window> {
TLS_KEY.get().unwrap().clone()
}
| utCompositorProxy {
sender: self.sender.clone(),
} as Box<CompositorProxy+Send>
}
}
local_data_ | identifier_body |
window.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/. */
//! A windowing implementation using GLUT.
use compositing::compositor_task::{mod, CompositorProxy, CompositorRec... | > panic!("I cannot recognize the type of mouse action that occured. :-(")
};
self.event_queue.borrow_mut().push(MouseWindowEventClass(event));
}
/// Helper function to pop up an alert box prompting the user to load a URL.
fn load_url(&self) {
let mut alert: Alert = AlertMethods::new... | if self.mouse_down_button.get() == button {
let pixel_dist = self.mouse_down_point.get() - Point2D(x, y);
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
pixel_dist.y * pixel_dist.y) as f32).sqrt();
if pixel_dist < max... | conditional_block |
window.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/. */
//! A windowing implementation using GLUT.
use compositing::compositor_task::{mod, CompositorProxy, CompositorRec... | lut::MouseCallback for MouseCallbackState {
fn call(&self, button: c_int, state: c_int, x: c_int, y: c_int) {
if button < 3 {
let tmp = local_window();
tmp.handle_mouse(button, state, x, y);
} else {
match button {
... | te;
impl g | identifier_name |
window.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/. */
//! A windowing implementation using GLUT.
use compositing::compositor_task::{mod, CompositorProxy, CompositorRec... | /// The type of a window.
pub struct Window {
pub glut_window: glut::Window,
pub event_queue: RefCell<Vec<WindowEvent>>,
pub drag_origin: Point2D<c_int>,
pub mouse_down_button: Cell<c_int>,
pub mouse_down_point: Cell<Point2D<c_int>>,
pub ready_state: Cell<ReadyState>,
pub render_state: C... | use glut::glut;
// static THROBBER: [char, ..8] = [ '⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷' ];
| random_line_split |
instr_pmuldq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn pmuldq_1() {
run_test(&Instruction { mnemonic: Mnemonic::PMULDQ, operand1: Some(Direct(XM... |
#[test]
fn pmuldq_4() {
run_test(&Instruction { mnemonic: Mnemonic::PMULDQ, operand1: Some(Direct(XMM5)), operand2: Some(Indirect(RSI, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 4... | {
run_test(&Instruction { mnemonic: Mnemonic::PMULDQ, operand1: Some(Direct(XMM1)), operand2: Some(Direct(XMM6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 40, 206], OperandSize::Qword)
} | identifier_body |
instr_pmuldq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn | () {
run_test(&Instruction { mnemonic: Mnemonic::PMULDQ, operand1: Some(Direct(XMM1)), operand2: Some(Direct(XMM0)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 40, 200], OperandSize::Dword)
}
#[test]
fn pmuldq_2() {
... | pmuldq_1 | identifier_name |
instr_pmuldq.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn pmuldq_1() {
run_test(&Instruction { mnemonic: Mnemonic::PMULDQ, operand1: Some(Direct(XM... | }
#[test]
fn pmuldq_4() {
run_test(&Instruction { mnemonic: Mnemonic::PMULDQ, operand1: Some(Direct(XMM5)), operand2: Some(Indirect(RSI, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, ... |
#[test]
fn pmuldq_3() {
run_test(&Instruction { mnemonic: Mnemonic::PMULDQ, operand1: Some(Direct(XMM1)), operand2: Some(Direct(XMM6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 40, 206], OperandSize::Qword) | random_line_split |
rc.rs | //! A reference-counted wrapper sharing one owned trace.
//!
//! The types in this module, `TraceBox` and `TraceRc` and meant to parallel `RcBox` and `Rc` in `std::rc`.
//!
//! The first typee is an owned trace with some information about the cumulative requirements of the shared
//! handles. This is roughly how much p... |
fn distinguish_frontier(&mut self) -> &[Tr::Time] { &self.through_frontier[..] }
/// Creates a new cursor over the wrapped trace.
fn cursor_through(&mut self, frontier: &[Tr::Time]) -> Option<(Tr::Cursor, <Tr::Cursor as Cursor<Tr::Key, Tr::Val, Tr::Time, Tr::R>>::Storage)> {
::std::cell::RefCell::b... | {
self.wrapper.borrow_mut().adjust_through_frontier(&self.through_frontier[..], frontier);
self.through_frontier = frontier.to_vec();
} | identifier_body |
rc.rs | //! A reference-counted wrapper sharing one owned trace.
//!
//! The types in this module, `TraceBox` and `TraceRc` and meant to parallel `RcBox` and `Rc` in `std::rc`.
//!
//! The first typee is an owned trace with some information about the cumulative requirements of the shared
//! handles. This is roughly how much p... | }
impl<Tr> TraceRc<Tr>
where
Tr::Time: Lattice+Ord+Clone+'static,
Tr: TraceReader,
{
/// Allocates a new handle from an existing wrapped wrapper.
pub fn make_from(trace: Tr) -> (Self, Rc<RefCell<TraceBox<Tr>>>) {
let wrapped = Rc::new(RefCell::new(TraceBox::new(trace)));
let handle = ... | ::std::cell::RefCell::borrow_mut(&self.wrapper).trace.map_batches(f)
} | random_line_split |
rc.rs | //! A reference-counted wrapper sharing one owned trace.
//!
//! The types in this module, `TraceBox` and `TraceRc` and meant to parallel `RcBox` and `Rc` in `std::rc`.
//!
//! The first typee is an owned trace with some information about the cumulative requirements of the shared
//! handles. This is roughly how much p... | (&mut self, lower: &[Tr::Time], upper: &[Tr::Time]) {
self.through_frontiers.update_iter(upper.iter().cloned().map(|t| (t,1)));
self.through_frontiers.update_iter(lower.iter().cloned().map(|t| (t,-1)));
// for element in upper { self.through_frontiers.update_and(element, 1, |_,_| {}); }
... | adjust_through_frontier | identifier_name |
error.rs | use std::error::Error;
use std::fmt;
use std::io;
use std::num::{ParseFloatError, ParseIntError};
use std::str::Utf8Error;
#[derive(Debug)]
pub enum OperationError {
OverflowError,
NotANumberError,
ValueError(String),
UnknownKeyError,
WrongTypeError,
OutOfBoundsError,
IOError(io::Error), |
impl OperationError {
fn message(&self) -> &str {
match self {
OperationError::WrongTypeError => {
"WRONGTYPE Operation against a key holding the wrong kind of value"
}
OperationError::NotANumberError => "ERR resulting score is not a number (NaN)",
... | } | random_line_split |
error.rs | use std::error::Error;
use std::fmt;
use std::io;
use std::num::{ParseFloatError, ParseIntError};
use std::str::Utf8Error;
#[derive(Debug)]
pub enum OperationError {
OverflowError,
NotANumberError,
ValueError(String),
UnknownKeyError,
WrongTypeError,
OutOfBoundsError,
IOError(io::Error),
}
... | (&self) -> &str {
self.message()
}
}
impl From<Utf8Error> for OperationError {
fn from(_: Utf8Error) -> OperationError {
OperationError::ValueError("ERR value is not a string".to_owned())
}
}
impl From<ParseIntError> for OperationError {
fn from(_: ParseIntError) -> OperationError {
... | description | identifier_name |
error.rs | use std::error::Error;
use std::fmt;
use std::io;
use std::num::{ParseFloatError, ParseIntError};
use std::str::Utf8Error;
#[derive(Debug)]
pub enum OperationError {
OverflowError,
NotANumberError,
ValueError(String),
UnknownKeyError,
WrongTypeError,
OutOfBoundsError,
IOError(io::Error),
}
... |
}
| {
OperationError::IOError(e)
} | identifier_body |
poll_immediate.rs | use super::assert_future;
use core::pin::Pin;
use futures_core::task::{Context, Poll};
use futures_core::{FusedFuture, Future, Stream};
use pin_project_lite::pin_project;
pin_project! {
/// Future for the [`poll_immediate`](poll_immediate()) function.
///
/// It will never return [Poll::Pending](core::task... | (self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let mut this = self.project();
match this.future.as_mut().as_pin_mut() {
// inner is gone, so we can signal that the stream is closed.
None => Poll::Ready(None),
Some(fut) => Poll::Ready(Some(f... | poll_next | identifier_name |
poll_immediate.rs | use super::assert_future;
use core::pin::Pin;
use futures_core::task::{Context, Poll};
use futures_core::{FusedFuture, Future, Stream};
use pin_project_lite::pin_project;
pin_project! {
/// Future for the [`poll_immediate`](poll_immediate()) function.
///
/// It will never return [Poll::Pending](core::task... | impl<T: Future> FusedFuture for PollImmediate<T> {
fn is_terminated(&self) -> bool {
self.future.is_none()
}
}
/// A [Stream](crate::stream::Stream) implementation that can be polled repeatedly until the future is done.
/// The stream will never return [Poll::Pending](core::task::Poll::Pending)
/// so ... | }
| random_line_split |
poll_immediate.rs | use super::assert_future;
use core::pin::Pin;
use futures_core::task::{Context, Poll};
use futures_core::{FusedFuture, Future, Stream};
use pin_project_lite::pin_project;
pin_project! {
/// Future for the [`poll_immediate`](poll_immediate()) function.
///
/// It will never return [Poll::Pending](core::task... |
}
/// Creates a future that is immediately ready with an Option of a value.
/// Specifically this means that [poll](core::future::Future::poll()) always returns [Poll::Ready](core::task::Poll::Ready).
///
/// # Caution
///
/// When consuming the future by this function, note the following:
///
/// - This function doe... | {
let mut this = self.project();
match this.future.as_mut().as_pin_mut() {
// inner is gone, so we can signal that the stream is closed.
None => Poll::Ready(None),
Some(fut) => Poll::Ready(Some(fut.poll(cx).map(|t| {
this.future.set(None);
... | identifier_body |
query.rs | use crate::namespace::*;
use crate::sparql::pattern::Pattern;
use crate::uri::Uri;
use crate::Result;
/// Query type.
#[derive(Clone, Debug)]
pub enum SparqlQueryType {
Ask,
Select,
SelectDistinct,
SelectReduced,
SelectAll,
SelectAllDistinct,
SelectAllReduced,
Construct,
Describe,
}... | // Variables used in the query.
variables: Vec<String>,
// Patterns used as constraints.
patterns: Vec<Box<Pattern>>,
}
impl SparqlQuery {
/// Constructor of `SparqlQuery`.
pub fn new(query_type: SparqlQueryType) -> SparqlQuery {
SparqlQuery {
query_type: query_type,
... | /// Namespaces stated in SPARQL query.
namespaces: NamespaceStore,
| random_line_split |
query.rs | use crate::namespace::*;
use crate::sparql::pattern::Pattern;
use crate::uri::Uri;
use crate::Result;
/// Query type.
#[derive(Clone, Debug)]
pub enum SparqlQueryType {
Ask,
Select,
SelectDistinct,
SelectReduced,
SelectAll,
SelectAllDistinct,
SelectAllReduced,
Construct,
Describe,
}... |
/// Get query variables.
///
/// todo
///
pub fn get_query_variables(&self) -> &Vec<String> {
&self.variables
}
/// Get the query patterns in the `WHERE` expression.
///
/// todo
///
// pub fn get_query_patterns(&self) -> &Vec<Pattern> {
// &self.patterns
... | {
&self.query_type
} | identifier_body |
query.rs | use crate::namespace::*;
use crate::sparql::pattern::Pattern;
use crate::uri::Uri;
use crate::Result;
/// Query type.
#[derive(Clone, Debug)]
pub enum | {
Ask,
Select,
SelectDistinct,
SelectReduced,
SelectAll,
SelectAllDistinct,
SelectAllReduced,
Construct,
Describe,
}
/// Represents a SPARQL query that can be applied to an RDF graph.
/// `SparqlQuery`s are created when parsing a SPARQL string using `SparqlParser`.
pub struct Sparq... | SparqlQueryType | identifier_name |
mod.rs | use crate::rendering::*;
use crate::geometry::*;
/// IMPORTANT: Must form a star domain at its center
#[derive(Clone, Debug)]
pub struct Polygon {
pub corners: Vec<Point>, /// defined anti-clockwise
pub center: Point,
pub rot: Rotation, /// anti-clockwise angle w.r.t. positive z-axis
pub pos: Point3,
... |
pub fn get_vertices(self) -> Vec<PolygonVertex> {
let mut output: Vec<PolygonVertex> = vec![];
let corners_it_shift = self.corners.clone().into_iter().cycle().skip(1);
for (corner1, corner2) in self.corners.into_iter().zip(corners_it_shift) {
output.push(PolygonVertex {
... | {
Polygon {
corners,
center,
rot: Rotation::new(0.0),
pos,
color,
fixed,
}
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.