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
cat-file.rs
extern crate gitters; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; use gitters::cli; use gitters::commits; use gitters::objects; use gitters::revisions; const USAGE: &'static str = " cat-file - Provide content or type and size information for repository objects Usage: cat-file -t <object...
fn show_contents(name: &objects::Name) -> cli::Result { let obj = try!(cli::wrap_with_status(objects::read_object(&name), 1)); match obj { objects::Object::Commit(commit) => { let objects::Name(name) = commit.name; println!("commit {}", name); let objects::Name(tree)...
cli::success() }
random_line_split
cat-file.rs
extern crate gitters; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; use gitters::cli; use gitters::commits; use gitters::objects; use gitters::revisions; const USAGE: &'static str = " cat-file - Provide content or type and size information for repository objects Usage: cat-file -t <object...
else if args.flag_s { show_size(&name) } else if args.flag_e { check_validity(&name) } else if args.flag_p { show_contents(&name) } else { Err(cli::Error { message: "No flags specified".to_string(), status: 2 }) } } fn main() { let args: Args = Docopt::new(USAGE) ...
{ show_type(&name) }
conditional_block
cat-file.rs
extern crate gitters; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; use gitters::cli; use gitters::commits; use gitters::objects; use gitters::revisions; const USAGE: &'static str = " cat-file - Provide content or type and size information for repository objects Usage: cat-file -t <object...
(name: &objects::Name) -> cli::Result { let obj = try!(cli::wrap_with_status(objects::read_object(&name), 1)); match obj { objects::Object::Commit(commit) => { let objects::Name(name) = commit.name; println!("commit {}", name); let objects::Name(tree) = commit.tree; ...
show_contents
identifier_name
cat-file.rs
extern crate gitters; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; use gitters::cli; use gitters::commits; use gitters::objects; use gitters::revisions; const USAGE: &'static str = " cat-file - Provide content or type and size information for repository objects Usage: cat-file -t <object...
println!(""); println!("{}", commit.message); }, objects::Object::Blob(contents) => { // Don't use println, as we don't want to include an extra newline at the end of the // blob contents. print!("{}", contents); }, _ => { /* N...
{ let obj = try!(cli::wrap_with_status(objects::read_object(&name), 1)); match obj { objects::Object::Commit(commit) => { let objects::Name(name) = commit.name; println!("commit {}", name); let objects::Name(tree) = commit.tree; println!("tree : {}", ...
identifier_body
edgeop_lsys.rs
extern crate rand; extern crate evo; extern crate petgraph; #[macro_use] extern crate graph_annealing; extern crate pcg; extern crate triadic_census; extern crate lindenmayer_system; extern crate graph_edge_evolution; extern crate asexp; extern crate expression; extern crate expression_num; extern crate expression_clos...
let driver_config = DriverConfig { mu: config.mu, lambda: config.lambda, k: config.k, ngen: config.ngen, num_objectives: num_objectives }; let toolbox = Toolbox::new(Goal::new(OptDenseDigraph::from(config.graph.clone())), config.objectives .iter() .map(|o|...
{ println!("Using expr system: {}", EXPR_NAME); let env = Env::new(); let plot = Plot::new(&env); let mut s = String::new(); let configfile = env::args().nth(1).unwrap(); let _ = File::open(configfile).unwrap().read_to_string(&mut s).unwrap(); let expr = asexp::Sexp::parse_toplevel(&s).unwr...
identifier_body
edgeop_lsys.rs
extern crate rand; extern crate evo; extern crate petgraph; #[macro_use] extern crate graph_annealing; extern crate pcg; extern crate triadic_census; extern crate lindenmayer_system; extern crate graph_edge_evolution; extern crate asexp; extern crate expression; extern crate expression_num; extern crate expression_clos...
struct Objective { fitness_function: FitnessFunction, threshold: f32, } fn parse_ops<T, I>(map: &BTreeMap<String, Sexp>, key: &str) -> Vec<(T, u32)> where T: FromStr<Err = I> + UniformDistribution, I: Debug { if let Some(&Sexp::Map(ref list)) = map.get(key) { let mut ops: Vec<(T, u32)> = Vec:...
#[derive(Debug)]
random_line_split
edgeop_lsys.rs
extern crate rand; extern crate evo; extern crate petgraph; #[macro_use] extern crate graph_annealing; extern crate pcg; extern crate triadic_census; extern crate lindenmayer_system; extern crate graph_edge_evolution; extern crate asexp; extern crate expression; extern crate expression_num; extern crate expression_clos...
(w: Option<&Sexp>) -> Option<f32> { match w { Some(s) => s.get_float().map(|f| f as f32), None => { // use a default Some(0.0) } } } fn parse_config(sexp: Sexp) -> Config { let map = sexp.into_map().unwrap(); // number of generations let ngen: usize ...
convert_weight
identifier_name
htmlareaelement.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::HTMLAreaElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAreaEl...
} } fn before_remove_attr(&self, name: &Atom, value: DOMString) { match self.super_type() { Some(ref s) => s.before_remove_attr(name, value.clone()), _ => (), } let node: JSRef<Node> = NodeCast::from_ref(*self); match name.as_slice() { ...
let node: JSRef<Node> = NodeCast::from_ref(*self); match name.as_slice() { "href" => node.set_enabled_state(true), _ => ()
random_line_split
htmlareaelement.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::HTMLAreaElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAreaEl...
} impl<'a> VirtualMethods for JSRef<'a, HTMLAreaElement> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self); Some(htmlelement as &VirtualMethods) } fn after_set_attr(&self, name: &Atom, value: DOMSt...
{ let element = HTMLAreaElement::new_inherited(localName, document); Node::reflect_node(box element, document, HTMLAreaElementBinding::Wrap) }
identifier_body
htmlareaelement.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::HTMLAreaElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAreaEl...
(&self) -> bool { self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAreaElementTypeId)) } } impl HTMLAreaElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAreaElement { HTMLAreaElement { htmlelement: HTMLElement::new_inherited(HTMLAreaElemen...
is_htmlareaelement
identifier_name
sizing.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! https://drafts.csswg.org/css-sizing/ use crate::style_ext::ComputedValuesExt; use style::properties::Compute...
let border = style.border_width(); let margin = style.margin(); pbm_lengths += border.inline_sum(); let mut add = |x: LengthPercentage| { if let Some(l) = x.to_length() { pbm_lengths += l; } if let Some(p) = x.to_percentage() { ...
let mut pbm_percentages = Percentage::zero(); let padding = style.padding();
random_line_split
sizing.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! https://drafts.csswg.org/css-sizing/ use crate::style_ext::ComputedValuesExt; use style::properties::Compute...
let inline = self.expect_inline(); available_size .max(inline.min_content) .min(inline.max_content) } }
identifier_body
sizing.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! https://drafts.csswg.org/css-sizing/ use crate::style_ext::ComputedValuesExt; use style::properties::Compute...
() -> Self { Self { min_content: Length::zero(), max_content: Length::zero(), } } pub fn max_assign(&mut self, other: &Self) { self.min_content.max_assign(other.min_content); self.max_content.max_assign(other.max_content); } /// Relevant to outer...
zero
identifier_name
worker.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 devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg}; use dom::abstractworker::{SharedRt, SimpleWor...
(address: TrustedWorkerAddress) { let worker = address.root(); worker.upcast().fire_event(atom!("error")); } } impl WorkerMethods for Worker { #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-worker-postmessage unsafe fn PostMessage(&self, cx: *mut JSContext, message...
dispatch_simple_error
identifier_name
worker.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 devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg}; use dom::abstractworker::{SharedRt, SimpleWor...
let global = worker.global(); let target = worker.upcast(); let _ac = JSAutoCompartment::new(global.get_cx(), target.reflector().get_jsobject().get()); rooted!(in(global.get_cx()) let mut message = UndefinedValue()); data.read(&global, message.handle_mut()); MessageEven...
{ return; }
conditional_block
worker.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 devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg}; use dom::abstractworker::{SharedRt, SimpleWor...
pub fn new(global: &GlobalScope, sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>, closing: Arc<AtomicBool>) -> DomRoot<Worker> { reflect_dom_object(Box::new(Worker::new_inherited(sender, closing)), global, WorkerBin...
random_line_split
overloaded-deref-count.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
self.count_imm.set(self.count_imm.get() + 1); &self.value } } impl<T> DerefMut<T> for DerefCounter<T> { fn deref_mut(&mut self) -> &mut T { self.count_mut += 1; &mut self.value } } pub fn main() { let mut n = DerefCounter::new(0i); let mut v = DerefCounter::new(Vec:...
impl<T> Deref<T> for DerefCounter<T> { fn deref(&self) -> &T {
random_line_split
overloaded-deref-count.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> (uint, uint) { (self.count_imm.get(), self.count_mut) } } impl<T> Deref<T> for DerefCounter<T> { fn deref(&self) -> &T { self.count_imm.set(self.count_imm.get() + 1); &self.value } } impl<T> DerefMut<T> for DerefCounter<T> { fn deref_mut(&mut self) -> &mut T { ...
counts
identifier_name
overloaded-deref-count.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 ...
} impl<T> Deref<T> for DerefCounter<T> { fn deref(&self) -> &T { self.count_imm.set(self.count_imm.get() + 1); &self.value } } impl<T> DerefMut<T> for DerefCounter<T> { fn deref_mut(&mut self) -> &mut T { self.count_mut += 1; &mut self.value } } pub fn main() { le...
{ (self.count_imm.get(), self.count_mut) }
identifier_body
iter.rs
use ::NbitsVec; use num::PrimInt; use typenum::NonZero; use typenum::uint::Unsigned; pub struct Iter<'a, N:'a, Block: 'a> where N: Unsigned + NonZero, Block: PrimInt { vec: &'a NbitsVec<N, Block>, pos: usize, } impl<'a, N:'a, Block: 'a> Iter<'a, N, Block> where N: Unsigned + NonZero, Block: PrimInt { } impl<...
else { None } } #[inline] fn size_hint(&self) -> (usize, Option<usize>) { match self.vec.len() { len if len > self.pos => { let diff = len - self.pos; (diff, Some(diff)) }, _ => (0, None), } } ...
{ Some(self.vec.get(self.pos)) }
conditional_block
iter.rs
use ::NbitsVec; use num::PrimInt; use typenum::NonZero; use typenum::uint::Unsigned; pub struct Iter<'a, N:'a, Block: 'a> where N: Unsigned + NonZero, Block: PrimInt { vec: &'a NbitsVec<N, Block>, pos: usize, } impl<'a, N:'a, Block: 'a> Iter<'a, N, Block> where N: Unsigned + NonZero, Block: PrimInt { } impl<...
(self) -> usize { self.size_hint().0 } #[inline] fn nth(&mut self, n: usize) -> Option<Block> { self.pos += n; if self.vec.len() > self.pos { Some(self.vec.get(self.pos)) } else { None } } } impl<'a, N:'a, Block: 'a> IntoIterator for &'a ...
count
identifier_name
iter.rs
use ::NbitsVec; use num::PrimInt; use typenum::NonZero; use typenum::uint::Unsigned; pub struct Iter<'a, N:'a, Block: 'a> where N: Unsigned + NonZero, Block: PrimInt { vec: &'a NbitsVec<N, Block>, pos: usize, } impl<'a, N:'a, Block: 'a> Iter<'a, N, Block> where N: Unsigned + NonZero, Block: PrimInt { } impl<...
} impl<'a, N:'a, Block: 'a> IntoIterator for &'a NbitsVec<N, Block> where N: Unsigned + NonZero, Block: PrimInt { type Item = Block; type IntoIter = Iter<'a, N, Block>; fn into_iter(self) -> Iter<'a, N, Block> { Iter { vec: self, pos: 0, } } } #[cfg(test)] mo...
{ self.pos += n; if self.vec.len() > self.pos { Some(self.vec.get(self.pos)) } else { None } }
identifier_body
iter.rs
use ::NbitsVec; use num::PrimInt; use typenum::NonZero; use typenum::uint::Unsigned; pub struct Iter<'a, N:'a, Block: 'a> where N: Unsigned + NonZero, Block: PrimInt { vec: &'a NbitsVec<N, Block>, pos: usize, } impl<'a, N:'a, Block: 'a> Iter<'a, N, Block> where N: Unsigned + NonZero, Block: PrimInt { } impl<...
#[inline] fn nth(&mut self, n: usize) -> Option<Block> { self.pos += n; if self.vec.len() > self.pos { Some(self.vec.get(self.pos)) } else { None } } } impl<'a, N:'a, Block: 'a> IntoIterator for &'a NbitsVec<N, Block> where N: Unsigned + NonZero, Bloc...
#[inline] fn count(self) -> usize { self.size_hint().0 }
random_line_split
rec-align-u64.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() { unsafe { let x = Outer {c8: 22u8, t: Inner {c64: 44u64}}; // Send it through the shape code let y = fmt!("%?", x); debug!("align inner = %?", rusti::min_align_of::<Inner>()); debug!("size outer = %?", sys::size_of::<Outer>()); debug!("y = %s", y); ...
} }
random_line_split
rec-align-u64.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 ...
() -> uint { 8u } pub fn size() -> uint { 16u } } } #[cfg(target_os = "android")] mod m { #[cfg(target_arch = "arm")] pub mod m { pub fn align() -> uint { 4u } pub fn size() -> uint { 12u } } } pub fn main() { unsafe { let x = Outer {c8: 22u8, t: Inner {c64: 44u64}}...
align
identifier_name
rec-align-u64.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 size() -> uint { 12u } } #[cfg(target_arch = "x86_64")] mod m { pub fn align() -> uint { 8u } pub fn size() -> uint { 16u } } } #[cfg(target_os = "win32")] mod m { #[cfg(target_arch = "x86")] pub mod m { pub fn align() -> uint { 8u } pub fn size(...
{ 4u }
identifier_body
main.rs
//Test File gtk_test extern crate gtk; //Custom mods mod system_io; mod gtk_converter; pub mod m_config; //Os interaction use std::process::Command; use std::process::ChildStdout; use std::io; use std::io::prelude::*; use gtk::Builder; use gtk::prelude::*; // make moving clones into closures more convenient //sha...
fn convert_to_str(x: &str) -> &str{ x } fn main() { if gtk::init().is_err() { println!("Failed to initialize GTK."); return; } let glade_src = include_str!("shipload.glade"); let builder = Builder::new(); builder.add_from_string(glade_src).unwrap(); //*************************...
{ Command::new("xterm") .arg("-hold") .arg("-e") .arg("cd ".to_string() + location + " && " + command + " " + arguments) .spawn() .expect("Failed to run command"); }
identifier_body
main.rs
//Test File gtk_test extern crate gtk; //Custom mods mod system_io; mod gtk_converter; pub mod m_config; //Os interaction use std::process::Command; use std::process::ChildStdout; use std::io; use std::io::prelude::*; use gtk::Builder; use gtk::prelude::*; // make moving clones into closures more convenient //sha...
(location: &String, command: &String, arguments: &String){ Command::new("xterm") .arg("-hold") .arg("-e") .arg("cd ".to_string() + location + " && " + command + " " + arguments) .spawn() .expect("Failed to run command"); } fn convert_to_str(x: &str) -> &str{ x } fn main() { if gtk::init().i...
execute_command
identifier_name
main.rs
//Test File gtk_test extern crate gtk; //Custom mods mod system_io; mod gtk_converter; pub mod m_config; //Os interaction use std::process::Command; use std::process::ChildStdout; use std::io; use std::io::prelude::*; use gtk::Builder; use gtk::prelude::*; // make moving clones into closures more convenient //sha...
pref_window.hide(); })); //Cargo cargo_build.connect_clicked(clone!(cargo_build_folder, cargo_build_arguments => move |_|{ let argument_string: String = gtk_converter::text_from_entry(&cargo_build_arguments); let locationstr: String = gtk_converter::path_from_filechooser(&cargo_build_...
//Hide, with save pref_save.connect_clicked(clone!(pref_window => move |_| {
random_line_split
main.rs
//Test File gtk_test extern crate gtk; //Custom mods mod system_io; mod gtk_converter; pub mod m_config; //Os interaction use std::process::Command; use std::process::ChildStdout; use std::io; use std::io::prelude::*; use gtk::Builder; use gtk::prelude::*; // make moving clones into closures more convenient //sha...
let glade_src = include_str!("shipload.glade"); let builder = Builder::new(); builder.add_from_string(glade_src).unwrap(); //********************************************** //Crucial let configuration = m_config::create_config(); //Main //Get Window let window: gtk::Window = builder.get_object(...
{ println!("Failed to initialize GTK."); return; }
conditional_block
event.rs
//! Event handling (mouse, keyboard, controller, touch screen, etc.) //! //! See [`Event`](enum.Event.html) for more information. //! //! # Unstable //! //! There are still many unanswered questions about the design of the events API in the turtle //! crate. This module may change or be completely removed in the future...
F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, Home, Delete, End, /// The PageDown (PgDn) key PageDown, /// The PageUp (PgUp) key PageUp, /// The backspace key, right ...
F3, F4, F5,
random_line_split
event.rs
//! Event handling (mouse, keyboard, controller, touch screen, etc.) //! //! See [`Event`](enum.Event.html) for more information. //! //! # Unstable //! //! There are still many unanswered questions about the design of the events API in the turtle //! crate. This module may change or be completely removed in the future...
(state: glutin_event::ElementState) -> PressedState { match state { glutin_event::ElementState::Pressed => PressedState::Pressed, glutin_event::ElementState::Released => PressedState::Released, } } } //TODO: Documentation #[non_exhaustive] #[derive(Debug, Clone, Copy, Partia...
from_state
identifier_name
event.rs
//! Event handling (mouse, keyboard, controller, touch screen, etc.) //! //! See [`Event`](enum.Event.html) for more information. //! //! # Unstable //! //! There are still many unanswered questions about the design of the events API in the turtle //! crate. This module may change or be completely removed in the future...
} //TODO: Documentation #[non_exhaustive] #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum Key { /// The '1' key above the letters. Num1, /// The '2' key above the letters. Num2, /// The '3' key above the letters. Num3, /// The '4' key above the letters. Num4, ...
{ match state { glutin_event::ElementState::Pressed => PressedState::Pressed, glutin_event::ElementState::Released => PressedState::Released, } }
identifier_body
borrowck-lend-flow-loop.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 ...
() { // In this instance, the borrow is carried through the loop. let mut v = ~3; let mut w = ~4; let mut _x = &w; for for_func { borrow_mut(v); //~ ERROR cannot borrow _x = &v; } } fn loop_aliased_mut_break() { // In this instance, the borrow is carried through the loop. ...
for_loop_aliased_mut
identifier_name
borrowck-lend-flow-loop.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } } fn main() {}
{ loop; // ...so it is not live as exit (and re-enter) the `while` loop here }
conditional_block
borrowck-lend-flow-loop.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 cond() -> bool { fail!() } fn for_func(_f: &fn() -> bool) -> bool { fail!() } fn produce<T>() -> T { fail!(); } fn inc(v: &mut ~int) { *v = ~(**v + 1); } fn loop_overarching_alias_mut() { // In this instance, the borrow encompasses the entire loop. let mut v = ~3; let mut x = &mut v; **x += 1...
{}
identifier_body
borrowck-lend-flow-loop.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
break; //...so it is not live as exit the `while` loop here } } } } fn loop_loop_pops_scopes<'r>(_v: &'r mut [uint], f: &fn(&'r mut uint) -> bool) { // Similar to `loop_break_pops_scopes` but for the `loop` keyword while cond() { while cond() { // th...
let r: &'r mut uint = produce(); if !f(&mut *r) {
random_line_split
source.rs
use crate::{Interest, Registry, Token}; use std::io; /// An event source that may be registered with [`Registry`]. /// /// Types that implement `event::Source` can be registered with /// `Registry`. Users of Mio **should not** use the `event::Source` trait /// functions directly. Instead, the equivalent functions on ...
/// /// [`Registry::reregister`]:../struct.Registry.html#method.reregister fn reregister( &mut self, registry: &Registry, token: Token, interests: Interest, ) -> io::Result<()>; /// Deregister `self` from the given `Registry` instance. /// /// This function s...
/// re-registration by either delegating the call to another `Source` type.
random_line_split
source.rs
use crate::{Interest, Registry, Token}; use std::io; /// An event source that may be registered with [`Registry`]. /// /// Types that implement `event::Source` can be registered with /// `Registry`. Users of Mio **should not** use the `event::Source` trait /// functions directly. Instead, the equivalent functions on ...
( &mut self, registry: &Registry, token: Token, interests: Interest, ) -> io::Result<()> { (&mut **self).register(registry, token, interests) } fn reregister( &mut self, registry: &Registry, token: Token, interests: Interest, ) -> ...
register
identifier_name
source.rs
use crate::{Interest, Registry, Token}; use std::io; /// An event source that may be registered with [`Registry`]. /// /// Types that implement `event::Source` can be registered with /// `Registry`. Users of Mio **should not** use the `event::Source` trait /// functions directly. Instead, the equivalent functions on ...
}
{ (&mut **self).deregister(registry) }
identifier_body
random.rs
use rand::{ distributions::Alphanumeric, prelude::{Rng, SeedableRng, StdRng}, }; const OPERATORS: &[char] = &[ '+', '-', '<', '>', '(', ')', '*', '/', '&', '|', '!', ',', '.', ]; pub struct
(StdRng); impl Rand { pub fn new(seed: usize) -> Self { Rand(StdRng::seed_from_u64(seed as u64)) } pub fn unsigned(&mut self, max: usize) -> usize { self.0.gen_range(0..max + 1) } pub fn words(&mut self, max_count: usize) -> Vec<u8> { let mut result = Vec::new(); l...
Rand
identifier_name
random.rs
use rand::{ distributions::Alphanumeric, prelude::{Rng, SeedableRng, StdRng}, }; const OPERATORS: &[char] = &[ '+', '-', '<', '>', '(', ')', '*', '/', '&', '|', '!', ',', '.', ]; pub struct Rand(StdRng); impl Rand { pub fn new(seed: usize) -> Self { Rand(StdRng::seed_from_u64(seed as u64)) ...
for i in 0..word_count { if i > 0 { if self.unsigned(5) == 0 { result.push('\n' as u8); } else { result.push(''as u8); } } if self.unsigned(3) == 0 { let index = self.unsig...
pub fn words(&mut self, max_count: usize) -> Vec<u8> { let mut result = Vec::new(); let word_count = self.unsigned(max_count);
random_line_split
random.rs
use rand::{ distributions::Alphanumeric, prelude::{Rng, SeedableRng, StdRng}, }; const OPERATORS: &[char] = &[ '+', '-', '<', '>', '(', ')', '*', '/', '&', '|', '!', ',', '.', ]; pub struct Rand(StdRng); impl Rand { pub fn new(seed: usize) -> Self { Rand(StdRng::seed_from_u64(seed as u64)) ...
} result } }
{ for _ in 0..self.unsigned(8) { result.push(self.0.sample(Alphanumeric) as u8); } }
conditional_block
version.rs
/*! Querying SDL Version */ use std::ffi::CStr; use std::fmt; use crate::sys; /// A structure that contains information about the version of SDL in use. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Version { /// major version pub major: u8, /// minor version pub minor: u8, /// u...
/// Get the version of SDL that is linked against your program. #[doc(alias = "SDL_GetVersion")] pub fn version() -> Version { unsafe { let mut cver = sys::SDL_version { major: 0, minor: 0, patch: 0, }; sys::SDL_GetVersion(&mut cver); Version::fro...
} }
random_line_split
version.rs
/*! Querying SDL Version */ use std::ffi::CStr; use std::fmt; use crate::sys; /// A structure that contains information about the version of SDL in use. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Version { /// major version pub major: u8, /// minor version pub minor: u8, /// u...
(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}.{}.{}", self.major, self.minor, self.patch) } } /// Get the version of SDL that is linked against your program. #[doc(alias = "SDL_GetVersion")] pub fn version() -> Version { unsafe { let mut cver = sys::SDL_version { ma...
fmt
identifier_name
version.rs
/*! Querying SDL Version */ use std::ffi::CStr; use std::fmt; use crate::sys; /// A structure that contains information about the version of SDL in use. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Version { /// major version pub major: u8, /// minor version pub minor: u8, /// u...
} /// Get the version of SDL that is linked against your program. #[doc(alias = "SDL_GetVersion")] pub fn version() -> Version { unsafe { let mut cver = sys::SDL_version { major: 0, minor: 0, patch: 0, }; sys::SDL_GetVersion(&mut cver); Version::...
{ write!(f, "{}.{}.{}", self.major, self.minor, self.patch) }
identifier_body
app.rs
use actix::prelude::*; use actix_web::*; use actors::{ForwardA2AMsg, GetEndpoint}; use actors::forward_agent::ForwardAgent; use bytes::Bytes; use domain::config::AppConfig; use futures::*; const MAX_PAYLOAD_SIZE: usize = 105_906_176; pub struct AppState { pub forward_agent: Addr<ForwardAgent>, } pub fn
(config: AppConfig, forward_agent: Addr<ForwardAgent>) -> App<AppState> { App::with_state(AppState { forward_agent }) .prefix(config.prefix) .middleware(middleware::Logger::default()) // enable logger .resource("", |r| r.method(http::Method::GET).with(_get_endpoint_details)) .resource("/...
new
identifier_name
app.rs
use actix::prelude::*; use actix_web::*; use actors::{ForwardA2AMsg, GetEndpoint}; use actors::forward_agent::ForwardAgent; use bytes::Bytes; use domain::config::AppConfig; use futures::*; const MAX_PAYLOAD_SIZE: usize = 105_906_176; pub struct AppState { pub forward_agent: Addr<ForwardAgent>, } pub fn new(confi...
fn _get_endpoint_details(state: State<AppState>) -> FutureResponse<HttpResponse> { state.forward_agent .send(GetEndpoint {}) .from_err() .map(|res| match res { Ok(endpoint) => HttpResponse::Ok().json(&endpoint), Err(err) => HttpResponse::InternalServerError().body(form...
{ App::with_state(AppState { forward_agent }) .prefix(config.prefix) .middleware(middleware::Logger::default()) // enable logger .resource("", |r| r.method(http::Method::GET).with(_get_endpoint_details)) .resource("/msg", |r| r.method(http::Method::POST).with(_forward_message)) }
identifier_body
app.rs
use actix::prelude::*; use actix_web::*; use actors::{ForwardA2AMsg, GetEndpoint}; use actors::forward_agent::ForwardAgent; use bytes::Bytes; use domain::config::AppConfig; use futures::*; const MAX_PAYLOAD_SIZE: usize = 105_906_176; pub struct AppState { pub forward_agent: Addr<ForwardAgent>, } pub fn new(confi...
}) .responder() } fn _forward_message((state, req): (State<AppState>, HttpRequest<AppState>)) -> FutureResponse<HttpResponse> { req .body() .limit(MAX_PAYLOAD_SIZE) .from_err() .and_then(move |body| { state.forward_agent .send(ForwardA2AMsg(body...
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(ascii)] #![feature(as_unsafe_cell)] #![feature(borrow_state)] #![feature(box_syntax)] #![feature(cell_e...
else { MAX_FILE_LIMIT } } }; match libc::setrlimit(libc::RLIMIT_NOFILE, &mut rlim) { 0 => (), _ => warn!("Failed to set file count limit"), }; }, ...
{ rlim.rlim_max }
conditional_block
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(ascii)] #![feature(as_unsafe_cell)] #![feature(borrow_state)] #![feature(box_syntax)] #![feature(cell_e...
// Bump up our number of file descriptors to save us from impending doom caused by an onslaught // of iframes. unsafe { let mut rlim: libc::rlimit = mem::uninitialized(); match libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) { 0 => { if rlim.rlim_cur >= MAX_FILE_L...
const MAX_FILE_LIMIT: libc::rlim_t = 4096;
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(ascii)] #![feature(as_unsafe_cell)] #![feature(borrow_state)] #![feature(box_syntax)] #![feature(cell_e...
() { use std::mem; // 4096 is default max on many linux systems const MAX_FILE_LIMIT: libc::rlim_t = 4096; // Bump up our number of file descriptors to save us from impending doom caused by an onslaught // of iframes. unsafe { let mut rlim: libc::rlimit = mem::uninitialized(); m...
perform_platform_specific_initialization
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(ascii)] #![feature(as_unsafe_cell)] #![feature(borrow_state)] #![feature(box_syntax)] #![feature(cell_e...
rlim.rlim_max } else { MAX_FILE_LIMIT } } }; match libc::setrlimit(libc::RLIMIT_NOFILE, &mut rlim) { 0 => (), _ => warn!("Fa...
{ use std::mem; // 4096 is default max on many linux systems const MAX_FILE_LIMIT: libc::rlim_t = 4096; // Bump up our number of file descriptors to save us from impending doom caused by an onslaught // of iframes. unsafe { let mut rlim: libc::rlimit = mem::uninitialized(); matc...
identifier_body
events.rs
use std::sync::mpsc::{Sender, Receiver, channel}; use std::iter::Iterator; use std::error::Error; use error; use frame::events::{ServerEvent as FrameServerEvent, SimpleServerEvent as FrameSimpleServerEvent, SchemaChange as FrameSchemaChange}; use frame::parser::parse_frame; use compression::Compres...
else { continue; }; match self.tx.send(event) { Err(err) => return Err(error::Error::General(err.description().to_string())), _ => continue, } } } } /// `EventStream` is an iterator which returns new events once they come....
{ // unwrap is safe is we've checked that event_opt.is_some() event_opt.unwrap().event as ServerEvent }
conditional_block
events.rs
use std::sync::mpsc::{Sender, Receiver, channel}; use std::iter::Iterator; use std::error::Error; use error; use frame::events::{ServerEvent as FrameServerEvent, SimpleServerEvent as FrameSimpleServerEvent, SchemaChange as FrameSchemaChange}; use frame::parser::parse_frame; use compression::Compres...
/// It is similar to `Receiver::iter`. pub fn new_listener<X>(transport: X) -> (Listener<X>, EventStream) { let (tx, rx) = channel(); let listener = Listener { transport: transport, tx: tx, }; let stream = EventStream { rx: rx }; (listener, stream) } /// `Listener` provides only one...
/// main thread. /// /// `EventStream` is an iterator which returns new events once they come.
random_line_split
events.rs
use std::sync::mpsc::{Sender, Receiver, channel}; use std::iter::Iterator; use std::error::Error; use error; use frame::events::{ServerEvent as FrameServerEvent, SimpleServerEvent as FrameSimpleServerEvent, SchemaChange as FrameSchemaChange}; use frame::parser::parse_frame; use compression::Compres...
} /// `EventStream` is an iterator which returns new events once they come. /// It is similar to `Receiver::iter`. pub struct EventStream { rx: Receiver<ServerEvent>, } impl Iterator for EventStream { type Item = ServerEvent; fn next(&mut self) -> Option<Self::Item> { self.rx.recv().ok() } }...
{ loop { let event_opt = try!(parse_frame(&mut self.transport, compressor)) .get_body()? .into_server_event(); let event = if event_opt.is_some() { // unwrap is safe is we've checked that event_opt.is_some() event_opt.unwra...
identifier_body
events.rs
use std::sync::mpsc::{Sender, Receiver, channel}; use std::iter::Iterator; use std::error::Error; use error; use frame::events::{ServerEvent as FrameServerEvent, SimpleServerEvent as FrameSimpleServerEvent, SchemaChange as FrameSchemaChange}; use frame::parser::parse_frame; use compression::Compres...
<X> { transport: X, tx: Sender<ServerEvent>, } impl<X: CDRSTransport> Listener<X> { /// It starts a process of listening to new events. Locks a frame. pub fn start(&mut self, compressor: &Compression) -> error::Result<()> { loop { let event_opt = try!(parse_frame(&mut self.transport...
Listener
identifier_name
sample.rs
use std::collections::HashMap;
/// total number of events. pub struct Sample<T> { pub counts: HashMap<T,usize>, pub total: usize, } impl<T: Eq + Hash> Sample<T> { /// Creates a new Sample. pub fn new() -> Sample<T> { Sample { counts: HashMap::new(), total: 0, } } /// Add an event to a...
use std::hash::Hash; use std::iter::FromIterator; /// A collection of events, with a running total of counts for each event and
random_line_split
sample.rs
use std::collections::HashMap; use std::hash::Hash; use std::iter::FromIterator; /// A collection of events, with a running total of counts for each event and /// total number of events. pub struct Sample<T> { pub counts: HashMap<T,usize>, pub total: usize, } impl<T: Eq + Hash> Sample<T> { /// Creates a n...
(&self, event: &T) -> f64 { let c = *self.counts.get(event).unwrap_or(&0); (c as f64) / (self.total as f64) } } // --------------------------- impl<T: Eq + Hash> Extend<T> for Sample<T> { fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I) { for k in iter { self.add(k); } } } i...
p
identifier_name
htmlhrelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLHRElementBinding::{self, HTMLHRElementMethods}; use...
(&self) -> Option<&VirtualMethods> { Some(self.upcast::<HTMLElement>() as &VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { match name { &local_name!("align") => AttrValue::from_dimension(value.into()), &local_name!("co...
super_type
identifier_name
htmlhrelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLHRElementBinding::{self, HTMLHRElementMethods}; use...
impl HTMLHRElementMethods for HTMLHRElement { // https://html.spec.whatwg.org/multipage/#dom-hr-align make_getter!(Align, "align"); // https://html.spec.whatwg.org/multipage/#dom-hr-align make_atomic_setter!(SetAlign, "align"); // https://html.spec.whatwg.org/multipage/#dom-hr-color make_gette...
random_line_split
sig.rs
use std::collections::HashMap;
use crypto::hmac::Hmac; use crypto::mac::Mac; use crypto::sha1::Sha1; use super::util; fn transform_payload<K, V>(d: &HashMap<K, V>) -> String where K: AsRef<str> + Eq + Hash, V: AsRef<str> + Eq + Hash { let mut kv_list: Vec<_> = d.iter().map(|(k, v)| (k.as_ref(), v.as_ref())).collect(); kv_li...
use std::hash::Hash;
random_line_split
sig.rs
use std::collections::HashMap; use std::hash::Hash; use crypto::hmac::Hmac; use crypto::mac::Mac; use crypto::sha1::Sha1; use super::util; fn transform_payload<K, V>(d: &HashMap<K, V>) -> String where K: AsRef<str> + Eq + Hash, V: AsRef<str> + Eq + Hash { let mut kv_list: Vec<_> = d.iter().map(|(k...
<K, V, S>(d: &HashMap<K, V>, secret: S) -> String where K: AsRef<str> + Eq + Hash, V: AsRef<str> + Eq + Hash, S: AsRef<str> { let payload = transform_payload(d); let mut hmac = Hmac::new(Sha1::new(), secret.as_ref().as_bytes()); hmac.input(payload.as_bytes()); util::b64encode(h...
sign
identifier_name
sig.rs
use std::collections::HashMap; use std::hash::Hash; use crypto::hmac::Hmac; use crypto::mac::Mac; use crypto::sha1::Sha1; use super::util; fn transform_payload<K, V>(d: &HashMap<K, V>) -> String where K: AsRef<str> + Eq + Hash, V: AsRef<str> + Eq + Hash { let mut kv_list: Vec<_> = d.iter().map(|(k...
result.push_str(k); result.push('='); result.push_str(v); } result } pub fn sign<K, V, S>(d: &HashMap<K, V>, secret: S) -> String where K: AsRef<str> + Eq + Hash, V: AsRef<str> + Eq + Hash, S: AsRef<str> { let payload = transform_payload(d); let mut hm...
{ result.push('&'); }
conditional_block
sig.rs
use std::collections::HashMap; use std::hash::Hash; use crypto::hmac::Hmac; use crypto::mac::Mac; use crypto::sha1::Sha1; use super::util; fn transform_payload<K, V>(d: &HashMap<K, V>) -> String where K: AsRef<str> + Eq + Hash, V: AsRef<str> + Eq + Hash { let mut kv_list: Vec<_> = d.iter().map(|(k...
}
{ let x = { let mut tmp: HashMap<&str, String> = HashMap::new(); tmp.insert("k2", "v2".to_string()); tmp.insert("k3", "v3".to_string()); tmp.insert("k1", "v1".to_string()); tmp }; assert_eq!(sign(&x, "012345"), "iAKpGb9i8EKY8q4HPfiMdfb2...
identifier_body
zdt1.rs
/// ZDT1 bi-objective test function /// /// Evaluates solution parameters using the ZDT1 [1] synthetic test /// test function to produce two objective values. /// /// [1 ]E. Zitzler, K. Deb, and L. Thiele. Comparison of Multiobjective /// Evolutionary Algorithms: Empirical Results. Evolutionary /// Computation, 8(2):17...
(parameters: [f32; 30]) -> [f32; 2] { // objective function 1 let f1 = parameters[0]; // objective function 2 let mut g = 1_f32; // g(x) for i in 1..parameters.len() { g = g + ((9_f32 / (parameters.len() as f32 - 1_f32)) * parameters[i]); } // h(f1, x) let h = 1_f32 - (f1 ...
zdt1
identifier_name
zdt1.rs
/// ZDT1 bi-objective test function /// /// Evaluates solution parameters using the ZDT1 [1] synthetic test /// test function to produce two objective values. /// /// [1 ]E. Zitzler, K. Deb, and L. Thiele. Comparison of Multiobjective /// Evolutionary Algorithms: Empirical Results. Evolutionary /// Computation, 8(2):17...
{ // objective function 1 let f1 = parameters[0]; // objective function 2 let mut g = 1_f32; // g(x) for i in 1..parameters.len() { g = g + ((9_f32 / (parameters.len() as f32 - 1_f32)) * parameters[i]); } // h(f1, x) let h = 1_f32 - (f1 / g).sqrt(); // f2(x) let f...
identifier_body
zdt1.rs
/// ZDT1 bi-objective test function /// /// Evaluates solution parameters using the ZDT1 [1] synthetic test /// test function to produce two objective values. /// /// [1 ]E. Zitzler, K. Deb, and L. Thiele. Comparison of Multiobjective /// Evolutionary Algorithms: Empirical Results. Evolutionary /// Computation, 8(2):17...
// objective function 1 let f1 = parameters[0]; // objective function 2 let mut g = 1_f32; // g(x) for i in 1..parameters.len() { g = g + ((9_f32 / (parameters.len() as f32 - 1_f32)) * parameters[i]); } // h(f1, x) let h = 1_f32 - (f1 / g).sqrt(); // f2(x) let f2 ...
pub fn zdt1(parameters: [f32; 30]) -> [f32; 2] {
random_line_split
revealer.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Hide and show with animation use ffi; use cast::{GTK_REVEALER}; use glib::{to_bool, ...
pub fn get_transition_duration(&self) -> u32 { unsafe { ffi::gtk_revealer_get_transition_duration(GTK_REVEALER(self.pointer)) } } pub fn set_transition_duration(&self, duration: u32) { unsafe { ffi::gtk_revealer_set_transition_duration(GTK_REVEALER(self.point...
unsafe { to_bool(ffi::gtk_revealer_get_child_revealed(GTK_REVEALER(self.pointer))) } }
identifier_body
revealer.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Hide and show with animation use ffi; use cast::{GTK_REVEALER}; use glib::{to_bool, ...
impl ::ContainerTrait for Revealer {} impl ::BinTrait for Revealer {}
impl_drop!(Revealer); impl_TraitWidget!(Revealer);
random_line_split
revealer.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Hide and show with animation use ffi; use cast::{GTK_REVEALER}; use glib::{to_bool, ...
self, duration: u32) { unsafe { ffi::gtk_revealer_set_transition_duration(GTK_REVEALER(self.pointer), duration) } } pub fn set_transition_type(&self, transition: ::RevealerTransitionType) { unsafe { ffi::gtk_revealer_set_transition_type(GTK_REVEALER(self.pointer)...
t_transition_duration(&
identifier_name
regroup_gradient_stops.rs
// svgcleaner could help you to clean up your SVG files // from unnecessary data. // Copyright (C) 2012-2018 Evgeniy Reizner // // 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 ...
if super::rm_dupl_defs::is_equal_stops(&node1, &node2) { join_nodes.push(node2.clone()); nodes.remove(i2 - 1); i2 -= 1; } } if!join_nodes.is_empty() { is_changed = true; let mut new_lg = doc.create_element...
{ let mut nodes: Vec<Node> = doc.descendants() .filter(|n| n.is_gradient()) .filter(|n| n.has_children()) .filter(|n| !n.has_attribute(AId::XlinkHref)) .collect(); let mut is_changed = false; let mut join_nodes = Vec::new(); // TODO: join with rm_dupl_defs::rm_loop ...
identifier_body
regroup_gradient_stops.rs
// svgcleaner could help you to clean up your SVG files // from unnecessary data. // Copyright (C) 2012-2018 Evgeniy Reizner // // 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 ...
(doc: &mut Document) { let mut nodes: Vec<Node> = doc.descendants() .filter(|n| n.is_gradient()) .filter(|n| n.has_children()) .filter(|n|!n.has_attribute(AId::XlinkHref)) .collect(); let mut is_changed = false; let mut join_nodes = Vec::new(); // TODO: join with rm_dupl_de...
regroup_gradient_stops
identifier_name
regroup_gradient_stops.rs
// svgcleaner could help you to clean up your SVG files // from unnecessary data. // Copyright (C) 2012-2018 Evgeniy Reizner // // 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 ...
n += 1; } s } #[cfg(test)] mod tests { use super::*; use svgdom::{Document, ToStringWithOptions}; use task; macro_rules! test { ($name:ident, $in_text:expr, $out_text:expr) => ( #[test] fn $name() { let mut doc = Document::from_str($in...
{ break; }
conditional_block
regroup_gradient_stops.rs
// svgcleaner could help you to clean up your SVG files // from unnecessary data. // Copyright (C) 2012-2018 Evgeniy Reizner // // 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 ...
) } test!(rm_1, "<svg> <linearGradient id='lg1' x1='50'> <stop offset='0'/> <stop offset='1'/> </linearGradient> <linearGradient id='lg2' x1='100'> <stop offset='0'/> <stop offset='1'/> </linearGradient> </svg>", "<svg> <linearGradient id='lg3'> ...
regroup_gradient_stops(&mut doc); assert_eq_text!(doc.to_string_with_opt(&write_opt_for_tests!()), $out_text); }
random_line_split
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use dom::binding...
/// Add a load to the list of blocking loads. fn add_blocking_load(&mut self, load: LoadType) { debug!("Adding blocking load {:?} ({}).", load, self.blocking_loads.len()); self.blocking_loads.push(load); } /// Initiate a new fetch. pub fn fetch_async(&mut self, ...
{ debug!("Initial blocking load {:?}.", initial_load); let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect(); DocumentLoader { resource_threads: resource_threads, blocking_loads: initial_loads, events_inhibited: false, } ...
identifier_body
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use dom::binding...
} } #[derive(JSTraceable, HeapSizeOf)] pub struct DocumentLoader { resource_threads: ResourceThreads, blocking_loads: Vec<LoadType>, events_inhibited: bool, } impl DocumentLoader { pub fn new(existing: &DocumentLoader) -> DocumentLoader { DocumentLoader::new_with_threads(existing.resource...
{ debug_assert!(self.load.is_none()); }
conditional_block
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use dom::binding...
doc: JS::from_ref(doc), load: Some(load), } } /// Remove this load from the associated document's list of blocking loads. pub fn terminate(blocker: &mut Option<LoadBlocker>) { if let Some(this) = blocker.as_mut() { this.doc.finish_load(this.load.take().un...
pub fn new(doc: &Document, load: LoadType) -> LoadBlocker { doc.mut_loader().add_blocking_load(load.clone()); LoadBlocker {
random_line_split
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use dom::binding...
(existing: &DocumentLoader) -> DocumentLoader { DocumentLoader::new_with_threads(existing.resource_threads.clone(), None) } pub fn new_with_threads(resource_threads: ResourceThreads, initial_load: Option<Url>) -> DocumentLoader { debug!("Initial blocking load {:?}.",...
new
identifier_name
lib.rs
// ================================================================= // // * WARNING * // // This file is generated! // // Changes made to this file will be overwritten. If changes are // required to the generated code, the service_crategen project // must be updated to g...
#[macro_use] extern crate serde_derive; extern crate serde_json; mod generated; mod custom; pub use generated::*; pub use custom::*;
extern crate futures; extern crate rusoto_core; extern crate serde;
random_line_split
mod.rs
// Copyright 2017, Igor Shaula // Licensed under the MIT License <LICENSE or // http://opensource.org/licenses/MIT>. This file // may not be copied, modified, or distributed // except according to those terms. use super::enums::*; use super::RegKey; use std::error::Error; use std::fmt; use std::io; use winapi::shared::...
enumeration_state: DecoderEnumerationState, } const DECODER_SAM: DWORD = KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS; impl Decoder { pub fn from_key(key: &RegKey) -> DecodeResult<Decoder> { key.open_subkey_with_flags("", DECODER_SAM) .map(Decoder::new) .map_err(DecoderError::IoError...
f_name: Option<String>, reading_state: DecoderReadingState,
random_line_split
mod.rs
// Copyright 2017, Igor Shaula // Licensed under the MIT License <LICENSE or // http://opensource.org/licenses/MIT>. This file // may not be copied, modified, or distributed // except according to those terms. use super::enums::*; use super::RegKey; use std::error::Error; use std::fmt; use std::io; use winapi::shared::...
(err: io::Error) -> DecoderError { DecoderError::IoError(err) } } pub type DecodeResult<T> = Result<T, DecoderError>; #[derive(Debug)] enum DecoderReadingState { WaitingForKey, WaitingForValue, } #[derive(Debug)] enum DecoderEnumerationState { EnumeratingKeys(DWORD), EnumeratingValues(DWO...
from
identifier_name
main.rs
// CITA // Copyright 2016-2017 Cryptape Technologies LLC. // 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. // Th...
let threadpool = threadpool::ThreadPool::new(2); let (tx, rx) = channel(); let (tx_sub, rx_sub) = channel(); let (tx_pub, rx_pub) = channel(); start_pubsub("consensus", vec!["net.tx", "jsonrpc.new_tx", "net.msg", "chain.status"], tx_sub, rx_pub); thread::spawn(move || loop { ...
{ thread::spawn(move || { thread::sleep(Duration::new(prof_start, 0)); println!("******Profiling Start******"); PROFILER.lock().unwrap().start("./consensus_poa.profile").expect("Couldn't start"); thread::slee...
conditional_block
main.rs
// CITA // Copyright 2016-2017 Cryptape Technologies LLC. // 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. // Th...
() { dotenv::dotenv().ok(); // Always print backtrace on panic. ::std::env::set_var("RUST_BACKTRACE", "1"); cita_log::format(LogLevelFilter::Info); println!("CITA:consensus:poa"); let matches = App::new("authority_round") .version("0.1") .author("Cryptape") .about("CITA Bl...
main
identifier_name
main.rs
// CITA // Copyright 2016-2017 Cryptape Technologies LLC. // 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. // Th...
let seal = engine.clone(); let dur = engine.duration(); let mut old_height = 0; let mut new_height = 0; let tx_pub = tx_pub.clone(); thread::spawn(move || loop { let seal = seal.clone(); trace!("seal worker lock!"); loop { ...
thread::spawn(move || loop { let process = process.clone(); handler::process(process, &rx, tx_pub1.clone()); });
random_line_split
main.rs
// CITA // Copyright 2016-2017 Cryptape Technologies LLC. // 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. // Th...
config_path = c; } //start profiling let mut prof_start: u64 = 0; let mut prof_duration: u64 = 0; if let Some(start) = matches.value_of("prof-start") { trace!("Value for prof-start: {}", start); prof_start = start.parse::<u64>().unwrap(); } if let Some(duration) = ma...
{ dotenv::dotenv().ok(); // Always print backtrace on panic. ::std::env::set_var("RUST_BACKTRACE", "1"); cita_log::format(LogLevelFilter::Info); println!("CITA:consensus:poa"); let matches = App::new("authority_round") .version("0.1") .author("Cryptape") .about("CITA Bl...
identifier_body
runner.rs
use regex::Regex; use state::Cucumber; use event::request::{InvokeArgument, Request}; use event::response::{InvokeResponse, Response, StepMatchesResponse}; use definitions::registration::{CucumberRegistrar, SimpleStep}; use std::panic::{self, AssertUnwindSafe}; use std::str::FromStr; /// The step runner for [Cucumber...
fn when(&mut self, file: &str, line: u32, regex: Regex, step: SimpleStep<World>) { self.cuke.when(file, line, regex, step) } fn then(&mut self, file: &str, line: u32, regex: Regex, step: SimpleStep<World>) { self.cuke.then(file, line, regex, step) } } pub fn invoke_to_response<World>(test_body: &Sim...
{ self.cuke.given(file, line, regex, step) }
identifier_body
runner.rs
use regex::Regex; use state::Cucumber; use event::request::{InvokeArgument, Request}; use event::response::{InvokeResponse, Response, StepMatchesResponse}; use definitions::registration::{CucumberRegistrar, SimpleStep}; use std::panic::{self, AssertUnwindSafe}; use std::str::FromStr; /// The step runner for [Cucumber...
} }, }; InvokeResponse::fail_from_str(msg) }, } }
random_line_split
runner.rs
use regex::Regex; use state::Cucumber; use event::request::{InvokeArgument, Request}; use event::response::{InvokeResponse, Response, StepMatchesResponse}; use definitions::registration::{CucumberRegistrar, SimpleStep}; use std::panic::{self, AssertUnwindSafe}; use std::str::FromStr; /// The step runner for [Cucumber...
, Request::EndScenario(_) => { self.cuke.tags = Vec::new(); Response::EndScenario }, // TODO: For some reason, cucumber prints the ruby snippet too. Fix that Request::SnippetText(params) => { let text = format!(" // In a step registration block where cuke: &mut \ ...
{ let matches = self.cuke.find_match(&params.name_to_match); if matches.len() == 0 { Response::StepMatches(StepMatchesResponse::NoMatch) } else { Response::StepMatches(StepMatchesResponse::Match(matches)) } }
conditional_block
runner.rs
use regex::Regex; use state::Cucumber; use event::request::{InvokeArgument, Request}; use event::response::{InvokeResponse, Response, StepMatchesResponse}; use definitions::registration::{CucumberRegistrar, SimpleStep}; use std::panic::{self, AssertUnwindSafe}; use std::str::FromStr; /// The step runner for [Cucumber...
(&mut self, file: &str, line: u32, regex: Regex, step: SimpleStep<World>) { self.cuke.when(file, line, regex, step) } fn then(&mut self, file: &str, line: u32, regex: Regex, step: SimpleStep<World>) { self.cuke.then(file, line, regex, step) } } pub fn invoke_to_response<World>(test_body: &SimpleStep<Wor...
when
identifier_name
quick.rs
//! An example using the Builder pattern API to configure the logger at run-time based on command //! line arguments. //! //! The default output is `module::path: message`, and the "tag", which is the text to the left of //! the colon, is colorized. This example allows the user to dynamically change the output based //...
warn!("This too is always printed to stderr"); info!("This is optional info printed to stdout"); // for./app -v or higher debug!("This is optional debug printed to stdout"); // for./app -vv or higher trace!("This is optional trace printed to stdout"); // for./app -vvv }
{ // Add the following line near the beginning of the main function for an application to enable // colorized output on Windows 10. // // Based on documentation for the ansi_term crate, Windows 10 supports ANSI escape characters, // but it must be enabled first using the `ansi_term::enable_ansi_sup...
identifier_body
quick.rs
//! An example using the Builder pattern API to configure the logger at run-time based on command //! line arguments. //! //! The default output is `module::path: message`, and the "tag", which is the text to the left of //! the colon, is colorized. This example allows the user to dynamically change the output based //...
() { // Add the following line near the beginning of the main function for an application to enable // colorized output on Windows 10. // // Based on documentation for the ansi_term crate, Windows 10 supports ANSI escape characters, // but it must be enabled first using the `ansi_term::enable_ansi_...
main
identifier_name
quick.rs
//! An example using the Builder pattern API to configure the logger at run-time based on command //! line arguments. //! //! The default output is `module::path: message`, and the "tag", which is the text to the left of //! the colon, is colorized. This example allows the user to dynamically change the output based //...
// // Based on documentation for the ansi_term crate, Windows 10 supports ANSI escape characters, // but it must be enabled first using the `ansi_term::enable_ansi_support()` function. It is // conditionally compiled and only exists for Windows builds. To avoid build errors on // non-windows platfor...
use clap::{Arg, App}; fn main() { // Add the following line near the beginning of the main function for an application to enable // colorized output on Windows 10.
random_line_split
deserialization.rs
use alias::Alias; use config::Config; use consts::*; use itertools::Itertools; use family::Family; use glib::functions; use pango::Context; use pango::ContextExt; use pango::FontMapExt; use pango::FontFamilyExt; use range::Range; use sxd_document::dom::Comment; use sxd_document::dom::ChildOfElement; use sxd_document::d...
fn child_element<'a: 'd, 'd>(name: &'a str, e: Element<'d>) -> Option<Element<'d>> { children_element(name, e).next() } fn children_element<'a: 'd, 'd>( name: &'a str, e: Element<'d>, ) -> impl Iterator<Item = Element<'d>> + 'd { e.children() .into_iter() .filter_map(|x| x.element()) ...
{ child_element(name, e).expect(&format!( "Element {} has no {} child!", e.name().local_part(), name )) }
identifier_body
deserialization.rs
use alias::Alias; use config::Config; use consts::*; use itertools::Itertools; use family::Family; use glib::functions; use pango::Context; use pango::ContextExt; use pango::FontMapExt; use pango::FontFamilyExt; use range::Range; use sxd_document::dom::Comment; use sxd_document::dom::ChildOfElement; use sxd_document::d...
.stripped_ranges = ranges; } matched_family } fn parse_alias<'a>(e: Element, families: &'a Vec<RefCell<Family>>) -> Alias<'a> { let alias_name = checked_text(checked_child_element("family", e)).text(); let p_list = children_element("family", checked_child_element("prefer", e)) .filter...
.collect_vec(); matched_family .unwrap() .borrow_mut() .deref_mut()
random_line_split
deserialization.rs
use alias::Alias; use config::Config; use consts::*; use itertools::Itertools; use family::Family; use glib::functions; use pango::Context; use pango::ContextExt; use pango::FontMapExt; use pango::FontFamilyExt; use range::Range; use sxd_document::dom::Comment; use sxd_document::dom::ChildOfElement; use sxd_document::d...
(context: &Context) -> Vec<RefCell<Family>> { match context.get_font_map() { Some(map) => { map.list_families() .iter() .filter_map(|x| x.get_name()) .filter(|x|!["Sans", "Serif", "Monospace"].contains(&x.as_str())) .map(|x| { ...
list_families
identifier_name
lib.rs
extern crate anduin; use anduin::logic::{Actable, lcm, Application}; use anduin::backends::vulkan; use anduin::core; use anduin::input::{InputProcessor, Key, InputType, InputEvent}; use anduin::graphics::Drawable; use anduin::audio::{music, sound, PlaybackController}; use anduin::logic::ApplicationListener; use anduin...
/*fn test_input() { match event { winit::Event::Moved(x, y) => { window.set_title(&format!("Window pos: ({:?}, {:?})", x, y)) } winit::Event::Resized(w, h) => { window.set_title(&format!("Window size: ({:?}, {:?})", w, h)) } winit::Event::Closed => { ...
random_line_split
lib.rs
extern crate anduin; use anduin::logic::{Actable, lcm, Application}; use anduin::backends::vulkan; use anduin::core; use anduin::input::{InputProcessor, Key, InputType, InputEvent}; use anduin::graphics::Drawable; use anduin::audio::{music, sound, PlaybackController}; use anduin::logic::ApplicationListener; use anduin...
; impl InputProcessor for InputProcessorStuct { fn process(&self, keyboard_event: InputEvent) { match keyboard_event.event_type { InputType::KeyDown => self.key_down(keyboard_event.key), InputType::KeyUp => self.key_up(keyboard_event.key), _ => (), } } f...
InputProcessorStuct
identifier_name
lib.rs
extern crate anduin; use anduin::logic::{Actable, lcm, Application}; use anduin::backends::vulkan; use anduin::core; use anduin::input::{InputProcessor, Key, InputType, InputEvent}; use anduin::graphics::Drawable; use anduin::audio::{music, sound, PlaybackController}; use anduin::logic::ApplicationListener; use anduin...
fn key_down(&self, key: Key) { println!("Key down {:?}", key) } fn key_up(&self, key: Key) { println!("Key up {:?}", key) } } struct Actor { } struct Image { } struct Control { } impl Actable for Actor { fn update(&self) { println!("Updating self"); } } impl Draw...
{ match keyboard_event.event_type { InputType::KeyDown => self.key_down(keyboard_event.key), InputType::KeyUp => self.key_up(keyboard_event.key), _ => (), } }
identifier_body
aarch64.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 ...
}; ret.cast_to(Uniform { unit, total: size }); return; } ret.make_indirect(); } fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>) where Ty: TyLayoutMethods<'a, C> + Copy, C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + H...
{ if !ret.layout.is_aggregate() { ret.extend_integer_width_to(32); return; } if let Some(uniform) = is_homogeneous_aggregate(cx, ret) { ret.cast_to(uniform); return; } let size = ret.layout.size; let bits = size.bits(); if bits <= 128 { let unit = if b...
identifier_body