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 |
|---|---|---|---|---|
inprocess.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::gl_context::GLContextFactory;
use crate::webgl_thread::{WebGLMainThread, WebGLThread, WebGLThreadInit};... |
}
fn clone_box(&self) -> Box<dyn webxr_api::WebGLExternalImageApi> {
Box::new(Self::new(self.webgl_channel.clone()))
}
}
/// Bridge between the webrender::ExternalImage callbacks and the WebGLThreads.
struct WebGLExternalImages {
webrender_gl: Rc<dyn gl::Gl>,
sendable: SendableWebGLExtern... | {
self.webgl_channel
.send(WebGLMsg::Unlock(WebGLContextId(id as usize)))
.unwrap()
} | conditional_block |
remove_console.rs | use serde::Deserialize;
use swc_atoms::JsWord;
use swc_common::collections::AHashSet;
use swc_common::DUMMY_SP;
use swc_ecmascript::ast::*;
use swc_ecmascript::utils::ident::IdentLike;
use swc_ecmascript::utils::Id;
use swc_ecmascript::visit::{noop_fold_type, Fold, FoldWith};
use crate::top_level_binding_collector::co... | {
#[serde(default)]
pub exclude: Vec<JsWord>,
}
struct RemoveConsole {
exclude: Vec<JsWord>,
bindings: Vec<AHashSet<Id>>,
in_function_params: bool,
}
impl RemoveConsole {
fn is_global_console(&self, ident: &Ident) -> bool {
&ident.sym == "console" &&!self.bindings.iter().any(|x| x.con... | Options | identifier_name |
remove_console.rs | use serde::Deserialize;
use swc_atoms::JsWord;
use swc_common::collections::AHashSet;
use swc_common::DUMMY_SP;
use swc_ecmascript::ast::*;
use swc_ecmascript::utils::ident::IdentLike;
use swc_ecmascript::utils::Id;
use swc_ecmascript::visit::{noop_fold_type, Fold, FoldWith};
use crate::top_level_binding_collector::co... |
fn fold_script(&mut self, script: Script) -> Script {
self.bindings.push(collect_top_level_decls(&script));
let s = script.fold_with(self);
self.bindings.pop().unwrap();
s
}
}
pub fn remove_console(config: Config) -> impl Fold {
let exclude = match config {
Config:... | {
self.bindings.push(collect_top_level_decls(&module));
let m = module.fold_children_with(self);
self.bindings.pop().unwrap();
m
} | identifier_body |
remove_console.rs | use serde::Deserialize;
use swc_atoms::JsWord;
use swc_common::collections::AHashSet;
use swc_common::DUMMY_SP;
use swc_ecmascript::ast::*;
use swc_ecmascript::utils::ident::IdentLike;
use swc_ecmascript::utils::Id;
use swc_ecmascript::visit::{noop_fold_type, Fold, FoldWith};
use crate::top_level_binding_collector::co... | Expr::Ident(i) if self.is_global_console(i) => {}
_ => return false,
}
// Check if the property is requested to be excluded.
// Here we do an O(n) search on the list of excluded properties because the size
// should be small.
match &member_expr.prop {
... |
// Only proceed if the object is the global `console` object.
match &*member_expr.obj { | random_line_split |
delegate.rs | // Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// This file is part of cancer.
//
// cancer 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
// (a... | use cocoa::appkit::{NSWindow, NSView};
use platform::cocoa::IdRef;
use platform::Event;
#[derive(Debug)]
pub struct Delegate {
state: Box<State>,
this: IdRef,
}
#[derive(Debug)]
pub struct State {
manager: Sender<Event>,
window: IdRef,
view: IdRef,
}
impl Delegate {
unsafe fn class() -> *const Class {
... |
use objc::runtime::{Class, Object, Sel, BOOL, YES};
use objc::declare::ClassDecl;
use cocoa::base::{id, nil}; | random_line_split |
delegate.rs | // Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// This file is part of cancer.
//
// cancer 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
// (a... | his: &Object, _: Sel, _: id) {
unsafe {
let state: *mut c_void = *this.get_ivar("state");
let state = state as *mut State;
let _ = (*state).manager.send(Event::Focus(false));
}
}
let mut decl = ClassDecl::new("CancerDelegate", Class::get("NSObject").unwrap()).unwrap();
decl.add_ivar::<*mut c_... | ndow_did_resign_key(t | identifier_name |
pokemon_model.rs | use super::enums;
use super::stats;
use enum_primitive::FromPrimitive;
/// Basic values for Pokemon species. Equal for every instance of the given Pokemon.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PokemonModel {
pokedex_id: usize,
name: String,
height: u8,
weight: u16,
gender_rate: ... |
None
}
// Setter methods
//
/// Sets a type of the pokemon
pub fn set_type(&mut self, type_id: i32, slot: u16) {
match slot {
1 => self.type_one = enums::Types::from_i32(type_id).unwrap(),
2 => self.type_two = enums::Types::from_i32(type_id).unwrap(),
... | {
return Some(self.clone().mega_evolution.unwrap());
} | conditional_block |
pokemon_model.rs | use super::enums;
use super::stats;
use enum_primitive::FromPrimitive;
/// Basic values for Pokemon species. Equal for every instance of the given Pokemon.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PokemonModel {
pokedex_id: usize,
name: String,
height: u8,
weight: u16,
gender_rate: ... |
/// Gets the height of the pokemon
pub fn get_height(&self) -> u8 {
self.clone().height
}
/// Gets the weight of the pokemon
pub fn get_weight(&self) -> u16 {
self.clone().weight
}
/// Gets the gender rate of the pokemon
pub fn get_gender_rate(&self) -> i8 {
self... | {
self.name.clone()
} | identifier_body |
pokemon_model.rs | use super::enums;
use super::stats;
use enum_primitive::FromPrimitive;
/// Basic values for Pokemon species. Equal for every instance of the given Pokemon.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PokemonModel {
pokedex_id: usize,
name: String,
height: u8,
weight: u16,
gender_rate: ... | (&self) -> i8 {
self.clone().gender_rate
}
/// Gets the description for the pokemon which is readable by the user of the program aswell
pub fn get_description(&self) -> String {
self.clone().description
}
/// Gets the types of the pokemon
pub fn get_types(&self) -> (enums::Types,... | get_gender_rate | identifier_name |
pokemon_model.rs | use super::enums;
use super::stats;
use enum_primitive::FromPrimitive;
/// Basic values for Pokemon species. Equal for every instance of the given Pokemon.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PokemonModel {
pokedex_id: usize,
name: String,
height: u8,
weight: u16,
gender_rate: ... | self.clone().description
}
/// Gets the types of the pokemon
pub fn get_types(&self) -> (enums::Types, enums::Types) {
(self.clone().type_one, self.clone().type_two)
}
/// Gets the base stats of the pokemon
pub fn get_stats(&self) -> stats::Stats {
self.clone().base_stats... | self.clone().gender_rate
}
/// Gets the description for the pokemon which is readable by the user of the program aswell
pub fn get_description(&self) -> String { | random_line_split |
process2.rs | gid_t, uid_t};
use mem;
use ptr;
use sys::pipe2::AnonPipe;
use sys::{self, retry, c, cvt};
////////////////////////////////////////////////////////////////////////////////
// Command
////////////////////////////////////////////////////////////////////////////////
#[derive(Clone)]
pub struct Command {
pub program... | {
/// Normal termination with an exit code.
Code(i32),
/// Termination by signal, with the signal number.
///
/// Never generated on Windows.
Signal(i32),
}
impl ExitStatus {
pub fn success(&self) -> bool {
*self == ExitStatus::Code(0)
}
pub fn code(&self) -> Option<i32> {... | ExitStatus | identifier_name |
process2.rs | gid_t, uid_t};
use mem;
use ptr;
use sys::pipe2::AnonPipe;
use sys::{self, retry, c, cvt};
////////////////////////////////////////////////////////////////////////////////
// Command
////////////////////////////////////////////////////////////////////////////////
#[derive(Clone)]
pub struct Command {
pub program... | unsafe fn getdtablesize() -> c_int {
libc::funcs::bsd44::getdtablesize()
}
let dirp = cfg.cwd.as_ref().map(|c| c.as_ptr()).unwrap_or(ptr::null());
with_envp(cfg.env.as_ref(), |envp: *const c_void| {
with_argv(&cfg.program, &cfg.args, |argv: *const *const libc::c... | {
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
mod rustrt {
extern {
pub fn rust_unset_sigprocmask();
}
}
unsafe fn set_cloexec(fd: c_int) {
let ret = c::ioctl(fd, c::FIOCLEX);
assert_eq!(ret, 0);
... | identifier_body |
process2.rs | gid_t, uid_t};
use mem;
use ptr;
use sys::pipe2::AnonPipe;
use sys::{self, retry, c, cvt};
////////////////////////////////////////////////////////////////////////////////
// Command
////////////////////////////////////////////////////////////////////////////////
#[derive(Clone)]
pub struct Command {
pub program... |
if!envp.is_null() {
*sys::os::environ() = envp as *const _;
}
let _ = execvp(*argv, argv as *mut _);
fail(&mut output);
})
})
}
pub fn wait(&self) -> io::Result<ExitStatus> {
let mut status = 0 as c... | {
fail(&mut output);
} | conditional_block |
process2.rs | , gid_t, uid_t};
use mem;
use ptr;
use sys::pipe2::AnonPipe;
use sys::{self, retry, c, cvt};
////////////////////////////////////////////////////////////////////////////////
// Command
////////////////////////////////////////////////////////////////////////////////
#[derive(Clone)]
pub struct Command {
pub progra... | in_fd: Option<AnonPipe>, out_fd: Option<AnonPipe>, err_fd: Option<AnonPipe>)
-> io::Result<Process>
{
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
mod rustrt {
extern {
pub fn rust_unset_sigprocmask();
... | try!(cvt(libc::funcs::posix88::signal::kill(self.pid, libc::SIGKILL)));
Ok(())
}
pub fn spawn(cfg: &Command, | random_line_split |
chaskeyrng.rs | //! A splittable pseudorandom generator based on the [Chaskey
//! MAC](http://mouha.be/chaskey/). **This is not intended to be a
//! cryptographically secure PRNG.**
//!
//! Like `SipRng`, this is broadly modeled after Claessen and Pałka's
//! splittable PRNGs, but with a different choice of cryptographic
//! primitiv... | let result = self.buf[self.i];
self.i += 1;
result
}
}
impl SeedableRng<[u32; 4]> for ChaskeyRng {
fn reseed(&mut self, seed: [u32; 4]) {
ChaskeyRng::reseed(self, seed);
}
fn from_seed(seed: [u32; 4]) -> ChaskeyRng {
ChaskeyRng::new(seed)
}
}
im... | self.advance();
}
| conditional_block |
chaskeyrng.rs | //! A splittable pseudorandom generator based on the [Chaskey
//! MAC](http://mouha.be/chaskey/). **This is not intended to be a
//! cryptographically secure PRNG.**
//!
//! Like `SipRng`, this is broadly modeled after Claessen and Pałka's
//! splittable PRNGs, but with a different choice of cryptographic
//! primitiv... | permute4(state); permute4(state);
}
#[inline(always)]
fn permute4(state: &mut [u32; 4]) {
round(state); round(state);
round(state); round(state);
}
/// The Chaskey round function.
#[inline(always)]
fn round(v: &mut [u32; 4]) {
v[0] = v[0].wrapping_add(v[1]); v[2] = v[2].wrapping_add(v[3]);
v[1]... | random_line_split | |
chaskeyrng.rs | //! A splittable pseudorandom generator based on the [Chaskey
//! MAC](http://mouha.be/chaskey/). **This is not intended to be a
//! cryptographically secure PRNG.**
//!
//! Like `SipRng`, this is broadly modeled after Claessen and Pałka's
//! splittable PRNGs, but with a different choice of cryptographic
//! primitiv... | fn reseed(&mut self, seed: [u32; 4]) {
self.state = seed;
self.k1 = times_two(seed);
self.ctr = 0;
self.buf = [0u32; 4];
self.i = 0;
self.advance();
}
fn clone(&self) -> ChaskeyRng {
ChaskeyRng {
state: self.state,
... | let mut result = ChaskeyRng {
state: seed,
k1: times_two(seed),
ctr: 0,
// We keep a buffer of the most recent words we generated
// so that we don't call the MAC as often.
buf: [0u32; 4],
// Current position within `buf... | identifier_body |
chaskeyrng.rs | //! A splittable pseudorandom generator based on the [Chaskey
//! MAC](http://mouha.be/chaskey/). **This is not intended to be a
//! cryptographically secure PRNG.**
//!
//! Like `SipRng`, this is broadly modeled after Claessen and Pałka's
//! splittable PRNGs, but with a different choice of cryptographic
//! primitiv... | -> [u32; 4] {
let mut osrng = OsRng::new().ok().expect("Could not create OsRng");
osrng.gen()
}
#[test]
fn test_rng_rand_seeded() {
let seed = gen_seed();
::tests::test_rng_rand_seeded::<ChaskeyRng, [u32; 4]>(seed);
}
#[test]
fn test_rng_seeded() {
let s... | _seed() | identifier_name |
commit_sync_config_utils.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 metaconfig_types::{DefaultSmallToLargeCommitSyncPathAction, SmallRepoCommitSyncConfig};
use mononoke_types::MPath;
use std::collections... | (
from: SmallRepoCommitSyncConfig,
to: SmallRepoCommitSyncConfig,
) -> SmallRepoCommitSyncConfigDiff {
let default_action_change = if from.default_action == to.default_action {
None
} else {
Some((from.default_action, to.default_action))
};
let mut mapping_added = HashMap::new(... | diff_small_repo_commit_sync_configs | identifier_name |
commit_sync_config_utils.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.
*/
| pub struct SmallRepoCommitSyncConfigDiff {
pub default_action_change: Option<(
DefaultSmallToLargeCommitSyncPathAction,
DefaultSmallToLargeCommitSyncPathAction,
)>,
pub mapping_added: HashMap<MPath, MPath>,
pub mapping_changed: HashMap<MPath, (MPath, MPath)>,
pub mapping_removed: Has... | use metaconfig_types::{DefaultSmallToLargeCommitSyncPathAction, SmallRepoCommitSyncConfig};
use mononoke_types::MPath;
use std::collections::HashMap;
| random_line_split |
commit_sync_config_utils.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 metaconfig_types::{DefaultSmallToLargeCommitSyncPathAction, SmallRepoCommitSyncConfig};
use mononoke_types::MPath;
use std::collections... | ;
let mut mapping_added = HashMap::new();
let mut mapping_changed = HashMap::new();
let mut mapping_removed = HashMap::new();
for (from_small, from_large) in &from.map {
match to.map.get(from_small) {
Some(to_large) if from_large!= to_large => {
mapping_changed.ins... | {
Some((from.default_action, to.default_action))
} | conditional_block |
mod.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
"Eq" => expand!(eq::expand_deriving_eq),
"TotalEq" => expand!(totaleq::expand_deriving_totaleq),
"Ord" => expand!(ord::expand_deriving_ord),
"TotalOrd" => expand!(totalord::expand_deriving_totalord),
... | "Decodable" => expand!(decodable::expand_deriving_decodable), | random_line_split |
issue-19404.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 ... | (&mut self, env: &Env) {
let engine = env.get_component::<Engine>();
}
}
fn main() {}
| init | identifier_name |
issue-19404.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 ... | struct Engine;
trait Component:'static {}
impl Component for Engine {}
trait Env {
fn get_component_type_id(&self, type_id: TypeId) -> Option<Fp<Component>>;
}
impl<'a> Env+'a {
fn get_component<T: Component>(&self) -> Option<Fp<T>> {
let x = self.get_component_type_id(TypeId::of::<T>());
Non... | use std::rc::Rc;
type Fp<T> = Rc<T>;
| random_line_split |
builder.rs | use std::rc::Rc;
use std::cell::RefCell;
use progress::timestamp::RootTimestamp;
use progress::{Timestamp, Scope, Subgraph};
use progress::nested::{Source, Target};
use progress::nested::product::Product;
use progress::nested::scope_wrapper::ScopeWrapper;
use communication::{Communicator, Data, Pullable};
use communic... | <T:Data+Serializable, D:Data+Serializable>(&mut self) -> (Vec<BoxedObserver<T, D>>, Box<Pullable<T, D>>) {
self.communicator.borrow_mut().new_channel()
}
}
impl<C: Communicator> Clone for GraphRoot<C> {
fn clone(&self) -> Self { GraphRoot { communicator: self.communicator.clone(), graph: self.graph.clo... | new_channel | identifier_name |
builder.rs | use std::rc::Rc;
use std::cell::RefCell;
use progress::timestamp::RootTimestamp;
use progress::{Timestamp, Scope, Subgraph};
use progress::nested::{Source, Target}; | use communication::{Communicator, Data, Pullable};
use communication::observer::BoxedObserver;
use serialization::Serializable;
/// The fundamental operations required to add and connect operators in a timely dataflow graph.
///
/// Importantly, this is often a *shared* object, backed by a `Rc<RefCell<>>` wrapper. Eac... | use progress::nested::product::Product;
use progress::nested::scope_wrapper::ScopeWrapper; | random_line_split |
builder.rs | use std::rc::Rc;
use std::cell::RefCell;
use progress::timestamp::RootTimestamp;
use progress::{Timestamp, Scope, Subgraph};
use progress::nested::{Source, Target};
use progress::nested::product::Product;
use progress::nested::scope_wrapper::ScopeWrapper;
use communication::{Communicator, Data, Pullable};
use communic... |
}
}
impl<C: Communicator> GraphBuilder for GraphRoot<C> {
type Timestamp = RootTimestamp;
fn name(&self) -> String { format!("Worker[{}]", self.communicator.borrow().index()) }
fn add_edge(&self, _source: Source, _target: Target) {
panic!("GraphRoot::connect(): root doesn't maintain edges; wh... | { panic!("GraphRoot::step(): empty; make sure to add a subgraph!") } | conditional_block |
builder.rs | use std::rc::Rc;
use std::cell::RefCell;
use progress::timestamp::RootTimestamp;
use progress::{Timestamp, Scope, Subgraph};
use progress::nested::{Source, Target};
use progress::nested::product::Product;
use progress::nested::scope_wrapper::ScopeWrapper;
use communication::{Communicator, Data, Pullable};
use communic... |
}
impl<G: GraphBuilder, T: Timestamp> Communicator for SubgraphBuilder<G, T> {
fn index(&self) -> u64 { self.parent.index() }
fn peers(&self) -> u64 { self.parent.peers() }
fn new_channel<T2:Data+Serializable, D:Data+Serializable>(&mut self) -> (Vec<BoxedObserver<T2, D>>, Box<Pullable<T2, D>>) {
s... | {
let index = self.subgraph.borrow().children() as u64;
let path = format!("{}", self.subgraph.borrow().path);
Subgraph::new_from(self, index, path)
} | identifier_body |
modifiers.rs | use modifier::Modifier;
use image_lib::FilterType;
use super::Image;
#[derive(Debug, Clone, Copy)]
/// Resize Modifier for `Image`
pub struct Resize {
/// The resized width of the new Image
pub width: u32,
/// The resized heigt of the new Image
pub height: u32,
}
impl Modifier<Image> for Resize {
... | (self, image: &mut Image) {
image.value = image.value.crop(self.x, self.y, self.width, self.height)
}
}
#[derive(Debug, Clone, Copy)]
/// Grayscale Modifier for `Image`
pub struct Grayscale;
impl Modifier<Image> for Grayscale {
fn modify(self, image: &mut Image) {
image.value = image.value.gra... | modify | identifier_name |
modifiers.rs | use modifier::Modifier;
use image_lib::FilterType;
use super::Image;
#[derive(Debug, Clone, Copy)]
/// Resize Modifier for `Image`
pub struct Resize {
/// The resized width of the new Image
pub width: u32,
/// The resized heigt of the new Image
pub height: u32,
}
impl Modifier<Image> for Resize {
... | } | random_line_split | |
main.rs | extern crate camera_controllers;
extern crate collada;
extern crate dev_menu;
extern crate env_logger;
extern crate gfx;
extern crate gfx_text;
extern crate gfx_debug_draw;
extern crate piston;
extern crate piston_window;
extern crate sdl2_window;
extern crate shader_version;
extern crate skeletal_animation;
extern cra... | let mut projection = CameraPerspective {
fov: 90.0f32,
near_clip: 0.1,
far_clip: 1000.0,
aspect_ratio: (win_width as f32) / (win_height as f32)
}.projection();
let mut orbit_zoom_camera: OrbitZoomCamera<f32> = OrbitZoomCamera::new(
[0.0, 0.0, 0.0],
OrbitZoomC... | {
env_logger::init().unwrap();
let (win_width, win_height) = (640, 480);
let mut window: PistonWindow<Sdl2Window> =
WindowSettings::new("Skeletal Animation Demo", [win_width, win_height])
.exit_on_esc(true)
.opengl(shader_version::OpenGL::V3_2)
.build()
... | identifier_body |
main.rs | extern crate camera_controllers;
extern crate collada;
extern crate dev_menu;
extern crate env_logger;
extern crate gfx;
extern crate gfx_text;
extern crate gfx_debug_draw;
extern crate piston;
extern crate piston_window;
extern crate sdl2_window;
extern crate shader_version;
extern crate skeletal_animation;
extern cra... | else {
0.01
};
menu.add_item(dev_menu::MenuItem::slider_item(
&format!("Param[{}] = ", param)[..],
range,
rate,
Box::new( move |ref settings| {
settings.params[¶m_copy_1[..]]
}),
Box::new( move |ref... | {
0.1
} | conditional_block |
main.rs | extern crate camera_controllers;
extern crate collada;
extern crate dev_menu;
extern crate env_logger;
extern crate gfx;
extern crate gfx_text;
extern crate gfx_debug_draw;
extern crate piston;
extern crate piston_window;
extern crate sdl2_window;
extern crate shader_version;
extern crate skeletal_animation;
extern cra... | () {
env_logger::init().unwrap();
let (win_width, win_height) = (640, 480);
let mut window: PistonWindow<Sdl2Window> =
WindowSettings::new("Skeletal Animation Demo", [win_width, win_height])
.exit_on_esc(true)
.opengl(shader_version::OpenGL::V3_2)
.build()
... | main | identifier_name |
main.rs | extern crate camera_controllers;
extern crate collada;
extern crate dev_menu;
extern crate env_logger;
extern crate gfx;
extern crate gfx_text;
extern crate gfx_debug_draw;
extern crate piston;
extern crate piston_window;
extern crate sdl2_window;
extern crate shader_version;
extern crate skeletal_animation;
extern cra... |
let camera_projection = model_view_projection(
model,
camera_view,
projection
);
// Draw IK target...
let target = [settings.params["target-x"],
settings.params["target-y"],
... |
let camera_view = orbit_zoom_camera.camera(args.ext_dt).orthogonal(); | random_line_split |
worker.rs | use std::borrow::Cow;
use std::cmp::{max, min};
use std::io::{Error, ErrorKind};
use std::sync::Arc;
use petgraph::graph::NodeIndex;
use petgraph::{EdgeDirection, Graph};
use crate::compiler::{CommandInfo, CompilationTask, Compiler, OutputInfo, SharedState, Toolchain};
pub type BuildGraph = Graph<Arc<BuildTask>, ()>... |
#[cfg(test)]
mod test {
use std::sync::{Arc, Mutex};
use crate::compiler::SharedState;
use crate::config::Config;
use super::*;
#[test]
fn test_execute_graph_empty() {
let state = SharedState::new(&Config::defaults().unwrap()).unwrap();
let graph = BuildGraph::new();
... | {
match &task.action {
BuildAction::Empty => Ok(OutputInfo {
status: Some(0),
stderr: Vec::new(),
stdout: Vec::new(),
}),
BuildAction::Exec(ref command, ref args) => state.wrap_slow(|| {
command
.to_command()
.ar... | identifier_body |
worker.rs | use std::borrow::Cow;
use std::cmp::{max, min};
use std::io::{Error, ErrorKind};
use std::sync::Arc;
use petgraph::graph::NodeIndex;
use petgraph::{EdgeDirection, Graph};
use crate::compiler::{CommandInfo, CompilationTask, Compiler, OutputInfo, SharedState, Toolchain};
pub type BuildGraph = Graph<Arc<BuildTask>, ()>... |
let (tx_result, rx_result) = crossbeam::channel::unbounded::<ResultMessage>();
let (tx_task, rx_task) = crossbeam::channel::unbounded::<TaskMessage>();
let num_cpus = max(1, min(process_limit, graph.node_count()));
crossbeam::scope(|scope| {
for worker_id in 0..num_cpus {
let local... | {
let task = &graph.raw_nodes()[0].weight;
let result = execute_compiler(state, task);
update_progress(BuildResult {
worker: 0,
completed: 1,
total: 1,
result: &result,
task,
})?;
return result.map(|output| output.status... | conditional_block |
worker.rs | use std::borrow::Cow;
use std::cmp::{max, min};
use std::io::{Error, ErrorKind};
use std::sync::Arc;
use petgraph::graph::NodeIndex;
use petgraph::{EdgeDirection, Graph};
use crate::compiler::{CommandInfo, CompilationTask, Compiler, OutputInfo, SharedState, Toolchain};
pub type BuildGraph = Graph<Arc<BuildTask>, ()>... | while i < queue.len() {
let index = queue[i];
if (!completed[index.index()]) && (is_ready(&graph, &completed, index)) {
completed[index.index()] = true;
for neighbor in graph.neighbors_directed(index, EdgeDirection::Incoming) {
queue.push(neighbor);
... | random_line_split | |
worker.rs | use std::borrow::Cow;
use std::cmp::{max, min};
use std::io::{Error, ErrorKind};
use std::sync::Arc;
use petgraph::graph::NodeIndex;
use petgraph::{EdgeDirection, Graph};
use crate::compiler::{CommandInfo, CompilationTask, Compiler, OutputInfo, SharedState, Toolchain};
pub type BuildGraph = Graph<Arc<BuildTask>, ()>... | (&self) -> Cow<str> {
match self {
BuildAction::Empty => Cow::Borrowed(""),
BuildAction::Exec(_, ref args) => Cow::Owned(format!("{:?}", args)),
BuildAction::Compilation(_, ref task) => {
Cow::Borrowed(task.input_source.to_str().unwrap_or(""))
}
... | title | identifier_name |
mod.rs | //! Public-key signatures
//! | //! # Selected primitive
//! `crypto::sign::sign` is `ed25519`, a signature scheme specified in
//! [Ed25519](http://ed25519.cr.yp.to/). This function is conjectured to meet the
//! standard notion of unforgeability for a public-key signature scheme under
//! chosen-message attacks.
//!
//! # Alternate primitives
//!
/... | //! # Security model
//! The `sign()` function is designed to meet the standard
//! notion of unforgeability for a public-key signature scheme under
//! chosen-message attacks.
//! | random_line_split |
hrtb-parse.rs | // run-pass
// Test that we can parse all the various places that a `for` keyword
// can appear representing universal quantification.
// pretty-expanded FIXME #23616
#![allow(unused_variables)]
#![allow(dead_code)]
trait Get<A,R> {
fn get(&self, arg: A) -> R;
}
// Parse HRTB with explicit `for` in a where-clau... | } | fn foo23(t: for<'a> unsafe extern "C" fn(i32) -> i32) { }
fn main() { | random_line_split |
hrtb-parse.rs | // run-pass
// Test that we can parse all the various places that a `for` keyword
// can appear representing universal quantification.
// pretty-expanded FIXME #23616
#![allow(unused_variables)]
#![allow(dead_code)]
trait Get<A,R> {
fn get(&self, arg: A) -> R;
}
// Parse HRTB with explicit `for` in a where-clau... |
fn foo01<T: for<'a> Get<&'a i32, &'a i32>>(t: T)
{
}
// Parse HRTB with explicit `for` in various sorts of types:
fn foo10(t: Box<dyn for<'a> Get<i32, i32>>) { }
fn foo11(t: Box<dyn for<'a> Fn(i32) -> i32>) { }
fn foo20(t: for<'a> fn(i32) -> i32) { }
fn foo21(t: for<'a> unsafe fn(i32) -> i32) { }
fn foo22(t: for<'... | {
} | identifier_body |
hrtb-parse.rs | // run-pass
// Test that we can parse all the various places that a `for` keyword
// can appear representing universal quantification.
// pretty-expanded FIXME #23616
#![allow(unused_variables)]
#![allow(dead_code)]
trait Get<A,R> {
fn get(&self, arg: A) -> R;
}
// Parse HRTB with explicit `for` in a where-clau... | () {
}
| main | identifier_name |
animation.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/. */
//! CSS transitions and animations.
use context::LayoutContext;
use flow::{self, Flow};
use gfx::display_list::Op... |
if should_push {
new_running_animations.push(animation);
}
}
if running_animations.is_empty() && new_running_animations.is_empty() {
// Nothing to do. Return early so we don't flood the compositor with
// `ChangeRunningAnimationsState` messages.
return
... | {
// If the animation was already present in the list for the
// node, just update its state, else push the new animation to
// run.
if let Some(ref mut animations) = running_animations.get_mut(node) {
// TODO: This being linear is probably not optimal.
... | conditional_block |
animation.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/. */
//! CSS transitions and animations.
use context::LayoutContext;
use flow::{self, Flow};
use gfx::display_list::Op... | (constellation_chan: &IpcSender<ConstellationMsg>,
script_chan: &IpcSender<ConstellationControlMsg>,
running_animations: &mut HashMap<OpaqueNode, Vec<Animation>>,
expired_animations: &mut HashMap<OpaqueNode, Vec<Animation>>,
... | update_animation_state | identifier_name |
animation.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/. */
//! CSS transitions and animations.
use context::LayoutContext;
use flow::{self, Flow};
use gfx::display_list::Op... | }
| {
let mut damage = RestyleDamage::empty();
flow.mutate_fragments(&mut |fragment| {
if let Some(ref animations) = animations.get(&fragment.node) {
for animation in animations.iter() {
let old_style = fragment.style.clone();
update_style_for_animation(&context.s... | identifier_body |
animation.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/. */
//! CSS transitions and animations.
use context::LayoutContext;
use flow::{self, Flow};
use gfx::display_list::Op... | new_running_animations.push(animation);
}
}
if running_animations.is_empty() && new_running_animations.is_empty() {
// Nothing to do. Return early so we don't flood the compositor with
// `ChangeRunningAnimationsState` messages.
return
}
let now = timer.seco... | }
if should_push { | random_line_split |
mod.rs | //! GPU resource managers
pub use crate::context::Texture;
pub use crate::resource::effect::{Effect, ShaderAttribute, ShaderUniform};
pub use crate::resource::framebuffer_manager::{
FramebufferManager, OffscreenBuffers, RenderTarget,
};
pub use crate::resource::gl_primitive::GLPrimitive;
pub use crate::resource::g... | mod planar_material_manager;
mod planar_mesh;
mod planar_mesh_manager;
mod texture_manager; | mod mesh;
mod mesh_manager; | random_line_split |
unique-send-2.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 ... |
use std::task;
fn child(tx: &Sender<Box<uint>>, i: uint) {
tx.send(box i);
}
pub fn main() {
let (tx, rx) = channel();
let n = 100u;
let mut expected = 0u;
for i in range(0u, n) {
let tx = tx.clone();
task::spawn(proc() {
child(&tx, i)
});
expected += i... | random_line_split | |
unique-send-2.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let (tx, rx) = channel();
let n = 100u;
let mut expected = 0u;
for i in range(0u, n) {
let tx = tx.clone();
task::spawn(proc() {
child(&tx, i)
});
expected += i;
}
let mut actual = 0u;
for _ in range(0u, n) {
let j = rx.recv();
... | main | identifier_name |
unique-send-2.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let (tx, rx) = channel();
let n = 100u;
let mut expected = 0u;
for i in range(0u, n) {
let tx = tx.clone();
task::spawn(proc() {
child(&tx, i)
});
expected += i;
}
let mut actual = 0u;
for _ in range(0u, n) {
let j = rx.recv();
a... | identifier_body | |
htmlfieldsetelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use crate::d... | match attr.local_name() {
&local_name!("disabled") => {
let disabled_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
// Fieldset was already disabled before.
... | Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods)
}
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation); | random_line_split |
htmlfieldsetelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use crate::d... |
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> DomRoot<ValidityState> {
let window = window_from_node(self);
ValidityState::new(&window, self.upcast())
}
// https://html.spec.whatwg.org/multipage/#dom-fieldset-disabled
make_bool_getter!(Disabled,... | {
#[derive(JSTraceable, MallocSizeOf)]
struct ElementsFilter;
impl CollectionFilter for ElementsFilter {
fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool {
elem.downcast::<HTMLElement>()
.map_or(false, HTMLElement::is_listed_element... | identifier_body |
htmlfieldsetelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use crate::d... | ;
impl CollectionFilter for ElementsFilter {
fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool {
elem.downcast::<HTMLElement>()
.map_or(false, HTMLElement::is_listed_element)
}
}
let filter = Box::new(ElementsFilter);
... | ElementsFilter | identifier_name |
htmlfieldsetelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use crate::d... |
},
&local_name!("form") => {
self.form_attribute_mutated(mutation);
},
_ => {},
}
}
}
impl FormControl for HTMLFieldSetElement {
fn form_owner(&self) -> Option<DomRoot<HTMLFormElement>> {
self.form_owner.get()
}
fn set_fo... | {
for field in fields {
let el = field.downcast::<Element>().unwrap();
el.check_disabled_attribute();
el.check_ancestors_disabled_state_for_form_control();
}
} | conditional_block |
error.rs | use std::ffi::OsString;
use std::fmt;
use std::io;
use std::path::PathBuf;
#[derive(Debug)]
pub enum ExpectedNumberOfArgs {
Single(usize),
Range(usize, usize),
}
impl fmt::Display for ExpectedNumberOfArgs {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expecte... | url: String,
msg: String,
},
GitLabDiffNotSupported,
BitbucketDiffNotSupported,
AzureDevOpsNotSupported,
NoUserInPath {
path: String,
},
NoRepoInPath {
path: String,
},
UnknownHostingService {
url: String,
},
BrokenUrl {
url: St... | },
CliParseFail(getopts::Fail),
OpenUrlFailure { | random_line_split |
error.rs | use std::ffi::OsString;
use std::fmt;
use std::io;
use std::path::PathBuf;
#[derive(Debug)]
pub enum ExpectedNumberOfArgs {
Single(usize),
Range(usize, usize),
}
impl fmt::Display for ExpectedNumberOfArgs {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expecte... | <T>(kind: ErrorKind) -> Result<T> {
Err(Error::new(kind))
}
pub fn kind(&self) -> &ErrorKind {
&self.kind
}
pub fn eprintln(&self) {
use std::error::Error;
fn eprint_cause(e: &dyn std::error::Error) {
eprint!(": {}", e);
if let Some(s) = e.source... | err | identifier_name |
main.rs | /* Aurélien DESBRIÈRES
aurelien(at)hackers(dot)camp
License GNU GPL latest */
// Rust experimentations ───────────┐
// Macro Rules Overload ────────────┘
// `test!` will compare `$left` and `$right`
// in different ways depending on how you invoke it:
macro_rules! test {
// Arguments don't need to be separated by... | stringify!($right),
$left && $right)
);
// ^ each arm must end with a semicolon.
($left:expr; or $right:expr) => (
println!("{:?} or {:?} is {:?}",
stringify!($left),
stringify!($right),
$left || $right)
);
}
f... | println!("{:?} and {:?} is {:?}",
stringify!($left), | random_line_split |
main.rs | /* Aurélien DESBRIÈRES
aurelien(at)hackers(dot)camp
License GNU GPL latest */
// Rust experimentations ───────────┐
// Macro Rules Overload ────────────┘
// `test!` will compare `$left` and `$right`
// in different ways depending on how you invoke it:
macro_rules! test {
// Arguments don't need to be separated by... | 2);
test!(true; or false);
}
| 4i3 | identifier_name |
main.rs | /* Aurélien DESBRIÈRES
aurelien(at)hackers(dot)camp
License GNU GPL latest */
// Rust experimentations ───────────┐
// Macro Rules Overload ────────────┘
// `test!` will compare `$left` and `$right`
// in different ways depending on how you invoke it:
macro_rules! test {
// Arguments don't need to be separated by... |
test!(true; or false);
}
| identifier_body | |
lib.rs | #![deny(missing_debug_implementations, missing_docs, missing_copy_implementations, trivial_casts,
trivial_numeric_casts, unsafe_code, unused_import_braces, unused_qualifications)]
//! rebind
//! ======
//!
//! A library for binding input keys to actions, and modifying mouse behaviour. Keys can
//! be
//! bound... | else {
unreachable!();
}
})
.collect()
}
| {
(a, ButtonTuple(buttons[0], buttons[1], buttons[2]))
} | conditional_block |
lib.rs | #![deny(missing_debug_implementations, missing_docs, missing_copy_implementations, trivial_casts,
trivial_numeric_casts, unsafe_code, unused_import_braces, unused_qualifications)]
//! rebind
//! ======
//!
//! A library for binding input keys to actions, and modifying mouse behaviour. Keys can
//! be
//! bound... | })
.collect()
} | } else {
unreachable!();
} | random_line_split |
lib.rs | #![deny(missing_debug_implementations, missing_docs, missing_copy_implementations, trivial_casts,
trivial_numeric_casts, unsafe_code, unused_import_braces, unused_qualifications)]
//! rebind
//! ======
//!
//! A library for binding input keys to actions, and modifying mouse behaviour. Keys can
//! be
//! bound... | (&self) -> usize {
(std::cmp::min(self.i as isize, 3) - 3).abs() as usize
}
}
/// An object which translates piston::input::Input events into input_map::Translated<A> events
#[derive(Clone, Debug, PartialEq)]
pub struct InputTranslator<A: Action, S: BuildHasher = RandomState> {
keymap: HashMap<Button, ... | len | identifier_name |
lib.rs | #![deny(missing_debug_implementations, missing_docs, missing_copy_implementations, trivial_casts,
trivial_numeric_casts, unsafe_code, unused_import_braces, unused_qualifications)]
//! rebind
//! ======
//!
//! A library for binding input keys to actions, and modifying mouse behaviour. Keys can
//! be
//! bound... |
/// Get the maximum number of buttons which this tuple can contain.
pub fn max_buttons(&self) -> usize {
3
}
/// Returns the number of buttons in the ButtonTuple which are not `None`.
pub fn num_buttons_set(&self) -> usize {
self.iter().map(|b| b.is_some() as usize).fold(0, std::o... | {
let sbtn = Some(button);
match self {
&mut ButtonTuple(None, _, _) => {
self.0 = sbtn;
true
}
&mut ButtonTuple(_, None, _) => {
self.1 = sbtn;
true
}
&mut ButtonTuple(_, _, None)... | identifier_body |
mod.rs | // SPDX-License-Identifier: Unlicense
//! Unifies the CPU-architecture specific code for the supported CPU's.
//!
//! All architectures are linked in for unit testing on the host platform.
//! Only the target architecture is linked for release builds (including when
//! used for integration testing).
//!
//! The targe... | // pub use x86_64 as arch; | // #[cfg(all(not(test), target_arch = "x86_64"))] | random_line_split |
a.rs | extern crate regex;
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::str;
use std::str::FromStr;
use regex::Regex;
fn main() {
let mut summation = 0;
let mut amount_of_correct = 0;
let regex = Regex::new(r"^(.*)-(\d+)\[(.+)\]$").unwrap();
for line_res in BufReader::new(File::open("input"... | (line: &str) -> String {
let alphabet = "abcdefghijklmnopqrstuvwxyz";
let mut frequency = vec![0isize; 26];
for character in line.chars() {
match alphabet.find(character) {
Some(index) => frequency[index] += 1,
None => (),
}
}
let mut result = String::with_cap... | gen_checksum | identifier_name |
a.rs | extern crate regex;
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::str;
use std::str::FromStr;
use regex::Regex;
fn main() {
let mut summation = 0;
let mut amount_of_correct = 0;
let regex = Regex::new(r"^(.*)-(\d+)\[(.+)\]$").unwrap();
for line_res in BufReader::new(File::open("input"... | {
let alphabet = "abcdefghijklmnopqrstuvwxyz";
let mut frequency = vec![0isize; 26];
for character in line.chars() {
match alphabet.find(character) {
Some(index) => frequency[index] += 1,
None => (),
}
}
let mut result = String::with_capacity(5);
for _ in ... | identifier_body | |
a.rs | extern crate regex; | use std::str;
use std::str::FromStr;
use regex::Regex;
fn main() {
let mut summation = 0;
let mut amount_of_correct = 0;
let regex = Regex::new(r"^(.*)-(\d+)\[(.+)\]$").unwrap();
for line_res in BufReader::new(File::open("input").expect("")).lines() {
let line = line_res.unwrap();
let c... |
use std::fs::File;
use std::io::{BufReader, BufRead}; | 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::b... | (&self) -> bool {
// TODO: Ensure that we report blocked if parsing is still ongoing.
!self.blocking_loads.is_empty()
}
pub fn inhibit_events(&mut self) {
self.events_inhibited = true;
}
pub fn events_inhibited(&self) -> bool {
self.events_inhibited
}
pub fn res... | is_blocked | identifier_name |
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::b... | PageSource(ServoUrl),
Media,
}
impl LoadType {
fn url(&self) -> Option<&ServoUrl> {
match *self {
LoadType::Image(ref url) |
LoadType::Script(ref url) |
LoadType::Subframe(ref url) |
LoadType::Stylesheet(ref url) |
LoadType::PageSource(ref... | Stylesheet(ServoUrl), | 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::b... |
pub fn inhibit_events(&mut self) {
self.events_inhibited = true;
}
pub fn events_inhibited(&self) -> bool {
self.events_inhibited
}
pub fn resource_threads(&self) -> &ResourceThreads {
&self.resource_threads
}
}
| {
// TODO: Ensure that we report blocked if parsing is still ongoing.
!self.blocking_loads.is_empty()
} | identifier_body |
generic-function.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {()}
| zzz | identifier_name |
generic-function.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
// debugger:finish
// debugger:print *t0
// check:$1 = 1
// debugger:print *t1
// check:$2 = 2.5
// debugger:print ret
// check:$3 = {{1, 2.5}, {2.5, 1}}
// debugger:continue
// debugger:finish
// debugger:print *t0
// check:$4 = 3.5
// debugger:print *t1
// check:$5 = 4
// debugger:print ret
// check:$6 = {{3.5, 4},... | // compile-flags:-Z extra-debug-info
// debugger:rbreak zzz
// debugger:run | random_line_split |
borrowck-autoref-3261.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 ... | <T, U> { Left(T), Right(U) }
struct X(Either<(uint,uint), fn()>);
impl X {
pub fn with<F>(&self, blk: F) where F: FnOnce(&Either<(uint, uint), fn()>) {
let X(ref e) = *self;
blk(e)
}
}
fn main() {
let mut x = X(Either::Right(main as fn()));
(&mut x).with(
|opt| { //~ ERROR can... | Either | identifier_name |
borrowck-autoref-3261.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 ... | (*f)()
},
_ => panic!()
}
})
} | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time
match opt {
&Either::Right(ref f) => {
x = X(Either::Left((0, 0))); | random_line_split |
borrowck-autoref-3261.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let mut x = X(Either::Right(main as fn()));
(&mut x).with(
|opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time
match opt {
&Either::Right(ref f) => {
x = X(Either::Left((0, 0)));
(*f)()
},
... | identifier_body | |
pe1.rs | /// # Solve project euler 1
///
/// Add all the natural numbers below one thousand
/// that are multiples of 3 or 5.
pub fn with_loop(n: u32) -> u32 {
let mut s: u32 = 0;
for i in 1..n + 1 {
if i % 3 == 0 || i % 5 == 0 {
s += i;
}
}
return s;
}
pub fn no_loop(n: u32) -> u32... |
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test() {
let cases: [u32; 5] = [
0, 10, 100, 1000, 10000,
];
let expects: [u32; 5] = [
0, 33, 2418, 234168, 23341668,
];
for i in 0..5 {
let case = cases[i as usize];
... | {
let s: u32 = with_loop(1000);
println!("{}", s);
} | identifier_body |
pe1.rs | /// # Solve project euler 1
///
/// Add all the natural numbers below one thousand
/// that are multiples of 3 or 5.
pub fn with_loop(n: u32) -> u32 {
let mut s: u32 = 0;
for i in 1..n + 1 {
if i % 3 == 0 || i % 5 == 0 {
s += i;
}
}
return s;
}
pub fn no_loop(n: u32) -> u32... | mod tests {
use super::*;
#[test]
fn test() {
let cases: [u32; 5] = [
0, 10, 100, 1000, 10000,
];
let expects: [u32; 5] = [
0, 33, 2418, 234168, 23341668,
];
for i in 0..5 {
let case = cases[i as usize];
let expect = ex... | random_line_split | |
pe1.rs | /// # Solve project euler 1
///
/// Add all the natural numbers below one thousand
/// that are multiples of 3 or 5.
pub fn with_loop(n: u32) -> u32 {
let mut s: u32 = 0;
for i in 1..n + 1 {
if i % 3 == 0 || i % 5 == 0 |
}
return s;
}
pub fn no_loop(n: u32) -> u32 {
let mut s: u32 = 0;
if n > 2 {
let n3: u32 = n / 3;
let n5: u32 = n / 5;
let n15: u32 = n / 15;
s = (3 * n3 * (n3 + 1) + 5 * n5 * (n5 + 1) - 15 * n15 * (n15 + 1)) >> 1;
}
return s;
}
pub fn pe1() {
let s: u32 = ... | {
s += i;
} | conditional_block |
pe1.rs | /// # Solve project euler 1
///
/// Add all the natural numbers below one thousand
/// that are multiples of 3 or 5.
pub fn | (n: u32) -> u32 {
let mut s: u32 = 0;
for i in 1..n + 1 {
if i % 3 == 0 || i % 5 == 0 {
s += i;
}
}
return s;
}
pub fn no_loop(n: u32) -> u32 {
let mut s: u32 = 0;
if n > 2 {
let n3: u32 = n / 3;
let n5: u32 = n / 5;
let n15: u32 = n / 15;
... | with_loop | identifier_name |
mod.rs | use snafu::{ResultExt, Snafu};
use std::fs::File;
use std::io::BufReader;
use std::path::Path; | pub mod osm_utils;
pub mod poi;
pub mod street;
pub type OsmPbfReader = osmpbfreader::OsmPbfReader<BufReader<File>>;
/// Size of the IO buffer over input PBF file
const PBF_BUFFER_SIZE: usize = 1024 * 1024; // 1MB
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("IO Error: {}", source))]
IO { source:... |
pub mod admin;
pub mod osm_store; | random_line_split |
mod.rs | use snafu::{ResultExt, Snafu};
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
pub mod admin;
pub mod osm_store;
pub mod osm_utils;
pub mod poi;
pub mod street;
pub type OsmPbfReader = osmpbfreader::OsmPbfReader<BufReader<File>>;
/// Size of the IO buffer over input PBF file
const PBF_BUFFER_SIZE: us... | (path: &Path) -> Result<OsmPbfReader, Error> {
let file = File::open(&path).context(IOSnafu)?;
Ok(osmpbfreader::OsmPbfReader::new(BufReader::with_capacity(
PBF_BUFFER_SIZE,
file,
)))
}
| make_osm_reader | identifier_name |
vec.rs | use super::id::{Id, IdIndex, MAXIMUM_CAPACITY};
use super::slab::IdSlab;
use flat::{Flat, FlatAccess, FlatAccessMut, FlatGet, FlatGetMut};
pub struct IdVec<F: Flat> {
ids: IdSlab<u32>,
reverse: Vec<IdIndex>,
flat: F,
}
impl<F: Flat> IdVec<F> {
pub fn new() -> Self {
IdVec {
ids: Id... |
#[inline]
pub fn get_mut<'a>(
&'a mut self,
id: Id<F::Element>,
) -> Option<<&'a mut F as FlatGetMut>::ElementRefMut>
where
&'a mut F: FlatGetMut,
{
// Not using `.and_then` to work around borrowck.
match self.ids.get(id.cast()) {
Some(&index) =>... | {
self.ids
.get(id.cast())
.and_then(|&index| self.flat.flat_get(index as usize))
} | identifier_body |
vec.rs | use super::id::{Id, IdIndex, MAXIMUM_CAPACITY};
use super::slab::IdSlab;
use flat::{Flat, FlatAccess, FlatAccessMut, FlatGet, FlatGetMut};
pub struct IdVec<F: Flat> {
ids: IdSlab<u32>,
reverse: Vec<IdIndex>,
flat: F,
}
impl<F: Flat> IdVec<F> {
pub fn new() -> Self {
IdVec {
ids: Id... | self.flat.flat_access_mut()
}
}
impl<T: Flat> Default for IdVec<T> {
fn default() -> Self {
Self::new()
}
} | &'a mut F: FlatAccessMut,
{ | random_line_split |
vec.rs | use super::id::{Id, IdIndex, MAXIMUM_CAPACITY};
use super::slab::IdSlab;
use flat::{Flat, FlatAccess, FlatAccessMut, FlatGet, FlatGetMut};
pub struct IdVec<F: Flat> {
ids: IdSlab<u32>,
reverse: Vec<IdIndex>,
flat: F,
}
impl<F: Flat> IdVec<F> {
pub fn new() -> Self {
IdVec {
ids: Id... | (capacity: usize) -> Self {
assert!(capacity <= MAXIMUM_CAPACITY);
IdVec {
ids: IdSlab::with_capacity(capacity),
reverse: Vec::with_capacity(capacity),
flat: F::with_capacity(capacity),
}
}
#[inline]
pub fn len(&self) -> usize {
self.ids.l... | with_capacity | identifier_name |
custom_tests.rs | use crate::generated::{CloudWatch, CloudWatchClient, Dimension, MetricDatum, PutMetricDataInput};
use rusoto_core::param::Params;
use rusoto_core::signature::SignedRequest;
use rusoto_core::signature::SignedRequestPayload;
use rusoto_core::Region;
use rusoto_mock::*;
use serde_urlencoded;
#[tokio::test]
async fn | () {
let mock = MockRequestDispatcher::with_status(200)
.with_body("")
.with_request_checker(|request: &SignedRequest| {
assert_eq!("POST", request.method);
assert_eq!("/", request.path);
if let Some(SignedRequestPayload::Buffer(ref buffer)) = request.payload {
... | should_serialize_complex_metric_data_params | identifier_name |
custom_tests.rs | use crate::generated::{CloudWatch, CloudWatchClient, Dimension, MetricDatum, PutMetricDataInput};
use rusoto_core::param::Params;
use rusoto_core::signature::SignedRequest;
use rusoto_core::signature::SignedRequestPayload;
use rusoto_core::Region;
use rusoto_mock::*;
use serde_urlencoded;
#[tokio::test]
async fn shou... | assert_eq!(
params.get("MetricData.member.1.Value"),
Some(&Some("1".to_owned()))
);
assert_eq!(
params.get("MetricData.member.1.Dimensions.member.1.Name"),
Some(&Some("foo".to_owned()))
... | {
let mock = MockRequestDispatcher::with_status(200)
.with_body("")
.with_request_checker(|request: &SignedRequest| {
assert_eq!("POST", request.method);
assert_eq!("/", request.path);
if let Some(SignedRequestPayload::Buffer(ref buffer)) = request.payload {
... | identifier_body |
custom_tests.rs | use crate::generated::{CloudWatch, CloudWatchClient, Dimension, MetricDatum, PutMetricDataInput};
use rusoto_core::param::Params;
use rusoto_core::signature::SignedRequest;
use rusoto_core::signature::SignedRequestPayload;
use rusoto_core::Region;
use rusoto_mock::*;
use serde_urlencoded;
#[tokio::test]
async fn shou... | Some(&Some("foo".to_owned()))
);
assert_eq!(
params.get("MetricData.member.1.Dimensions.member.1.Value"),
Some(&Some("bar".to_owned()))
);
}
else {
panic!("Unexpected request.payload:... | {
let params: Params = serde_urlencoded::from_bytes(buffer).unwrap();
assert_eq!(
params.get("Namespace"),
Some(&Some("TestNamespace".to_owned()))
);
assert_eq!(
params.get("MetricData.member.1.Me... | conditional_block |
custom_tests.rs | use crate::generated::{CloudWatch, CloudWatchClient, Dimension, MetricDatum, PutMetricDataInput};
use rusoto_core::param::Params;
use rusoto_core::signature::SignedRequest;
use rusoto_core::signature::SignedRequestPayload;
use rusoto_core::Region;
use rusoto_mock::*;
use serde_urlencoded;
#[tokio::test]
async fn shou... | name: "foo".to_string(),
value: "bar".to_string(),
}]),
metric_name: "buffers".to_string(),
statistic_values: None,
timestamp: None,
unit: Some("Bytes".to_string()),
value: Some(1.0),
..Default::default()
}];
let request = PutMetricD... | random_line_split | |
whoami.rs | //! `GET /_matrix/client/*/account/whoami`
pub mod v3 {
//! `/v3/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3accountwhoami
use ruma_common::{api::ruma_api, DeviceId, UserId};
ruma_api! {
metadata: {
description: "Get information... |
}
}
| {
Self { user_id, device_id: None, is_guest }
} | identifier_body |
whoami.rs | //! `GET /_matrix/client/*/account/whoami`
pub mod v3 {
//! `/v3/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3accountwhoami
use ruma_common::{api::ruma_api, DeviceId, UserId};
ruma_api! {
metadata: {
description: "Get information... | (user_id: Box<UserId>, is_guest: bool) -> Self {
Self { user_id, device_id: None, is_guest }
}
}
}
| new | identifier_name |
whoami.rs | //! `GET /_matrix/client/*/account/whoami`
pub mod v3 {
//! `/v3/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3accountwhoami
use ruma_common::{api::ruma_api, DeviceId, UserId};
ruma_api! {
metadata: {
description: "Get information... | #[derive(Default)]
request: {}
response: {
/// The id of the user that owns the access token.
pub user_id: Box<UserId>,
/// The device ID associated with the access token, if any.
#[serde(skip_serializing_if = "Option::is_none")]
pub ... | added: 1.0,
}
| random_line_split |
test_reactor.rs | use tokio::io::Ready;
use tokio::reactor::{self, Config, Reactor, Task, Tick};
use std::io;
use std::sync::mpsc::{self, Sender};
#[test]
fn test_internal_source_state_is_cleaned_up() {
use mio::{Evented, EventSet, Poll, PollOpt, Token};
struct Foo;
impl Evented for Foo {
fn register(&self, _: &Po... |
// Create a reactor that will only accept a single source
let reactor = Reactor::new(config).unwrap();
reactor.handle().oneshot(|| {
let foo = Foo;
// Run this a few times, because even if we request a slab of size 1,
// there could be greater capacity (usually 2 given rounding to... | }
}
let config = Config::new()
.max_sources(1); | random_line_split |
test_reactor.rs | use tokio::io::Ready;
use tokio::reactor::{self, Config, Reactor, Task, Tick};
use std::io;
use std::sync::mpsc::{self, Sender};
#[test]
fn test_internal_source_state_is_cleaned_up() {
use mio::{Evented, EventSet, Poll, PollOpt, Token};
struct Foo;
impl Evented for Foo {
fn register(&self, _: &Po... | (&self, _: &Poll) -> io::Result<()> {
Ok(())
}
}
let config = Config::new()
.max_sources(1);
// Create a reactor that will only accept a single source
let reactor = Reactor::new(config).unwrap();
reactor.handle().oneshot(|| {
let foo = Foo;
// Run this ... | deregister | identifier_name |
ns_css_shadow_item.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/. */
//! Rust helpers for Gecko's `nsCSSShadowItem`.
use app_units::Au;
use gecko::values::{convert_rgba_to_nscolor, c... | color: self.extract_color(),
horizontal: Au(self.mXOffset).into(),
vertical: Au(self.mYOffset).into(),
blur: Au(self.mRadius).into(),
}
}
/// Returns this item as a simple shadow.
#[inline]
pub fn to_simple_shadow(&self) -> SimpleShadow {
... | fn extract_simple_shadow(&self) -> SimpleShadow {
SimpleShadow { | random_line_split |
ns_css_shadow_item.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/. */
//! Rust helpers for Gecko's `nsCSSShadowItem`.
use app_units::Au;
use gecko::values::{convert_rgba_to_nscolor, c... |
}
#[inline]
fn extract_color(&self) -> Option<RGBAColor> {
if self.mHasColor {
Some(convert_nscolor_to_rgba(self.mColor))
} else {
None
}
}
/// Gets a simple shadow from this item.
#[inline]
fn extract_simple_shadow(&self) -> SimpleShadow {
... | {
// TODO handle currentColor
// https://bugzilla.mozilla.org/show_bug.cgi?id=760345
self.mHasColor = false;
self.mColor = 0;
} | conditional_block |
ns_css_shadow_item.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/. */
//! Rust helpers for Gecko's `nsCSSShadowItem`.
use app_units::Au;
use gecko::values::{convert_rgba_to_nscolor, c... | (&mut self, shadow: BoxShadow) {
self.set_from_simple_shadow(shadow.base);
self.mSpread = shadow.spread.to_i32_au();
self.mInset = shadow.inset;
}
/// Returns this item as a box shadow.
#[inline]
pub fn to_box_shadow(&self) -> BoxShadow {
BoxShadow {
base: se... | set_from_box_shadow | identifier_name |
ns_css_shadow_item.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/. */
//! Rust helpers for Gecko's `nsCSSShadowItem`.
use app_units::Au;
use gecko::values::{convert_rgba_to_nscolor, c... |
/// Sets this item from the given simple shadow.
#[inline]
pub fn set_from_simple_shadow(&mut self, shadow: SimpleShadow) {
self.mXOffset = shadow.horizontal.to_i32_au();
self.mYOffset = shadow.vertical.to_i32_au();
self.mRadius = shadow.blur.0.to_i32_au();
self.mSpread = 0... | {
BoxShadow {
base: self.extract_simple_shadow(),
spread: Au(self.mSpread).into(),
inset: self.mInset,
}
} | identifier_body |
shard.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 anyhow::Error;
use context::{CoreContext, PerfCounterType};
use futures_stats::TimedTryFutureExt;
use std::collections::hash_map::Defau... | (shard_count: NonZeroUsize, perf_counter_type: PerfCounterType) -> Self {
let semaphores = (0..shard_count.get())
.into_iter()
.map(|_| Semaphore::new(1))
.collect();
Self {
semaphores,
perf_counter_type,
}
}
pub fn len(&self) ->... | new | identifier_name |
shard.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 anyhow::Error;
use context::{CoreContext, PerfCounterType};
use futures_stats::TimedTryFutureExt;
use std::collections::hash_map::Defau... |
Ok(SemaphoreAcquisition::Acquired(permit))
}
}
| {
return Ok(SemaphoreAcquisition::Cancelled(r, ticket));
} | conditional_block |
shard.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 anyhow::Error;
use context::{CoreContext, PerfCounterType};
use futures_stats::TimedTryFutureExt;
use std::collections::hash_map::Defau... |
pub fn len(&self) -> usize {
self.semaphores.len()
}
fn handle<'a>(&'a self, ctx: &'a CoreContext, key: &str) -> ShardHandle<'a> {
let mut hasher = DefaultHasher::new();
key.hash(&mut hasher);
let semaphore = &self.semaphores[(hasher.finish() % self.semaphores.len() as u64... | {
let semaphores = (0..shard_count.get())
.into_iter()
.map(|_| Semaphore::new(1))
.collect();
Self {
semaphores,
perf_counter_type,
}
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.