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
row.rs
use fallible_iterator::FallibleIterator; use fallible_streaming_iterator::FallibleStreamingIterator; use std::convert; use super::{Error, Result, Statement}; use crate::types::{FromSql, FromSqlError, ValueRef}; /// An handle for the resulting rows of a query. #[must_use = "Rows is lazy and will do nothing unless cons...
/// Renamed to [`get_ref`](Row::get_ref). #[deprecated = "Use [`get_ref`](Row::get_ref) instead."] #[inline] pub fn get_raw_checked<I: RowIndex>(&self, idx: I) -> Result<ValueRef<'_>> { self.get_ref(idx) } /// Renamed to [`get_ref_unwrap`](Row::get_ref_unwrap). #[deprecated = "Use...
{ self.get_ref(idx).unwrap() }
identifier_body
cast-enum-with-dtor.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ assert_eq!(FLAG.load(Ordering::SeqCst), 0); { let e = E::C; assert_eq!(e as u32, 2); assert_eq!(FLAG.load(Ordering::SeqCst), 0); } assert_eq!(FLAG.load(Ordering::SeqCst), 1); }
identifier_body
cast-enum-with-dtor.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
enum E { A = 0, B = 1, C = 2 } static FLAG: atomic::AtomicUsize = atomic::AtomicUsize::new(0); impl Drop for E { fn drop(&mut self) { // avoid dtor loop unsafe { mem::forget(mem::replace(self, E::B)) }; FLAG.store(FLAG.load(Ordering::SeqCst)+1, Ordering::SeqCst); } } fn m...
use std::sync::atomic; use std::sync::atomic::Ordering; use std::mem;
random_line_split
cast-enum-with-dtor.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert_eq!(FLAG.load(Ordering::SeqCst), 0); { let e = E::C; assert_eq!(e as u32, 2); assert_eq!(FLAG.load(Ordering::SeqCst), 0); } assert_eq!(FLAG.load(Ordering::SeqCst), 1); }
main
identifier_name
mod.rs
pub mod spout; pub mod bolt; use rustc_serialize::json; use tokio_core::net::TcpStream; use tokio_io; use futures::Future; use std; use tokio_uds::UnixStream; pub struct ComponentConfig{ pub sock_file: String, pub component_id: String } #[derive(Debug)] #[derive(RustcEncodable, RustcDecodable)] pub enum Mes...
(&self, stream: tokio_io::io::WriteHalf<UnixStream>) -> Box<Future<Item = (tokio_io::io::WriteHalf<UnixStream>), Error = std::io::Error > + Send> { Box::new(tokio_io::io::write_all(stream, self.encoded()).and_then(|c| Ok(c.0))) } pub fn encoded(&self) -> Vec<u8>{ let message = json::encode(...
to_half_uds
identifier_name
mod.rs
pub mod spout; pub mod bolt; use rustc_serialize::json; use tokio_core::net::TcpStream; use tokio_io; use futures::Future; use std; use tokio_uds::UnixStream; pub struct ComponentConfig{ pub sock_file: String, pub component_id: String } #[derive(Debug)] #[derive(RustcEncodable, RustcDecodable)] pub enum Mes...
}
{ Message::Tuple(stream.to_string(), value.to_string()) }
identifier_body
mod.rs
pub mod spout; pub mod bolt; use rustc_serialize::json; use tokio_core::net::TcpStream; use tokio_io; use futures::Future; use std; use tokio_uds::UnixStream; pub struct ComponentConfig{ pub sock_file: String, pub component_id: String } #[derive(Debug)] #[derive(RustcEncodable, RustcDecodable)] pub enum Mes...
unimplemented!(); } pub fn tuple(stream: &str, value: &str) -> Self{ Message::Tuple(stream.to_string(), value.to_string()) } }
random_line_split
trampoline_to_glib.rs
use analysis::conversion_type::ConversionType; use library; pub trait TrampolineToGlib { fn trampoline_to_glib(&self, library: &library::Library) -> String; } impl TrampolineToGlib for library::Parameter { fn trampoline_to_glib(&self, library: &library::Library) -> String
} fn to_glib_xxx(transfer: library::Transfer) -> &'static str { use library::Transfer::*; match transfer { None => "/*Not checked*/.to_glib_none().0", Full => ".to_glib_full()", Container => "/*Not checked*/.to_glib_container().0", } }
{ use analysis::conversion_type::ConversionType::*; match ConversionType::of(library, self.typ) { Direct => String::new(), Scalar => ".to_glib()".to_owned(), Pointer => to_glib_xxx(self.transfer).to_owned(), Unknown => "/*Unknown conversion*/".to_owned(), ...
identifier_body
trampoline_to_glib.rs
use analysis::conversion_type::ConversionType; use library; pub trait TrampolineToGlib { fn trampoline_to_glib(&self, library: &library::Library) -> String; } impl TrampolineToGlib for library::Parameter { fn trampoline_to_glib(&self, library: &library::Library) -> String { use analysis::conversion_ty...
None => "/*Not checked*/.to_glib_none().0", Full => ".to_glib_full()", Container => "/*Not checked*/.to_glib_container().0", } }
fn to_glib_xxx(transfer: library::Transfer) -> &'static str { use library::Transfer::*; match transfer {
random_line_split
trampoline_to_glib.rs
use analysis::conversion_type::ConversionType; use library; pub trait TrampolineToGlib { fn trampoline_to_glib(&self, library: &library::Library) -> String; } impl TrampolineToGlib for library::Parameter { fn trampoline_to_glib(&self, library: &library::Library) -> String { use analysis::conversion_ty...
(transfer: library::Transfer) -> &'static str { use library::Transfer::*; match transfer { None => "/*Not checked*/.to_glib_none().0", Full => ".to_glib_full()", Container => "/*Not checked*/.to_glib_container().0", } }
to_glib_xxx
identifier_name
counts.rs
use needletail::bitkmer::{bitmer_to_bytes, reverse_complement}; use needletail::Sequence; use crate::sketch_schemes::{KmerCount, SketchParams, SketchScheme}; use needletail::parser::SequenceRecord; #[derive(Clone)] pub struct AllCountsSketcher { counts: Vec<u32>, total_bases: u64, k: u8, } impl AllCounts...
fn total_bases_and_kmers(&self) -> (u64, u64) { ( self.total_bases, self.counts.iter().map(|x| u64::from(*x)).sum(), ) } fn to_vec(&self) -> Vec<KmerCount> { let mut counts = self.counts.clone(); let mut results = Vec::with_capacity(self.counts.len(...
{ for (_, kmer, _) in seq.normalize(false).bit_kmers(self.k, false) { self.counts[kmer.0 as usize] = self.counts[kmer.0 as usize].saturating_add(1); } }
identifier_body
counts.rs
use needletail::bitkmer::{bitmer_to_bytes, reverse_complement}; use needletail::Sequence; use crate::sketch_schemes::{KmerCount, SketchParams, SketchScheme}; use needletail::parser::SequenceRecord; #[derive(Clone)] pub struct AllCountsSketcher { counts: Vec<u32>, total_bases: u64, k: u8, } impl AllCounts...
let extra_count = self.counts[reverse_complement((ix, self.k)).0 as usize]; counts[reverse_complement((ix, self.k)).0 as usize] = 0; count += extra_count; let new_item = KmerCount { hash: ix, kmer: bitmer_to_bytes((ix as u64, self.k)), ...
{ continue; }
conditional_block
counts.rs
use needletail::bitkmer::{bitmer_to_bytes, reverse_complement}; use needletail::Sequence; use crate::sketch_schemes::{KmerCount, SketchParams, SketchScheme}; use needletail::parser::SequenceRecord; #[derive(Clone)] pub struct
{ counts: Vec<u32>, total_bases: u64, k: u8, } impl AllCountsSketcher { pub fn new(k: u8) -> Self { // TODO: should we take a size parameter or the like and clip this? AllCountsSketcher { counts: vec![0; 4usize.pow(k.into())], total_bases: 0, k, ...
AllCountsSketcher
identifier_name
counts.rs
use needletail::bitkmer::{bitmer_to_bytes, reverse_complement}; use needletail::Sequence; use crate::sketch_schemes::{KmerCount, SketchParams, SketchScheme}; use needletail::parser::SequenceRecord; #[derive(Clone)] pub struct AllCountsSketcher { counts: Vec<u32>, total_bases: u64, k: u8, } impl AllCounts...
fn parameters(&self) -> SketchParams { SketchParams::AllCounts { kmer_length: self.k, } } }
results }
random_line_split
mod.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
// option. This file may not be copied, modified, or distributed // except according to those terms. //! Unordered containers, implemented as hash-tables mod table; pub mod map; pub mod set; trait Recover<Q:?Sized> { type Key; fn get(&self, key: &Q) -> Option<&Self::Key>; fn take(&mut self, key: &Q) -> ...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
bezier.rs
// Copyright (C) 2020 Inderjit Gill <email@indy.io> // This file is part of Seni // Seni is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any l...
let x0 = coords[0]; let x1 = coords[2]; let x2 = coords[4]; let x3 = coords[6]; let y0 = coords[1]; let y1 = coords[3]; let y2 = coords[5]; let y3 = coords[7]; let unit = (t_end - t_start) / (tessellation as f32 - 1.0); let tex_t = 1.0 / tessellation as f32; // this chunk ...
{ let au = uvm.map[0]; let av = uvm.map[1]; let bu = uvm.map[2]; let bv = uvm.map[3]; let cu = uvm.map[4]; let cv = uvm.map[5]; let du = uvm.map[6]; let dv = uvm.map[7]; // modify the width so that the brush textures provide good coverage // let line_width_start = width_star...
identifier_body
bezier.rs
// Copyright (C) 2020 Inderjit Gill <email@indy.io> // This file is part of Seni // Seni is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any l...
let tex_t = 1.0 / tessellation as f32; // this chunk of code is just to calc the initial verts for prepare_to_add_triangle_strip // and to get the appropriate render packet // let t_val = t_start; let t_val_next = t_start + (1.0 * unit); let xs = bezier_point(x0, x1, x2, x3, t_val); let...
random_line_split
bezier.rs
// Copyright (C) 2020 Inderjit Gill <email@indy.io> // This file is part of Seni // Seni is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any l...
( render_list: &mut RenderList, matrix: &Matrix, coords: &[f32; 8], width_start: f32, width_end: f32, width_mapping: Easing, t_start: f32, t_end: f32, colour: &Rgb, tessellation: usize, uvm: &UvMapping, ) -> Result<()> { let au = uvm.map[0]; let av = uvm.map[1]; l...
render
identifier_name
error.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::error; use std::fmt::Display; use std::fmt::{self}; use std::io; use std::str; use std::string; use std::{self}; use serde::de; u...
impl error::Error for Error { fn description(&self) -> &str { &self.msg } } impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.msg) } } impl ser::Error for Error { fn custom<T: Display>(msg: T) -> Self { Error::new(msg) } }...
msg: msg.to_string(), } } }
random_line_split
error.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::error; use std::fmt::Display; use std::fmt::{self}; use std::io; use std::str; use std::string; use std::{self}; use serde::de; u...
} impl From<string::FromUtf8Error> for Error { fn from(err: string::FromUtf8Error) -> Self { Error::new(err) } }
{ Error::new(err) }
identifier_body
error.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::error; use std::fmt::Display; use std::fmt::{self}; use std::io; use std::str; use std::string; use std::{self}; use serde::de; u...
(&self) -> &str { &self.msg } } impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.msg) } } impl ser::Error for Error { fn custom<T: Display>(msg: T) -> Self { Error::new(msg) } } impl de::Error for Error { fn custom<T: Di...
description
identifier_name
background_datastore.rs
use rand; use rand::distributions::*; use structures; use constants::*; use GameUpdateArgs; pub struct BackgroundDatastore<'a> { buffer_data: &'a mut [structures::BackgroundInstance; MAX_BK_COUNT], instance_data: &'a mut [u32; MAX_BK_COUNT] } impl <'a> BackgroundDatastore<'a> { pub fn new(buffer_data_ref: &'a mut ...
else { self.buffer_data[i].offset[1] += update_args.delta_time * 22.0f32; *m = if self.buffer_data[i].offset[1] >= 20.0f32 { 0 } else { 1 }; } } } }
{ let mut require_appear = appear; let mut left_range = rand::distributions::Range::new(-14.0f32, 14.0f32); let mut count_range = rand::distributions::Range::new(2, 10); let mut scale_range = rand::distributions::Range::new(1.0f32, 3.0f32); for (i, m) in self.instance_data.iter_mut().enumerate() { if *m ...
identifier_body
background_datastore.rs
use rand; use rand::distributions::*; use structures; use constants::*; use GameUpdateArgs; pub struct BackgroundDatastore<'a> { buffer_data: &'a mut [structures::BackgroundInstance; MAX_BK_COUNT], instance_data: &'a mut [u32; MAX_BK_COUNT] } impl <'a> BackgroundDatastore<'a> {
{ buffer_data: buffer_data_ref, instance_data: instance_data_ref } } pub fn update(&mut self, update_args: &mut GameUpdateArgs, appear: bool) { let mut require_appear = appear; let mut left_range = rand::distributions::Range::new(-14.0f32, 14.0f32); let mut count_range = rand::distributions::Range::n...
pub fn new(buffer_data_ref: &'a mut [structures::BackgroundInstance; MAX_BK_COUNT], instance_data_ref: &'a mut [u32; MAX_BK_COUNT]) -> Self { BackgroundDatastore
random_line_split
background_datastore.rs
use rand; use rand::distributions::*; use structures; use constants::*; use GameUpdateArgs; pub struct BackgroundDatastore<'a> { buffer_data: &'a mut [structures::BackgroundInstance; MAX_BK_COUNT], instance_data: &'a mut [u32; MAX_BK_COUNT] } impl <'a> BackgroundDatastore<'a> { pub fn new(buffer_data_ref: &'a mut ...
(&mut self, update_args: &mut GameUpdateArgs, appear: bool) { let mut require_appear = appear; let mut left_range = rand::distributions::Range::new(-14.0f32, 14.0f32); let mut count_range = rand::distributions::Range::new(2, 10); let mut scale_range = rand::distributions::Range::new(1.0f32, 3.0f32); for (i, ...
update
identifier_name
background_datastore.rs
use rand; use rand::distributions::*; use structures; use constants::*; use GameUpdateArgs; pub struct BackgroundDatastore<'a> { buffer_data: &'a mut [structures::BackgroundInstance; MAX_BK_COUNT], instance_data: &'a mut [u32; MAX_BK_COUNT] } impl <'a> BackgroundDatastore<'a> { pub fn new(buffer_data_ref: &'a mut ...
else { self.buffer_data[i].offset[1] += update_args.delta_time * 22.0f32; *m = if self.buffer_data[i].offset[1] >= 20.0f32 { 0 } else { 1 }; } } } }
{ // instantiate randomly if require_appear { let scale = scale_range.sample(&mut update_args.randomizer); *m = 1; self.buffer_data[i].offset = [left_range.sample(&mut update_args.randomizer), -20.0f32, -20.0f32, count_range.sample(&mut update_args.randomizer) as f32]; self.buffer_...
conditional_block
boxed.rs
rust1", since = "1.0.0")] use core::any::Any; use core::borrow; use core::cmp::Ordering; use core::convert::From; use core::fmt; use core::future::Future; use core::hash::{Hash, Hasher}; use core::iter::{Iterator, FromIterator, FusedIterator}; use core::marker::{Unpin, Unsize}; use core::mem; use core::pin::Pin; use c...
fn write_i8(&mut self, i: i8) { (**self).write_i8(i) } fn write_i16(&mut self, i: i16) { (**self).write_i16(i) } fn write_i32(&mut self, i: i32) { (**self).write_i32(i) } fn write_i64(&mut self, i: i64) { (**self).write_i64(i) } fn write_i128(&mut sel...
{ (**self).write_usize(i) }
identifier_body
boxed.rs
rust1", since = "1.0.0")] use core::any::Any; use core::borrow; use core::cmp::Ordering; use core::convert::From; use core::fmt; use core::future::Future; use core::hash::{Hash, Hasher}; use core::iter::{Iterator, FromIterator, FusedIterator}; use core::marker::{Unpin, Unsize}; use core::mem; use core::pin::Pin; use c...
<T: Any>(self) -> Result<Box<T>, Box<dyn Any>> { if self.is::<T>() { unsafe { let raw: *mut dyn Any = Box::into_raw(self); Ok(Box::from_raw(raw as *mut T)) } } else { Err(self) } } } impl Box<dyn Any + Send> { #[inline]...
downcast
identifier_name
boxed.rs
"rust1", since = "1.0.0")] use core::any::Any; use core::borrow; use core::cmp::Ordering; use core::convert::From; use core::fmt; use core::future::Future; use core::hash::{Hash, Hasher}; use core::iter::{Iterator, FromIterator, FusedIterator}; use core::marker::{Unpin, Unsize}; use core::mem; use core::pin::Pin; use...
} } #[stable(feature = "rust1", since = "1.0.0")] impl<T:?Sized + PartialOrd> PartialOrd for Box<T> { #[inline] fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> { PartialOrd::partial_cmp(&**self, &**other) } #[inline] fn lt(&self, other: &Box<T>) -> bool { PartialOrd::lt...
random_line_split
boxed.rs
rust1", since = "1.0.0")] use core::any::Any; use core::borrow; use core::cmp::Ordering; use core::convert::From; use core::fmt; use core::future::Future; use core::hash::{Hash, Hasher}; use core::iter::{Iterator, FromIterator, FusedIterator}; use core::marker::{Unpin, Unsize}; use core::mem; use core::pin::Pin; use c...
} } impl Box<dyn Any + Send> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] /// Attempt to downcast the box to a concrete type. /// /// # Examples /// /// ``` /// use std::any::Any; /// /// fn print_if_string(value: Box<dyn Any + Send>) { /// if let Ok(st...
{ Err(self) }
conditional_block
exec_commands.rs
use arguments::{VERBOSE_MODE, JOBLOG}; use execute::command::{self, CommandErr}; use input_iterator::InputsLock; use numtoa::NumToA; use time::{self, Timespec}; use tokenizer::Token; use verbose; use super::pipe::disk::State; use super::job_log::JobLog; use super::child::handle_child; use std::io::{self, Read, Write};...
} } }
{ verbose::task_complete(&stdout, job_id, self.num_inputs, &input); }
conditional_block
exec_commands.rs
use arguments::{VERBOSE_MODE, JOBLOG}; use execute::command::{self, CommandErr}; use input_iterator::InputsLock; use numtoa::NumToA; use time::{self, Timespec}; use tokenizer::Token; use verbose; use super::pipe::disk::State; use super::job_log::JobLog; use super::child::handle_child; use std::io::{self, Read, Write};...
<IO: Read> { pub slot: usize, pub num_inputs: usize, pub flags: u16, pub timeout: Duration, pub inputs: InputsLock<IO>, pub output_tx: Sender<State>, pub arguments: &'static [Token], pub tempdir: String, } impl<IO: Read> ExecCommands<IO> { pub fn run(&mut self...
ExecCommands
identifier_name
exec_commands.rs
use arguments::{VERBOSE_MODE, JOBLOG}; use execute::command::{self, CommandErr}; use input_iterator::InputsLock; use numtoa::NumToA; use time::{self, Timespec}; use tokenizer::Token; use verbose; use super::pipe::disk::State; use super::job_log::JobLog; use super::child::handle_child; use std::io::{self, Read, Write};...
start_indice = (job_id+1).numtoa(10, &mut id_buffer); let command = command::ParallelCommand { slot_no: slot, job_no: &id_buffer[start_indice..], job_total: job_total, input: &input, ...
{ let stdout = io::stdout(); let stderr = io::stderr(); let slot = &self.slot.to_string(); let mut command_buffer = &mut String::with_capacity(64); let has_timeout = self.timeout != Duration::from_millis(0); let mut input = String::with_capa...
identifier_body
exec_commands.rs
use arguments::{VERBOSE_MODE, JOBLOG}; use execute::command::{self, CommandErr}; use input_iterator::InputsLock; use numtoa::NumToA; use time::{self, Timespec}; use tokenizer::Token; use verbose; use super::pipe::disk::State; use super::job_log::JobLog; use super::child::handle_child; use std::io::{self, Read, Write};...
let mut command_buffer = &mut String::with_capacity(64); let has_timeout = self.timeout!= Duration::from_millis(0); let mut input = String::with_capacity(64); let mut id_buffer = [0u8; 20]; let mut job_buffer = [0u8; 20]; let mut total_buffer = ...
pub fn run(&mut self) { let stdout = io::stdout(); let stderr = io::stderr(); let slot = &self.slot.to_string();
random_line_split
lib.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
/* The libcore prelude, not as all-encompassing as the libstd prelude */ pub mod prelude; /* Core modules for ownership management */ pub mod intrinsics; pub mod mem; pub mod nonzero; pub mod ptr; /* Core language traits */ pub mod marker; pub mod ops; pub mod cmp; pub mod clone; pub mod default; /* Core types a...
pub mod num;
random_line_split
borrowck-borrow-overloaded-deref-mut.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 ...
<T> { value: *mut T } impl<T> Deref for Own<T> { type Target = T; fn deref<'a>(&'a self) -> &'a T { unsafe { &*self.value } } } impl<T> DerefMut for Own<T> { fn deref_mut<'a>(&'a mut self) -> &'a mut T { unsafe { &mut *self.value } } } fn deref_imm(x: Own<isize>) { let _i...
Own
identifier_name
borrowck-borrow-overloaded-deref-mut.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() {}
**x = 3;
random_line_split
borrowck-borrow-overloaded-deref-mut.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() {}
{ **x = 3; }
identifier_body
lib.rs
extern crate ai_behavior; extern crate find_folder; extern crate gfx_device_gl; extern crate graphics; extern crate nalgebra; extern crate ncollide; extern crate piston_window; extern crate rand; extern crate sprite; extern crate uuid; mod mobs; use gfx_device_gl::Resources; use graphics::Image; use graphics::rectang...
let assets = find_folder::Search::ParentsThenKids(3, 3) .for_folder("assets") .unwrap(); let ref font = assets.join("Fresca-Regular.ttf"); let factory = w.factory.clone(); let mut glyphs = Glyphs::new(font, factory).unwrap(); let Size { height, width } = w....
} } pub fn on_draw(&mut self, e: &Input, _: RenderArgs, w: &mut PistonWindow) {
random_line_split
lib.rs
extern crate ai_behavior; extern crate find_folder; extern crate gfx_device_gl; extern crate graphics; extern crate nalgebra; extern crate ncollide; extern crate piston_window; extern crate rand; extern crate sprite; extern crate uuid; mod mobs; use gfx_device_gl::Resources; use graphics::Image; use graphics::rectang...
return; } if!grew { self.player.shrink(&mut self.scene, upd.dt); } if self.player.size > 0.0 { self.player.mov(w, &mut self.scene, upd.dt); } else { self.loss = true; self.victory = false; } } pub fn ...
{ if self.pause || self.victory || self.loss { return; } self.scene.event(e); let mut grew = false; for mut star in &mut self.stars { if !star.destroyed && self.player.collides(&star) { star.destroy(&mut self.scene, upd.dt); ...
identifier_body
lib.rs
extern crate ai_behavior; extern crate find_folder; extern crate gfx_device_gl; extern crate graphics; extern crate nalgebra; extern crate ncollide; extern crate piston_window; extern crate rand; extern crate sprite; extern crate uuid; mod mobs; use gfx_device_gl::Resources; use graphics::Image; use graphics::rectang...
(&mut self, e: &Input, _: RenderArgs, w: &mut PistonWindow) { let assets = find_folder::Search::ParentsThenKids(3, 3) .for_folder("assets") .unwrap(); let ref font = assets.join("Fresca-Regular.ttf"); let factory = w.factory.clone(); let mut glyphs = Glyphs::new(fon...
on_draw
identifier_name
lib.rs
extern crate ai_behavior; extern crate find_folder; extern crate gfx_device_gl; extern crate graphics; extern crate nalgebra; extern crate ncollide; extern crate piston_window; extern crate rand; extern crate sprite; extern crate uuid; mod mobs; use gfx_device_gl::Resources; use graphics::Image; use graphics::rectang...
Button::Keyboard(Key::Down) => { self.player.dir = (self.player.dir.0, 0.0); } Button::Keyboard(Key::Left) => { self.player.dir = (0.0, self.player.dir.1); } Button::Keybo...
{ self.player.dir = (self.player.dir.0, 0.0); }
conditional_block
paste_data.rs
use rocket::Outcome; use rocket::Request; use rocket::data::{self, FromData, Data}; use rocket::http::{Status, ContentType}; use std::io::{Read}; #[derive(Serialize, Deserialize)] pub struct
{ content: String, } impl PasteData { pub fn get_content_cloned(&self) -> String { self.content.clone() } } impl FromData for PasteData { type Error = String; fn from_data(req: &Request, data: Data) -> data::Outcome<Self, String> { let corr_content_type = ContentType::new("text",...
PasteData
identifier_name
paste_data.rs
use rocket::Outcome; use rocket::Request; use rocket::data::{self, FromData, Data}; use rocket::http::{Status, ContentType}; use std::io::{Read}; #[derive(Serialize, Deserialize)] pub struct PasteData { content: String, } impl PasteData { pub fn get_content_cloned(&self) -> String
} impl FromData for PasteData { type Error = String; fn from_data(req: &Request, data: Data) -> data::Outcome<Self, String> { let corr_content_type = ContentType::new("text", "plain"); if req.content_type().expect("Could not extract content type")!= corr_content_type { return Outc...
{ self.content.clone() }
identifier_body
paste_data.rs
use rocket::Outcome; use rocket::Request; use rocket::data::{self, FromData, Data}; use rocket::http::{Status, ContentType}; use std::io::{Read}; #[derive(Serialize, Deserialize)] pub struct PasteData { content: String, } impl PasteData { pub fn get_content_cloned(&self) -> String { self.content.clone...
let mut data_string = String::new(); if let Err(e) = data.open().read_to_string(&mut data_string) { return Outcome::Failure((Status::InternalServerError, format!("{:?}", e))); } // remove the "paste=" from the raw data //TODO Problem: paste= must be at end of request ...
random_line_split
onboarding.rs
use std::io; struct Enemy { name: String, dist: i32, } macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } fn debugScanInformation(enemys: &Vec<&Enemy>) { eprintln!("Debug Scan Data"); let mut i: i16; i = 0; for e in enemys.iter() { eprintln!("- ...
() { // game loop loop { // Vec (list) of enemys let mut enemys: Vec<&Enemy> = Vec::new(); // Enemy 1 let mut input_line = String::new(); io::stdin().read_line(&mut input_line).unwrap(); let enemy_1 = input_line.trim().to_string(); // name of enemy 1 let ...
main
identifier_name
onboarding.rs
use std::io; struct Enemy { name: String, dist: i32, } macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } fn debugScanInformation(enemys: &Vec<&Enemy>)
/** * CodinGame planet is being attacked by slimy insectoid aliens. * <--- * Hint:To protect the planet, you can implement the pseudo-code provided in the statement, below the player. **/ fn main() { // game loop loop { // Vec (list) of enemys let mut enemys: Vec<&Enemy> = Vec::new(); ...
{ eprintln!("Debug Scan Data"); let mut i: i16; i = 0; for e in enemys.iter() { eprintln!("- enemy_{}: {}", i, e.name); eprintln!("- dist_{} : {}", i, e.dist); i = i + 1; } }
identifier_body
onboarding.rs
use std::io; struct Enemy { name: String, dist: i32, } macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } fn debugScanInformation(enemys: &Vec<&Enemy>) { eprintln!("Debug Scan Data"); let mut i: i16; i = 0; for e in enemys.iter() { eprintln!("- ...
} /** * CodinGame planet is being attacked by slimy insectoid aliens. * <--- * Hint:To protect the planet, you can implement the pseudo-code provided in the statement, below the player. **/ fn main() { // game loop loop { // Vec (list) of enemys let mut enemys: Vec<&Enemy> = Vec::new(); ...
i = i + 1; }
random_line_split
unwind-rec2.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 ...
() -> ~[int] { ~[0,0,0,0,0,0,0] } fn build2() -> ~[int] { fail!(); } struct Blk { node: ~[int], span: ~[int] } fn main() { let _blk = Blk { node: build1(), span: build2() }; }
build1
identifier_name
unwind-rec2.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
// error-pattern:fail fn build1() -> ~[int] { ~[0,0,0,0,0,0,0] } fn build2() -> ~[int] { fail!(); } struct Blk { node: ~[int], span: ~[int] } fn main() { let _blk = Blk { node: build1(), span: build2() }; }
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
unwind-rec2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
struct Blk { node: ~[int], span: ~[int] } fn main() { let _blk = Blk { node: build1(), span: build2() }; }
{ fail!(); }
identifier_body
cssnamespacerule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding; use dom::bindings::codegen::Bindings::CSSNamespaceR...
namespacerule: Arc<Locked<NamespaceRule>>) -> DomRoot<CSSNamespaceRule> { reflect_dom_object(box CSSNamespaceRule::new_inherited(parent_stylesheet, namespacerule), window, CSSNamespaceRuleBinding::Wrap) } } impl CSSNamespaceRuleMethods fo...
#[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
random_line_split
cssnamespacerule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding; use dom::bindings::codegen::Bindings::CSSNamespaceR...
(&self) -> DOMString { let guard = self.cssrule.shared_lock().read(); self.namespacerule.read_with(&guard).to_css_string(&guard).into() } }
get_css
identifier_name
cssnamespacerule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding; use dom::bindings::codegen::Bindings::CSSNamespaceR...
}
{ let guard = self.cssrule.shared_lock().read(); self.namespacerule.read_with(&guard).to_css_string(&guard).into() }
identifier_body
mod.rs
type FontSize = u32; /// A context for building some **Text**. pub struct Builder<'a> { text: Cow<'a, str>, layout_builder: layout::Builder, } /// An instance of some multi-line text and its layout. #[derive(Clone)] pub struct Text<'a> { text: Cow<'a, str>, font: Font, layout: Layout, line_in...
} /// Align the top edge of the text with the top edge of its bounding rectangle. pub fn align_top(self) -> Self { self.map_layout(|l| l.align_top()) } /// Align the middle of the text with the middle of the bounding rect along the y axis.. /// /// This is the default behaviour. ...
/// Specify how the whole text should be aligned along the y axis of its bounding rectangle pub fn y_align(self, align: Align) -> Self { self.map_layout(|l| l.y_align(align))
random_line_split
mod.rs
FontSize = u32; /// A context for building some **Text**. pub struct
<'a> { text: Cow<'a, str>, layout_builder: layout::Builder, } /// An instance of some multi-line text and its layout. #[derive(Clone)] pub struct Text<'a> { text: Cow<'a, str>, font: Font, layout: Layout, line_infos: Vec<line::Info>, rect: geom::Rect, } /// An iterator yielding each line w...
Builder
identifier_name
mod.rs
FontSize = u32; /// A context for building some **Text**. pub struct Builder<'a> { text: Cow<'a, str>, layout_builder: layout::Builder, } /// An instance of some multi-line text and its layout. #[derive(Clone)] pub struct Text<'a> { text: Cow<'a, str>, font: Font, layout: Layout, line_infos: ...
layout, line_infos, rect, } } } impl<'a> Text<'a> { /// Produce an iterator yielding information about each line. pub fn line_infos(&self) -> &[line::Info] { &self.line_infos } /// The full string of text as a slice. pub fn text(&self) -> &s...
{ let text = self.text; let layout = self.layout_builder.build(); #[allow(unreachable_code)] let font = layout.font.clone().unwrap_or_else(|| { #[cfg(feature = "notosans")] { return font::default_notosans(); } let assets = c...
identifier_body
dht22_pt.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
pin = &pin; timer = &timer; }", |cx, failed, pt| { let mut builder = Builder::new(pt.clone()); pt.get_by_name("timer").unwrap().set_type_name("T".to_string()); pt.get_by_name("pin").unwrap().set_type_name("P".to_string()); super::mutate_pin(&mut builder, cx, pt.get_by_name(...
dht@dht22 {
random_line_split
dht22_pt.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
"zinc::hal::pin::Gpio".to_string()); node.set_type_params(ty_params); let st = quote_stmt!(&*cx, let $name = zinc::drivers::dht22::DHT22::new(&$timer, &$pin); ); builder.add_main_statement(st); } #[cfg(test)] mod test { use std::ops::Deref; use builder::Builder; use test_helpers::{assert_eq...
{ if !node.expect_no_subnodes(cx) {return} if !node.expect_attributes(cx, &[("pin", node::RefAttribute), ("timer", node::RefAttribute)]) { return } let pin_node_name = node.get_ref_attr("pin").unwrap(); let timer_node_name = node.get_ref_attr("timer").unwrap(); let pin = TokenString(pin_node_na...
identifier_body
dht22_pt.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
if!node.expect_attributes(cx, &[("pin", node::RefAttribute), ("timer", node::RefAttribute)]) { return } let pin_node_name = node.get_ref_attr("pin").unwrap(); let timer_node_name = node.get_ref_attr("timer").unwrap(); let pin = TokenString(pin_node_name); let timer = TokenString(timer_node_nam...
{return}
conditional_block
dht22_pt.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc<node::Node>) { if!node.expect_no_subnodes(cx) {return} if!node.expect_attributes(cx, &[("pin", node::RefAttribute), ("timer", node::RefAttribute)]) { return } let pin_node_name = node.get_ref_attr("pin").unwrap(); let timer_node_name = node.get_re...
build_dht22
identifier_name
messageport.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use crate::dom::bindings::c...
/// <https://html.spec.whatwg.org/multipage/#dom-messageport-close> fn Close(&self) { if self.detached.get() { return; } self.detached.set(true); self.global().close_message_port(self.message_port_id()); } /// <https://html.spec.whatwg.org/multipage/#handle...
{ if self.detached.get() { return; } self.global().start_message_port(self.message_port_id()); }
identifier_body
messageport.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use crate::dom::bindings::c...
(owner: &GlobalScope) -> DomRoot<MessagePort> { let port_id = MessagePortId::new(); reflect_dom_object(Box::new(MessagePort::new_inherited(port_id)), owner, Wrap) } /// Create a new port for an incoming transfer-received one. fn new_transferred( owner: &GlobalScope, transfer...
new
identifier_name
messageport.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use crate::dom::bindings::c...
Ok(()) } } impl MessagePortMethods for MessagePort { /// <https://html.spec.whatwg.org/multipage/#dom-messageport-postmessage> fn PostMessage( &self, cx: SafeJSContext, message: HandleValue, transfer: CustomAutoRooterGuard<Vec<*mut JSObject>>, ) -> ErrorResult ...
{ let mut ports = Vec::with_capacity(ports_len); ports.push(transferred_port); *message_ports = Some(ports); }
conditional_block
messageport.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use crate::dom::bindings::c...
ports.push(transferred_port); } else { let mut ports = Vec::with_capacity(ports_len); ports.push(transferred_port); *message_ports = Some(ports); } Ok(()) } } impl MessagePortMethods for MessagePort { /// <https://html.spec.whatwg.org/mul...
// Store the DOM port where it will be passed along to script in the message-event. if let Some(ports) = message_ports.as_mut() {
random_line_split
text.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" /> <% from data import Method %> <% data.new_style_struct("Tex...
"computed::TextOverflow::get_initial_value()", animation_value_type="discrete", boxed=True, flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow")} $...
${helpers.predefined_type("text-overflow", "TextOverflow",
random_line_split
round_trip.rs
// Copyright 2017 GFX Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law o...
() { let sponza: Obj = Obj::load("test_assets/sponza.obj").unwrap(); let mut obj = Vec::new(); sponza.data.write_to_buf(&mut obj).unwrap(); let sponza_round_trip = ObjData::load_buf(obj.as_slice()).unwrap(); assert_eq!(sponza_round_trip, sponza.data); } #[test] fn round_trip_sponza_with_mtl() { ...
round_trip_sponza_no_mtls
identifier_name
round_trip.rs
// Copyright 2017 GFX Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law o...
let mut obj = Vec::new(); sponza.data.write_to_buf(&mut obj).unwrap(); let sponza_round_trip = ObjData::load_buf(obj.as_slice()).unwrap(); assert_eq!(sponza_round_trip, sponza.data); } #[test] fn round_trip_sponza_with_mtl() { let mut sponza: Obj = Obj::load("test_assets/sponza.obj").unwrap(); ...
#[test] fn round_trip_sponza_no_mtls() { let sponza: Obj = Obj::load("test_assets/sponza.obj").unwrap();
random_line_split
round_trip.rs
// Copyright 2017 GFX Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law o...
.load_mtls_fn(|_, mtllib| Ok(round_trip_mtl_libs.get(mtllib).unwrap().as_slice())) .unwrap(); assert_eq!(sponza_round_trip.data, sponza.data); }
{ let mut sponza: Obj = Obj::load("test_assets/sponza.obj").unwrap(); sponza.load_mtls().unwrap(); // Write obj to string, and then load it from that string to create a round trip Obj instance. let mut obj = Vec::new(); sponza.data.write_to_buf(&mut obj).unwrap(); let mut sponza_round_trip: Obj...
identifier_body
workletglobalscope.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::globalsc...
executor: WorkletExecutor, init: &WorkletGlobalScopeInit, ) -> DomRoot<WorkletGlobalScope> { match *self { WorkletGlobalScopeType::Test => DomRoot::upcast(TestWorkletGlobalScope::new( runtime, pipeline_id, base_url, ...
&self, runtime: &Runtime, pipeline_id: PipelineId, base_url: ServoUrl,
random_line_split
workletglobalscope.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::globalsc...
{ /// A servo-specific testing worklet Test, /// A paint worklet Paint, } impl WorkletGlobalScopeType { /// Create a new heap-allocated `WorkletGlobalScope`. pub fn new( &self, runtime: &Runtime, pipeline_id: PipelineId, base_url: ServoUrl, executor: Wor...
WorkletGlobalScopeType
identifier_name
workletglobalscope.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::globalsc...
} /// A task which can be performed in the context of a worklet global. pub enum WorkletTask { Test(TestWorkletTask), Paint(PaintWorkletTask), }
{ match *self { WorkletGlobalScopeType::Test => DomRoot::upcast(TestWorkletGlobalScope::new( runtime, pipeline_id, base_url, executor, init, )), WorkletGlobalScopeType::Paint => DomRoot::upcast(Pa...
identifier_body
event.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program 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 ve...
pub fn construct(&self, current_navigation_state: &NavigationState) -> Event { let mut result = self.create_global_event(); if result.is_none() { result = match *current_navigation_state { NavigationState::Menu => self.create_menu_event(), NavigationSta...
{ EventBuilder { input: input, key: key, } }
identifier_body
event.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program 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 ve...
} fn create_input_event(&self) -> Option<Event> { match self.input { Input::Kb(Key::Left, None) => { Some(Event::Search(SearchAction::ReadInput(KEY_LEFT_SEQ.to_vec()))) } Input::Kb(Key::Right, None) => { Some(Event::Search(SearchAction...
Input::Kb(Key::Home, None) => Some(Event::ScrollContents(Offset::Top)), Input::Kb(Key::End, None) => Some(Event::ScrollContents(Offset::Bottom)), Input::Resize => Some(Event::Resize), _ => None, }
random_line_split
event.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program 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 ve...
(&self) -> Option<Event> { match self.input { Input::Kb(Key::Char('n'), Some(Modifier::Alt(_))) => { Some(Event::Search(SearchAction::FindNextMatch)) } Input::Kb(Key::Char('p'), Some(Modifier::Alt(_))) => { Some(Event::Search(SearchAction::Find...
create_search_event
identifier_name
allocator.rs
use crate::attributes; use libc::c_uint; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_session::config::DebugInfo; use rustc_span::symbol::sym; use crate::debuginfo; use crate::llvm::{self, False, True}; use crate::Modu...
} AllocatorTy::Ptr => args.push(i8p), AllocatorTy::Usize => args.push(usize), AllocatorTy::ResultPtr | AllocatorTy::Unit => panic!("invalid allocator arg"), } } let output = match method.output { AllocatorTy::Result...
{ let llcx = &*module_llvm.llcx; let llmod = module_llvm.llmod(); let usize = match tcx.sess.target.pointer_width { 16 => llvm::LLVMInt16TypeInContext(llcx), 32 => llvm::LLVMInt32TypeInContext(llcx), 64 => llvm::LLVMInt64TypeInContext(llcx), tws => bug!("Unsupported target wo...
identifier_body
allocator.rs
use crate::attributes; use libc::c_uint; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_session::config::DebugInfo; use rustc_span::symbol::sym; use crate::debuginfo; use crate::llvm::{self, False, True}; use crate::Modu...
let ty = llvm::LLVMFunctionType(void, args.as_ptr(), args.len() as c_uint, False); let name = "__rust_alloc_error_handler"; let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty); // ->! DIFlagNoReturn llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Fun...
// rust alloc error handler let args = [usize, usize]; // size, align
random_line_split
allocator.rs
use crate::attributes; use libc::c_uint; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_session::config::DebugInfo; use rustc_span::symbol::sym; use crate::debuginfo; use crate::llvm::{self, False, True}; use crate::Modu...
( tcx: TyCtxt<'_>, module_llvm: &mut ModuleLlvm, module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool, ) { let llcx = &*module_llvm.llcx; let llmod = module_llvm.llmod(); let usize = match tcx.sess.target.pointer_width { 16 => llvm::LLVMInt16TypeInContext(llcx), ...
codegen
identifier_name
allocator.rs
use crate::attributes; use libc::c_uint; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_session::config::DebugInfo; use rustc_span::symbol::sym; use crate::debuginfo; use crate::llvm::{self, False, True}; use crate::Modu...
else { llvm::LLVMBuildRetVoid(llbuilder); } llvm::LLVMDisposeBuilder(llbuilder); } // rust alloc error handler let args = [usize, usize]; // size, align let ty = llvm::LLVMFunctionType(void, args.as_ptr(), args.len() as c_uint, False); let name = "__rust_alloc_error_ha...
{ llvm::LLVMBuildRet(llbuilder, ret); }
conditional_block
main.rs
#[macro_use] extern crate glium; extern crate glium_text_rusttype as glium_text; extern crate glutin; extern crate winit; use std::io; use std::io::prelude::*; use std::fs::File; use glium::{Surface, Program}; use glium::backend::Facade; use glium::glutin::{Event, WindowEvent}; #[derive(Copy, Clone, Debug, PartialEq...
(_e: io::Error) -> ShaderError { ShaderError } } fn read_file(path: &str) -> io::Result<String> { let mut s = String::new(); let mut f = try!(File::open(path)); try!(f.read_to_string(&mut s)); Ok(s) } fn load_shader_program<F: Facade>(display: &F) -> Result<Program, ShaderError> { let ...
from
identifier_name
main.rs
#[macro_use] extern crate glium; extern crate glium_text_rusttype as glium_text; extern crate glutin; extern crate winit; use std::io; use std::io::prelude::*; use std::fs::File; use glium::{Surface, Program}; use glium::backend::Facade; use glium::glutin::{Event, WindowEvent}; #[derive(Copy, Clone, Debug, PartialEq...
Point { position: ( -1.0, 1.0 ) }, Point { position: ( -1.0, -1.0 ) }, Point { position: ( 1.0, -1.0 ) }, ]; /// Two triangles arranged as a rectangle covering OpenGL screen space. /// All the real work happens in the fragment shader, so we just want to /// run the shader on every pixel. const INDICES: [...
const VERTICES: [Point; 4] = [ Point { position: ( 1.0, 1.0 ) },
random_line_split
main.rs
#[macro_use] extern crate glium; extern crate glium_text_rusttype as glium_text; extern crate glutin; extern crate winit; use std::io; use std::io::prelude::*; use std::fs::File; use glium::{Surface, Program}; use glium::backend::Facade; use glium::glutin::{Event, WindowEvent}; #[derive(Copy, Clone, Debug, PartialEq...
}
{ Err(ShaderError) }
conditional_block
blockDoc.rs
/*! # Iterator * * The heart and soul of this module is the [`Iterator`] trait. The core of * [`Iterator`] looks like this: * * ``` * trait Iterator { * type Item; * fn next(&mut self) -> Option<Self::Item>; * }
* [`Option`]`<Item>`. [`next()`] will return `Some(Item)` as long as there * are elements, and once they've all been exhausted, will return `None` to * indicate that iteration is finished. Individual iterators may choose to * resume iteration, and so calling [`next()`] again may or may not eventually * start ...
* ``` * * An iterator has a method, [`next()`], which when called, returns an
random_line_split
html_writer.rs
extern crate marksman_escape; use self::marksman_escape::Escape; use {DomNode, DomNodes, DomValue}; use processors::DomNodeProcessor; // This module as a whole is "use_std"-only, so these don't need to be cfg'd use std::marker::PhantomData; use std::fmt; use std::io; /// Type to use for processing a `DomNode` tree a...
} } add_node } } /// Wrapper struct to allow `DomNode`s to implement `Display` as html #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct HtmlDisplayable<'a, M, T: DomNode<M> + 'a>(pub &'a T, pub PhantomData<M>); impl<'a, M, T: DomNode<M>> fmt::Display for ...
{ for escaped_u8 in Escape::new(text.bytes()) { w.write(&[escaped_u8])?; } Ok(()) }
conditional_block
html_writer.rs
extern crate marksman_escape; use self::marksman_escape::Escape; use {DomNode, DomNodes, DomValue}; use processors::DomNodeProcessor; // This module as a whole is "use_std"-only, so these don't need to be cfg'd use std::marker::PhantomData; use std::fmt; use std::io; /// Type to use for processing a `DomNode` tree a...
impl<'a, M, T: DomNode<M>> fmt::Display for HtmlDisplayable<'a, M, T> { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { // TODO the extra string allocation here is almost certainly avoidable let mut string_buffer = Vec::new(); self.0.write_html(&mut string_buffer) ...
/// Wrapper struct to allow `DomNode`s to implement `Display` as html #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct HtmlDisplayable<'a, M, T: DomNode<M> + 'a>(pub &'a T, pub PhantomData<M>);
random_line_split
html_writer.rs
extern crate marksman_escape; use self::marksman_escape::Escape; use {DomNode, DomNodes, DomValue}; use processors::DomNodeProcessor; // This module as a whole is "use_std"-only, so these don't need to be cfg'd use std::marker::PhantomData; use std::fmt; use std::io; /// Type to use for processing a `DomNode` tree a...
}
{ // TODO the extra string allocation here is almost certainly avoidable let mut string_buffer = Vec::new(); self.0.write_html(&mut string_buffer) .map_err(|_| fmt::Error)?; let string = String::from_utf8(string_buffer) .map_err(|_| fmt::Error)?; formatter...
identifier_body
html_writer.rs
extern crate marksman_escape; use self::marksman_escape::Escape; use {DomNode, DomNodes, DomValue}; use processors::DomNodeProcessor; // This module as a whole is "use_std"-only, so these don't need to be cfg'd use std::marker::PhantomData; use std::fmt; use std::io; /// Type to use for processing a `DomNode` tree a...
<'a, M, T: DomNode<M> + 'a>(pub &'a T, pub PhantomData<M>); impl<'a, M, T: DomNode<M>> fmt::Display for HtmlDisplayable<'a, M, T> { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { // TODO the extra string allocation here is almost certainly avoidable let mut string_buffer ...
HtmlDisplayable
identifier_name
load_instructions.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 extern crate test_generation; use test_generation::abstract_state::{AbstractState, AbstractValue}; use vm::file_format::{Bytecode, ConstantPoolIndex, SignatureToken}; mod common; #[test] fn bytecode_ldu64() { let state1 = Abstract...
{ let state1 = AbstractState::new(); let (state2, _) = common::run_instruction(Bytecode::LdConst(ConstantPoolIndex::new(0)), state1); assert_eq!( state2.stack_peek(0), Some(AbstractValue::new_primitive(SignatureToken::Address)), "stack type postcondition not met" ); }
identifier_body
load_instructions.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 extern crate test_generation; use test_generation::abstract_state::{AbstractState, AbstractValue}; use vm::file_format::{Bytecode, ConstantPoolIndex, SignatureToken}; mod common; #[test] fn bytecode_ldu64() { let state1 = Abstract...
() { let state1 = AbstractState::new(); let (state2, _) = common::run_instruction(Bytecode::LdConst(ConstantPoolIndex::new(0)), state1); assert_eq!( state2.stack_peek(0), Some(AbstractValue::new_primitive(SignatureToken::Address)), "stack type postcondition not met" ); }
bytecode_ldconst
identifier_name
load_instructions.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0
#[test] fn bytecode_ldu64() { let state1 = AbstractState::new(); let (state2, _) = common::run_instruction(Bytecode::LdU64(0), state1); assert_eq!( state2.stack_peek(0), Some(AbstractValue::new_primitive(SignatureToken::U64)), "stack type postcondition not met" ); } #[test] fn ...
extern crate test_generation; use test_generation::abstract_state::{AbstractState, AbstractValue}; use vm::file_format::{Bytecode, ConstantPoolIndex, SignatureToken}; mod common;
random_line_split
lib.rs
#![cfg(any( target_os = "windows", target_os = "linux", target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd" ))] #![allow(non_camel_case_types)] pub mod egl { pub type khronos_utime_nanoseconds_t = super::khronos_utime_nanose...
include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs")); } pub use self::egl::types::EGLContext; pub use self::egl::types::EGLDisplay; use std::os::raw; pub type khronos_utime_nanoseconds_t = khronos_uint64_t; pub type khronos_uint64_t = u64; pub type khronos_ssize_t = raw::c_long; pub type EGLint = i32; pub typ...
pub type NativeDisplayType = super::EGLNativeDisplayType; pub type NativePixmapType = super::EGLNativePixmapType; pub type NativeWindowType = super::EGLNativeWindowType;
random_line_split
iso_8859_5.rs
pub fn charmap() -> [&'static str,.. 256]
"\x14", // 0x14 "\x15", // 0x15 "\x16", // 0x16 "\x17", // 0x17 "\x18", // 0x18 "\x19", // 0x19 "\x1a", // 0x1a "\x1b", // 0x1b "\x1c", // 0x1c "\x1d", // 0x1d "\x1e", // 0x1e "\x1f", // 0x1f " ", // 0x20 "!", // 0x21 "\"", // 0x22 "#", // 0x23 "$", // 0x24 "%", // 0x25 "&", // 0x26 "'", // 0x27 "(", // 0x28 ")", // 0x...
{ return ["\x00", // 0x0 "\x01", // 0x1 "\x02", // 0x2 "\x03", // 0x3 "\x04", // 0x4 "\x05", // 0x5 "\x06", // 0x6 "\x07", // 0x7 "\x08", // 0x8 "\t", // 0x9 "\n", // 0xa "\x0b", // 0xb "\x0c", // 0xc "\r", // 0xd "\x0e", // 0xe "\x0f", // 0xf "\x10", // 0x10 "\x11", // 0x11 "\x12", // 0x12 "\x13", // 0x13
identifier_body
iso_8859_5.rs
pub fn charmap() -> [&'static str,.. 256]{ return ["\x00", // 0x0 "\x01", // 0x1 "\x02", // 0x2 "\x03", // 0x3 "\x04", // 0x4 "\x05", // 0x5 "\x06", // 0x6 "\x07", // 0x7 "\x08", // 0x8 "\t", // 0x9 "\n", // 0xa "\x0b", // 0xb "\x0c", // 0xc "\r", // 0xd "\x0e", // 0xe "\x0f", // 0xf "\x10", // 0x10 "\x11", // 0x11 "\x...
"M", // 0x4d "N", // 0x4e "O", // 0x4f "P", // 0x50 "Q", // 0x51 "R", // 0x52 "S", // 0x53 "T", // 0x54 "U", // 0x55 "V", // 0x56 "W", // 0x57 "X", // 0x58 "Y", // 0x59 "Z", // 0x5a "[", // 0x5b "\\", // 0x5c "]", // 0x5d "^", // 0x5e "_", // 0x5f "`", // 0x60 "a", // 0x61 "b", // 0x62 "c", // 0x63 "d", // 0x64 "e", //...
"J", // 0x4a "K", // 0x4b "L", // 0x4c
random_line_split
iso_8859_5.rs
pub fn
() -> [&'static str,.. 256]{ return ["\x00", // 0x0 "\x01", // 0x1 "\x02", // 0x2 "\x03", // 0x3 "\x04", // 0x4 "\x05", // 0x5 "\x06", // 0x6 "\x07", // 0x7 "\x08", // 0x8 "\t", // 0x9 "\n", // 0xa "\x0b", // 0xb "\x0c", // 0xc "\r", // 0xd "\x0e", // 0xe "\x0f", // 0xf "\x10", // 0x10 "\x11", // 0x11 "\x12", // 0x12 "...
charmap
identifier_name
lib.rs
// Copyright (C) 2016 Cloudlabs, Inc // // This program 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. // // This program is distri...
else { Ok(err as usize) } } #[test] fn test_file_ext() { extern crate tempfile; let file = tempfile::tempfile().unwrap(); file.write_at(50, &[1, 2, 3, 4, 5]).unwrap(); file.write_at(100, &[7, 6, 5, 4, 3, 2, 1]).unwrap(); let mut buf = &mut [0; 5]; file.read_at(50, buf).unwrap(); ...
{ Err(io::Error::last_os_error()) }
conditional_block
lib.rs
// Copyright (C) 2016 Cloudlabs, Inc // // This program 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. // // This program is distri...
data.as_ptr() as *const ::libc::c_void, data.len(), offset as ::libc::off_t) as ::libc::c_int) } } fn close(self) -> io::Result<()> { use libc::close; use std::os::unix::io::IntoRawFd; unsafe { cvt(clos...
unsafe { cvt(pwrite(self.as_raw_fd(),
random_line_split
lib.rs
// Copyright (C) 2016 Cloudlabs, Inc // // This program 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. // // This program is distri...
(&self, offset: u64, size: usize) -> io::Result<()> { use libc::{fallocate, FALLOC_FL_PUNCH_HOLE, FALLOC_FL_KEEP_SIZE}; use std::os::unix::io::AsRawFd; unsafe { cvt(fallocate(self.as_raw_fd(), FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ...
punch
identifier_name
lib.rs
// Copyright (C) 2016 Cloudlabs, Inc // // This program 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. // // This program is distri...
} // Shim for converting C-style errors to io::Errors. fn cvt(err: ::libc::c_int) -> io::Result<usize> { if err < 0 { Err(io::Error::last_os_error()) } else { Ok(err as usize) } } #[test] fn test_file_ext() { extern crate tempfile; let file = tempfile::tempfile().unwrap(); fi...
{ self.write_at(offset, &vec![0; size]).map(|_| ()) }
identifier_body
envelope.rs
//! Envelope function used by sounds 1, 2 and 4 use spu::{Sample, SOUND_MAX}; #[derive(Clone,Copy)] pub struct Envelope { direction: EnvelopeDirection, volume: Volume, step_duration: u32, counter: u32, } impl Envelope { pub fn from_reg(val: u8) -> Envelope { let vol = Vo...
} fn down(&mut self) { let Volume(v) = *self; if v > 0 { *self = Volume(v - 1); } } }
{ *self = Volume(v + 1); }
conditional_block
envelope.rs
//! Envelope function used by sounds 1, 2 and 4 use spu::{Sample, SOUND_MAX}; #[derive(Clone,Copy)] pub struct Envelope { direction: EnvelopeDirection, volume: Volume, step_duration: u32, counter: u32, } impl Envelope { pub fn from_reg(val: u8) -> Envelope { let vol = Vo...
let Volume(v) = *self; if v > 0 { *self = Volume(v - 1); } } }
fn down(&mut self) {
random_line_split
envelope.rs
//! Envelope function used by sounds 1, 2 and 4 use spu::{Sample, SOUND_MAX}; #[derive(Clone,Copy)] pub struct Envelope { direction: EnvelopeDirection, volume: Volume, step_duration: u32, counter: u32, } impl Envelope { pub fn from_reg(val: u8) -> Envelope { let vol = Vo...
(&self) -> Sample { self.volume.into_sample() } /// DAC is disabled when envelope direction goes down and volume is 0 pub fn dac_enabled(&self) -> bool { self.direction!= EnvelopeDirection::Down || self.volume.into_sample()!= 0 } } // Sound envelopes can become louder or qu...
into_sample
identifier_name