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 |
|---|---|---|---|---|
install.rs | //! Implementation of the install aspects of the compiler.
//!
//! This module is responsible for installing the standard library,
//! compiler, and documentation.
use std::env;
use std::fs;
use std::path::{Component, PathBuf};
use std::process::Command;
use build_helper::t;
use crate::dist::{self, sanitize_sh};
use... |
// The installation command is not executed from the current directory, but from a temporary
// directory. To prevent relative paths from breaking this converts relative paths to absolute
// paths. std::fs::canonicalize is not used as that requires the path to actually be present.
if path.is_relative(... | {
let without_destdir = path.clone();
path = destdir;
// Custom .join() which ignores disk roots.
for part in without_destdir.components() {
if let Component::Normal(s) = part {
path.push(s)
}
}
} | conditional_block |
install.rs | //! Implementation of the install aspects of the compiler.
//!
//! This module is responsible for installing the standard library,
//! compiler, and documentation.
use std::env;
use std::fs;
use std::path::{Component, PathBuf};
use std::process::Command;
use build_helper::t;
use crate::dist::{self, sanitize_sh};
use... | );
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Src {
pub stage: u32,
}
impl Step for Src {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let config = &run.builder.config;
let cond... | random_line_split | |
install.rs | //! Implementation of the install aspects of the compiler.
//!
//! This module is responsible for installing the standard library,
//! compiler, and documentation.
use std::env;
use std::fs;
use std::path::{Component, PathBuf};
use std::process::Command;
use build_helper::t;
use crate::dist::{self, sanitize_sh};
use... |
fn prepare_dir(mut path: PathBuf) -> String {
// The DESTDIR environment variable is a standard way to install software in a subdirectory
// while keeping the original directory structure, even if the prefix or other directories
// contain absolute paths.
//
// More information on the environment ... | {
config.as_ref().cloned().unwrap_or_else(|| PathBuf::from(default))
} | identifier_body |
install.rs | //! Implementation of the install aspects of the compiler.
//!
//! This module is responsible for installing the standard library,
//! compiler, and documentation.
use std::env;
use std::fs;
use std::path::{Component, PathBuf};
use std::process::Command;
use build_helper::t;
use crate::dist::{self, sanitize_sh};
use... | (
builder: &Builder<'_>,
package: &str,
stage: u32,
host: Option<TargetSelection>,
tarball: &GeneratedTarball,
) {
builder.info(&format!("Install {} stage{} ({:?})", package, stage, host));
let prefix = default_path(&builder.config.prefix, "/usr/local");
let sysconfdir = prefix.join(def... | install_sh | identifier_name |
base_hanlder.rs | // CITA
// Copyright 2016-2017 Cryptape Technologies LLC.
// This program is free software: you can redistribute it
// and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any
// later version.
// Th... | {}
impl BaseHandler for Handler {}
#[test]
fn test_get_topic() {
assert_eq!(Handler::select_topic(&"net_work".to_string()), "jsonrpc.net".to_string());
assert_eq!(Handler::select_topic(&"cita_send".to_string()), "jsonrpc.new_tx".to_string());
assert_eq!(Handler::select_topic(&"cita... | Handler | identifier_name |
base_hanlder.rs | // CITA
// Copyright 2016-2017 Cryptape Technologies LLC.
// This program is free software: you can redistribute it
// and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any
// later version.
// Th... |
.to_string();
topic
}
fn into_json(body: String) -> Result<RpcRequest, Error> {
let rpc: Result<RpcRequest, serde_json::Error> = serde_json::from_str(&body);
match rpc {
Err(_err_msg) => Err(Error::parse_error()),
Ok(rpc) => Ok(rpc),
}... | {
"jsonrpc"
} | conditional_block |
base_hanlder.rs | // CITA
// Copyright 2016-2017 Cryptape Technologies LLC.
// This program is free software: you can redistribute it
// and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any
// later version.
// Th... | let topic = if method.starts_with("cita_send") {
"jsonrpc.new_tx"
} else if method.starts_with("cita") || method.starts_with("eth") {
"jsonrpc.request"
} else if method.starts_with("net_") {
"jsonrpc.... | pub type RpcResult<T> = result::Result<T, Error>;
pub trait BaseHandler {
fn select_topic(method: &String) -> String { | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(custom_derive, plugin)]
#![plugin(heapsize_plugin, plugins, serde_macros)]
#![crate_name = "gfx_traits... | pub fn null() -> LayerId {
LayerId(LayerType::FragmentBody, 0, 0)
}
pub fn new_of_type(layer_type: LayerType, fragment_id: usize) -> LayerId {
LayerId(layer_type, fragment_id, 0)
}
pub fn companion_layer_id(&self) -> LayerId {
let LayerId(layer_type, id, companion) = *self;... | /// FIXME(#2011, pcwalton): This is unfortunate. Maybe remove this in the future. | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(custom_derive, plugin)]
#![plugin(heapsize_plugin, plugins, serde_macros)]
#![crate_name = "gfx_traits... | (&self, f: &mut Formatter) -> fmt::Result {
let LayerId(layer_type, id, companion) = *self;
let type_string = match layer_type {
LayerType::FragmentBody => "-FragmentBody",
LayerType::OverflowScroll => "-OverflowScroll",
LayerType::BeforePseudoContent => "-BeforePseud... | fmt | identifier_name |
issue-21974.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 ... | () { }
| main | identifier_name |
issue-21974.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 ... | y.foo();
}
fn main() { } | &'b T : Foo
{
x.foo(); //~ ERROR type annotations required | random_line_split |
issue-21974.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 ... | { } | identifier_body | |
custom.rs | use graphics::character::CharacterCache;
use super::Kind;
use super::Update;
use ui::{Ui, UiId};
/// A trait to be implemented for Custom widget types.
///
/// If you think your widget might be useful enough for conrod's official widget library, Feel free
/// to submit a PR at https://github.com/PistonDevelopers/conro... | Update {
new_state: (),
xy: [0.0, 0.0],
depth: 0.0,
element: ::elmesque::element::empty(),
}
}
}
impl State for () {
fn matches(&self, _other: &()) -> bool { true }
fn init() -> Self { () }
} | random_line_split | |
custom.rs |
use graphics::character::CharacterCache;
use super::Kind;
use super::Update;
use ui::{Ui, UiId};
/// A trait to be implemented for Custom widget types.
///
/// If you think your widget might be useful enough for conrod's official widget library, Feel free
/// to submit a PR at https://github.com/PistonDevelopers/conr... | <C>(self, ui_id: UiId, ui: &mut Ui<C, Self>) where C: CharacterCache {
let state = match *ui.get_widget_mut(ui_id, Kind::Custom(Self::State::init())) {
::widget::Kind::Custom(ref state) => state.clone(),
_ => panic!("The Kind variant returned by Ui is different to that which \
... | set | identifier_name |
custom.rs |
use graphics::character::CharacterCache;
use super::Kind;
use super::Update;
use ui::{Ui, UiId};
/// A trait to be implemented for Custom widget types.
///
/// If you think your widget might be useful enough for conrod's official widget library, Feel free
/// to submit a PR at https://github.com/PistonDevelopers/conr... |
/// This is the method you have to implement! Your widget's previous state is given to you as a
/// parameter and it is your job to construct and return an Update that will be used to update
/// the widget's cached state.
fn update<C>(mut self, prev: Self::State, ui_id: UiId, ui: &mut Ui<C, Self>) -> ... | {
let state = match *ui.get_widget_mut(ui_id, Kind::Custom(Self::State::init())) {
::widget::Kind::Custom(ref state) => state.clone(),
_ => panic!("The Kind variant returned by Ui is different to that which \
was requested (Check that there are no UiId conflicts).... | identifier_body |
main.rs | extern crate clap;
extern crate octavo;
use octavo::digest::prelude::*;
use std::fmt::Write;
fn md5(input: &str, mut output: &mut [u8]) |
#[inline(always)]
fn to_char(x: u8) -> char {
if x < 10 {
(x + '0' as u8) as char
} else if x < 16 {
(x - 10 + 'a' as u8) as char
} else {
panic!("bad hex value: {}", x)
}
}
fn crack_password_1(door_id: &str) -> String {
let mut password = String::new();
let mut passwo... | {
let mut digest = Md5::default();
digest.update(input);
digest.result(&mut output);
} | identifier_body |
main.rs | extern crate clap;
extern crate octavo;
use octavo::digest::prelude::*;
use std::fmt::Write;
fn md5(input: &str, mut output: &mut [u8]) {
let mut digest = Md5::default();
digest.update(input);
digest.result(&mut output);
}
#[inline(always)]
fn to_char(x: u8) -> char {
if x < 10 | else if x < 16 {
(x - 10 + 'a' as u8) as char
} else {
panic!("bad hex value: {}", x)
}
}
fn crack_password_1(door_id: &str) -> String {
let mut password = String::new();
let mut password_buffer = door_id.to_owned();
password.reserve(format!("{}", u64::max_value()).len());
let ... | {
(x + '0' as u8) as char
} | conditional_block |
main.rs | extern crate clap;
extern crate octavo;
use octavo::digest::prelude::*;
use std::fmt::Write;
fn md5(input: &str, mut output: &mut [u8]) {
let mut digest = Md5::default();
digest.update(input);
digest.result(&mut output);
}
#[inline(always)]
fn to_char(x: u8) -> char {
if x < 10 {
(x + '0' as ... | (door_id: &str) -> String {
let mut password = vec![None; 8];
let mut password_buffer = door_id.to_owned();
password.reserve(format!("{}", u64::max_value()).len());
let mut buf = vec![0u8; Md5::output_bytes()];
for index in 0u64.. {
if password.iter().all(|opt| opt.is_some()) {
b... | crack_password_2 | identifier_name |
main.rs | extern crate clap;
extern crate octavo;
use octavo::digest::prelude::*;
use std::fmt::Write;
fn md5(input: &str, mut output: &mut [u8]) {
let mut digest = Md5::default();
digest.update(input);
digest.result(&mut output);
}
#[inline(always)]
fn to_char(x: u8) -> char {
if x < 10 {
(x + '0' as ... | .expect("Could not write to buffer");
md5(&password_buffer, &mut buf);
if buf[0] == 0 && buf[1] == 0 && (buf[2] & 0xF0) == 0 {
password.push(to_char(buf[2] & 0xF));
}
}
password
}
fn crack_password_2(door_id: &str) -> String {
let mut password = vec![None; 8];... | write!(password_buffer, "{}", index) | random_line_split |
borrowck-uninit-field-access.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 ... | () {
let mut a: Point;
let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x`
//[mir]~^ ERROR [E0381]
let mut line1 = Line::default();
let _moved = line1.origin;
let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x`
... | main | identifier_name |
borrowck-uninit-field-access.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 ... | y: isize,
}
#[derive(Default)]
struct Line {
origin: Point,
middle: Point,
target: Point,
}
impl Line { fn consume(self) { } }
fn main() {
let mut a: Point;
let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x`
//[mir]~^ ERROR [E0381]
let mut ... | struct Point {
x: isize, | random_line_split |
front_test.rs | use std::env;
use wtest_basic::dependencies::*;
#[ test ]
#[ rustversion::stable ]
fn trybuild_tests()
{
println!( "current_dir : {:?}", env::current_dir().unwrap() );
}
#[ test ]
#[ rustversion::nightly ]
fn trybuild_tests()
{
println!( "current_dir : {:?}", env::current_dir().unwrap() );
let t = trybuild::Tes... | mod basic_runtime { include!( "./all/basic_runtime.rs" ); }
mod basic { include!( "./all/basic.rs" ); }
mod conflict { include!( "./all/conflict.rs" ); }
mod string_slice_runtime { include!( "./all/string_slice_runtime.rs" ); }
mod string_slice { include!( "./all/string_slice.rs" ); }
mod default_primitive { include!(... |
/* xxx : use mod_at */
| random_line_split |
front_test.rs |
use std::env;
use wtest_basic::dependencies::*;
#[ test ]
#[ rustversion::stable ]
fn trybuild_tests()
{
println!( "current_dir : {:?}", env::current_dir().unwrap() );
}
#[ test ]
#[ rustversion::nightly ]
fn | ()
{
println!( "current_dir : {:?}", env::current_dir().unwrap() );
let t = trybuild::TestCases::new();
t.compile_fail( "../../../rust/test/former/all/bad_attr.rs" );
t.compile_fail( "../../../rust/test/former/all/vector_without_parameter.rs" );
t.compile_fail( "../../../rust/test/former/all/hashmap_without_p... | trybuild_tests | identifier_name |
front_test.rs |
use std::env;
use wtest_basic::dependencies::*;
#[ test ]
#[ rustversion::stable ]
fn trybuild_tests()
|
#[ test ]
#[ rustversion::nightly ]
fn trybuild_tests()
{
println!( "current_dir : {:?}", env::current_dir().unwrap() );
let t = trybuild::TestCases::new();
t.compile_fail( "../../../rust/test/former/all/bad_attr.rs" );
t.compile_fail( "../../../rust/test/former/all/vector_without_parameter.rs" );
t.compile... | {
println!( "current_dir : {:?}", env::current_dir().unwrap() );
} | identifier_body |
skip_client_extensions.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.
*/
use crate::util::CustomMetadataDirectives;
use graphql_ir::Selection;
use graphql_ir::{
Directive, FragmentDefinition, Fragment... |
fn transform_linked_field(&mut self, field: &LinkedField) -> Transformed<Selection> {
if self
.program
.schema()
.field(field.definition.item)
.is_extension
{
Transformed::Delete
} else {
self.default_transform_linked_fiel... | {
if let Some(type_condition) = fragment.type_condition {
if self.program.schema().is_extension_type(type_condition) {
return Transformed::Delete;
}
}
self.default_transform_inline_fragment(fragment)
} | identifier_body |
skip_client_extensions.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.
*/
use crate::util::CustomMetadataDirectives;
use graphql_ir::Selection;
use graphql_ir::{
Directive, FragmentDefinition, Fragment... | .schema()
.field(field.definition.item)
.is_extension
{
Transformed::Delete
} else {
self.default_transform_linked_field(field)
}
}
fn transform_scalar_field(&mut self, field: &ScalarField) -> Transformed<Selection> {
if s... | if self
.program | random_line_split |
skip_client_extensions.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.
*/
use crate::util::CustomMetadataDirectives;
use graphql_ir::Selection;
use graphql_ir::{
Directive, FragmentDefinition, Fragment... |
}
fn transform_fragment_spread(&mut self, spread: &FragmentSpread) -> Transformed<Selection> {
let fragment = self.program.fragment(spread.fragment.item).unwrap();
if self
.program
.schema()
.is_extension_type(fragment.type_condition)
{
Tran... | {
self.default_transform_fragment(fragment)
} | conditional_block |
skip_client_extensions.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.
*/
use crate::util::CustomMetadataDirectives;
use graphql_ir::Selection;
use graphql_ir::{
Directive, FragmentDefinition, Fragment... | (&mut self, spread: &FragmentSpread) -> Transformed<Selection> {
let fragment = self.program.fragment(spread.fragment.item).unwrap();
if self
.program
.schema()
.is_extension_type(fragment.type_condition)
{
Transformed::Delete
} else {
... | transform_fragment_spread | identifier_name |
mod.rs | pub mod mocknet_controller;
pub mod bitcoin_regtest_controller;
pub use self::mocknet_controller::{MocknetController};
pub use self::bitcoin_regtest_controller::{BitcoinRegtestController};
use super::operations::BurnchainOpSigner;
use std::time::Instant;
use stacks::burnchains::BurnchainStateTransition;
use stacks:... |
}
winning_tx_vtindex
}
}
| {
if op.txid == winning_tx_id {
winning_tx_vtindex = Some(op.vtxindex)
}
} | conditional_block |
mod.rs | pub mod mocknet_controller;
pub mod bitcoin_regtest_controller;
pub use self::mocknet_controller::{MocknetController};
pub use self::bitcoin_regtest_controller::{BitcoinRegtestController};
use super::operations::BurnchainOpSigner;
use std::time::Instant;
use stacks::burnchains::BurnchainStateTransition;
use stacks:... | (&self) -> Option<u32> {
let winning_tx_id = self.block_snapshot.winning_block_txid;
let mut winning_tx_vtindex = None;
for op in self.state_transition.accepted_ops.iter() {
if let BlockstackOperationType::LeaderBlockCommit(op) = op {
if op.txid == winning_tx_id {
... | get_winning_tx_index | identifier_name |
mod.rs | pub mod mocknet_controller;
pub mod bitcoin_regtest_controller;
pub use self::mocknet_controller::{MocknetController};
pub use self::bitcoin_regtest_controller::{BitcoinRegtestController};
use super::operations::BurnchainOpSigner;
use std::time::Instant;
use stacks::burnchains::BurnchainStateTransition;
use stacks:... |
#[cfg(test)]
fn bootstrap_chain(&mut self, blocks_count: u64);
}
#[derive(Debug, Clone)]
pub struct BurnchainTip {
pub block_snapshot: BlockSnapshot,
pub state_transition: BurnchainStateTransition,
pub received_at: Instant,
}
impl BurnchainTip {
pub fn get_winning_tx_index(&self) -> Option<... | fn get_chain_tip(&mut self) -> BurnchainTip; | random_line_split |
bwt.rs | #![feature(test)]
extern crate nucleic_acid;
#[macro_use]
extern crate lazy_static;
extern crate test;
extern crate rand;
use nucleic_acid::{suffix_array, FMIndex};
use rand::Rng;
use test::Bencher; | (0..1000).map(|_| bases[rng.gen_range(0, bases.len())]).collect()
};
static ref QUERY: String = {
let mut rng = rand::thread_rng();
let idx = rng.gen_range(0, DATA.len() - 100);
String::from_utf8_lossy(&DATA[idx..idx + 100]).into_owned()
};
}
#[bench]
fn bench_sort_rotation... |
lazy_static! {
static ref DATA: Vec<u8> = {
let mut rng = rand::thread_rng();
let bases = vec![65, 67, 71, 84]; | random_line_split |
bwt.rs | #![feature(test)]
extern crate nucleic_acid;
#[macro_use]
extern crate lazy_static;
extern crate test;
extern crate rand;
use nucleic_acid::{suffix_array, FMIndex};
use rand::Rng;
use test::Bencher;
lazy_static! {
static ref DATA: Vec<u8> = {
let mut rng = rand::thread_rng();
let bases = vec![65,... | {
let index = FMIndex::new(&DATA);
b.iter(|| {
index.search(&QUERY);
})
} | identifier_body | |
bwt.rs | #![feature(test)]
extern crate nucleic_acid;
#[macro_use]
extern crate lazy_static;
extern crate test;
extern crate rand;
use nucleic_acid::{suffix_array, FMIndex};
use rand::Rng;
use test::Bencher;
lazy_static! {
static ref DATA: Vec<u8> = {
let mut rng = rand::thread_rng();
let bases = vec![65,... | (b: &mut Bencher) {
b.iter(|| {
FMIndex::new(&DATA);
})
}
#[bench]
fn bench_fm_index_1000_random_values_get_100_chars(b: &mut Bencher) {
let index = FMIndex::new(&DATA);
b.iter(|| {
index.search(&QUERY);
})
}
| bench_fm_index_1000_random_values_constructor | identifier_name |
focus.rs | use dces::prelude::Entity;
use crate::{
prelude::*,
proc_macros::{Event, IntoHandler},
};
/// Used to request keyboard focus on the window.
#[derive(Event, Clone)]
pub enum FocusEvent {
RequestFocus(Entity),
RemoveFocus(Entity),
}
pub type FocusHandlerFn = dyn Fn(&mut StatesContext, FocusEvent) -> bo... |
fn handles_event(&self, event: &EventBox) -> bool {
event.is_type::<FocusEvent>()
}
}
| {
if let Ok(event) = event.downcast_ref::<FocusEvent>() {
return (self.handler)(states, event.clone());
}
false
} | identifier_body |
focus.rs | use dces::prelude::Entity;
use crate::{
prelude::*,
proc_macros::{Event, IntoHandler},
};
/// Used to request keyboard focus on the window.
#[derive(Event, Clone)]
pub enum | {
RequestFocus(Entity),
RemoveFocus(Entity),
}
pub type FocusHandlerFn = dyn Fn(&mut StatesContext, FocusEvent) -> bool +'static;
/// Structure for the focus handling of an event
#[derive(IntoHandler)]
pub struct FocusEventHandler {
/// A reference counted handler
pub handler: Rc<FocusHandlerFn>,
}
... | FocusEvent | identifier_name |
focus.rs | use dces::prelude::Entity;
use crate::{
prelude::*,
proc_macros::{Event, IntoHandler},
};
/// Used to request keyboard focus on the window.
#[derive(Event, Clone)]
pub enum FocusEvent {
RequestFocus(Entity),
RemoveFocus(Entity),
}
pub type FocusHandlerFn = dyn Fn(&mut StatesContext, FocusEvent) -> bo... |
false
}
fn handles_event(&self, event: &EventBox) -> bool {
event.is_type::<FocusEvent>()
}
}
| {
return (self.handler)(states, event.clone());
} | conditional_block |
focus.rs | use dces::prelude::Entity;
use crate::{
prelude::*,
proc_macros::{Event, IntoHandler},
};
/// Used to request keyboard focus on the window.
#[derive(Event, Clone)]
pub enum FocusEvent {
RequestFocus(Entity),
RemoveFocus(Entity),
}
pub type FocusHandlerFn = dyn Fn(&mut StatesContext, FocusEvent) -> bo... |
fn handles_event(&self, event: &EventBox) -> bool {
event.is_type::<FocusEvent>()
}
} |
false
} | random_line_split |
init.rs | extern crate num_complex;
use consts;
use kiss_fft;
use mode;
use opus_decoder;
use std;
#[no_mangle]
pub extern "C" fn opus_decoder_create<'a>() -> *mut opus_decoder::OpusDecoder<'a> {
let mut mode = mode::CeltMode {
window: vec![0.0; consts::WINDOW_SIZE],
fft0: kiss_fft::KissFft::new(0, vec![5, ... | ,
_ => {},
}
}
}
let opus_decoder = opus_decoder::OpusDecoder {
mode: mode,
range: 0,
pitch: 0,
gain: 0.0,
tapset: 0,
preemph_mem: [0.0; 2],
decode_mem: [
vec![0.0; opus_decoder::BUFFER_SIZE + 120 / 2],
vec![0.0; opu... | {
let (temp, overflow) = a.overflowing_add(b);
if !overflow {
let (temp, overflow) = temp.overflowing_add(c);
if !overflow {
mode.v[n][k] = Some(temp);
}
}
} | conditional_block |
init.rs | extern crate num_complex;
use consts;
use kiss_fft;
use mode;
use opus_decoder;
use std;
#[no_mangle]
pub extern "C" fn | <'a>() -> *mut opus_decoder::OpusDecoder<'a> {
let mut mode = mode::CeltMode {
window: vec![0.0; consts::WINDOW_SIZE],
fft0: kiss_fft::KissFft::new(0, vec![5, 4, 4, 3, 2]),
fft3: kiss_fft::KissFft::new(3, vec![5, 4, 3]),
twiddles: vec![Default::default(); consts::FRAME_SIZE / 2],
... | opus_decoder_create | identifier_name |
init.rs | extern crate num_complex;
use consts;
use kiss_fft;
use mode;
use opus_decoder;
use std;
#[no_mangle]
pub extern "C" fn opus_decoder_create<'a>() -> *mut opus_decoder::OpusDecoder<'a> {
let mut mode = mode::CeltMode {
window: vec![0.0; consts::WINDOW_SIZE],
fft0: kiss_fft::KissFft::new(0, vec![5, ... | }
let opus_decoder = opus_decoder::OpusDecoder {
mode: mode,
range: 0,
pitch: 0,
gain: 0.0,
tapset: 0,
preemph_mem: [0.0; 2],
decode_mem: [
vec![0.0; opus_decoder::BUFFER_SIZE + 120 / 2],
vec![0.0; opus_decoder::BUFFER_SIZE + 120 /... | }
},
_ => {},
}
} | random_line_split |
init.rs | extern crate num_complex;
use consts;
use kiss_fft;
use mode;
use opus_decoder;
use std;
#[no_mangle]
pub extern "C" fn opus_decoder_create<'a>() -> *mut opus_decoder::OpusDecoder<'a> | //
// The number of combinations, with replacement, of n items, taken k at a time, when a sign bit is added to each item taken at least once. A table of values for n < 10 and k < 10 looks like:
//
// v[10][10] = {
// {1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
//... | {
let mut mode = mode::CeltMode {
window: vec![0.0; consts::WINDOW_SIZE],
fft0: kiss_fft::KissFft::new(0, vec![5, 4, 4, 3, 2]),
fft3: kiss_fft::KissFft::new(3, vec![5, 4, 3]),
twiddles: vec![Default::default(); consts::FRAME_SIZE / 2],
v: vec![vec![None; 176]; 176],
};
... | identifier_body |
capsule_capsule_manifold_generator.rs | use crate::math::Isometry;
use crate::pipeline::narrow_phase::{
ContactDispatcher, ContactManifoldGenerator, ConvexPolyhedronConvexPolyhedronManifoldGenerator,
};
use crate::query::{ContactManifold, ContactPrediction, ContactPreprocessor};
use crate::shape::{Capsule, Shape};
use na::{self, RealField};
/// Collisio... | (
&mut self,
d: &dyn ContactDispatcher<N>,
ma: &Isometry<N>,
a: &dyn Shape<N>,
proc1: Option<&dyn ContactPreprocessor<N>>,
mb: &Isometry<N>,
b: &dyn Shape<N>,
proc2: Option<&dyn ContactPreprocessor<N>>,
prediction: &ContactPrediction<N>,
ma... | generate_contacts | identifier_name |
capsule_capsule_manifold_generator.rs | use crate::math::Isometry;
use crate::pipeline::narrow_phase::{
ContactDispatcher, ContactManifoldGenerator, ConvexPolyhedronConvexPolyhedronManifoldGenerator,
};
use crate::query::{ContactManifold, ContactPrediction, ContactPreprocessor};
use crate::shape::{Capsule, Shape};
use na::{self, RealField};
/// Collisio... | else {
false
}
}
}
| {
self.do_update(d, ma, cs1, proc1, mb, cs2, proc2, prediction, manifold)
} | conditional_block |
capsule_capsule_manifold_generator.rs | use crate::math::Isometry;
use crate::pipeline::narrow_phase::{
ContactDispatcher, ContactManifoldGenerator, ConvexPolyhedronConvexPolyhedronManifoldGenerator,
};
use crate::query::{ContactManifold, ContactPrediction, ContactPreprocessor};
use crate::shape::{Capsule, Shape};
use na::{self, RealField}; | /// Collision detector between a concave shape and another shape.
pub struct CapsuleCapsuleManifoldGenerator<N: RealField> {
// FIXME: use a dedicated segment-segment algorithm instead.
sub_detector: ConvexPolyhedronConvexPolyhedronManifoldGenerator<N>,
}
impl<N: RealField> CapsuleCapsuleManifoldGenerator<N> {... | random_line_split | |
capsule_capsule_manifold_generator.rs | use crate::math::Isometry;
use crate::pipeline::narrow_phase::{
ContactDispatcher, ContactManifoldGenerator, ConvexPolyhedronConvexPolyhedronManifoldGenerator,
};
use crate::query::{ContactManifold, ContactPrediction, ContactPreprocessor};
use crate::shape::{Capsule, Shape};
use na::{self, RealField};
/// Collisio... |
fn do_update(
&mut self,
dispatcher: &dyn ContactDispatcher<N>,
m1: &Isometry<N>,
g1: &Capsule<N>,
proc1: Option<&dyn ContactPreprocessor<N>>,
m2: &Isometry<N>,
g2: &Capsule<N>,
proc2: Option<&dyn ContactPreprocessor<N>>,
prediction: &Contact... | {
CapsuleCapsuleManifoldGenerator {
sub_detector: ConvexPolyhedronConvexPolyhedronManifoldGenerator::new(),
}
} | identifier_body |
error.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 ... | /// Any I/O error not part of this list.
#[unstable(feature = "io_error_internals",
reason = "better expressed through extensible enums that this \
enum cannot be exhaustively matched against")]
#[doc(hidden)]
__Nonexhaustive,
}
impl Error {
/// Creates a new... | random_line_split | |
error.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 ... | (&self) -> Option<&error::Error> {
match self.repr {
Repr::Os(..) => None,
Repr::Custom(ref c) => c.error.cause(),
}
}
}
fn _assert_error_is_sync_send() {
fn _is_sync_send<T: Sync+Send>() {}
_is_sync_send::<Error>();
}
#[cfg(test)]
mod test {
use prelude::v1::*;... | cause | identifier_name |
delete_permission_response.rs | use crate::from_headers::*;
use azure_sdk_core::errors::AzureError;
use azure_sdk_core::session_token_from_headers;
use http::HeaderMap;
#[derive(Debug, Clone, PartialEq)]
pub struct DeletePermissionResponse { | pub content_path: String,
pub alt_content_path: String,
}
impl std::convert::TryFrom<(&HeaderMap, &[u8])> for DeletePermissionResponse {
type Error = AzureError;
fn try_from(value: (&HeaderMap, &[u8])) -> Result<Self, Self::Error> {
let headers = value.0;
let _body = value.1;
d... | pub charge: f64,
pub activity_id: uuid::Uuid,
pub session_token: String, | random_line_split |
delete_permission_response.rs | use crate::from_headers::*;
use azure_sdk_core::errors::AzureError;
use azure_sdk_core::session_token_from_headers;
use http::HeaderMap;
#[derive(Debug, Clone, PartialEq)]
pub struct | {
pub charge: f64,
pub activity_id: uuid::Uuid,
pub session_token: String,
pub content_path: String,
pub alt_content_path: String,
}
impl std::convert::TryFrom<(&HeaderMap, &[u8])> for DeletePermissionResponse {
type Error = AzureError;
fn try_from(value: (&HeaderMap, &[u8])) -> Result<Sel... | DeletePermissionResponse | identifier_name |
main.rs | // Copyright 2014 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | let locals = Locals { offsets: self.cycles };
encoder.update_constant_buffer(&self.bundle.data.locals, &locals);
encoder.clear(&self.bundle.data.out, [0.3, 0.3, 0.3, 1.0]);
self.bundle.encode(encoder);
}
fn on_resize(&mut self, window_targets: gfx_app::WindowTargets<R>) {
... | {
let delta = self.time_start.elapsed();
self.time_start = Instant::now();
let delta = delta.as_secs() as f32 + delta.subsec_nanos() as f32 / 1000_000_000.0;
// since we sample our diffuse texture twice we need to lerp between
// them to get a smooth transition (shouldn't even b... | identifier_body |
main.rs | // Copyright 2014 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | Vertex {
pos: p,
uv: u,
}
}
}
fn load_texture<R, F>(factory: &mut F, data: &[u8])
-> Result<gfx::handle::ShaderResourceView<R, [f32; 4]>, String>
where R: gfx::Resources, F: gfx::Factory<R> {
use gfx::texture as t;
let img = image::load(Cursor... | impl Vertex {
fn new(p: [f32; 2], u: [f32; 2]) -> Vertex { | random_line_split |
main.rs | // Copyright 2014 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
self.cycles[1] += 0.25 * delta;
if self.cycles[1] > 1.0 {
self.cycles[1] -= 1.0;
}
self.bundle.data.offset0 = self.cycles[0];
self.bundle.data.offset1 = self.cycles[1];
let locals = Locals { offsets: self.cycles };
encoder.update_constant_buffer(&sel... | {
self.cycles[0] -= 1.0;
} | conditional_block |
main.rs | // Copyright 2014 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | <R: gfx::Resources>{
bundle: Bundle<R, pipe::Data<R>>,
cycles: [f32; 2],
time_start: Instant,
}
impl<R: gfx::Resources> gfx_app::Application<R> for App<R> {
fn new<F: gfx::Factory<R>>(factory: &mut F, backend: gfx_app::shade::Backend,
window_targets: gfx_app::WindowTargets<R>) -> Self {
... | App | identifier_name |
cstore.rs | // Copyright 2012-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-MI... | (&self) {
}
pub fn reset(&self) {
self.metas.borrow_mut().clear();
self.extern_mod_crate_map.borrow_mut().clear();
self.used_crate_sources.borrow_mut().clear();
self.used_libraries.borrow_mut().clear();
self.used_link_args.borrow_mut().clear();
}
// This method ... | dump_phase_syntax_crates | identifier_name |
cstore.rs | // Copyright 2012-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-MI... | // Where a crate came from on the local filesystem. One of these two options
// must be non-None.
#[deriving(Eq, Clone)]
pub struct CrateSource {
pub dylib: Option<Path>,
pub rlib: Option<Path>,
pub cnum: ast::CrateNum,
}
pub struct CStore {
metas: RefCell<HashMap<ast::CrateNum, Rc<crate_metadata>>>,
... | random_line_split | |
cstore.rs | // Copyright 2012-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-MI... |
let meta = cstore.get_crate_data(cnum);
for (_, &dep) in meta.cnum_map.iter() {
visit(cstore, dep, ordering);
}
ordering.push(cnum);
};
for (&num, _) in self.metas.borrow().iter() {
visit(self, num, &mut ordering);
}
... | { return } | conditional_block |
issue_16723_multiple_items_syntax_ext.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
}
fn main() {
Struct1::foo();
Struct2::foo();
println!("hallo");
}
| foo | identifier_name |
issue_16723_multiple_items_syntax_ext.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 |
// ignore-stage1
// ignore-android
// aux-build:issue_16723_multiple_items_syntax_ext.rs
#![feature(phase)]
#[phase(plugin)] extern crate issue_16723_multiple_items_syntax_ext;
multiple_items!()
impl Struct1 {
fn foo() {}
}
impl Struct2 {
fn foo() {}
}
fn main() {
Struct1::foo();
Struct2::foo();
... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms. | random_line_split |
issue_16723_multiple_items_syntax_ext.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 ... | {
Struct1::foo();
Struct2::foo();
println!("hallo");
} | identifier_body | |
design_pattern-command.rs | //! Example of design pattern inspired from Head First Design Patterns
//!
//! Tested with rust-1.41.1-nightly
//!
//! @author Eliovir <http://github.com/~eliovir>
//!
//! @license MIT license <http://www.opensource.org/licenses/mit-license.php>
//!
//! @since 2014-04-20
//! Each action is encapsulated into a struct w... | }
}
// The second command on the object: light off
struct LightOffCommand {
light: Light,
}
impl LightOffCommand {
fn new(light: Light) -> LightOffCommand {
LightOffCommand { light }
}
}
impl Command for LightOffCommand {
fn execute(&self) {
self.light.off();
}
}
// The command will be launched by a remote ... | random_line_split | |
design_pattern-command.rs | //! Example of design pattern inspired from Head First Design Patterns
//!
//! Tested with rust-1.41.1-nightly
//!
//! @author Eliovir <http://github.com/~eliovir>
//!
//! @license MIT license <http://www.opensource.org/licenses/mit-license.php>
//!
//! @since 2014-04-20
//! Each action is encapsulated into a struct w... | (&self) {
self.light.off();
}
}
// The command will be launched by a remote control.
struct SimpleRemoteControl<'a> {
command: Box<dyn Command + 'a>,
}
impl<'a> SimpleRemoteControl<'a> {
fn new() -> SimpleRemoteControl<'a> {
SimpleRemoteControl { command: Box::new(NullCommand::new()) }
}
fn set_command(&mut s... | execute | identifier_name |
r3msg.rs | extern crate r3bar;
extern crate i3ipc;
use r3bar::r3ipc::{R3Msg};
use std::env;
fn help() {
println!("usage:
msgtype <integer>
msgtype number - see r3ipc documentation.
payload [string]
msg arguments if any.");
}
fn main() {
let args: Vec<String> = env::args().collect();
let empty_payload = "".t... | ,
// all the other cases
_ => {
// show a help message
help();
}
}
}
fn send(msgtype: u32, payload: &str) {
match R3Msg::new(None).unwrap().send_msg(msgtype, payload) {
Ok(i3ipc::reply::Command{outcomes}) => println!("{:?}", outcomes),
Err(e) => ... | {
let cmd = &args[1];
let payload;
if l == 3 {
payload = &args[2];
} else {
payload = &empty_payload;
}
match cmd.parse::<u32>() {
Ok(msgtype) => send(msgtype, payload),
Err(_) => re... | conditional_block |
r3msg.rs | extern crate r3bar;
extern crate i3ipc;
use r3bar::r3ipc::{R3Msg};
use std::env;
fn help() {
println!("usage:
msgtype <integer>
msgtype number - see r3ipc documentation.
payload [string]
msg arguments if any.");
}
fn main() | match cmd.parse::<u32>() {
Ok(msgtype) => send(msgtype, payload),
Err(_) => return help(),
}
},
// all the other cases
_ => {
// show a help message
help();
}
}
}
fn send(msgtype: u32, payload: &str) {... | {
let args: Vec<String> = env::args().collect();
let empty_payload = "".to_string();
match args.len() {
// no arguments passed
1 => {
help();
},
l @ 2...3 => {
let cmd = &args[1];
let payload;
if l == 3 {
payl... | identifier_body |
r3msg.rs | extern crate r3bar;
extern crate i3ipc;
use r3bar::r3ipc::{R3Msg};
use std::env;
fn | () {
println!("usage:
msgtype <integer>
msgtype number - see r3ipc documentation.
payload [string]
msg arguments if any.");
}
fn main() {
let args: Vec<String> = env::args().collect();
let empty_payload = "".to_string();
match args.len() {
// no arguments passed
1 => {
... | help | identifier_name |
r3msg.rs | extern crate r3bar;
extern crate i3ipc;
use r3bar::r3ipc::{R3Msg};
use std::env;
fn help() {
println!("usage:
msgtype <integer>
msgtype number - see r3ipc documentation.
payload [string]
msg arguments if any.");
}
| let empty_payload = "".to_string();
match args.len() {
// no arguments passed
1 => {
help();
},
l @ 2...3 => {
let cmd = &args[1];
let payload;
if l == 3 {
payload = &args[2];
} else {
... | fn main() {
let args: Vec<String> = env::args().collect(); | random_line_split |
fmt.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... | (ecx: &mut base::ExtCtxt, sp: Span,
_tts: &[ast::TokenTree]) -> ~base::MacResult {
ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead");
ecx.parse_sess.span_diagnostic.span_note(sp,
"see http://static.rust-lang.org/doc/master/std/fmt/index.html \
for document... | expand_syntax_ext | identifier_name |
fmt.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... | {
ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead");
ecx.parse_sess.span_diagnostic.span_note(sp,
"see http://static.rust-lang.org/doc/master/std/fmt/index.html \
for documentation");
base::MacExpr::new(ecx.expr_uint(sp, 2))
} | identifier_body | |
fmt.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 | // except according to those terms.
/// Deprecated fmt! syntax extension
use ast;
use codemap::Span;
use ext::base;
use ext::build::AstBuilder;
pub fn expand_syntax_ext(ecx: &mut base::ExtCtxt, sp: Span,
_tts: &[ast::TokenTree]) -> ~base::MacResult {
ecx.span_err(sp, "`fmt!` is deprecate... | // 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 | random_line_split |
gamepadlist.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::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GamepadListBinding::Game... |
}
impl GamepadListMethods for GamepadList {
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
fn Length(&self) -> u32 {
self.list.borrow().len() as u32
}
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
fn Item(&self, index: u32) -> Option<DomRoot<Gamepad>> {
... | {
for gamepad in gamepads {
if !self
.list
.borrow()
.iter()
.any(|g| g.gamepad_id() == gamepad.gamepad_id())
{
self.list.borrow_mut().push(Dom::from_ref(&*gamepad));
// Ensure that the gamepa... | identifier_body |
gamepadlist.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::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GamepadListBinding::Game... | (global: &GlobalScope, list: &[&Gamepad]) -> DomRoot<GamepadList> {
reflect_dom_object(Box::new(GamepadList::new_inherited(list)), global)
}
pub fn add_if_not_exists(&self, gamepads: &[DomRoot<Gamepad>]) {
for gamepad in gamepads {
if!self
.list
.borrow... | new | identifier_name |
gamepadlist.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::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GamepadListBinding::Game... | // https://w3c.github.io/gamepad/#dom-navigator-getgamepads
fn Length(&self) -> u32 {
self.list.borrow().len() as u32
}
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
fn Item(&self, index: u32) -> Option<DomRoot<Gamepad>> {
self.list
.borrow()
.get... | random_line_split | |
gamepadlist.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::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GamepadListBinding::Game... |
}
}
}
impl GamepadListMethods for GamepadList {
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
fn Length(&self) -> u32 {
self.list.borrow().len() as u32
}
// https://w3c.github.io/gamepad/#dom-navigator-getgamepads
fn Item(&self, index: u32) -> Option<DomRoot<Game... | {
self.list.borrow_mut().push(Dom::from_ref(&*gamepad));
// Ensure that the gamepad has the correct index
gamepad.update_index(self.list.borrow().len() as i32 - 1);
} | conditional_block |
bswap-const.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 ... | () {
assert_eq!(SWAPPED_U8, 0x12);
assert_eq!(SWAPPED_U16, 0x34_12);
assert_eq!(SWAPPED_I32, 0x78_56_34_12);
}
| main | identifier_name |
bswap-const.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 ... | {
assert_eq!(SWAPPED_U8, 0x12);
assert_eq!(SWAPPED_U16, 0x34_12);
assert_eq!(SWAPPED_I32, 0x78_56_34_12);
} | identifier_body | |
bswap-const.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 ... | fn main() {
assert_eq!(SWAPPED_U8, 0x12);
assert_eq!(SWAPPED_U16, 0x34_12);
assert_eq!(SWAPPED_I32, 0x78_56_34_12);
} |
const SWAPPED_U8: u8 = unsafe { intrinsics::bswap(0x12_u8) };
const SWAPPED_U16: u16 = unsafe { intrinsics::bswap(0x12_34_u16) };
const SWAPPED_I32: i32 = unsafe { intrinsics::bswap(0x12_34_56_78_i32) };
| random_line_split |
reseeding.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 ... |
}
impl<S, R: SeedableRng<S>, Rsdr: Reseeder<R> + Default>
SeedableRng<(Rsdr, S)> for ReseedingRng<R, Rsdr> {
fn reseed(&mut self, (rsdr, seed): (Rsdr, S)) {
self.rng.reseed(seed);
self.reseeder = rsdr;
self.bytes_generated = 0;
}
/// Create a new `ReseedingRng` from the given... | {
self.reseed_if_necessary();
self.bytes_generated += dest.len();
self.rng.fill_bytes(dest)
} | identifier_body |
reseeding.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 ... | pub trait Reseeder<R> {
/// Reseed the given RNG.
fn reseed(&mut self, rng: &mut R);
}
/// Reseed an RNG using a `Default` instance. This reseeds by
/// replacing the RNG with the result of a `Default::default` call.
#[derive(Copy, Clone)]
pub struct ReseedWithDefault;
impl<R: Rng + Default> Reseeder<R> for R... | ///
/// ``` | random_line_split |
reseeding.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 ... |
}
}
impl<R: Rng, Rsdr: Reseeder<R>> Rng for ReseedingRng<R, Rsdr> {
fn next_u32(&mut self) -> u32 {
self.reseed_if_necessary();
self.bytes_generated += 4;
self.rng.next_u32()
}
fn next_u64(&mut self) -> u64 {
self.reseed_if_necessary();
self.bytes_generated +=... | {
self.reseeder.reseed(&mut self.rng);
self.bytes_generated = 0;
} | conditional_block |
reseeding.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 ... | <R, Rsdr> {
rng: R,
generation_threshold: usize,
bytes_generated: usize,
/// Controls the behaviour when reseeding the RNG.
pub reseeder: Rsdr,
}
impl<R: Rng, Rsdr: Reseeder<R>> ReseedingRng<R, Rsdr> {
/// Create a new `ReseedingRng` with the given parameters.
///
/// # Arguments
//... | ReseedingRng | identifier_name |
first.rs | pub fn | (x: &mut [u32], up: bool) {
if x.len() > 1 {
let mid_point = x.len() / 2;
sort(&mut x[..mid_point], true);
sort(&mut x[mid_point..], false);
sub_sort(x, up);
}
}
fn sub_sort(x: &mut [u32], up: bool) {
if x.len() > 1 {
compare_and_swap(x, up);
let mid_point = ... | sort | identifier_name |
first.rs | pub fn sort(x: &mut [u32], up: bool) {
if x.len() > 1 {
let mid_point = x.len() / 2;
sort(&mut x[..mid_point], true);
sort(&mut x[mid_point..], false);
sub_sort(x, up);
}
}
fn sub_sort(x: &mut [u32], up: bool) {
if x.len() > 1 {
compare_and_swap(x, up);
let m... |
#[test]
fn sort_u32_descending() {
let mut x = vec![10, 30, 11, 20, 4, 330, 21, 110];
sort(&mut x, false);
assert_eq!(x, vec![330, 110, 30, 21, 20, 11, 10, 4]);
}
} | {
let mut x = vec![10, 30, 11, 20, 4, 330, 21, 110];
sort(&mut x, true);
assert_eq!(x, vec![4, 10, 11, 20, 21, 30, 110, 330]);
} | identifier_body |
first.rs | pub fn sort(x: &mut [u32], up: bool) {
if x.len() > 1 {
let mid_point = x.len() / 2;
sort(&mut x[..mid_point], true);
sort(&mut x[mid_point..], false);
sub_sort(x, up);
}
}
fn sub_sort(x: &mut [u32], up: bool) {
if x.len() > 1 {
compare_and_swap(x, up);
let m... | }
#[test]
fn sort_u32_descending() {
let mut x = vec![10, 30, 11, 20, 4, 330, 21, 110];
sort(&mut x, false);
assert_eq!(x, vec![330, 110, 30, 21, 20, 11, 10, 4]);
}
} | let mut x = vec![10, 30, 11, 20, 4, 330, 21, 110];
sort(&mut x, true);
assert_eq!(x, vec![4, 10, 11, 20, 21, 30, 110, 330]); | random_line_split |
first.rs | pub fn sort(x: &mut [u32], up: bool) {
if x.len() > 1 {
let mid_point = x.len() / 2;
sort(&mut x[..mid_point], true);
sort(&mut x[mid_point..], false);
sub_sort(x, up);
}
}
fn sub_sort(x: &mut [u32], up: bool) {
if x.len() > 1 {
compare_and_swap(x, up);
let m... |
}
}
#[cfg(test)]
mod tests {
use super::sort;
#[test]
fn sort_u32_ascending() {
let mut x = vec![10, 30, 11, 20, 4, 330, 21, 110];
sort(&mut x, true);
assert_eq!(x, vec![4, 10, 11, 20, 21, 30, 110, 330]);
}
#[test]
fn sort_u32_descending() {
let mut x = v... | {
x.swap(i, mid_point + i);
} | conditional_block |
connected_pov.rs | use serde_derive::Serialize;
use std::sync::{Arc, Mutex};
use std::sync::mpsc;
use std::thread;
use serde_json;
use uuid::Uuid;
use crate::lila;
use crate::lila::Session;
use super::LatencyRecorder;
use super::Pov;
use super::Color;
use crate::game::socket;
use crate::game::lila_message::LilaMessage;
pub struct C... | {
pub from: String,
pub to: String,
pub promotion: Option<String>,
}
| Dest | identifier_name |
connected_pov.rs | use serde_derive::Serialize;
use std::sync::{Arc, Mutex};
use std::sync::mpsc;
use std::thread;
use serde_json;
use uuid::Uuid;
use crate::lila;
use crate::lila::Session;
use super::LatencyRecorder;
use super::Pov;
use super::Color;
use crate::game::socket;
use crate::game::lila_message::LilaMessage;
pub struct C... | pub struct MovePacket {
t: String,
d: Dest,
l: Option<i64>,
}
#[derive(Serialize, Debug)]
pub struct Dest {
pub from: String,
pub to: String,
pub promotion: Option<String>,
} | self.send_tx.send(message).unwrap();
}
}
#[derive(Serialize, Debug)] | random_line_split |
connected_pov.rs | use serde_derive::Serialize;
use std::sync::{Arc, Mutex};
use std::sync::mpsc;
use std::thread;
use serde_json;
use uuid::Uuid;
use crate::lila;
use crate::lila::Session;
use super::LatencyRecorder;
use super::Pov;
use super::Color;
use crate::game::socket;
use crate::game::lila_message::LilaMessage;
pub struct C... | ;
if let Some(c) = m.clock {
pov.clock = Some(c);
};
},
Some(LilaMessage::Clock(c)) => {
pov.clock = Some(c);
},
//LilaMessage::End => tx_1.send(Message::close()).unwrap(),... | { Color::black } | conditional_block |
md5.rs | use std::io::{MemWriter, BufWriter};
use super::Hasher;
static R: [u32,..64]= [
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, ... | (&self) -> uint
{
128
}
fn block_size_bits(&self) -> uint
{
512
}
}
#[cfg(test)]
mod test
{
use hash::Hasher;
use hash::md5::MD5;
use serialize::hex::ToHex;
#[test]
fn test_simple()
{
let tests = [
("The quick brown fox jumps over the l... | output_size_bits | identifier_name |
md5.rs | use std::io::{MemWriter, BufWriter};
use super::Hasher;
static R: [u32,..64]= [
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, ... |
}
}
#[allow(unused_must_use)]
fn output(&self, out: &mut [u8])
{
let mut m = MD5 {
h: self.h,
data: Vec::new(),
length: 0,
};
let mut w = MemWriter::new();
w.write(self.data.as_slice());
w.write_u8(0x80);
w.wr... | {
self.data.push_all(chunk);
} | conditional_block |
md5.rs | use std::io::{MemWriter, BufWriter};
use super::Hasher;
static R: [u32,..64]= [
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, ... |
let tmp = d;
d = c;
c = b;
b = left_rotate(a + f + K[i] + words[g], R[i]) + b;
a = tmp;
}
self.h[0] += a;
self.h[1] += b;
self.h[2] += c;
self.h[3] += d;
}
}
impl Hasher for MD5
{
fn reset(&mut self)
{
... | _ => (0, 0),
}; | random_line_split |
md5.rs | use std::io::{MemWriter, BufWriter};
use super::Hasher;
static R: [u32,..64]= [
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, ... |
fn update(&mut self, data: &[u8])
{
let mut d = self.data.clone();
self.data.clear();
d.push_all(data);
for chunk in d.as_slice().chunks(64)
{
self.length += chunk.len() as u64;
if chunk.len() == 64
{
self.process_b... | {
self.h = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476];
self.data.clear();
self.length = 0;
} | identifier_body |
alg.rs | use super::{Graph, NodeId, Length};
use std::time::Instant;
use std::cmp::Ordering;
use std::usize;
use std::collections::VecDeque;
impl Graph {
pub fn count_components(&self) -> usize {
let start = Instant::now();
let mut union = UnionFind::new(self.node_info.len());
for id in 0..self.nod... | (&self) -> usize {
let mut result = 0;
for (index, &par) in self.parent.iter().enumerate() {
if index == par {
result += 1;
}
}
result
}
}
#[derive(PartialEq, Eq, Debug)]
struct NodeCost {
node: NodeId,
cost: usize,
}
impl Ord for Nod... | count | identifier_name |
alg.rs | use super::{Graph, NodeId, Length};
use std::time::Instant;
use std::cmp::Ordering;
use std::usize;
use std::collections::VecDeque;
impl Graph {
pub fn count_components(&self) -> usize {
let start = Instant::now();
let mut union = UnionFind::new(self.node_info.len());
for id in 0..self.nod... | union.union(start, n);
queue.extend(self.outgoing_edges_for(n).iter().map(|e| e.endpoint));
}
}
}
pub fn dijkstra(&self) -> Dijkstra {
Dijkstra {
dist: vec![usize::MAX; self.node_count()],
touched: Default::default(),
... | if union.find(n) == n { | random_line_split |
alg.rs | use super::{Graph, NodeId, Length};
use std::time::Instant;
use std::cmp::Ordering;
use std::usize;
use std::collections::VecDeque;
impl Graph {
pub fn count_components(&self) -> usize {
let start = Instant::now();
let mut union = UnionFind::new(self.node_info.len());
for id in 0..self.nod... |
if cost > self.dist[node] {
continue;
}
for edge in self.graph.outgoing_edges_for(node) {
let next = NodeCost {
node: edge.endpoint,
cost: cost + edge.weight,
};
if next.cost < s... | {
let mut path = VecDeque::new();
let mut cur = node;
while cur != source {
path.push_front(cur);
cur = prev[cur];
}
path.push_front(source);
return Some((cost, path));
} | conditional_block |
gamepadbuttonlist.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::GamepadButtonListBinding;
use dom::bindings::codegen::Bindings::GamepadButto... | (list: &[&GamepadButton]) -> GamepadButtonList {
GamepadButtonList {
reflector_: Reflector::new(),
list: list.iter().map(|button| Dom::from_ref(*button)).collect(),
}
}
pub fn new_from_vr(global: &GlobalScope, buttons: &[WebVRGamepadButton]) -> DomRoot<GamepadButtonList>... | new_inherited | identifier_name |
gamepadbuttonlist.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::GamepadButtonListBinding;
use dom::bindings::codegen::Bindings::GamepadButto... |
pub fn sync_from_vr(&self, vr_buttons: &[WebVRGamepadButton]) {
for (gp_btn, btn) in self.list.iter().zip(vr_buttons.iter()) {
gp_btn.update(btn.pressed, btn.touched);
}
}
}
impl GamepadButtonListMethods for GamepadButtonList {
// https://w3c.github.io/gamepad/#dom-gamepad-but... | {
rooted_vec!(let list <- buttons.iter()
.map(|btn| GamepadButton::new(&global, btn.pressed, btn.touched)));
reflect_dom_object(Box::new(GamepadButtonList::new_inherited(list.r())),
global,
GamepadButtonListBin... | identifier_body |
gamepadbuttonlist.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::root::{Dom, DomRoot, RootedReference};
use dom::gamepadbutton::GamepadButton;
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use webvr_traits::WebVRGamepadButton;
// https://w3c.github.io/gamepad/#gamepadbutton-interface
#[dom_struct]
pub struct GamepadButtonList {
reflector_: Re... |
use dom::bindings::codegen::Bindings::GamepadButtonListBinding;
use dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object}; | random_line_split |
free.rs | #![deny(warnings)]
extern crate coreutils;
extern crate extra;
#[cfg(target_os = "redox")]
extern crate syscall;
#[cfg(target_os = "redox")]
fn free(parser: &coreutils::ArgParser) -> ::std::io::Result<()> {
use coreutils::to_human_readable_string;
use std::io::Error;
use syscall::data::StatVfs;
let m... | () {
use std::io::{stderr, Write};
use std::process::exit;
let mut stderr = stderr();
stderr.write(b"error: unimplemented outside redox").unwrap();
exit(1);
}
| main | identifier_name |
free.rs | #![deny(warnings)]
extern crate coreutils;
extern crate extra;
#[cfg(target_os = "redox")]
extern crate syscall;
#[cfg(target_os = "redox")]
fn free(parser: &coreutils::ArgParser) -> ::std::io::Result<()> {
use coreutils::to_human_readable_string;
use std::io::Error;
use syscall::data::StatVfs;
let m... |
if parser.found("human-readable") {
println!("{:<8}{:>10}{:>10}{:>10}",
"Mem:",
to_human_readable_string(size),
to_human_readable_string(used),
to_human_readable_string(free));
} else {
println!("{:<8}{:>10}{:>10}{:>10}",
... | let free = stat.f_bavail * stat.f_bsize as u64; | random_line_split |
free.rs | #![deny(warnings)]
extern crate coreutils;
extern crate extra;
#[cfg(target_os = "redox")]
extern crate syscall;
#[cfg(target_os = "redox")]
fn free(parser: &coreutils::ArgParser) -> ::std::io::Result<()> {
use coreutils::to_human_readable_string;
use std::io::Error;
use syscall::data::StatVfs;
let m... | {
use std::io::{stderr, Write};
use std::process::exit;
let mut stderr = stderr();
stderr.write(b"error: unimplemented outside redox").unwrap();
exit(1);
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.