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
cssstylerule.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::{Parser as CssParser, ParserInput as CssParserInput}; use cssparser::ToCss; use dom::bindings::code...
use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; use selectors::parser::SelectorList; use servo_arc::Arc; use std::mem; use style::selector_parser::SelectorParser; use style::shared_lock::{Locked, ToCssWithGuard}; use style::stylesheets::{StyleRule, Origin}; #[dom_struct] pub...
use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
random_line_split
cssstylerule.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::{Parser as CssParser, ParserInput as CssParserInput}; use cssparser::ToCss; use dom::bindings::code...
} }
{ // This mirrors what we do in CSSStyleOwner::mutate_associated_block. let mut guard = self.cssrule.shared_lock().write(); let stylerule = self.stylerule.write_with(&mut guard); mem::swap(&mut stylerule.selectors, &mut s); // It seems like we will want to avo...
conditional_block
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} impl Deref for ServerLoop { type Target = Server; fn deref(&self) -> &Self::Target { &self.server } } /// Setup a mock signer for tests pub fn serve() -> (ServerLoop, usize, GuardedAuthCodes) { let mut path = RandomTempPath::new(); path.panic_on_drop_failure = false; let queue = Arc::new(ConfirmationsQueue...
/// RPC Event Loop pub event_loop: RpcEventLoop,
random_line_split
mod.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
(&mut self) -> &mut AuthCodes { &mut self.authcodes } } /// Server with event loop pub struct ServerLoop { /// Signer Server pub server: Server, /// RPC Event Loop pub event_loop: RpcEventLoop, } impl Deref for ServerLoop { type Target = Server; fn deref(&self) -> &Self::Target { &self.server } } /// Se...
deref_mut
identifier_name
keyframes.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/. */ //! Keyframes: https://drafts.csswg.org/css-animations/#keyframes #![deny(missing_docs)]
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser}; use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule}; use error_reporting::NullReporter; use parser::{LengthParsingMode, ParserContext, log_css_error}; use properties::{Importance, PropertyDeclaration, PropertyDeclarationBl...
random_line_split
keyframes.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/. */ //! Keyframes: https://drafts.csswg.org/css-animations/#keyframes #![deny(missing_docs)] use cssparser::{AtRuleP...
} } fn parse_block(&mut self, prelude: Self::Prelude, input: &mut Parser) -> Result<Self::QualifiedRule, ()> { let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Keyframe)); let parser = KeyframeDeclarationParser { context: &c...
{ let message = format!("Invalid keyframe rule: '{}'", input.slice_from(start)); log_css_error(input, start, &message, self.context); Err(()) }
conditional_block
keyframes.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/. */ //! Keyframes: https://drafts.csswg.org/css-animations/#keyframes #![deny(missing_docs)] use cssparser::{AtRuleP...
{ /// The percentage of the animation duration when this step starts. pub start_percentage: KeyframePercentage, /// Declarations that will determine the final style during the step, or /// `ComputedValues` if this is an autogenerated step. pub value: KeyframesStepValue, /// Wether a animation-t...
KeyframesStep
identifier_name
mod.rs
extern crate rand; extern crate std; use self::rand::Rng; use std::fmt; #[derive(Clone,Debug)] pub struct Vector2D { pub x: f64, pub y: f64 } impl Vector2D { pub fn len(&self) -> f64 { f64::sqrt(self.x*self.x + self.y*self.y) } pub fn normal(&self) -> Vector2D { Vector...
<R: Rng>(rng: &mut R) -> Vector2D { Vector2D{ x: rng.gen::<f64>(), y: rng.gen::<f64>() } } } impl std::fmt::Display for Vector2D { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({}, {})", self.x, self.y) } }
rand
identifier_name
mod.rs
extern crate rand; extern crate std; use self::rand::Rng; use std::fmt; #[derive(Clone,Debug)] pub struct Vector2D { pub x: f64, pub y: f64 } impl Vector2D { pub fn len(&self) -> f64 { f64::sqrt(self.x*self.x + self.y*self.y) } pub fn normal(&self) -> Vector2D {
} pub fn normalized(&self) -> Vector2D { let mut v = self.clone(); v.normalize(); v } pub fn normalize(&mut self) { let l = self.len(); self.x /= l; self.y /= l; } pub fn scale(&mut self, s: f64) { self.x *= s; self....
Vector2D { x:-self.y, y:self.x }
random_line_split
generic-impl-less-params-with-defaults.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 ...
{ Foo::<int>::new(); //~^ ERROR the impl referenced by this path needs at least 2 type parameters, // but 1 was supplied //~^^^ ERROR not enough type parameters provided: expected at least 2, found 1 }
identifier_body
generic-impl-less-params-with-defaults.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 ...
<A, B, C = (A, B)>; impl<A, B, C = (A, B)> Foo<A, B, C> { fn new() -> Foo<A, B, C> {Foo} } fn main() { Foo::<int>::new(); //~^ ERROR the impl referenced by this path needs at least 2 type parameters, // but 1 was supplied //~^^^ ERROR not enough type parameters provided: expected at least ...
Foo
identifier_name
generic-impl-less-params-with-defaults.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 ...
struct Foo<A, B, C = (A, B)>; impl<A, B, C = (A, B)> Foo<A, B, C> { fn new() -> Foo<A, B, C> {Foo} } fn main() { Foo::<int>::new(); //~^ ERROR the impl referenced by this path needs at least 2 type parameters, // but 1 was supplied //~^^^ ERROR not enough type parameters provided: expected...
// except according to those terms. #![feature(default_type_params)]
random_line_split
land_stack.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::BTreeMap; use std::io::Write; use anyhow::{anyhow, bail, Error, Result}; use clap::{App, AppSettings, Arg, ArgMatche...
let bookmark: String = matches.value_of(ARG_NAME).expect("name is required").into(); let service_identity = get_service_id(matches).map(String::from); let pushvars = get_pushvars(&matches)?; let (head, base) = match ids.as_slice() { [head_id, base_id] => (head_id.clone(), base_id.clone()), ...
let commit_ids = get_commit_ids(matches)?; if commit_ids.len() != 2 { bail!("expected 2 commit_ids (got {})", commit_ids.len()) } let ids = resolve_commit_ids(&connection, &repo, &commit_ids).await?;
random_line_split
land_stack.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::BTreeMap; use std::io::Write; use anyhow::{anyhow, bail, Error, Result}; use clap::{App, AppSettings, Arg, ArgMatche...
} pub(super) async fn run(matches: &ArgMatches<'_>, connection: Connection) -> Result<RenderStream> { let repo = get_repo_specifier(matches).expect("repository is required"); let commit_ids = get_commit_ids(matches)?; if commit_ids.len()!= 2 { bail!("expected 2 commit_ids (got {})", commit_ids.len...
{ Ok(serde_json::to_writer(w, self)?) }
identifier_body
land_stack.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::BTreeMap; use std::io::Write; use anyhow::{anyhow, bail, Error, Result}; use clap::{App, AppSettings, Arg, ArgMatche...
(&self, _matches: &ArgMatches, w: &mut dyn Write) -> Result<(), Error> { Ok(serde_json::to_writer(w, self)?) } } pub(super) async fn run(matches: &ArgMatches<'_>, connection: Connection) -> Result<RenderStream> { let repo = get_repo_specifier(matches).expect("repository is required"); let commit_id...
render_json
identifier_name
mod.rs
//! Module defining gist hosts. //! //! A host is an external (web) service that hosts gists, and allows users to paste snippets //! of code to share with others. gist.github.com is a prime example; others are the various //! "pastebins", including the pastebin.com namesake. mod common; mod github; mod bpaste; mod co...
() { for (&id, host) in &*HOSTS { assert_eq!(id, host.id()); } } #[test] fn default_host_id() { assert!(HOSTS.contains_key(DEFAULT_HOST_ID), "Default host ID `{}` doesn't occur among known gist hosts", DEFAULT_HOST_ID); } #[test] fn inmemory_host...
consistent_hosts
identifier_name
mod.rs
//! Module defining gist hosts. //! //! A host is an external (web) service that hosts gists, and allows users to paste snippets //! of code to share with others. gist.github.com is a prime example; others are the various //! "pastebins", including the pastebin.com namesake. mod common; mod github; mod bpaste; mod co...
fn fetch_gist(&self, gist: &Gist, mode: FetchMode) -> io::Result<()> { (&**self).fetch_gist(gist, mode) } fn gist_url(&self, gist: &Gist) -> io::Result<String> { (&**self).gist_url(gist) } fn gist_info(&self, gist: &Gist) -> io::Result<Option<gist::Info>> { (&**self).gist_i...
{ (&**self).name() }
identifier_body
mod.rs
//! Module defining gist hosts. //! //! A host is an external (web) service that hosts gists, and allows users to paste snippets //! of code to share with others. gist.github.com is a prime example; others are the various //! "pastebins", including the pastebin.com namesake. mod common; mod github; mod bpaste; mod co...
mozilla::ID => Arc::new(mozilla::create()) as Arc<Host>, paste_rs::ID => Arc::new(paste_rs::create()) as Arc<Host>, hastebin::ID => Arc::new(hastebin::Hastebin::new()) as Arc<Host>, mibpaste::ID => Arc::new(mibpaste::create()) as Arc<Host>, sprunge::ID => Arc::new(sprunge::Sprung...
heypasteit::ID => Arc::new(heypasteit::create()) as Arc<Host>, bpaste::ID => Arc::new(bpaste::create()) as Arc<Host>,
random_line_split
rotation_construction.rs
use num::{One, Zero}; use simba::scalar::{ClosedAdd, ClosedMul}; use crate::base::allocator::Allocator; use crate::base::dimension::DimName; use crate::base::{DefaultAllocator, MatrixN, Scalar}; use crate::geometry::Rotation; impl<N, D: DimName> Rotation<N, D> where N: Scalar + Zero + One, DefaultAllocator:...
() -> Self { Self::identity() } }
one
identifier_name
rotation_construction.rs
use num::{One, Zero}; use simba::scalar::{ClosedAdd, ClosedMul}; use crate::base::allocator::Allocator; use crate::base::dimension::DimName; use crate::base::{DefaultAllocator, MatrixN, Scalar};
impl<N, D: DimName> Rotation<N, D> where N: Scalar + Zero + One, DefaultAllocator: Allocator<N, D, D>, { /// Creates a new square identity rotation of the given `dimension`. /// /// # Example /// ``` /// # use nalgebra::Quaternion; /// let rot1 = Quaternion::identity(); /// let rot2...
use crate::geometry::Rotation;
random_line_split
rotation_construction.rs
use num::{One, Zero}; use simba::scalar::{ClosedAdd, ClosedMul}; use crate::base::allocator::Allocator; use crate::base::dimension::DimName; use crate::base::{DefaultAllocator, MatrixN, Scalar}; use crate::geometry::Rotation; impl<N, D: DimName> Rotation<N, D> where N: Scalar + Zero + One, DefaultAllocator:...
}
{ Self::identity() }
identifier_body
json2mod.rs
use std::fs::File; use std::io::BufWriter; use std::io::BufReader; use anyhow::{Context, Result, anyhow}; // Command line use docopt::Docopt; // JSON use serde::Deserialize; // ProTracker and ThePlayer use modfile::ptmf; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); static USAGE: &'static str = " json2mod...
-h, --help Show this text. <source> Input file. <destination> Output file. "; #[derive(Debug, Deserialize)] struct Args { arg_source: String, arg_destination: String, flag_help: bool, flag_version: bool, } fn main() -> Result<()> { let args: Args = Docopt:...
Options: -V, --version Show version info.
random_line_split
json2mod.rs
use std::fs::File; use std::io::BufWriter; use std::io::BufReader; use anyhow::{Context, Result, anyhow}; // Command line use docopt::Docopt; // JSON use serde::Deserialize; // ProTracker and ThePlayer use modfile::ptmf; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); static USAGE: &'static str = " json2mod...
{ arg_source: String, arg_destination: String, flag_help: bool, flag_version: bool, } fn main() -> Result<()> { let args: Args = Docopt::new(USAGE) .and_then(|d| d.deserialize()) .unwrap_or_else(|e| e.exit()); if args.flag_version { println!(...
Args
identifier_name
mod.rs
extern crate std; use std::sync::{ Arc, Future, Mutex }; use std::rc::Rc; use threaded_executer::CommandsThread; use std::string::String; #[allow(dead_code)] mod libglfw3; mod window; pub struct GLContext { window: Mutex<window::Window> } impl GLContext { pub fn new(width: uint, height: uint, title: &str) -> GLCo...
pub fn exec<T:Send>(&self, f: proc(): Send -> T) -> Future<T> { let mut lock = self.window.lock(); lock.exec(f) } pub fn swap_buffers(&self) { let mut lock = self.window.lock(); lock.swap_buffers() } }
lock.recv() }
random_line_split
mod.rs
extern crate std; use std::sync::{ Arc, Future, Mutex }; use std::rc::Rc; use threaded_executer::CommandsThread; use std::string::String; #[allow(dead_code)] mod libglfw3; mod window; pub struct GLContext { window: Mutex<window::Window> } impl GLContext { pub fn new(width: uint, height: uint, title: &str) -> GLCo...
pub fn exec<T:Send>(&self, f: proc(): Send -> T) -> Future<T> { let mut lock = self.window.lock(); lock.exec(f) } pub fn swap_buffers(&self) { let mut lock = self.window.lock(); lock.swap_buffers() } }
{ let mut lock = self.window.lock(); lock.recv() }
identifier_body
mod.rs
extern crate std; use std::sync::{ Arc, Future, Mutex }; use std::rc::Rc; use threaded_executer::CommandsThread; use std::string::String; #[allow(dead_code)] mod libglfw3; mod window; pub struct GLContext { window: Mutex<window::Window> } impl GLContext { pub fn new(width: uint, height: uint, title: &str) -> GLCo...
(&self) { let mut lock = self.window.lock(); lock.swap_buffers() } }
swap_buffers
identifier_name
imgui_demo.rs
extern crate glutin; extern crate gl; extern crate time; #[macro_use] extern crate rust_imgui; use rust_imgui as imgui; pub fn imgui_example_draw() { let mut opened = true; imgui::begin(imstr!("Not A Window"), &mut opened, imgui::ImGuiWindowFlags_None); imgui::text(imstr!("Hello World")); imgui::text(imstr!("Appli...
(state: &DemoGLState, draw_data: &mut imgui::ImDrawData) { use std::mem; let io = imgui::get_io(); let fb_width = io.display_size.x * io.display_framebuffer_scale.x; let fb_height = io.display_size.y * io.display_framebuffer_scale.y; if fb_width == 0.0 || fb_height == 0.0 { return; } // draw_data.scale_clip_rect...
imgui_render_draw_lists
identifier_name
imgui_demo.rs
extern crate glutin; extern crate gl; extern crate time; #[macro_use] extern crate rust_imgui; use rust_imgui as imgui; pub fn imgui_example_draw() { let mut opened = true; imgui::begin(imstr!("Not A Window"), &mut opened, imgui::ImGuiWindowFlags_None); imgui::text(imstr!("Hello World")); imgui::text(imstr!("Appli...
pub fn imgui_new_frame(state: &mut DemoGLState, window_size: (u32, u32), hidpi_factor: f32) { if state.font_texture == 0 { unsafe { imgui_create_device_objects(state) }; } let io = imgui::get_io(); let (w, h) = window_size; let hidpi_factor = hidpi_factor; io.display_size = imgui::vec2(w as f32, h as f32);...
{ for i in 0..draw_data.cmd_lists_count { let cmd_list = unsafe { (*draw_data.cmd_lists.offset(i as isize)).as_mut() .expect("Indexing CMD list in placeholder_scale_clip_rects") }; for cmd_i in 0..cmd_list.cmd_buffer.size { let imgui::ImVec4 {x, y, z, w} = cmd_list.cmd_buffer[cmd_i as usize].clip_rect;...
identifier_body
imgui_demo.rs
extern crate glutin; extern crate gl; extern crate time; #[macro_use] extern crate rust_imgui; use rust_imgui as imgui; pub fn imgui_example_draw() { let mut opened = true; imgui::begin(imstr!("Not A Window"), &mut opened, imgui::ImGuiWindowFlags_None); imgui::text(imstr!("Hello World")); imgui::text(imstr!("Appli...
} imgui::shutdown(); } // You can also use a callback by wrapping imgui_render_draw_lists // in an extern C function. pub fn imgui_render(state: &DemoGLState) { imgui::render(); let draw_data = imgui::get_draw_data().expect("null imgui draw data."); unsafe { imgui_render_draw_lists(state, draw_data) }; } pub fn...
{ use std::ptr; gl::DeleteTextures(1, &state.font_texture); imgui::get_io().fonts.tex_id = ptr::null_mut(); state.font_texture = 0; }
conditional_block
imgui_demo.rs
extern crate glutin; extern crate gl; extern crate time; #[macro_use] extern crate rust_imgui; use rust_imgui as imgui; pub fn imgui_example_draw() { let mut opened = true; imgui::begin(imstr!("Not A Window"), &mut opened, imgui::ImGuiWindowFlags_None); imgui::text(imstr!("Hello World")); imgui::text(imstr!("Appli...
else { gl::Disable(gl::CULL_FACE) } if last_enable_depth_test!= 0 { gl::Enable(gl::DEPTH_TEST); } else { gl::Disable(gl::DEPTH_TEST); } if last_enable_scissor_test!= 0 { gl::Enable(gl::SCISSOR_TEST); } else { gl::Disable(gl::SCISSOR_TEST); } gl::Viewport(last_viewport[0], last_viewport[1], last_viewport[2], la...
random_line_split
geometry.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 geom::length::Length; use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::defaul...
} #[inline] pub fn max(x: Au, y: Au) -> Au { if x > y { x } else { y } } impl NumCast for Au { #[inline] fn from<T:ToPrimitive>(n: T) -> Option<Au> { Some(Au(n.to_i32().unwrap())) } } impl ToPrimitive for Au { #[inline] fn to_i64(&self) -> Option<i64> { let Au(s) = *self; ...
{ y }
conditional_block
geometry.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 geom::length::Length; use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::defaul...
impl Mul<Au,Au> for Au { #[inline] fn mul(&self, other: &Au) -> Au { let Au(s) = *self; let Au(o) = *other; Au(s * o) } } impl Div<Au,Au> for Au { #[inline] fn div(&self, other: &Au) -> Au { let Au(s) = *self; let Au(o) = *other; Au(s / o) } } im...
Au(s - o) } }
random_line_split
geometry.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 geom::length::Length; use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::defaul...
} impl Sub<Au,Au> for Au { #[inline] fn sub(&self, other: &Au) -> Au { let Au(s) = *self; let Au(o) = *other; Au(s - o) } } impl Mul<Au,Au> for Au { #[inline] fn mul(&self, other: &Au) -> Au { let Au(s) = *self; let Au(o) = *other; Au(s * o) } ...
{ let Au(s) = *self; let Au(o) = *other; Au(s + o) }
identifier_body
geometry.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 geom::length::Length; use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::defaul...
(&self) -> int { let Au(s) = *self; ((s as f64) / 60f64).round() as int } #[inline] pub fn to_snapped(&self) -> Au { let Au(s) = *self; let res = s % 60i32; return if res >= 30i32 { return Au(s - res + 60i32) } else { return Au(s - res) }; ...
to_nearest_px
identifier_name
option.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 ...
#[test] fn test_get_resource() { use std::rc::Rc; use core::cell::RefCell; struct R { i: Rc<RefCell<int>>, } #[unsafe_destructor] impl Drop for R { fn drop(&mut self) { let ii = &*self.i; let i = *ii.borrow(); *ii.borrow_mut() = i + 1; ...
{ let x = "test".to_string(); let addr_x = x.as_ptr(); let opt = Some(x); let y = opt.unwrap(); let addr_y = y.as_ptr(); assert_eq!(addr_x, addr_y); }
identifier_body
option.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 ...
{ i: Rc<RefCell<int>>, } #[unsafe_destructor] impl Drop for R { fn drop(&mut self) { let ii = &*self.i; let i = *ii.borrow(); *ii.borrow_mut() = i + 1; } } fn r(i: Rc<RefCell<int>>) -> R { R { i: i } } ...
R
identifier_name
option.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 ...
// test that it does not take more elements than it needs let mut functions: [Box<Fn() -> Option<()>>; 3] = [box || Some(()), box || None, box || panic!()]; let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == None); } */ #[test] fn test_cloned() { let val...
if x > 1 { None } else { Some(x) } }).collect(); assert!(v == None);
random_line_split
htmlimageelement.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::attr::Attr; use dom::attr::{AttrHelpers, AttrValue}; use dom::bindings::cell::DOMRefCell; use dom::bindin...
Ok(image) } } pub trait LayoutHTMLImageElementHelpers { #[allow(unsafe_code)] unsafe fn image(&self) -> Option<Arc<Image>>; #[allow(unsafe_code)] unsafe fn image_url(&self) -> Option<Url>; } impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> { #[allow(unsafe_code)] ...
{ image.SetHeight(h); }
conditional_block
htmlimageelement.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::attr::Attr; use dom::attr::{AttrHelpers, AttrValue}; use dom::bindings::cell::DOMRefCell; use dom::bindin...
(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> Root<HTMLImageElement> { let element = HTMLImageElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLImageElementBinding::Wrap) } pub fn Image(gl...
new
identifier_name
htmlimageelement.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::attr::Attr; use dom::attr::{AttrHelpers, AttrValue}; use dom::bindings::cell::DOMRefCell; use dom::bindin...
ROUTER.add_route(responder_receiver.to_opaque(), box move |message| { // Return the image via a message to the script task, which marks the element // as dirty and triggers a reflow. let image_response = message.to().unwrap(); ...
random_line_split
os_str.rs
// Copyright 2017 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 ...
#[inline] pub fn into_arc(&self) -> Arc<Slice> { let arc: Arc<[u8]> = Arc::from(&self.inner); unsafe { Arc::from_raw(Arc::into_raw(arc) as *const Slice) } } #[inline] pub fn into_rc(&self) -> Rc<Slice> { let rc: Rc<[u8]> = Rc::from(&self.inner); unsafe { Rc::from_r...
{ let boxed: Box<[u8]> = Default::default(); unsafe { mem::transmute(boxed) } }
identifier_body
os_str.rs
// Copyright 2017 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 to_str(&self) -> Option<&str> { str::from_utf8(&self.inner).ok() } pub fn to_string_lossy(&self) -> Cow<str> { String::from_utf8_lossy(&self.inner) } pub fn to_owned(&self) -> Buf { Buf { inner: self.inner.to_vec() } } #[inline] pub fn into_box(&self) -...
}
random_line_split
os_str.rs
// Copyright 2017 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 ...
(capacity: usize) -> Buf { Buf { inner: Vec::with_capacity(capacity) } } #[inline] pub fn clear(&mut self) { self.inner.clear() } #[inline] pub fn capacity(&self) -> usize { self.inner.capacity() } #[inline] pub fn reserve(&mut self, add...
with_capacity
identifier_name
i_renderobj.rs
extern crate mazth; use std::collections::HashMap; use self::mazth::mat::{ Mat4, Mat3x1 }; use implement::render::renderdevice_gl::RenderUniformCollection; pub trait Xform { fn get_xform() -> Mat4< f32 >; } pub trait ObjPos { fn get_pos( & self ) -> Mat3x1< f32 >; } #[derive(Debug)] #[derive(Clone)] #[deri...
{ ADS, PBR, NONE, } pub trait IRenderable : IRenderBuffer { fn get_render_method( & self ) -> RenderMethod; } pub trait IRenderUniform { fn load_into_uniform( & mut self, uniforms: & mut RenderUniformCollection ) -> Result< (), &'static str >; }
RenderMethod
identifier_name
i_renderobj.rs
extern crate mazth; use std::collections::HashMap; use self::mazth::mat::{ Mat4, Mat3x1 }; use implement::render::renderdevice_gl::RenderUniformCollection; pub trait Xform { fn get_xform() -> Mat4< f32 >; } pub trait ObjPos { fn get_pos( & self ) -> Mat3x1< f32 >;
#[derive(Debug)] #[derive(Clone)] #[derive(Copy)] pub enum RenderObjType { TRI, //todo QUAD, POINT, LINE, } #[derive(Debug)] #[derive(Clone)] #[derive(Copy)] #[derive(Eq)] #[derive(Hash)] #[derive(PartialEq)] pub enum BuffDataType { POS, NORMAL, TC, } pub trait RenderDevice { fn b...
}
random_line_split
cast-rfc0401-vtable-kinds.rs
// Check that you can cast between different pointers to trait objects // whose vtable have the same kind (both lengths, or both trait pointers). trait Foo<T> { fn foo(&self, _: T) -> u32 { 42 } } trait Bar { fn
(&self) { println!("Bar!"); } } impl<T> Foo<T> for () {} impl Foo<u32> for u32 { fn foo(&self, _: u32) -> u32 { self+43 } } impl Bar for () {} unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo<u32>+'a)) -> u32 { let foo_e : *const dyn Foo<u16> = t as *const _; let r_1 = foo_e as *mut dyn Foo<u32>; (&*...
bar
identifier_name
cast-rfc0401-vtable-kinds.rs
// Check that you can cast between different pointers to trait objects // whose vtable have the same kind (both lengths, or both trait pointers). trait Foo<T> { fn foo(&self, _: T) -> u32 { 42 } } trait Bar { fn bar(&self) { println!("Bar!"); } } impl<T> Foo<T> for () {} impl Foo<u32> for u32 { fn foo(&self,...
} fn main() { let x = 4u32; let y : &dyn Foo<u32> = &x; let fl = unsafe { round_trip_and_call(y as *const dyn Foo<u32>) }; assert_eq!(fl, (43+4)); let s = FooS([0,1,2]); let u: &FooS<[u32]> = &s; let u: *const FooS<[u32]> = u; let bar_ref : *const BarS<[u32]> = foo_to_bar(u); let z...
u as *const BarS<T>
random_line_split
issue-17718-const-borrow.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 ...
{ a: UnsafeCell<usize> } const D: C = C { a: UnsafeCell::new(1) }; const E: &'static UnsafeCell<usize> = &D.a; //~^ ERROR: cannot borrow a constant which may contain interior mutability const F: &'static C = &D; //~^ ERROR: cannot borrow a constant which may contain interior mutability fn main() {}
C
identifier_name
issue-17718-const-borrow.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// 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. use std::cell::UnsafeCell; const A: UnsafeCell<usize> = UnsafeCell::new(1); const B: &'...
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
json_codegen_test.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @generated SignedSource<<60c1b1263e2d35528792da979dcebe3f>> */ mod json_codegen; use json_codegen::transform_fixture; use fixtu...
#[test] fn stable_literals() { let input = include_str!("json_codegen/fixtures/stable-literals.graphql"); let expected = include_str!("json_codegen/fixtures/stable-literals.expected"); test_fixture(transform_fixture, "stable-literals.graphql", "json_codegen/fixtures/stable-literals.expected", input, expec...
{ let input = include_str!("json_codegen/fixtures/kitchen-sink.graphql"); let expected = include_str!("json_codegen/fixtures/kitchen-sink.expected"); test_fixture(transform_fixture, "kitchen-sink.graphql", "json_codegen/fixtures/kitchen-sink.expected", input, expected); }
identifier_body
json_codegen_test.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @generated SignedSource<<60c1b1263e2d35528792da979dcebe3f>> */ mod json_codegen;
fn kitchen_sink() { let input = include_str!("json_codegen/fixtures/kitchen-sink.graphql"); let expected = include_str!("json_codegen/fixtures/kitchen-sink.expected"); test_fixture(transform_fixture, "kitchen-sink.graphql", "json_codegen/fixtures/kitchen-sink.expected", input, expected); } #[test] fn stabl...
use json_codegen::transform_fixture; use fixture_tests::test_fixture; #[test]
random_line_split
json_codegen_test.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @generated SignedSource<<60c1b1263e2d35528792da979dcebe3f>> */ mod json_codegen; use json_codegen::transform_fixture; use fixtu...
() { let input = include_str!("json_codegen/fixtures/stable-literals.graphql"); let expected = include_str!("json_codegen/fixtures/stable-literals.expected"); test_fixture(transform_fixture, "stable-literals.graphql", "json_codegen/fixtures/stable-literals.expected", input, expected); }
stable_literals
identifier_name
print.rs
fn main() { // In general, the `{}` will be automatically replaced with any // arguments. These will be stringified. println!("{} days", 31); // Without a suffix, 31 becomes an i32. You can change what type 31 is, // with a suffix. // There are various optional patterns this works with. Positi...
// Special formatting can be specified after a `:`. println!("{} of {:b} people know binary, the other half don't", 1, 2); // You can right-align text with a specified width. This will output // " 1". 5 white spaces and a "1". println!("{number:>width$}", number=1, width=6); // You can pad...
subject="the quick brown fox", verb="jumps over");
random_line_split
print.rs
fn main() { // In general, the `{}` will be automatically replaced with any // arguments. These will be stringified. println!("{} days", 31); // Without a suffix, 31 becomes an i32. You can change what type 31 is, // with a suffix. // There are various optional patterns this works with. Positi...
(i32); // However, custom types such as this structure require more complicated // handling. This will not work. println!("This struct `{}` won't print...", Structure(3)); // FIXME ^ Comment out this line. }
Structure
identifier_name
print.rs
fn main()
// You can right-align text with a specified width. This will output // " 1". 5 white spaces and a "1". println!("{number:>width$}", number=1, width=6); // You can pad numbers with extra zeroes. This will output "000001". println!("{number:>0width$}", number=1, width=6); // It will even c...
{ // In general, the `{}` will be automatically replaced with any // arguments. These will be stringified. println!("{} days", 31); // Without a suffix, 31 becomes an i32. You can change what type 31 is, // with a suffix. // There are various optional patterns this works with. Positional /...
identifier_body
build.rs
extern crate gcc; use std::fs; use std::io; use std::env; use std::path::{Path, PathBuf}; use std::process::Command; use std::ffi::OsString; trait CommandExt { fn execute(&mut self) -> io::Result<()>; } impl CommandExt for Command { /// Execute the command and return an error if it exited with a failure stat...
if!build_dir.join("liblua.a").exists() { let tooling = config.get_compiler(); try!(fs::create_dir_all(&build_dir)); try!(build_lua(&tooling, &lua_dir, &build_dir)); } println!("cargo:rustc-link-search=native={}", build_dir.display()); } // Ensure the ...
{ let lua_dir = match env::var_os("LUA_LOCAL_SOURCE") { // If LUA_LOCAL_SOURCE is set, use it Some(dir) => PathBuf::from(dir), // Otherwise, pull from lua-source/src in the crate root None => { let mut dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); ...
identifier_body
build.rs
extern crate gcc; use std::fs; use std::io; use std::env; use std::path::{Path, PathBuf}; use std::process::Command; use std::ffi::OsString; trait CommandExt { fn execute(&mut self) -> io::Result<()>; } impl CommandExt for Command { /// Execute the command and return an error if it exited with a failure stat...
Err(io::Error::new(io::ErrorKind::Other, format!("The command\n\ \t{:?}\n\ did not run successfully.", self))) } } } /// The command to build lua, with switches for different OSes. fn build_lua(tooling: &gcc::Tool, source: &Path, build: &Path) -> io::Result<()> { // ...
} else {
random_line_split
build.rs
extern crate gcc; use std::fs; use std::io; use std::env; use std::path::{Path, PathBuf}; use std::process::Command; use std::ffi::OsString; trait CommandExt { fn execute(&mut self) -> io::Result<()>; } impl CommandExt for Command { /// Execute the command and return an error if it exited with a failure stat...
(tooling: &gcc::Tool, source: &Path, build: &Path) -> io::Result<()> { // calculate the Lua platform name let platform = match env::var("TARGET").unwrap().split('-').nth(2).unwrap() { "windows" => "mingw", "macos" => "macosx", "linux" => "linux", "freebsd" => "freebsd", "...
build_lua
identifier_name
xz.rs
/* * Copyright (c) 2017 Jean Guyomarc'h * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, pub...
* extension) of in_file */ let mut output = out_dir.to_path_buf(); match in_file.file_name() { Some(os_str) => { output.push(os_str); }, None => { return Err(unpacker::PathError); } } output.set_extension(""); let mut cmd = subprocess::new("xz...
std::fs::create_dir_all(out_dir)?; } /* We will write a single file in out_dir with the basename (without
random_line_split
xz.rs
/* * Copyright (c) 2017 Jean Guyomarc'h * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, pub...
() -> &'static str { "xz" }
name_get
identifier_name
xz.rs
/* * Copyright (c) 2017 Jean Guyomarc'h * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, pub...
}; /* Create the output directory if it does not exist */ if! out_dir.exists() { std::fs::create_dir_all(out_dir)?; } /* We will write a single file in out_dir with the basename (without * extension) of in_file */ let mut output = out_dir.to_path_buf(); match...
{ return Err(unpacker::PathError); }
conditional_block
canvas_util.rs
use std::convert::{Into}; use super::canvas::{Canvas, Image, FONT_W}; use super::{WidgetId}; use ::{V2, Rect, color, Rgba}; use ::Anchor::*; /// Helper methods for canvas context that do not depend on the underlying /// implementation details. pub trait CanvasUtil { /// Draw a thick solid line on the canvas. f...
self.push_vertex(p1 + v2 + v1, layer, tex, color, color::BLACK); self.push_triangle(ind0, ind0 + 1, ind0 + 2); self.push_triangle(ind0, ind0 + 2, ind0 + 3); self.flush(); } fn image_dim(&self, img: Image) -> V2<u32> { self.image_data(img).pos.1.map(|x| x as u32) } ...
{ if p1 == p2 { return; } let tex = self.solid_tex_coord(); // The front vector. Extend by width. let v1 = p2 - p1; let scalar = v1.dot(v1); let scalar = (scalar + width * width) / scalar; let v1 = v1 * scalar; // The sideways vector, turn into unit vec...
identifier_body
canvas_util.rs
use std::convert::{Into}; use super::canvas::{Canvas, Image, FONT_W}; use super::{WidgetId}; use ::{V2, Rect, color, Rgba}; use ::Anchor::*; /// Helper methods for canvas context that do not depend on the underlying /// implementation details. pub trait CanvasUtil { /// Draw a thick solid line on the canvas. f...
// Default if we fail to generate any of the 100 candidates for this // second, just overwrite with the "xx" prefix then. let mut filename = format!("{}-{}{}.png", basename, timestamp, "xx"); // Run through candidates for this second. for i in 0..100 { let test_filen...
let timestamp = time::precise_time_s() as u64; // Create screenshot filenames by concatenating the current timestamp in // seconds with a running number from 00 to 99. 100 shots per second // should be good enough.
random_line_split
canvas_util.rs
use std::convert::{Into}; use super::canvas::{Canvas, Image, FONT_W}; use super::{WidgetId}; use ::{V2, Rect, color, Rgba}; use ::Anchor::*; /// Helper methods for canvas context that do not depend on the underlying /// implementation details. pub trait CanvasUtil { /// Draw a thick solid line on the canvas. f...
} let _ = image::save_buffer(&Path::new(&filename), &shot, shot.width(), shot.height(), image::ColorType::RGB(8)); } }
{ // Thread-safe claiming: create_dir will fail if the dir // already exists (it'll exist if another thread is gunning // for the same filename and managed to get past us here). // At least assuming that create_dir is atomic... let squat_di...
conditional_block
canvas_util.rs
use std::convert::{Into}; use super::canvas::{Canvas, Image, FONT_W}; use super::{WidgetId}; use ::{V2, Rect, color, Rgba}; use ::Anchor::*; /// Helper methods for canvas context that do not depend on the underlying /// implementation details. pub trait CanvasUtil { /// Draw a thick solid line on the canvas. f...
<C: Into<Rgba>+Copy>(&mut self, width: f32, p1: V2<f32>, p2: V2<f32>, layer: f32, color: C) { if p1 == p2 { return; } let tex = self.solid_tex_coord(); // The front vector. Extend by width. let v1 = p2 - p1; let scalar = v1.dot(v1); let scalar = (scalar + width * width)...
draw_line
identifier_name
service.rs
// This file is generated. Do not edit // @generated #![allow(dead_code)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(unused_imports)] use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; #...
(&self) -> u32 { self.cached_size.get() } fn get_unknown_fields<'s>(&'s self) -> &'s ::protobuf::UnknownFields { &self.unknown_fields } fn mut_unknown_fields<'s>(&'s mut self) -> &'s mut ::protobuf::UnknownFields { &mut self.unknown_fields } fn type_id(&self) -> ::std:...
get_cached_size
identifier_name
service.rs
// This file is generated. Do not edit // @generated #![allow(dead_code)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(unused_imports)] use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; #...
pub fn get_name<'a>(&'a self) -> &'a str { match self.name.as_ref() { Some(v) => &v, None => "", } } } impl ::protobuf::Message for Service { fn is_initialized(&self) -> bool { true } fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -...
random_line_split
service.rs
// This file is generated. Do not edit // @generated #![allow(dead_code)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(unused_imports)] use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; #...
fn descriptor_static(_: ::std::option::Option<Service>) -> &'static ::protobuf::reflect::MessageDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protob...
{ Service::new() }
identifier_body
htmlbrelement.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::HTMLBRElementBinding; use dom::bindings::codegen::InheritTypes::HTMLBRElemen...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLBRElement> { let element = HTMLBRElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLBRElementBinding::Wrap) }...
{ HTMLBRElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLBRElement, localName, prefix, document) } }
identifier_body
htmlbrelement.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::HTMLBRElementBinding; use dom::bindings::codegen::InheritTypes::HTMLBRElemen...
(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLBRElement { HTMLBRElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLBRElement, localName, prefix, document) } } #[allow(unrooted_must_root)] pub fn new(localName: DOMString...
new_inherited
identifier_name
htmlbrelement.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::HTMLBRElementBinding; use dom::bindings::codegen::InheritTypes::HTMLBRElemen...
Node::reflect_node(box element, document, HTMLBRElementBinding::Wrap) } }
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLBRElement> { let element = HTMLBRElement::new_inherited(localName, prefix, document);
random_line_split
cci_class_cast.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 ...
} impl cat { pub fn speak(&mut self) { self.meow(); } pub fn eat(&mut self) -> bool { if self.how_hungry > 0 { println!("OM NOM NOM"); self.how_hungry -= 2; return true; } else { println!("Not...
{ println!("Meow"); self.meows += 1_usize; if self.meows % 5_usize == 0_usize { self.how_hungry += 1; } }
identifier_body
cci_class_cast.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 ...
} } impl cat { fn meow(&mut self) { println!("Meow"); self.meows += 1_usize; if self.meows % 5_usize == 0_usize { self.how_hungry += 1; } } } impl cat { pub fn speak(&mut self) { self.meow(); } pu...
} impl fmt::String for cat { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.name)
random_line_split
cci_class_cast.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 { println!("Not hungry!"); return false; } } } pub fn cat(in_x : uint, in_y : int, in_name: String) -> cat { cat { meows: in_x, how_hungry: in_y, name: in_name } } }
{ println!("OM NOM NOM"); self.how_hungry -= 2; return true; }
conditional_block
cci_class_cast.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 ...
(&mut self) -> bool { if self.how_hungry > 0 { println!("OM NOM NOM"); self.how_hungry -= 2; return true; } else { println!("Not hungry!"); return false; } } } pub fn cat(in_x...
eat
identifier_name
driver.rs
extern crate cleaver; use cleaver::fe; use cleaver::diag; extern crate clap; use clap::{App, Arg}; extern crate time; use time::PreciseTime; use std::path::Path; use std::process::exit; fn main() { // commandline arguments let arguments = App::new("Cleaver") .about("Cleaver is a toy / research compil...
fe::check_with_diag(&functions, &config).unwrap(); let end = PreciseTime::now(); if arguments.is_present("timings") { println!("Frontend time: {}", start.to(end)); } // TODO error hanlding }
// run frontend let start = PreciseTime::now(); let functions = fe::parse_with_diag(&inputs, &config).unwrap();
random_line_split
driver.rs
extern crate cleaver; use cleaver::fe; use cleaver::diag; extern crate clap; use clap::{App, Arg}; extern crate time; use time::PreciseTime; use std::path::Path; use std::process::exit; fn main()
} else { None }; // list of input files let inputs: Vec<_> = arguments.values_of("input").unwrap().map(Path::new).collect(); // run frontend let start = PreciseTime::now(); let functions = fe::parse_with_diag(&inputs, &config).unwrap(); fe::check_with_diag(&functions, &config)....
{ // commandline arguments let arguments = App::new("Cleaver") .about("Cleaver is a toy / research compiler, it takes .gib files as input.") .version("0.1") .author("Alex Hirsch <W4RH4WK@bluephoenix.at>") .arg(Arg::with_name("diagnostics") .short("d") .hel...
identifier_body
driver.rs
extern crate cleaver; use cleaver::fe; use cleaver::diag; extern crate clap; use clap::{App, Arg}; extern crate time; use time::PreciseTime; use std::path::Path; use std::process::exit; fn
() { // commandline arguments let arguments = App::new("Cleaver") .about("Cleaver is a toy / research compiler, it takes.gib files as input.") .version("0.1") .author("Alex Hirsch <W4RH4WK@bluephoenix.at>") .arg(Arg::with_name("diagnostics") .short("d") .help("c...
main
identifier_name
driver.rs
extern crate cleaver; use cleaver::fe; use cleaver::diag; extern crate clap; use clap::{App, Arg}; extern crate time; use time::PreciseTime; use std::path::Path; use std::process::exit; fn main() { // commandline arguments let arguments = App::new("Cleaver") .about("Cleaver is a toy / research compil...
; // list of input files let inputs: Vec<_> = arguments.values_of("input").unwrap().map(Path::new).collect(); // run frontend let start = PreciseTime::now(); let functions = fe::parse_with_diag(&inputs, &config).unwrap(); fe::check_with_diag(&functions, &config).unwrap(); let end = Precise...
{ None }
conditional_block
poison.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 ...
} #[stable(feature = "rust1", since = "1.0.0")] impl<T: Send + Reflect> fmt::Display for TryLockError<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.description().fmt(f) } } impl<T: Send + Reflect> Error for TryLockError<T> { fn description(&self) -> &str { match *self { ...
TryLockError::WouldBlock => "WouldBlock".fmt(f) } }
random_line_split
poison.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 ...
} #[stable(feature = "rust1", since = "1.0.0")] impl<T: Send + Reflect> fmt::Display for TryLockError<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.description().fmt(f) } } impl<T: Send + Reflect> Error for TryLockError<T> { fn description(&self) -> &str { match *self {...
{ match *self { TryLockError::Poisoned(..) => "Poisoned(..)".fmt(f), TryLockError::WouldBlock => "WouldBlock".fmt(f) } }
identifier_body
poison.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) -> &T { &self.guard } /// Reaches into this error indicating that a lock is poisoned, returning a /// mutable reference to the underlying guard to allow access regardless. #[unstable(feature = "std_misc")] pub fn get_mut(&mut self) -> &mut T { &mut self.guard } } impl<T> From<PoisonError<T>> f...
get_ref
identifier_name
lod.rs
//! Structs for keeping track of terrain level of detail. use std::cmp::Ordering; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::ops::Add; use block_position::BlockPosition; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] /// A strongly-typed index into various LOD-indexe...
(u32); impl Add<u32> for OwnerId { type Output = OwnerId; fn add(self, rhs: u32) -> OwnerId { let OwnerId(id) = self; OwnerId(id + rhs) } } struct BlockLoadState { /// The LOD indexes requested by each owner of this block. // TODO: Change this back to a HashMap once initial capacity is zero for tho...
OwnerId
identifier_name
lod.rs
//! Structs for keeping track of terrain level of detail. use std::cmp::Ordering; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::ops::Add; use block_position::BlockPosition; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] /// A strongly-typed index into various LOD-indexe...
r() }; if remove { entry.remove(); } r }, } } } /// A before and after LOD struct. pub struct LODChange { /// The target LOD. pub desired: Option<LOD>, /// Currently-loaded LOD pub loaded: Option<LOD>, } /// These are used to identify the owner...
desired: Some(new_lod), }), ) };
random_line_split
params.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
() -> Self { SpecType::Mainnet } } impl str::FromStr for SpecType { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { let spec = match s { "frontier" | "homestead" | "mainnet" => SpecType::Mainnet, "frontier-dogmatic" | "homestead-dogmatic" | "classic" => SpecType::Classic, "morden"...
default
identifier_name
params.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
} } } #[derive(Debug, PartialEq)] pub struct MinerExtras { pub author: Address, pub extra_data: Vec<u8>, pub gas_floor_target: U256, pub gas_ceil_target: U256, pub transactions_limit: usize, } impl Default for MinerExtras { fn default() -> Self { MinerExtras { author: Default::default(), extra_data:...
{ GasPricer::new_calibrated(GasPriceCalibratorOptions { usd_per_tx: usd_per_tx, recalibration_period: recalibration_period, }) }
conditional_block
params.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
fn user_defaults_with_tracing(first_launch: bool, tracing: bool) -> UserDefaults { let mut ud = UserDefaults::default(); ud.is_first_launch = first_launch; ud.tracing = tracing; ud } #[test] fn test_switch_to_bool() { assert!(!tracing_switch_to_bool(Switch::Off, &user_defaults_with_tracing(true, true))...
{ assert_eq!(Switch::default(), Switch::Auto); }
identifier_body
params.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
author: Default::default(), extra_data: version_data(), gas_floor_target: U256::from(4_700_000), gas_ceil_target: U256::from(6_283_184), transactions_limit: 1024, } } } /// 3-value enum. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Switch { /// True. On, /// False. Off, /// Auto. Auto, } ...
fn default() -> Self { MinerExtras {
random_line_split
frameobject.rs
use libc::c_int; use crate::code::{PyCodeObject, CO_MAXBLOCKS}; use crate::object::*; use crate::pyport::Py_ssize_t; use crate::pystate::PyThreadState; #[repr(C)] #[derive(Copy, Clone)] pub struct PyTryBlock { pub b_type: c_int, pub b_handler: c_int, pub b_level: c_int, } #[repr(C)] #[derive(Copy, Clone)...
(op: *mut PyObject) -> c_int { ((*op).ob_type == &mut PyFrame_Type) as c_int } ignore! { #[inline] pub unsafe fn PyFrame_IsRestricted(f: *mut PyFrameObject) -> c_int { ((*f).f_builtins!= (*(*(*f).f_tstate).interp).builtins) as c_int } } #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" ...
PyFrame_Check
identifier_name
frameobject.rs
use libc::c_int; use crate::code::{PyCodeObject, CO_MAXBLOCKS}; use crate::object::*; use crate::pyport::Py_ssize_t; use crate::pystate::PyThreadState;
pub b_type: c_int, pub b_handler: c_int, pub b_level: c_int, } #[repr(C)] #[derive(Copy, Clone)] pub struct PyFrameObject { #[cfg(py_sys_config = "Py_TRACE_REFS")] pub _ob_next: *mut PyObject, #[cfg(py_sys_config = "Py_TRACE_REFS")] pub _ob_prev: *mut PyObject, pub ob_refcnt: Py_ssize_t...
#[repr(C)] #[derive(Copy, Clone)] pub struct PyTryBlock {
random_line_split
lib.rs
/*! # graphite-rust Herein lies a humble reimplementation of the graphite metrics system -- a time series database system, with HTTP frontend and management tools. It strikes a reasonable balance between features you need, easy management, and a rich ecosystem of tools which can talk to graphite. `graphite-rust` aim...
// TODO: scuttled until I want to fix all the iron related issues // pub mod graphite;
pub mod carbon;
random_line_split
accept_ranges.rs
//! The Accept-Ranges request header, defined in RFC 2616, Section 14.5. use std::io::IoResult; use std::ascii::AsciiExt; pub use self::AcceptableRanges::{RangeUnits, NoAcceptableRanges}; pub use self::RangeUnit::{Bytes, OtherRangeUnit}; #[derive(Clone, PartialEq, Eq)] // RFC 2616: range-unit = bytes-unit | other-ra...
RangeUnits(ref range_units) => { let mut result = String::new(); for ru in range_units.iter() { match ru { &Bytes => result.push_str("bytes"), &OtherRangeUnit(ref ru) => result.push_str(&ru[]), ...
random_line_split
accept_ranges.rs
//! The Accept-Ranges request header, defined in RFC 2616, Section 14.5. use std::io::IoResult; use std::ascii::AsciiExt; pub use self::AcceptableRanges::{RangeUnits, NoAcceptableRanges}; pub use self::RangeUnit::{Bytes, OtherRangeUnit}; #[derive(Clone, PartialEq, Eq)] // RFC 2616: range-unit = bytes-unit | other-ra...
}
{ match *self { NoAcceptableRanges => String::from_str("none"), RangeUnits(ref range_units) => { let mut result = String::new(); for ru in range_units.iter() { match ru { &Bytes => result.push_str("bytes"), ...
identifier_body
accept_ranges.rs
//! The Accept-Ranges request header, defined in RFC 2616, Section 14.5. use std::io::IoResult; use std::ascii::AsciiExt; pub use self::AcceptableRanges::{RangeUnits, NoAcceptableRanges}; pub use self::RangeUnit::{Bytes, OtherRangeUnit}; #[derive(Clone, PartialEq, Eq)] // RFC 2616: range-unit = bytes-unit | other-ra...
{ RangeUnits(Vec<RangeUnit>), NoAcceptableRanges, } impl super::HeaderConvertible for AcceptableRanges { fn from_stream<R: Reader>(reader: &mut super::HeaderValueByteIterator<R>) -> Option<AcceptableRanges> { let mut range_units = Vec::new(); loop { match reader.rea...
AcceptableRanges
identifier_name
revidx.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::ops::{Add, Mul}; use std::str::FromStr; use std::u32; /// Index into a `RevLog` #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, ...
else { None } } } #[cfg(test)] mod test { use super::*; use std::str::FromStr; #[test] fn zero() { assert_eq!(RevIdx::zero(), RevIdx(0)) } #[test] fn succ() { assert_eq!(RevIdx::zero().succ(), RevIdx(1)); assert_eq!(RevIdx::zero().succ().su...
{ let ret = RevIdx(self.0); self.0 += 1; Some(ret) }
conditional_block
revidx.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::ops::{Add, Mul}; use std::str::FromStr; use std::u32; /// Index into a `RevLog` #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, ...
RevIdx(self.0 - 1) } /// Return iterator for a range from index to `lim`. pub fn range_to(&self, lim: Self) -> RevIdxRange { RevIdxRange(self.0, lim.0) } /// Return an open ended iterator from index. pub fn range(&self) -> RevIdxRange { RevIdxRange(self.0, u32::MAX) ...
random_line_split
revidx.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::ops::{Add, Mul}; use std::str::FromStr; use std::u32; /// Index into a `RevLog` #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, ...
#[test] fn range_to() { let v: Vec<_> = RevIdx::zero().range_to(RevIdx(5)).collect(); assert_eq!( v, vec![RevIdx(0), RevIdx(1), RevIdx(2), RevIdx(3), RevIdx(4)] ); } #[test] fn iter() { let v: Vec<_> = RevIdx::zero().into_iter().take(5).coll...
{ println!("bad {:?}", RevIdx::zero().pred()); }
identifier_body
revidx.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::ops::{Add, Mul}; use std::str::FromStr; use std::u32; /// Index into a `RevLog` #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, ...
() { let v: Vec<_> = RevIdx::zero().into_iter().take(5).collect(); assert_eq!( v, vec![RevIdx(0), RevIdx(1), RevIdx(2), RevIdx(3), RevIdx(4)] ) } #[test] fn fromstr() { let idx: RevIdx = FromStr::from_str("555").expect("Valid string"); assert_...
iter
identifier_name
init.rs
use std::sync::{Arc, Mutex}; use std::io; use std::ptr; use std::mem; use std::thread; use super::callback; use super::Window; use super::MonitorId; use super::WindowWrapper; use super::Context; use Api; use CreationError; use CreationError::OsError; use CursorState; use GlAttributes; use GlRequest; use PixelFormatRe...
}; // now that the `Window` struct is initialized, the main `Window::new()` function will // return and this events loop will run in parallel loop { let mut msg = mem::uninitialized(); if user32::GetMessageW(&mut msg, ptr::null_mut(), 0...
{ tx.send(Err(e)).ok(); return; }
conditional_block
init.rs
use std::sync::{Arc, Mutex}; use std::io; use std::ptr; use std::mem; use std::thread; use super::callback; use super::Window; use super::MonitorId; use super::WindowWrapper; use super::Context; use Api; use CreationError; use CreationError::OsError; use CursorState; use GlAttributes; use GlRequest; use PixelFormatRe...
() -> Vec<u16> { let class_name = OsStr::new("Window Class").encode_wide().chain(Some(0).into_iter()) .collect::<Vec<_>>(); let class = winapi::WNDCLASSEXW { cbSize: mem::size_of::<winapi::WNDCLASSEXW>() as winapi::UINT, style: winapi::CS_HREDRAW | ...
register_window_class
identifier_name