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
texture_animator.rs
use resources::AnimatedTexture; use rand::{Rng, thread_rng}; use sfml::graphics::IntRect; pub struct TextureAnimator { n_frames: u32, step: i32, randomize: (bool, bool), tex_width: u32, current: u32, delay: f32, timer: f32, rect: IntRect, } impl TextureAnimator { pub fn new(anim_te...
fn gen_rect(&mut self) { let (left, width) = if self.randomize.0 && thread_rng().gen_weighted_bool(2) { (self.tex_width as i32, -(self.tex_width as i32)) } else { (0, self.tex_width as i32) }; let (top, height) = if self.randomize.1 && thread_rng().gen_weig...
{ self.rect }
identifier_body
texture_animator.rs
use resources::AnimatedTexture; use rand::{Rng, thread_rng}; use sfml::graphics::IntRect; pub struct TextureAnimator { n_frames: u32, step: i32, randomize: (bool, bool), tex_width: u32, current: u32, delay: f32, timer: f32, rect: IntRect, } impl TextureAnimator { pub fn new(anim_te...
(&self) -> IntRect { self.rect } fn gen_rect(&mut self) { let (left, width) = if self.randomize.0 && thread_rng().gen_weighted_bool(2) { (self.tex_width as i32, -(self.tex_width as i32)) } else { (0, self.tex_width as i32) }; let (top, height) = ...
texture_rect
identifier_name
layout_debug.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/. */ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to m...
(&mut self) { STATE_KEY.with(|ref r| { match *r.borrow_mut() { Some(ref mut state) => { let mut current_scope = state.scope_stack.pop().unwrap(); current_scope.post = json::encode(&flow::base(&*state.flow_root)).unwrap(); l...
drop
identifier_name
layout_debug.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/. */ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to m...
None => {} } }); } } /// Generate a unique ID. This is used for items such as Fragment /// which are often reallocated but represent essentially the /// same data. #[cfg(debug_assertions)] pub fn generate_unique_debug_id() -> u16 { DEBUG_ID_COUNTER.fetch_add(1, Ordering::Se...
{ let mut current_scope = state.scope_stack.pop().unwrap(); current_scope.post = json::encode(&flow::base(&*state.flow_root)).unwrap(); let previous_scope = state.scope_stack.last_mut().unwrap(); previous_scope.children.push(current_scope);...
conditional_block
layout_debug.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/. */ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to m...
impl Drop for Scope { fn drop(&mut self) { STATE_KEY.with(|ref r| { match *r.borrow_mut() { Some(ref mut state) => { let mut current_scope = state.scope_stack.pop().unwrap(); current_scope.post = json::encode(&flow::base(&*state.flow_root)...
#[cfg(debug_assertions)]
random_line_split
pattern.rs
use std::sync::mpsc; use std::thread; use std::time::Duration; use dmx_output::DmxOutput; use error::Error; use types::{Runnable, SequenceData}; use utils; pub struct Pattern { data: SequenceData } impl Pattern { pub fn new(seq_path: String) -> Result<Pattern, Error> { // TODO check if path exists let d...
// Output every frame for frame in rx { let d = &self.data.data[frame as usize]; match dmx.send(d) { Ok(_) => (), Err(e) => println!("\tError: {}", e), } } println!("Done."); Ok(()) } }
{ println!("Running pattern"); // Create channels for clock thread tx/rx let (tx, rx) = mpsc::channel(); // Spawn timer that ticks once per frame until all frames have been ticked let num_frames = self.data.num_frames; let frame_dur = self.data.frame_dur_ms as u64; le...
identifier_body
pattern.rs
use std::sync::mpsc; use std::thread; use std::time::Duration; use dmx_output::DmxOutput; use error::Error; use types::{Runnable, SequenceData}; use utils; pub struct Pattern { data: SequenceData } impl Pattern { pub fn new(seq_path: String) -> Result<Pattern, Error> { // TODO check if path exists let d...
println!("Done."); Ok(()) } }
} }
random_line_split
pattern.rs
use std::sync::mpsc; use std::thread; use std::time::Duration; use dmx_output::DmxOutput; use error::Error; use types::{Runnable, SequenceData}; use utils; pub struct Pattern { data: SequenceData } impl Pattern { pub fn new(seq_path: String) -> Result<Pattern, Error> { // TODO check if path exists let d...
(&mut self, dmx: &mut D) -> Result<(), Error> { println!("Running pattern"); // Create channels for clock thread tx/rx let (tx, rx) = mpsc::channel(); // Spawn timer that ticks once per frame until all frames have been ticked let num_frames = self.data.num_frames; let frame_d...
run
identifier_name
paint.rs
//! Paint trait and implementations. use crate::canvas::Canvas; use lyon_path::PathEvent; /// A trait for types which can be represented on a `Canvas`. pub trait Paint { /// Paints self in the composition. fn paint(&self, canvas: &mut Canvas); } /// Paints a path with a fill pattern. pub struct Filled<D>(pub...
(&self, comp: &mut Canvas) { self.element.paint(comp); comp.set_stroke_width(self.width); comp.stroke(); } } impl<P> Paint for P where P: Iterator<Item = PathEvent> + Clone, { fn paint(&self, canvas: &mut Canvas) { self.clone().for_each(|p| match p { PathEvent::L...
paint
identifier_name
paint.rs
//! Paint trait and implementations. use crate::canvas::Canvas; use lyon_path::PathEvent; /// A trait for types which can be represented on a `Canvas`. pub trait Paint { /// Paints self in the composition. fn paint(&self, canvas: &mut Canvas); } /// Paints a path with a fill pattern. pub struct Filled<D>(pub...
PathEvent::Quadratic { ctrl, to,.. } => canvas.quadratic_to(ctrl, to), PathEvent::Cubic { ctrl1, ctrl2, to,.. } => canvas.cubic_to(ctrl1, ctrl2, to), PathEvent::Begin { at } => canvas.move_to(at), PathEvent::End { close,.. } if close => canvas....
random_line_split
waveform_with_overlay.rs
use gtk::{cairo, pango, prelude::*}; use log::debug; use std::{ cell::RefCell, collections::Bound::Included, rc::Rc, sync::{Arc, Mutex}, }; use metadata::Duration; use renderers::{ImagePositions, SampleIndexRange, Timestamp, WaveformRenderer, BACKGROUND_COLOR}; use crate::info::{self, ChaptersBounda...
else { cursor.x - cursor_text_end }; cr.move_to(cursor_text_x, self.text_metrics.font_size); cr.show_text(&cursor_text).unwrap(); cr.set_line_width(1f64); cr.move_to(cursor.x, 0f64); cr.line_to(cursor.x, area_height - self.text_me...
{ cursor.x + 5f64 }
conditional_block
waveform_with_overlay.rs
use gtk::{cairo, pango, prelude::*}; use log::debug; use std::{ cell::RefCell, collections::Bound::Included, rc::Rc, sync::{Arc, Mutex}, }; use metadata::Duration; use renderers::{ImagePositions, SampleIndexRange, Timestamp, WaveformRenderer, BACKGROUND_COLOR}; use crate::info::{self, ChaptersBounda...
} } } } pub struct WaveformWithOverlay { waveform_renderer_mtx: Arc<Mutex<Box<WaveformRenderer>>>, text_metrics: TextMetrics, boundaries: Rc<RefCell<ChaptersBoundaries>>, positions: Rc<RefCell<ImagePositions>>, last_other_ui_refresh: Timestamp, } impl WaveformWithOverlay { ...
self.cursor_mn_width = cr.text_extents(CURSOR_TEXT_MN).unwrap().width; self.cursor_h_width = cr.text_extents(CURSOR_TEXT_H).unwrap().width; self.cursor_y = font_size;
random_line_split
waveform_with_overlay.rs
use gtk::{cairo, pango, prelude::*}; use log::debug; use std::{ cell::RefCell, collections::Bound::Included, rc::Rc, sync::{Arc, Mutex}, }; use metadata::Duration; use renderers::{ImagePositions, SampleIndexRange, Timestamp, WaveformRenderer, BACKGROUND_COLOR}; use crate::info::{self, ChaptersBounda...
self.twice_font_size = 2f64 * font_size; self.half_font_size = 0.5f64 * font_size; self.limit_mn_width = cr.text_extents(LIMIT_TEXT_MN).unwrap().width; self.limit_h_width = cr.text_extents(LIMIT_TEXT_H).unwrap().width; self.limit_y = 2f64 ...
{ // FIXME use Once for this match self.font_family { Some(ref family) => { cr.select_font_face(family, cairo::FontSlant::Normal, cairo::FontWeight::Normal); cr.set_font_size(self.font_size); } None => { // Get font spec...
identifier_body
waveform_with_overlay.rs
use gtk::{cairo, pango, prelude::*}; use log::debug; use std::{ cell::RefCell, collections::Bound::Included, rc::Rc, sync::{Arc, Mutex}, }; use metadata::Duration; use renderers::{ImagePositions, SampleIndexRange, Timestamp, WaveformRenderer, BACKGROUND_COLOR}; use crate::info::{self, ChaptersBounda...
(&mut self, da: &gtk::DrawingArea, cr: &cairo::Context) { cr.set_source_rgb(BACKGROUND_COLOR.0, BACKGROUND_COLOR.1, BACKGROUND_COLOR.2); cr.paint().unwrap(); let (positions, state) = { let waveform_renderer = &mut *self.waveform_renderer_mtx.lock().unwrap(); // FIXME sen...
draw
identifier_name
dialog.rs
use std::collections::HashMap; use std::boxed::Box; use core::position::{Size, HasSize}; use core::cellbuffer::CellAccessor; use ui::core::{ Alignable, HorizontalAlign, VerticalAlign, Widget, Frame, Button, ButtonResult, Layout, Painter }; use ui::label::Label; /// Pack labels, b...
&self.frame } fn frame_mut(&mut self) -> &mut Frame { &mut self.frame } } impl HasSize for Dialog { fn size(&self) -> Size { self.frame.size() } }
random_line_split
dialog.rs
use std::collections::HashMap; use std::boxed::Box; use core::position::{Size, HasSize}; use core::cellbuffer::CellAccessor; use ui::core::{ Alignable, HorizontalAlign, VerticalAlign, Widget, Frame, Button, ButtonResult, Layout, Painter }; use ui::label::Label; /// Pack labels, b...
(&mut self, parent: &HasSize, halign: HorizontalAlign, valign: VerticalAlign, margin: (usize, usize)) { self.frame.align(parent, halign, valign, margin); } fn draw_box(&mut self) { self.frame.draw_box(); } fn resize(&mut self, new_size: Size) { self.frame.resize...
pack
identifier_name
dialog.rs
use std::collections::HashMap; use std::boxed::Box; use core::position::{Size, HasSize}; use core::cellbuffer::CellAccessor; use ui::core::{ Alignable, HorizontalAlign, VerticalAlign, Widget, Frame, Button, ButtonResult, Layout, Painter }; use ui::label::Label; /// Pack labels, b...
fn frame_mut(&mut self) -> &mut Frame { &mut self.frame } } impl HasSize for Dialog { fn size(&self) -> Size { self.frame.size() } }
{ &self.frame }
identifier_body
to_ref.rs
pub trait ToRef<'a> { type Ref: 'a; fn to_ref(&'a self) -> Self::Ref; } pub trait ToMut<'a>: ToRef<'a> { type Mut: 'a; fn to_mut(&'a mut self) -> Self::Mut; } impl<'a, T: 'a> ToRef<'a> for &'a T { type Ref = &'a T; fn to_ref(&'a self) -> Self::Ref { &*self } } impl<'a, T: 'a> T...
} impl<'a> ToRef<'a> for () { type Ref = (); fn to_ref(&'a self) -> Self::Ref { () } } impl<'a> ToMut<'a> for () { type Mut = (); fn to_mut(&'a mut self) -> Self::Mut { () } }
{ &mut *self }
identifier_body
to_ref.rs
pub trait ToRef<'a> { type Ref: 'a; fn to_ref(&'a self) -> Self::Ref; } pub trait ToMut<'a>: ToRef<'a> { type Mut: 'a; fn to_mut(&'a mut self) -> Self::Mut; } impl<'a, T: 'a> ToRef<'a> for &'a T { type Ref = &'a T; fn to_ref(&'a self) -> Self::Ref { &*self } } impl<'a, T: 'a> T...
(&'a mut self) -> Self::Mut { () } }
to_mut
identifier_name
to_ref.rs
pub trait ToRef<'a> { type Ref: 'a; fn to_ref(&'a self) -> Self::Ref; } pub trait ToMut<'a>: ToRef<'a> { type Mut: 'a; fn to_mut(&'a mut self) -> Self::Mut; } impl<'a, T: 'a> ToRef<'a> for &'a T { type Ref = &'a T; fn to_ref(&'a self) -> Self::Ref { &*self } } impl<'a, T: 'a> T...
type Ref = (); fn to_ref(&'a self) -> Self::Ref { () } } impl<'a> ToMut<'a> for () { type Mut = (); fn to_mut(&'a mut self) -> Self::Mut { () } }
&mut *self } } impl<'a> ToRef<'a> for () {
random_line_split
structs.rs
use collections::BTreeMap; //JSON support use serialize::json::{ self, ToJson, Json}; // syntax elements use syntax::ast::StructDef; use syntax::ast::StructFieldKind::*; pub struct StructDefinition { name: String, // (name ,type ) fields: Vec<(String, String)>, } impl StructDefinition { ...
(name: String, struct_def: &StructDef) -> StructDefinition { let mut tuple_struct_index = 0i64; let fields: Vec<(String,String)> = struct_def.fields .iter() .map(|field| match field.node.kind { // TODO: handle visibility NamedField(ref ident, ref...
new
identifier_name
structs.rs
use collections::BTreeMap; //JSON support
use serialize::json::{ self, ToJson, Json}; // syntax elements use syntax::ast::StructDef; use syntax::ast::StructFieldKind::*; pub struct StructDefinition { name: String, // (name ,type ) fields: Vec<(String, String)>, } impl StructDefinition { pub fn new(name: String, struct_def: &Str...
random_line_split
structs.rs
use collections::BTreeMap; //JSON support use serialize::json::{ self, ToJson, Json}; // syntax elements use syntax::ast::StructDef; use syntax::ast::StructFieldKind::*; pub struct StructDefinition { name: String, // (name ,type ) fields: Vec<(String, String)>, } impl StructDefinition { ...
} // for serialization // eg: struct Test { a: i64, b: String } // => {"name":"Test","fields":[["a","i64"],["b","String"]]} impl ToJson for StructDefinition { fn to_json(&self) -> json::Json { let mut j = BTreeMap::new(); j.insert("name".to_string(), self.name.to_json()); j.insert("fields...
{ let mut tuple_struct_index = 0i64; let fields: Vec<(String,String)> = struct_def.fields .iter() .map(|field| match field.node.kind { // TODO: handle visibility NamedField(ref ident, ref _visibility) => (super::get_name_fro...
identifier_body
meth.rs
-> Callee<'blk, 'tcx> { let _icx = push_ctxt("meth::trans_monomorphized_callee"); match vtable { traits::VtableImpl(vtable_impl) => { let ccx = bcx.ccx(); let impl_did = vtable_impl.impl_def_id; let mname = match ty::trait_item(ccx.tcx...
emit_vtable_methods
identifier_name
meth.rs
method_num, origin) } typeck::MethodTraitObject(ref mt) => { let self_expr = match self_expr { Some(self_expr) => self_expr, None => { bcx.sess().span_bug(bcx.tcx().map.span(method_call.expr_id), ...
fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, method_call: MethodCall, trait_id: ast::DefId, n_method: uint, vtable: traits::Vtabl...
{ match ccx.impl_method_cache().borrow().find_copy(&(impl_id, name)) { Some(m) => return m, None => {} } let impl_items = ccx.tcx().impl_items.borrow(); let impl_items = impl_items.get(&impl_id) .expect("could not find impl while translating"); let meth_did...
identifier_body
meth.rs
method_num, origin) } typeck::MethodTraitObject(ref mt) => { let self_expr = match self_expr { Some(self_expr) => self_expr, None => { bcx.sess().span_bug(bcx.tcx().map.span(method_call.expr_id), ...
}; let llvtable = Load(bcx, PointerCast(bcx, GEPi(bcx, llpair, [0u, abi::trt_field_vtable]), Type::vtable(ccx).ptr_to().ptr_to())); let mptr = Load(bcx, GEPi(bcx, llvtabl...
{ ccx.sess().bug("meth::trans_trait_callee given non-bare-rust-fn"); }
conditional_block
meth.rs
Some(self_expr) => self_expr, None => { bcx.sess().span_bug(bcx.tcx().map.span(method_call.expr_id), "self expr wasn't provided for trait object \ callee (trying to call overloaded op?)") ...
box_ty.repr(bcx.tcx()), trait_ref.repr(bcx.tcx())); let tcx = bcx.tcx(); let ccx = bcx.ccx();
random_line_split
re_trait.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
<'t>( self, text: &'t Self::Text, ) -> FindMatches<'t, Self> { FindMatches { re: self, text: text, last_end: 0, last_match: None, } } /// Returns an iterator over all non-overlapping successive leftmost-first /// matches wi...
find_iter
identifier_name
re_trait.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
else { self.0.last_end = e; } self.0.last_match = Some(e); Some(slots) } }
{ self.0.last_end = self.0.re.next_after_empty(&self.0.text, e); if Some(e) == self.0.last_match { return self.next(); } }
conditional_block
re_trait.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} } impl<'t, R> Iterator for FindMatches<'t, R> where R: RegularExpression, R::Text: 't + AsRef<[u8]> { type Item = (usize, usize); fn next(&mut self) -> Option<(usize, usize)> { if self.last_end > self.text.as_ref().len() { return None; } let (s, e) = match sel...
/// Return the underlying regex. pub fn regex(&self) -> &R { &self.re
random_line_split
re_trait.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} impl<'t, R> Iterator for FindCaptures<'t, R> where R: RegularExpression, R::Text: 't + AsRef<[u8]> { type Item = Vec<Slot>; fn next(&mut self) -> Option<Vec<Slot>> { if self.0.last_end > self.0.text.as_ref().len() { return None } let mut slots = vec![None; self.0...
{ self.0.regex() }
identifier_body
issue-3794.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 print_s(s: &S) { s.print(); } pub fn main() { let s: Box<S> = box S { s: 5 }; print_s(s); let t: Box<T> = s as Box<T>; print_t(t); }
{ t.print(); }
identifier_body
issue-3794.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) { println!("{:?}", self); } } fn print_t(t: &T) { t.print(); } fn print_s(s: &S) { s.print(); } pub fn main() { let s: Box<S> = box S { s: 5 }; print_s(s); let t: Box<T> = s as Box<T>; print_t(t); }
print
identifier_name
issue-3794.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 t: Box<T> = s as Box<T>; print_t(t); }
} pub fn main() { let s: Box<S> = box S { s: 5 }; print_s(s);
random_line_split
acl.rs
use std::fmt; use std::ops; use std::string::ToString; /// Describes the ability of a user to perform a certain action. /// /// Permissions can be mixed together like integers with `|` and `&`. #[derive(Clone, Copy, Debug, PartialEq)] pub struct Permission(u32); impl Permission { /// No permissions are set (serv...
self.0 } /// Check that all `permissions` are set. /// /// ``` /// use zookeeper::Permission; /// /// (Permission::READ | Permission::WRITE).can(Permission::WRITE); // -> true /// Permission::ADMIN.can(Permission::CREATE); // -> false /// ``` pub fn can(self, permissions...
pub(crate) fn code(&self) -> u32 {
random_line_split
acl.rs
use std::fmt; use std::ops; use std::string::ToString; /// Describes the ability of a user to perform a certain action. /// /// Permissions can be mixed together like integers with `|` and `&`. #[derive(Clone, Copy, Debug, PartialEq)] pub struct Permission(u32); impl Permission { /// No permissions are set (serv...
() -> &'static Vec<Acl> { &ACL_OPEN_UNSAFE } /// This ACL gives the world the ability to read. pub fn read_unsafe() -> &'static Vec<Acl> { &ACL_READ_UNSAFE } } lazy_static! { static ref ACL_CREATOR_ALL: Vec<Acl> = vec![Acl::new(Permission::ALL, "auth", "")]; static ref ACL_OPEN...
open_unsafe
identifier_name
acl.rs
use std::fmt; use std::ops; use std::string::ToString; /// Describes the ability of a user to perform a certain action. /// /// Permissions can be mixed together like integers with `|` and `&`. #[derive(Clone, Copy, Debug, PartialEq)] pub struct Permission(u32); impl Permission { /// No permissions are set (serv...
if self.can(Permission::ADMIN) { write!(f, "{}ADMIN", tick())?; } Ok(()) } } } #[cfg(test)] mod tests { use super::*; #[test] fn permission_bitor() { let all = Permission::READ | Permission::WRITE | Permission::CREATE ...
{ write!(f, "{}DELETE", tick())?; }
conditional_block
acl.rs
use std::fmt; use std::ops; use std::string::ToString; /// Describes the ability of a user to perform a certain action. /// /// Permissions can be mixed together like integers with `|` and `&`. #[derive(Clone, Copy, Debug, PartialEq)] pub struct Permission(u32); impl Permission { /// No permissions are set (serv...
} impl fmt::Display for Permission { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if *self == Permission::ALL { write!(f, "ALL") } else if *self == Permission::NONE { write!(f, "NONE") } else { let mut first = true; let mut tick = ...
{ Permission::from_raw(self.0 | rhs.0) }
identifier_body
helloworld.rs
#include <constants.rh> #include <crctools.rh> #include <math.rh> #include <util.rh> ; vim: syntax=fasm ; Test RAR assembly file that just demonstrates the syntax. ; ; Usage: ; ; $ unrar p -inul helloworld.rar ; Hello, World! ; _start: ; Install our message in the output buffer mov r3, #0x1000 ...
call $_success
mov [r3+#4], #0x57202c6f ; 'W ,o' mov [r3+#8], #0x646c726f ; 'dlro' mov [r3+#12], #0x00000a21 ; '!\n' mov [VMADDR_NEWBLOCKPOS], r3 ; Pointer mov [VMADDR_NEWBLOCKSIZE], #14 ; Size
random_line_split
mod.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
mod view; pub use self::control::run_title_screen; // ========================================================================= //
// | You should have received a copy of the GNU General Public License along | // | with System Syzygy. If not, see <http://www.gnu.org/licenses/>. | // +--------------------------------------------------------------------------+ mod control;
random_line_split
token.rs
use combine::primitives::Positioner; use conv::ValueFrom; use std::fmt; #[derive(Clone, Debug, PartialEq)] pub enum Literal { Bool(bool), Int(i64), Flt(f64), Str(String), } #[derive(Clone, Debug, PartialEq)] pub enum Token { LParen, RParen, LBracket, RBracket, Quote, Literal(Li...
} impl From<i32> for Literal { fn from(x: i32) -> Self { Literal::Int(x.into()) } } impl From<i64> for Literal { fn from(x: i64) -> Self { Literal::Int(x) } } impl From<f32> for Literal { fn from(x: f32) -> Self { Literal::Flt(x.into()) } } impl From<f64> for Literal...
{ match *self { Token::Literal(ref lit) => write!(f, "{}", lit), Token::Symbol(ref s) => write!(f, "{}", s), _ => write!(f, "{:#?}", self), } }
identifier_body
token.rs
use combine::primitives::Positioner; use conv::ValueFrom; use std::fmt; #[derive(Clone, Debug, PartialEq)] pub enum Literal { Bool(bool), Int(i64), Flt(f64), Str(String), } #[derive(Clone, Debug, PartialEq)] pub enum Token { LParen, RParen, LBracket, RBracket, Quote, Literal(Li...
} impl From<f64> for Literal { fn from(x: f64) -> Self { Literal::Flt(x) } } impl From<bool> for Literal { fn from(x: bool) -> Self { Literal::Bool(x) } } impl<'a> From<&'a str> for Literal { fn from(x: &'a str) -> Self { Literal::Str(x.to_owned()) } } impl From<Strin...
fn from(x: f32) -> Self { Literal::Flt(x.into()) }
random_line_split
token.rs
use combine::primitives::Positioner; use conv::ValueFrom; use std::fmt; #[derive(Clone, Debug, PartialEq)] pub enum Literal { Bool(bool), Int(i64), Flt(f64), Str(String), } #[derive(Clone, Debug, PartialEq)] pub enum Token { LParen, RParen, LBracket, RBracket, Quote, Literal(Li...
(x: String) -> Self { Literal::Str(x) } } impl<T> From<T> for Token where T: Into<Literal>, { fn from(x: T) -> Self { Token::Literal(x.into()) } } #[cfg(test)] mod test { use super::*; #[test] fn format_literal() { let int = Literal::from(32i64); let flt = ...
from
identifier_name
error.rs
use std::error::Error; use std::fmt; use std::io; use std::result; pub type Result<T> = result::Result<T, StreamDelimitError>; #[derive(Debug)] pub enum StreamDelimitError { #[cfg(feature = "with_kafka")] KafkaInitializeError(::kafka::error::Error), VarintDecodeError(io::Error), InvalidStreamTypeError...
(&self) -> &str { match *self { #[cfg(feature = "with_kafka")] StreamDelimitError::KafkaInitializeError(_) => "couldn't initialize kafka consumer", StreamDelimitError::VarintDecodeError(_) | StreamDelimitError::VarintDecodeMaxBytesError => "couldn't decode leading...
description
identifier_name
error.rs
use std::error::Error; use std::fmt; use std::io; use std::result;
pub type Result<T> = result::Result<T, StreamDelimitError>; #[derive(Debug)] pub enum StreamDelimitError { #[cfg(feature = "with_kafka")] KafkaInitializeError(::kafka::error::Error), VarintDecodeError(io::Error), InvalidStreamTypeError(String), VarintDecodeMaxBytesError, } impl fmt::Display for S...
random_line_split
error.rs
use std::error::Error; use std::fmt; use std::io; use std::result; pub type Result<T> = result::Result<T, StreamDelimitError>; #[derive(Debug)] pub enum StreamDelimitError { #[cfg(feature = "with_kafka")] KafkaInitializeError(::kafka::error::Error), VarintDecodeError(io::Error), InvalidStreamTypeError...
} impl Error for StreamDelimitError { fn description(&self) -> &str { match *self { #[cfg(feature = "with_kafka")] StreamDelimitError::KafkaInitializeError(_) => "couldn't initialize kafka consumer", StreamDelimitError::VarintDecodeError(_) | StreamDelimitEr...
{ match *self { #[cfg(feature = "with_kafka")] StreamDelimitError::KafkaInitializeError(ref e) => { write!(f, "Couldn't initialize kafka consumer: {}", e) } StreamDelimitError::VarintDecodeError(ref e) => { write!(f, "Couldn't decod...
identifier_body
publish.rs
use std::path::PathBuf; use std::io::prelude::*; use std::fs::{self, File}; use support::paths; use support::git::{repo, Repository}; use url::Url; pub fn
() -> Repository { let config = paths::root().join(".cargo/config"); t!(fs::create_dir_all(config.parent().unwrap())); t!(t!(File::create(&config)).write_all(format!(r#" [registry] token = "api-token" [registries.alternative] index = "{registry}" "#, registry = regis...
setup
identifier_name
publish.rs
use std::path::PathBuf; use std::io::prelude::*; use std::fs::{self, File}; use support::paths; use support::git::{repo, Repository}; use url::Url; pub fn setup() -> Repository
repo(&registry_path()) .file("config.json", &format!(r#"{{ "dl": "{0}", "api": "{0}" }}"#, upload())) .build() } fn registry_path() -> PathBuf { paths::root().join("registry") } pub fn registry() -> Url { Url::from_file_path(&*registry_path()).ok().unwrap() } pub fn u...
{ let config = paths::root().join(".cargo/config"); t!(fs::create_dir_all(config.parent().unwrap())); t!(t!(File::create(&config)).write_all(format!(r#" [registry] token = "api-token" [registries.alternative] index = "{registry}" "#, registry = registry().to_string()...
identifier_body
publish.rs
use std::path::PathBuf; use std::io::prelude::*; use std::fs::{self, File}; use support::paths; use support::git::{repo, Repository}; use url::Url; pub fn setup() -> Repository { let config = paths::root().join(".cargo/config"); t!(fs::create_dir_all(config.parent().unwrap())); t!(t!(File::create(&config...
pub fn upload_path() -> PathBuf { paths::root().join("upload") } fn upload() -> Url { Url::from_file_path(&*upload_path()).ok().unwrap() }
pub fn registry() -> Url { Url::from_file_path(&*registry_path()).ok().unwrap() }
random_line_split
timeout.rs
// * This file is part of the uutils coreutils package. // * // * (c) Alex Lyon <arcterus@mail.com> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // spell-checker:ignore (ToDO) tstr sigstr cmdname setpgid sigchld #[macro_u...
(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(); let app = uu_app(); let matches = app.get_matches_from(args); let config = Config::from(&matches)?; timeout( &config.command, config.duration...
uumain
identifier_name
timeout.rs
// * This file is part of the uutils coreutils package. // * // * (c) Alex Lyon <arcterus@mail.com> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // spell-checker:ignore (ToDO) tstr sigstr cmdname setpgid sigchld #[macro_u...
fn timeout( cmd: &[String], duration: Duration, signal: usize, kill_after: Option<Duration>, foreground: bool, preserve_status: bool, verbose: bool, ) -> UResult<()> { if!foreground { unsafe { libc::setpgid(0, 0) }; } let mut process = Command::new(&cmd[0]) .args(&...
/// TODO: Improve exit codes, and make them consistent with the GNU Coreutils exit codes.
random_line_split
lib.rs
// Copyright 2017 The Gfx-rs 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 or ag...
Adapter { adapter: adapter, info: info, queue_families: vec![QueueFamily], // TODO: }); } cur_index += 1; } Instance { inner: dxgi_factory, a...
{ // We have found a possible adapter // acquire the device information let mut desc: winapi::DXGI_ADAPTER_DESC2 = unsafe { std::mem::uninitialized() }; unsafe { adapter.GetDesc2(&mut desc); } let device_name = { let le...
conditional_block
lib.rs
// Copyright 2017 The Gfx-rs 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 or ag...
let device_name = { let len = desc.Description.iter().take_while(|&&c| c!= 0).count(); let name = <OsString as OsStringExt>::from_wide(&desc.Description[..len]); name.to_string_lossy().into_owned() }; let info ...
// We have found a possible adapter // acquire the device information let mut desc: winapi::DXGI_ADAPTER_DESC2 = unsafe { std::mem::uninitialized() }; unsafe { adapter.GetDesc2(&mut desc); }
random_line_split
lib.rs
// Copyright 2017 The Gfx-rs 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 or ag...
(&self) -> &core::AdapterInfo { &self.info } fn get_queue_families(&self) -> std::slice::Iter<QueueFamily> { self.queue_families.iter() } } pub struct Factory { inner: ComPtr<winapi::ID3D12Device>, } pub struct CommandQueue { inner: ComPtr<winapi::ID3D12CommandQueue>, device: ...
get_info
identifier_name
lib.rs
// Copyright 2017 The Gfx-rs 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 or ag...
let queue_desc = winapi::D3D12_COMMAND_QUEUE_DESC { Type: winapi::D3D12_COMMAND_LIST_TYPE_DIRECT, // TODO: correct queue type Priority: 0, Flags: winapi::D3D12_COMMAND_QUEUE_FLAG_NONE, NodeMask: 0, }; ...
{ // Create D3D12 device let mut device = ComPtr::<winapi::ID3D12Device>::new(ptr::null_mut()); let hr = unsafe { d3d12::D3D12CreateDevice( self.adapter.as_mut_ptr() as *mut _ as *mut winapi::IUnknown, winapi::D3D_FEATURE_LEVEL_12_0, // TODO: correct f...
identifier_body
test.rs
pub fn config_read_word(bus: u8, slot: u8, func: u8, offset: u8) -> u16 { let device: i32 = match (bus, slot, func) { // root PCI controller (0, 0, 0) => 0, // secondary bus controller (for bus 1) (0, 1, 0) => 1, (9, 0, 0) => 2, (_, _, _) => -1, }; match o...
_ => 0xFFFF, }, // classes 0x0A => match device { 0 => 0x0600, 1 => 0x0604, 2 => 0x0300, _ => 0xFFFF, }, // header type 0x0E => match device { 1 => 0x0001, _ => 0x0000, }, ...
0 => 0x15D0, 1 => 0x15D3, 2 => 0x00B8,
random_line_split
test.rs
pub fn config_read_word(bus: u8, slot: u8, func: u8, offset: u8) -> u16
}, // device ID 0x02 => match device { 0 => 0x15D0, 1 => 0x15D3, 2 => 0x00B8, _ => 0xFFFF, }, // classes 0x0A => match device { 0 => 0x0600, 1 => 0x0604, 2 => 0x0300, _ => 0x...
{ let device: i32 = match (bus, slot, func) { // root PCI controller (0, 0, 0) => 0, // secondary bus controller (for bus 1) (0, 1, 0) => 1, (9, 0, 0) => 2, (_, _, _) => -1, }; match offset { // vendor ID 0x00 => match device { ...
identifier_body
test.rs
pub fn
(bus: u8, slot: u8, func: u8, offset: u8) -> u16 { let device: i32 = match (bus, slot, func) { // root PCI controller (0, 0, 0) => 0, // secondary bus controller (for bus 1) (0, 1, 0) => 1, (9, 0, 0) => 2, (_, _, _) => -1, }; match offset { // vend...
config_read_word
identifier_name
ecbadmin.rs
use common::{err, ascii, challenge, url}; use common::cipher::{aes, key, padding}; const max_blocksize: usize = 32; pub static info: challenge::Info = challenge::Info { no: 13, title: "ECB cut-and-paste", help: "", execute_fn: interactive }; struct User { email: String, ...
return Ok(len2 - len1); } } mkerr!("unable to detect cipher block size") } pub fn init_authbox() -> Result<AuthBox, err::Error> { Ok(try!(AuthBox::new())) } pub fn interactive() -> err::ExitCode { let authbox = rtry!(init_authbox(), exit_err!()); rtry!(auth_as_admin(&authbox...
let len2 = try!(authbox.profile_for(&raw!(strjoin!(&email_name, &email_domain).as_ref()))).len(); if len2 > len1 {
random_line_split
ecbadmin.rs
use common::{err, ascii, challenge, url}; use common::cipher::{aes, key, padding}; const max_blocksize: usize = 32; pub static info: challenge::Info = challenge::Info { no: 13, title: "ECB cut-and-paste", help: "", execute_fn: interactive }; struct User { email: String, ...
, _ => { println!("admin access denied :("); Ok(false) } } } fn detect_blocksize(authbox: &AuthBox, max: usize) -> Result<usize, err::Error> { let mut email_name = String::from("a"); let email_domain = "b.co"; let len1 = try!(authbox.profile_for(&raw!(strjoin!(&email_name, &email_domain...
{ println!("admin access granted !!"); Ok(true) }
conditional_block
ecbadmin.rs
use common::{err, ascii, challenge, url}; use common::cipher::{aes, key, padding}; const max_blocksize: usize = 32; pub static info: challenge::Info = challenge::Info { no: 13, title: "ECB cut-and-paste", help: "", execute_fn: interactive }; struct User { email: String, ...
pub fn init_authbox() -> Result<AuthBox, err::Error> { Ok(try!(AuthBox::new())) } pub fn interactive() -> err::ExitCode { let authbox = rtry!(init_authbox(), exit_err!()); rtry!(auth_as_admin(&authbox), exit_err!()); exit_ok!() }
{ let mut email_name = String::from("a"); let email_domain = "b.co"; let len1 = try!(authbox.profile_for(&raw!(strjoin!(&email_name, &email_domain).as_ref()))).len(); for _ in 0 .. max { email_name.push('a'); let len2 = try!(authbox.profile_for(&raw!(strjoin!(&email_name, &email_domain...
identifier_body
ecbadmin.rs
use common::{err, ascii, challenge, url}; use common::cipher::{aes, key, padding}; const max_blocksize: usize = 32; pub static info: challenge::Info = challenge::Info { no: 13, title: "ECB cut-and-paste", help: "", execute_fn: interactive }; struct User { email: String, ...
() -> err::ExitCode { let authbox = rtry!(init_authbox(), exit_err!()); rtry!(auth_as_admin(&authbox), exit_err!()); exit_ok!() }
interactive
identifier_name
aarch64_unknown_openbsd.rs
// Copyright 2018 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 ...
Ok(Target { llvm_target: "aarch64-unknown-openbsd".to_string(), target_endian: "little".to_string(), target_pointer_width: "64".to_string(), target_c_int_width: "32".to_string(), data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), arch: "aa...
base.abi_blacklist = super::arm_base::abi_blacklist();
random_line_split
aarch64_unknown_openbsd.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut base = super::openbsd_base::opts(); base.max_atomic_width = Some(128); base.abi_blacklist = super::arm_base::abi_blacklist(); Ok(Target { llvm_target: "aarch64-unknown-openbsd".to_string(), target_endian: "little".to_string(), target_pointer_width: "64".to_string(), ...
identifier_body
aarch64_unknown_openbsd.rs
// Copyright 2018 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 ...
() -> TargetResult { let mut base = super::openbsd_base::opts(); base.max_atomic_width = Some(128); base.abi_blacklist = super::arm_base::abi_blacklist(); Ok(Target { llvm_target: "aarch64-unknown-openbsd".to_string(), target_endian: "little".to_string(), target_pointer_width: "...
target
identifier_name
enum_count.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Data, DeriveInput}; use crate::helpers::{non_enum_error, HasTypeProperties}; pub(crate) fn enum_count_inner(ast: &DeriveInput) -> syn::Result<TokenStream>
}
{ let n = match &ast.data { Data::Enum(v) => v.variants.len(), _ => return Err(non_enum_error()), }; let type_properties = ast.get_type_properties()?; let strum_module_path = type_properties.crate_module_path(); // Used in the quasi-quotation below as `#name` let name = &ast.ide...
identifier_body
enum_count.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Data, DeriveInput}; use crate::helpers::{non_enum_error, HasTypeProperties}; pub(crate) fn enum_count_inner(ast: &DeriveInput) -> syn::Result<TokenStream> { let n = match &ast.data { Data::Enum(v) => v.variants.len(), _ => return Err(non_en...
// Helper is provided for handling complex generic types correctly and effortlessly let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); Ok(quote! { // Implementation impl #impl_generics #strum_module_path::EnumCount for #name #ty_generics #where_clause { ...
// Used in the quasi-quotation below as `#name` let name = &ast.ident;
random_line_split
enum_count.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Data, DeriveInput}; use crate::helpers::{non_enum_error, HasTypeProperties}; pub(crate) fn
(ast: &DeriveInput) -> syn::Result<TokenStream> { let n = match &ast.data { Data::Enum(v) => v.variants.len(), _ => return Err(non_enum_error()), }; let type_properties = ast.get_type_properties()?; let strum_module_path = type_properties.crate_module_path(); // Used in the quasi-qu...
enum_count_inner
identifier_name
tr.rs
#[macro_use] mod common; use common::util::*; static UTIL_NAME: &'static str = "tr"; #[test] fn test_toupper() { let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&["a-z", "A-Z"]).run_piped_stdin(b"!abcd!"); assert_eq!(result.stdout, "!ABCD!"); } #[test] fn test_small_set2() {
let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&["0-9", "X"]).run_piped_stdin(b"@0123456789"); assert_eq!(result.stdout, "@XXXXXXXXXX"); } #[test] fn test_unicode() { let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&[", ┬─┬", "╯︵┻━┻"]) .run_piped_s...
random_line_split
tr.rs
#[macro_use] mod common; use common::util::*; static UTIL_NAME: &'static str = "tr"; #[test] fn test_toupper() { let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&["a-z", "A-Z"]).run_piped_stdin(b"!abcd!"); assert_eq!(result.stdout, "!ABCD!"); } #[test] fn test_small_set2() { let (_,...
); let result = ucmd.args(&["-d", "a-z"]).run_piped_stdin(b"aBcD"); assert_eq!(result.stdout, "BD"); } #[test] fn test_delete_complement() { let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&["-d", "-c", "a-z"]).run_piped_stdin(b"aBcD"); assert_eq!(result.stdout, "ac"); }
g(UTIL_NAME
identifier_name
tr.rs
#[macro_use] mod common; use common::util::*; static UTIL_NAME: &'static str = "tr"; #[test] fn test_toupper() { let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&["a-z", "A-Z"]).run_piped_stdin(b"!abcd!"); assert_eq!(result.stdout, "!ABCD!"); } #[test] fn test_small_set2() { let (_,...
cmd) = testing(UTIL_NAME); let result = ucmd.args(&["-d", "a-z"]).run_piped_stdin(b"aBcD"); assert_eq!(result.stdout, "BD"); } #[test] fn test_delete_complement() { let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&["-d", "-c", "a-z"]).run_piped_stdin(b"aBcD"); assert_eq!(result.stdou...
{ let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.args(&[", ┬─┬", "╯︵┻━┻"]) .run_piped_stdin("(,°□°), ┬─┬".as_bytes()); assert_eq!(result.stdout, "(╯°□°)╯︵┻━┻"); } #[test] fn test_delete() { let (_, mut u
identifier_body
generate.rs
use crate::rclio::CliInputOutput; use crate::rclio::OutputType; use crate::rutil::safe_string::SafeString; use rand::{rngs::OsRng, Rng}; use std::io::Result as IoResult; fn
(alnum: bool, len: usize) -> IoResult<SafeString> { let mut password_as_string = String::new(); let mut rng = OsRng::default(); for _ in 0..len { if alnum { match rng.gen_range(0..3) { // Numbers 0-9 0 => password_as_string.push(rng.gen_range(48..58) as u8...
generate_password
identifier_name
generate.rs
use crate::rclio::CliInputOutput; use crate::rclio::OutputType; use crate::rutil::safe_string::SafeString; use rand::{rngs::OsRng, Rng}; use std::io::Result as IoResult; fn generate_password(alnum: bool, len: usize) -> IoResult<SafeString>
/// Returns true if the password contains at least one digit, one uppercase letter and one /// lowercase letter. fn password_is_hard(password: &str, alnum: bool) -> bool { let is_punctuation = |c| -> bool { "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".find(c).is_some() }; password.find(char::is_numeric).is_some() ...
{ let mut password_as_string = String::new(); let mut rng = OsRng::default(); for _ in 0..len { if alnum { match rng.gen_range(0..3) { // Numbers 0-9 0 => password_as_string.push(rng.gen_range(48..58) as u8 as char), // Uppercase A-Z ...
identifier_body
generate.rs
use crate::rclio::CliInputOutput; use crate::rclio::OutputType; use crate::rutil::safe_string::SafeString; use rand::{rngs::OsRng, Rng}; use std::io::Result as IoResult; fn generate_password(alnum: bool, len: usize) -> IoResult<SafeString> { let mut password_as_string = String::new(); let mut rng = OsRng::defa...
impl PasswordSpec { pub fn new(alnum: bool, password_len: Option<usize>) -> PasswordSpec { PasswordSpec { alnum: alnum, len: password_len.unwrap_or(32), } } pub fn generate_hard_password(&self) -> IoResult<SafeString> { loop { let password = gener...
pub len: usize, }
random_line_split
generate.rs
use crate::rclio::CliInputOutput; use crate::rclio::OutputType; use crate::rutil::safe_string::SafeString; use rand::{rngs::OsRng, Rng}; use std::io::Result as IoResult; fn generate_password(alnum: bool, len: usize) -> IoResult<SafeString> { let mut password_as_string = String::new(); let mut rng = OsRng::defa...
} Ok(SafeString::from_string(password_as_string)) } /// Returns true if the password contains at least one digit, one uppercase letter and one /// lowercase letter. fn password_is_hard(password: &str, alnum: bool) -> bool { let is_punctuation = |c| -> bool { "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".find(c).is...
{ password_as_string.push(rng.gen_range(33..127) as u8 as char); }
conditional_block
font.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/. */ //! Generic types for font stuff. use app_units::Au; use byteorder::{BigEndian, ReadBytesExt}; use cssparser::Par...
} } } impl<L> SpecifiedValueInfo for KeywordInfo<L> { fn collect_completion_keywords(f: KeywordsCollectFn) { <KeywordSize as SpecifiedValueInfo>::collect_completion_keywords(f); } } /// CSS font keywords #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, P...
offset: Au(0).into(),
random_line_split
font.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/. */ //! Generic types for font stuff. use app_units::Au; use byteorder::{BigEndian, ReadBytesExt}; use cssparser::Par...
<Integer> { /// A four-character tag, packed into a u32 (one byte per character). pub tag: FontTag, /// The actual value. pub value: Integer, } impl<Integer> ToCss for FeatureTagValue<Integer> where Integer: One + ToCss + PartialEq, { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result ...
FeatureTagValue
identifier_name
font.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/. */ //! Generic types for font stuff. use app_units::Au; use byteorder::{BigEndian, ReadBytesExt}; use cssparser::Par...
} /// A generic value for the `font-style` property. /// /// https://drafts.csswg.org/css-fonts-4/#font-style-prop #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, T...
{ KeywordSize::Medium }
identifier_body
font.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/. */ //! Generic types for font stuff. use app_units::Au; use byteorder::{BigEndian, ReadBytesExt}; use cssparser::Par...
let mut raw = Cursor::new(tag.as_bytes()); Ok(FontTag(raw.read_u32::<BigEndian>().unwrap())) } } #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToAnimatedZero, ToCss)] /// Additional information for keyword-derived font sizes. pub ...
{ return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); }
conditional_block
lazy-and-or.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 ...
else { assert!((false)); } }
{ assert!((true)); }
conditional_block
lazy-and-or.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn incr(x: &mu...
// file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
random_line_split
lazy-and-or.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(x: &mut int) -> bool { *x += 1; assert!((false)); return false; } pub fn main() { let x = 1 == 2 || 3 == 3; assert!((x)); let mut y: int = 10; info2!("{:?}", x || incr(&mut y)); assert_eq!(y, 10); if true && x { assert!((true)); } else { assert!((false)); } }
incr
identifier_name
lazy-and-or.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 fn main() { let x = 1 == 2 || 3 == 3; assert!((x)); let mut y: int = 10; info2!("{:?}", x || incr(&mut y)); assert_eq!(y, 10); if true && x { assert!((true)); } else { assert!((false)); } }
{ *x += 1; assert!((false)); return false; }
identifier_body
schema.rs
use types::{ChecksumType, Column, ColumnValue}; use v1::row::{Row}; use v1::write::{schema_write}; use v1::read::schema_read; use v1::parse::parse_string; use std::io::{Error, ErrorKind, Read, Write}; use std::str; pub struct Metadata { pub checksum: ChecksumType, pub header_bytes: usize, ...
pub fn write<W: Write>(&self, writer: &mut W, names: &[&str], values: &[ColumnValue]) { schema_write( &self.columns, writer, names, values, self.header_bytes, ...
{ let mut s: String = String::new(); match reader.read_to_string(&mut s) { Ok(_) => { parse_string(&s).ok_or(Error::new(ErrorKind::Other, "parsing failed")) } Err(why) => Err(why), } }
identifier_body
schema.rs
use types::{ChecksumType, Column, ColumnValue}; use v1::row::{Row}; use v1::write::{schema_write}; use v1::read::schema_read; use v1::parse::parse_string; use std::io::{Error, ErrorKind, Read, Write}; use std::str; pub struct Metadata { pub checksum: ChecksumType, pub header_bytes: usize, ...
Err(why) => Err(why), } } pub fn write<W: Write>(&self, writer: &mut W, names: &[&str], values: &[ColumnValue]) { schema_write( &self.columns, writer, names, ...
{ parse_string(&s).ok_or(Error::new(ErrorKind::Other, "parsing failed")) }
conditional_block
schema.rs
use types::{ChecksumType, Column, ColumnValue}; use v1::row::{Row}; use v1::write::{schema_write}; use v1::read::schema_read; use v1::parse::parse_string; use std::io::{Error, ErrorKind, Read, Write}; use std::str; pub struct
{ pub checksum: ChecksumType, pub header_bytes: usize, // ordered list of columns pub columns: Vec<Column>, } impl Metadata { pub fn parse<R: Read>(reader: &mut R) -> Result<Self, Error> { let mut s: String = String::new(); match reader.read_to_string(&m...
Metadata
identifier_name
schema.rs
use types::{ChecksumType, Column, ColumnValue}; use v1::row::{Row}; use v1::write::{schema_write}; use v1::read::schema_read; use v1::parse::parse_string; use std::io::{Error, ErrorKind, Read, Write}; use std::str; pub struct Metadata { pub checksum: ChecksumType, pub header_bytes: usize, ...
values: &[ColumnValue]) { schema_write( &self.columns, writer, names, values, self.header_bytes, &self.checksum ); } pub fn read<R: Read>(&self, reader: &mut R) -> Row { loop { ...
pub fn write<W: Write>(&self, writer: &mut W, names: &[&str],
random_line_split
history_traversal.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 script_thread::{CommonScriptMsg, MainThreadScriptMsg, ScriptChan}; use std::sync::mpsc::Sender; #[derive(JSTr...
(&self, msg: CommonScriptMsg) -> Result<(), ()> { let HistoryTraversalTaskSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box<ScriptChan + Send> { let HistoryTraversalTaskSource(ref chan) = *self; box HistoryTraversalTas...
send
identifier_name
history_traversal.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 script_thread::{CommonScriptMsg, MainThreadScriptMsg, ScriptChan}; use std::sync::mpsc::Sender; #[derive(JSTr...
impl ScriptChan for HistoryTraversalTaskSource { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { let HistoryTraversalTaskSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box<ScriptChan + Send> { let HistoryTraversalT...
random_line_split
main.rs
// // zhttpto.rs // // Starting code for PS1 // Running on Rust 0.12 // // Note that this code has serious security risks! You should not run it // on any system with access to sensitive files. // // University of Virginia - cs4414 Spring 2014 // Weilin Xu and David Evans // Version 0.3 #![feature(globs)] use std::io...
let mut acceptor = net::tcp::TcpListener::bind(addr).listen(); println!("Listening on [{}]...", addr); for stream in acceptor.incoming() { match stream { Err(_) => (), // Spawn a task to handle the connection Ok(mut stream) => spawn(proc() { matc...
fn main() { let addr = "127.0.0.1:4414";
random_line_split
main.rs
// // zhttpto.rs // // Starting code for PS1 // Running on Rust 0.12 // // Note that this code has serious security risks! You should not run it // on any system with access to sensitive files. // // University of Virginia - cs4414 Spring 2014 // Weilin Xu and David Evans // Version 0.3 #![feature(globs)] use std::io...
() { let addr = "127.0.0.1:4414"; let mut acceptor = net::tcp::TcpListener::bind(addr).listen(); println!("Listening on [{}]...", addr); for stream in acceptor.incoming() { match stream { Err(_) => (), // Spawn a task to handle the connection Ok(mut stream)...
main
identifier_name
main.rs
// // zhttpto.rs // // Starting code for PS1 // Running on Rust 0.12 // // Note that this code has serious security risks! You should not run it // on any system with access to sensitive files. // // University of Virginia - cs4414 Spring 2014 // Weilin Xu and David Evans // Version 0.3 #![feature(globs)] use std::io...
println!("Received request :\n{}", request_str); let response = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n <doctype!html><html><head><title>Hello, Rust!</title> <style>body { background-color: #111; co...
{ let addr = "127.0.0.1:4414"; let mut acceptor = net::tcp::TcpListener::bind(addr).listen(); println!("Listening on [{}] ...", addr); for stream in acceptor.incoming() { match stream { Err(_) => (), // Spawn a task to handle the connection Ok(mut stream) =...
identifier_body
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
// https://dom.spec.whatwg.org/#dom-childnode-after fn After(&self, nodes: Vec<NodeOrString>) -> ErrorResult { self.upcast::<Node>().after(nodes) } // https://dom.spec.whatwg.org/#dom-childnode-replacewith fn ReplaceWith(&self, nodes: Vec<NodeOrString>) -> ErrorResult { self.upcas...
{ self.upcast::<Node>().before(nodes) }
identifier_body
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
} // https://dom.spec.whatwg.org/#dom-characterdata-substringdata fn SubstringData(&self, offset: u32, count: u32) -> Fallible<DOMString> { let data = self.data.borrow(); // Step 1. let mut substring = String::new(); let remaining; match split_at_utf16_code_unit_offs...
self.data.borrow().encode_utf16().count() as u32
random_line_split
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
(&self, data: DOMString, document: &Document) -> Root<Node> { match self.upcast::<Node>().type_id() { NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => { Root::upcast(Comment::new(data, &document)) } NodeTypeId::CharacterData(CharacterDataTypeId::Proc...
clone_with_data
identifier_name
assert-eq-macro-success.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(&Point{x:34},&Point{x:34}); }
assert_eq!("abc".to_string(),"abc".to_string()); assert_eq!(Box::new(Point{x:34}),Box::new(Point{x:34}));
random_line_split
assert-eq-macro-success.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ assert_eq!(14,14); assert_eq!("abc".to_string(),"abc".to_string()); assert_eq!(Box::new(Point{x:34}),Box::new(Point{x:34})); assert_eq!(&Point{x:34},&Point{x:34}); }
identifier_body
assert-eq-macro-success.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert_eq!(14,14); assert_eq!("abc".to_string(),"abc".to_string()); assert_eq!(Box::new(Point{x:34}),Box::new(Point{x:34})); assert_eq!(&Point{x:34},&Point{x:34}); }
main
identifier_name
lib.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may n...
//! Rust runtime library for the Apache Thrift RPC system. //! //! This crate implements the components required to build a working //! Thrift server and client. It is divided into the following modules: //! //! 1. errors //! 2. protocol //! 3. transport //! 4. server //! 5. autogen //! //! The modules are layered as ...
// software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License.
random_line_split
keystore.rs
#![allow(non_snake_case)] use serde_json::{self, Value}; use request::Handler; use error::ConsulResult; use std::error::Error; pub struct Keystore{ handler: Handler } impl Keystore { pub fn new(address: &str) -> Keystore { Keystore { handler: Handler::new(&format!("{}/v1/kv", address)) ...
(&self, key: String, value: String) -> ConsulResult<()> { self.handler.put(&key, value, Some("application/json"))?; Ok(()) } pub fn acquire_lock(&self, key: String, address: String, session_id: &String) -> ConsulResult<bool> { let uri = format!("{}?acquire={}", key, session_id); ...
set_key
identifier_name