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
cabi_powerpc.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
Type::struct_(ccx, coerce_to_int(ccx, size).as_slice(), false) } pub fn compute_abi_info(ccx: &CrateContext, atys: &[Type], rty: Type, ret_def: bool) -> FnType { let ret_ty = if ret_def { classify_ret_ty(ccx, rty) } else { ...
args } fn struct_ty(ccx: &CrateContext, ty: Type) -> Type { let size = ty_size(ty) * 8;
random_line_split
cabi_powerpc.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} fn is_reg_ty(ty: Type) -> bool { return match ty.kind() { Integer | Pointer | Float | Double => true, _ => false }; } fn padding_ty(ccx: &CrateContext, align: uint, offset: uint) -> Option<Type> { if ((align - 1 ) & offset) > 0 { Some(Type::i32(ccx)) ...
{ ArgType::direct( ty, Some(struct_ty(ccx, ty)), padding_ty(ccx, align, orig_offset), None ) }
conditional_block
type-ascription-precedence.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) -> Z { panic!() } } impl Deref for S { type Target = Z; fn deref(&self) -> &Z { panic!() } } fn main() { &S: &S; // OK (&S): &S; // OK &(S: &S); //~ ERROR mismatched types *S: Z; // OK (*S): Z; // OK *(S: Z); //~ ERROR mismatched types //~^ ERROR type `Z` cannot be dereferen...
neg
identifier_name
type-ascription-precedence.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 ...
} fn main() { &S: &S; // OK (&S): &S; // OK &(S: &S); //~ ERROR mismatched types *S: Z; // OK (*S): Z; // OK *(S: Z); //~ ERROR mismatched types //~^ ERROR type `Z` cannot be dereferenced -S: Z; // OK (-S): Z; // OK -(S: Z); //~ ERROR mismatched types //~^ ERROR cannot ap...
{ panic!() }
identifier_body
type-ascription-precedence.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 ...
#![feature(type_ascription)] use std::ops::*; struct S; struct Z; impl Add<Z> for S { type Output = S; fn add(self, _rhs: Z) -> S { panic!() } } impl Mul<Z> for S { type Output = S; fn mul(self, _rhs: Z) -> S { panic!() } } impl Neg for S { type Output = Z; fn neg(self) -> Z { panic!() } } im...
// Operator precedence of type ascription // Type ascription has very high precedence, the same as operator `as`
random_line_split
types.rs
use vecmath::{self, vec2_sub, vec2_len}; pub type Scalar = f64; /// [width, height] pub type Extent = vecmath::Vector2<Scalar>; /// [x, y] pub type Position = vecmath::Vector2<Scalar>; pub type Velocity = vecmath::Vector2<Scalar>; use transition::Transition; /// Points on screen. Usually they correspond to pixels, ...
_ => { self.left() <= other.right() && self.right() >= other.left() && self.top() <= other.bottom() && self.bottom() >= other.top() } } } } #[derive(Debug, Clone, PartialEq)] pub enum ObstacleKind { /// Enables a temporary attractive force At...
{ vec2_len(vec2_sub(self.pos, other.pos)) <= self.half_size + other.half_size }
conditional_block
types.rs
use vecmath::{self, vec2_sub, vec2_len}; pub type Scalar = f64; /// [width, height] pub type Extent = vecmath::Vector2<Scalar>; /// [x, y] pub type Position = vecmath::Vector2<Scalar>; pub type Velocity = vecmath::Vector2<Scalar>; use transition::Transition; /// Points on screen. Usually they correspond to pixels, ...
{ /// Enables a temporary attractive force AttractiveForceSwitch, /// Causes all other obstacles to hide themselves for a while InvisibiltySwitch, /// Kills the player Deadly, } /// An obstacle the hunter can collide with #[derive(Debug, Clone, PartialEq)] pub struct Obstacle { pub kind: O...
ObstacleKind
identifier_name
types.rs
use vecmath::{self, vec2_sub, vec2_len}; pub type Scalar = f64; /// [width, height] pub type Extent = vecmath::Vector2<Scalar>; /// [x, y] pub type Position = vecmath::Vector2<Scalar>; pub type Velocity = vecmath::Vector2<Scalar>; use transition::Transition; /// Points on screen. Usually they correspond to pixels, ...
pub fn top(&self) -> Scalar { self.pos[1] - self.half_size } pub fn bottom(&self) -> Scalar { self.pos[1] + self.half_size } /// Returns true if both objects intersect pub fn intersects(&self, other: &Object) -> bool { match (&self.shape, &other.shape) { (&...
}
random_line_split
lib.rs
)] grammar ); pub mod infix; mod layout; mod str_suffix; mod token; fn new_ident<Id>(type_cache: &TypeCache<Id, ArcType<Id>>, name: Id) -> TypedIdent<Id> { TypedIdent { name: name, typ: type_cache.hole(), } } type LalrpopError<'input> = lalrpop_util::ParseError<BytePos, BorrowedToken<...
ExtraToken { token: (lpos, token, rpos), } => pos::spanned2(lpos, rpos, Error::ExtraToken(token.map(|s| s.into()))), User { error } => error, } } } #[derive(Debug)] pub enum FieldExpr<'ast, Id> { Type( BaseMetadata<'ast>, Spanned<Id, B...
}
random_line_split
lib.rs
grammar ); pub mod infix; mod layout; mod str_suffix; mod token; fn new_ident<Id>(type_cache: &TypeCache<Id, ArcType<Id>>, name: Id) -> TypedIdent<Id> { TypedIdent { name: name, typ: type_cache.hole(), } } type LalrpopError<'input> = lalrpop_util::ParseError<BytePos, BorrowedToken<'i...
Ok(OpMeta { fixity, precedence }) } match parse_infix(infix_attribute) { Ok(op_meta) => { self.op_table.operators.insert(id.clone(), op_meta); } Err(err) ...
{ let mut iter = s.splitn(2, ","); let fixity = match iter.next().ok_or(InfixError::InvalidFixity)?.trim() { "left" => Fixity::Left, "right" => Fixity::Right, _ => { ...
identifier_body
lib.rs
grammar ); pub mod infix; mod layout; mod str_suffix; mod token; fn new_ident<Id>(type_cache: &TypeCache<Id, ArcType<Id>>, name: Id) -> TypedIdent<Id> { TypedIdent { name: name, typ: type_cache.hole(), } } type LalrpopError<'input> = lalrpop_util::ParseError<BytePos, BorrowedToken<'i...
ExtraToken { token: (lpos, token, rpos), } => pos::spanned2(lpos, rpos, Error::ExtraToken(token.map(|s| s.into()))), User { error } => error, } } } #[derive(Debug)] pub enum FieldExpr<'ast, Id> { Type( BaseMetadata<'ast>, Spanned<Id, ...
{ // LALRPOP will use `Default::default()` as the location if it is unable to find // one. This is not correct for codespan as that represents "nil" so we must grab // the end from the current source instead let location = if location == BytePos::default()...
conditional_block
lib.rs
grammar ); pub mod infix; mod layout; mod str_suffix; mod token; fn new_ident<Id>(type_cache: &TypeCache<Id, ArcType<Id>>, name: Id) -> TypedIdent<Id> { TypedIdent { name: name, typ: type_cache.hole(), } } type LalrpopError<'input> = lalrpop_util::ParseError<BytePos, BorrowedToken<'i...
<'a, Iter>( source_span: Span<BytePos>, errors: Iter, ) -> Errors<Spanned<Error, BytePos>> where Iter: IntoIterator<Item = LalrpopError<'a>>, { errors .into_iter() .map(|err| Error::from_lalrpop(source_span, err)) .collect() } struct Expected<'a>(&'a [String]); impl<'a> fmt::Displ...
transform_errors
identifier_name
issue-4252.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 ...
// xfail-test trait X { fn call(&self); } struct Y; struct Z<T> { x: T } impl X for Y { fn call(&self) { } } impl<T: X> Drop for Z<T> { fn drop(&mut self) { self.x.call(); // Adding this statement causes an ICE. } } fn main() { let y = Y; let _z = Z{x: y}; }
random_line_split
issue-4252.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 ...
() { let y = Y; let _z = Z{x: y}; }
main
identifier_name
issue-4252.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<T: X> Drop for Z<T> { fn drop(&mut self) { self.x.call(); // Adding this statement causes an ICE. } } fn main() { let y = Y; let _z = Z{x: y}; }
{ }
identifier_body
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 https://mozilla.org/MPL/2.0/. */ #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] extern crate num_derive; #[mac...
pub fn send(&self, msg: (Option<TopLevelBrowsingContextId>, EmbedderMsg)) { // Send a message and kick the OS event loop awake. if let Err(err) = self.sender.send(msg) { warn!("Failed to send response ({:?}).", err); } self.event_loop_waker.wake(); } } impl Clone for...
impl EmbedderProxy {
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 https://mozilla.org/MPL/2.0/. */ #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] extern crate num_derive; #[mac...
pub duration: f64, pub playback_rate: f64, pub position: f64, } impl MediaPositionState { pub fn new(duration: f64, playback_rate: f64, position: f64) -> Self { Self { duration, playback_rate, position, } } } /// Type of events sent from script to t...
ositionState {
identifier_name
isr.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
#[path="cortex_m3/isr.rs"] pub mod isr_cortex_m4; #[cfg(feature = "mcu_lpc17xx")] #[path="lpc17xx/isr.rs"] pub mod isr_lpc17xx; #[cfg(feature = "mcu_k20")] #[path="k20/isr.rs"] pub mod isr_k20; #[cfg(feature = "mcu_tiva_c")] #[path="tiva_c/isr.rs"] pub mod isr_tiva_c;
#[cfg(feature = "cpu_cortex-m3")] #[path="cortex_m3/isr.rs"] pub mod isr_cortex_m3; #[cfg(feature = "cpu_cortex-m4")]
random_line_split
gamestate.rs
extern crate rand; use std::fmt; use rand::{Rng, SeedableRng, XorShiftRng}; pub const GRID_HEIGHT: i16 = 1000; pub const GRID_WIDTH: i16 = 400; pub const BLOCK_SIZE: i16 = 1; pub const WINDOW_HEIGHT: i16 = GRID_HEIGHT * BLOCK_SIZE; pub const WINDOW_WIDTH: i16 = GRID_WIDTH * BLOCK_SIZE; pub const RAIN_SPARSENESS: ...
(x: i16, y: i16) -> bool { !(x < 0 || x >= GRID_WIDTH || y < 0 || y >= GRID_HEIGHT) } pub fn update(&mut self) { // MAIN LOGIC for (index, particle) in self.particles.iter_mut().enumerate() { let (x, y) = (particle.x, particle.y); let neighbours = self.map.get_nei...
is_valid
identifier_name
gamestate.rs
extern crate rand; use std::fmt; use rand::{Rng, SeedableRng, XorShiftRng}; pub const GRID_HEIGHT: i16 = 1000; pub const GRID_WIDTH: i16 = 400; pub const BLOCK_SIZE: i16 = 1; pub const WINDOW_HEIGHT: i16 = GRID_HEIGHT * BLOCK_SIZE; pub const WINDOW_WIDTH: i16 = GRID_WIDTH * BLOCK_SIZE; pub const RAIN_SPARSENESS: ...
} pub fn paint_square_obstacles(&mut self, ux: i16, uy: i16, dx: i16, dy: i16) { //if Self::is_valid(ux + dx, uy + dy) { if Self::is_valid(ux, uy) && Self::is_valid(ux + dx, uy + dy) { for x in ux..ux + dx { for y in uy..uy + dy { if!self.map.is_...
{ for x in ux..ux + dx { for y in uy..uy + dy { self.map.remove_coord_map(x, y); } } let ul = Loc { x: ux, y: uy }; let lr = Loc { x: ux + dx, y: uy + dy, }; Self::...
conditional_block
gamestate.rs
extern crate rand; use std::fmt; use rand::{Rng, SeedableRng, XorShiftRng}; pub const GRID_HEIGHT: i16 = 1000; pub const GRID_WIDTH: i16 = 400; pub const BLOCK_SIZE: i16 = 1; pub const WINDOW_HEIGHT: i16 = GRID_HEIGHT * BLOCK_SIZE; pub const WINDOW_WIDTH: i16 = GRID_WIDTH * BLOCK_SIZE; pub const RAIN_SPARSENESS: ...
fn new() -> Map { // casting a vector of bools into a 2d array of bools unsafely // to avoid using unstable box_syntax // code taken from: //https://gist.github.com/anonymous/62f21e4fb7a13867891c let mut v: Vec<bool> = Vec::with_capacity(GRID_HEIGHT as usize * GRID_WIDTH as usize)...
{ self.map[x as usize][y as usize] = false; }
identifier_body
gamestate.rs
extern crate rand; use std::fmt; use rand::{Rng, SeedableRng, XorShiftRng}; pub const GRID_HEIGHT: i16 = 1000; pub const GRID_WIDTH: i16 = 400; pub const BLOCK_SIZE: i16 = 1; pub const WINDOW_HEIGHT: i16 = GRID_HEIGHT * BLOCK_SIZE; pub const WINDOW_WIDTH: i16 = GRID_WIDTH * BLOCK_SIZE; pub const RAIN_SPARSENESS: ...
let neighbours = self.map.get_neighbours(x, y); let (x_new, y_new) = match neighbours { // 1-2-3 above 4-5 sides 6-7-8 below (_, _, _, _, _, _, o, _) => (x, y + 1), //fall straight down if possible (_, X, _, o, X, _, X, _) => (x - 1, y), //move sid...
// MAIN LOGIC for (index, particle) in self.particles.iter_mut().enumerate() { let (x, y) = (particle.x, particle.y);
random_line_split
lib.rs
//! # Fixerio API Wrapper //! //! http://fixer.io //! //! ## Usage //! Add the following to `Cargo.toml`: //! //! ```rust,ignore
//! [dependencies] //! fixerio = "0.1.3" //! ``` //! //! Synchronous example: //! //! ```rust,no_run //! //! extern crate fixerio; //! //! use fixerio::{Config, Currency, SyncApi}; //! //! fn main() { //! let api = SyncApi::new().expect("Error creating API"); //! //! let config = Config::new(Currency::USD); //!...
random_line_split
traversal.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use context::{LocalStyleContext, SharedStyleContext, StyleContext}; use dom::OpaqueNode; use gecko::context::Stand...
fn process_preorder(&self, node: GeckoNode<'ln>) -> RestyleResult { // FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML // parser. node.initialize_data(); recalc_style_at(&self.context, self.root, node) } fn process_postorder(&self, _: G...
{ // See the comment in RecalcStyleAndConstructFlows::new for an explanation of why this is // necessary. let shared_lc: &'lc Self::SharedContext = unsafe { mem::transmute(shared) }; RecalcStyleOnly { context: StandaloneStyleContext::new(shared_lc), root: root, ...
identifier_body
traversal.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use context::{LocalStyleContext, SharedStyleContext, StyleContext}; use dom::OpaqueNode; use gecko::context::Stand...
// parser. node.initialize_data(); recalc_style_at(&self.context, self.root, node) } fn process_postorder(&self, _: GeckoNode<'ln>) { unreachable!(); } /// We don't use the post-order traversal for anything. fn needs_postorder_traversal(&self) -> bool { false } ...
// FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML
random_line_split
traversal.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use context::{LocalStyleContext, SharedStyleContext, StyleContext}; use dom::OpaqueNode; use gecko::context::Stand...
(&self) -> bool { false } fn local_context(&self) -> &LocalStyleContext { self.context.local_context() } }
needs_postorder_traversal
identifier_name
main.rs
/* * main.rs * This file is part of Oblique_Projection * * Copyright (C) 2017 - Lilith Wynter * * Oblique_Projection 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 2 of the License, or ...
temp_data.push(Vec::new()); for j in 0..num_dim-1 { if j%2 == 0 { temp_data[i].push(final_array[i][j] as f64 + 0.5*final_array[i][num_dim-1]*angle.cos() as f64); } else { temp_data[i].push(final_array[i][j] as f64 + 0.5*final_array[i][num_dim-1]*angle.sin() as f64); ...
{ // Gather data from specified file let data = read_nd_data(file); // The standard angle in a oblique projection let angle: f64 = 63.4; let mut final_array = data; // Number of points in dataset let num_points = final_array.len(); // Number of dimensions let mut num_dim = final_array[0].le...
identifier_body
main.rs
/* * main.rs * This file is part of Oblique_Projection * * Copyright (C) 2017 - Lilith Wynter * * Oblique_Projection 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 2 of the License, or ...
() { oblique_projection_from_nd("./data/DorotheaData.csv"); }
main
identifier_name
main.rs
/* * main.rs * This file is part of Oblique_Projection * * Copyright (C) 2017 - Lilith Wynter * * Oblique_Projection 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 2 of the License, or ...
} } let mut array_2d: Vec<[f64; 2]> = Vec::new(); // Change array structure for imaging for i in 0..num_points { array_2d.push([final_array[i][0], final_array[i][1]]); } array_to_image(&mut array_2d); } fn main() { oblique_projection_from_nd("./data/DorotheaData.csv"); }
{ smaller_than_10000 = false; }
conditional_block
main.rs
/* * main.rs * This file is part of Oblique_Projection * * Copyright (C) 2017 - Lilith Wynter * * Oblique_Projection 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 2 of the License, or ...
oblique_projection_from_nd("./data/DorotheaData.csv"); }
} fn main() {
random_line_split
mod.rs
//! Utilities for handling shell surfaces with the `wlr_layer_shell` protocol //! //! This interface should be suitable for the implementation of many desktop shell components, //! and a broad number of other applications that interact with the desktop. //! //! ### Initialization //! //! To initialize this handler, sim...
{ known_layers: Vec<LayerSurface>, } impl LayerShellState { /// Access all the shell surfaces known by this handler pub fn layer_surfaces(&self) -> &[LayerSurface] { &self.known_layers[..] } } #[derive(Clone)] struct ShellUserData { _log: ::slog::Logger, user_impl: Rc<RefCell<dyn FnMu...
LayerShellState
identifier_name
mod.rs
//! Utilities for handling shell surfaces with the `wlr_layer_shell` protocol //! //! This interface should be suitable for the implementation of many desktop shell components, //! and a broad number of other applications that interact with the desktop. //! //! ### Initialization //! //! To initialize this handler, sim...
Ok(compositor::with_states(&self.wl_surface, |states| { let mut attributes = states .data_map .get::<Mutex<LayerSurfaceAttributes>>() .unwrap() .lock() .unwrap(); if attributes.server_pending.is_none() { ...
{ return Err(DeadResource); }
conditional_block
mod.rs
//! Utilities for handling shell surfaces with the `wlr_layer_shell` protocol //! //! This interface should be suitable for the implementation of many desktop shell components, //! and a broad number of other applications that interact with the desktop. //! //! ### Initialization //! //! To initialize this handler, sim...
}, }; mod handlers; mod types; pub use types::{Anchor, ExclusiveZone, KeyboardInteractivity, Layer, Margins}; /// The role of a wlr_layer_shell_surface pub const LAYER_SURFACE_ROLE: &str = "zwlr_layer_surface_v1"; /// Attributes for layer surface #[derive(Debug)] pub struct LayerSurfaceAttributes { surface:...
Serial, SERIAL_COUNTER,
random_line_split
mod.rs
//! Utilities for handling shell surfaces with the `wlr_layer_shell` protocol //! //! This interface should be suitable for the implementation of many desktop shell components, //! and a broad number of other applications that interact with the desktop. //! //! ### Initialization //! //! To initialize this handler, sim...
fn merge_into(self, into: &mut Self) { *into = self; } } /// Shell global state /// /// This state allows you to retrieve a list of surfaces /// currently known to the shell global. #[derive(Debug)] pub struct LayerShellState { known_layers: Vec<LayerSurface>, } impl LayerShellState { /// Acc...
{ *self }
identifier_body
http_server.rs
use std::thread; use actix_web::{middleware, web, App, HttpRequest, HttpServer, Responder}; use prometheus::{Encoder, TextEncoder}; pub fn start_http_server( addr: std::net::SocketAddr, ) -> (thread::JoinHandle<()>, actix_rt::System, actix_web::dev::Server) { let (tx, rx) = std::sync::mpsc::channel(); l...
async fn metrics(_req: HttpRequest) -> impl Responder { let metric_families = prometheus::gather(); let encoder = TextEncoder::new(); let mut buffer = Vec::new(); let encode_result = encoder.encode(&metric_families, &mut buffer); match encode_result { Ok(_) => {} Err(e) => error...
let server = rx_http.recv().unwrap(); (join_handle, system, server) }
random_line_split
http_server.rs
use std::thread; use actix_web::{middleware, web, App, HttpRequest, HttpServer, Responder}; use prometheus::{Encoder, TextEncoder}; pub fn start_http_server( addr: std::net::SocketAddr, ) -> (thread::JoinHandle<()>, actix_rt::System, actix_web::dev::Server) { let (tx, rx) = std::sync::mpsc::channel(); l...
(_req: HttpRequest) -> impl Responder { let metric_families = prometheus::gather(); let encoder = TextEncoder::new(); let mut buffer = Vec::new(); let encode_result = encoder.encode(&metric_families, &mut buffer); match encode_result { Ok(_) => {} Err(e) => error!("[E02011] Error...
metrics
identifier_name
http_server.rs
use std::thread; use actix_web::{middleware, web, App, HttpRequest, HttpServer, Responder}; use prometheus::{Encoder, TextEncoder}; pub fn start_http_server( addr: std::net::SocketAddr, ) -> (thread::JoinHandle<()>, actix_rt::System, actix_web::dev::Server)
system.run().unwrap(); debug!("http server shutdown"); }); let system = rx.recv().unwrap(); let server = rx_http.recv().unwrap(); (join_handle, system, server) } async fn metrics(_req: HttpRequest) -> impl Responder { let metric_families = prometheus::gather(); let encoder...
{ let (tx, rx) = std::sync::mpsc::channel(); let (tx_http, rx_http) = std::sync::mpsc::channel(); let join_handle = thread::spawn(move || { let system = actix_rt::System::new("http_server"); let server = HttpServer::new(move || { App::new() .wrap(middleware::Log...
identifier_body
message.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warrant...
cmd => return Err(d.error(format!("unrecognized network command `{}`", cmd))) }; Ok(RawNetworkMessage { magic: magic, payload: payload }) } } #[cfg(test)] mod test { use super::{RawNetworkMessage, NetworkMessage, CommandString}; use network::ser...
{ let magic = try!(ConsensusDecodable::consensus_decode(d)); let CommandString(cmd): CommandString= try!(ConsensusDecodable::consensus_decode(d)); let CheckedData(raw_payload): CheckedData = try!(ConsensusDecodable::consensus_decode(d)); let mut mem_d = RawDecoder::new(Cursor::new(raw_p...
identifier_body
message.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warrant...
/// `verack` Verack, /// `addr` Addr(Vec<(u32, Address)>), /// `inv` Inv(Vec<message_blockdata::Inventory>), /// `getdata` GetData(Vec<message_blockdata::Inventory>), /// `notfound` NotFound(Vec<message_blockdata::Inventory>), /// `getblocks` GetBlocks(message_blockdata::...
/// A Network message payload. Proper documentation is available on the Bitcoin /// wiki https://en.bitcoin.it/wiki/Protocol_specification pub enum NetworkMessage { /// `version` Version(message_network::VersionMessage),
random_line_split
message.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warrant...
(d: &mut D) -> Result<RawNetworkMessage, D::Error> { let magic = try!(ConsensusDecodable::consensus_decode(d)); let CommandString(cmd): CommandString= try!(ConsensusDecodable::consensus_decode(d)); let CheckedData(raw_payload): CheckedData = try!(ConsensusDecodable::consensus_decode(d)); ...
consensus_decode
identifier_name
event.rs
use crate::Token; use super::Ready; pub type SysEvent = Event; #[derive(Debug, Clone)] pub struct Event { token: Token, readiness: Ready, } impl Event { pub(crate) fn new(readiness: Ready, token: Token) -> Event { Event { token, readiness } } pub fn token(&self) -> Token { self....
} pub fn is_priority(&self) -> bool { self.readiness.is_priority() } pub fn is_aio(&self) -> bool { self.readiness.is_aio() } pub fn is_lio(&self) -> bool { self.readiness.is_lio() } }
} pub fn is_hup(&self) -> bool { self.readiness.is_hup()
random_line_split
event.rs
use crate::Token; use super::Ready; pub type SysEvent = Event; #[derive(Debug, Clone)] pub struct Event { token: Token, readiness: Ready, } impl Event { pub(crate) fn new(readiness: Ready, token: Token) -> Event { Event { token, readiness } } pub fn token(&self) -> Token { self....
(&self) -> bool { self.readiness.is_readable() } pub fn is_writable(&self) -> bool { self.readiness.is_writable() } pub fn is_error(&self) -> bool { self.readiness.is_error() } pub fn is_hup(&self) -> bool { self.readiness.is_hup() } pub fn is_priority...
is_readable
identifier_name
from_json.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
pub trait FromJson { /// Convert a JSON value to an instance of this type. fn from_json(json: &Json) -> Self; } impl FromJson for U256 { fn from_json(json: &Json) -> Self { match *json { Json::String(ref s) => { if s.len() >= 2 && &s[0..2] == "0x" { FromStr::from_str(&s[2..]).unwrap_or_else(|_| Defaul...
} } /// Trait allowing conversion from a JSON value.
random_line_split
from_json.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
}
{ match *json { Json::String(ref s) => { if s.len() >= 2 && &s[0..2] == "0x" { FromStr::from_str(&s[2..]).unwrap_or_else(|_| Default::default()) } else { Uint::from_dec_str(s).unwrap_or_else(|_| Default::default()) } }, Json::U64(u) => From::from(u), Json::I64(i) => From::from(i as u...
identifier_body
from_json.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
(json: &Json) -> Self { match *json { Json::String(ref s) => { if s.len() >= 2 && &s[0..2] == "0x" { FromStr::from_str(&s[2..]).unwrap_or_else(|_| Default::default()) } else { Uint::from_dec_str(s).unwrap_or_else(|_| Default::default()) } }, Json::U64(u) => From::from(u), Json::I64(i...
from_json
identifier_name
util.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::sync::Arc; use cpython::*; use cpython_ext::{ExtractInner, PyPath, PyPathBuf, ResultPyErrExt}; use edenapi::{Progress, ProgressCal...
<'a>( py: Python, keys: impl IntoIterator<Item = &'a (PyPathBuf, PyBytes)>, ) -> PyResult<Vec<Key>> { keys.into_iter() .map(|(path, hgid)| to_key(py, path, hgid)) .collect() } pub fn wrap_callback(callback: PyObject) -> ProgressCallback { Box::new(move |progress: Progress| { let g...
to_keys
identifier_name
util.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::sync::Arc; use cpython::*; use cpython_ext::{ExtractInner, PyPath, PyPathBuf, ResultPyErrExt}; use edenapi::{Progress, ProgressCal...
pub fn as_deltastore(py: Python, store: PyObject) -> PyResult<Arc<dyn HgIdMutableDeltaStore>> { Ok(store.extract::<mutabledeltastore>(py)?.extract_inner(py)) } pub fn as_historystore(py: Python, store: PyObject) -> PyResult<Arc<dyn HgIdMutableHistoryStore>> { Ok(store.extract::<mutablehistorystore>(py)?.extr...
{ Box::new(move |progress: Progress| { let gil = Python::acquire_gil(); let py = gil.python(); let _ = callback.call(py, progress.as_tuple(), None); }) }
identifier_body
util.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::sync::Arc; use cpython::*; use cpython_ext::{ExtractInner, PyPath, PyPathBuf, ResultPyErrExt}; use edenapi::{Progress, ProgressCal...
.transpose()? .unwrap_or(attributes.parents); attributes.child_metadata = attrs .get_item(py, "child_metadata") .map(|v| v.extract::<bool>(py)) .transpose()? .unwrap_or(attributes.child_metadata); Ok(attributes) } pub fn to_hgids(py: Python, hgids: impl IntoIterator<I...
.get_item(py, "parents") .map(|v| v.extract::<bool>(py))
random_line_split
global_gen.rs
// Copyright 2013-2014 The gl-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
pub fn is_loaded() -> bool {{ unsafe {{ storage::{fnname}.is_loaded }} }} #[allow(dead_code)] pub fn load_with<F>(loadfn: F) where F: FnMut(&str) -> *const super::__gl_imports::libc::c_void {{ unsafe {{ ...
{ for c in registry.cmd_iter() { let fallbacks = match registry.aliases.get(&c.proto.ident) { Some(v) => { let names = v.iter().map(|name| format!("\"{}\"", super::gen_symbol_name(ns, &name[..]))).collect::<Vec<_>>(); format!("&[{}]", names.connect(", ")) ...
identifier_body
global_gen.rs
// Copyright 2013-2014 The gl-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
} /// Creates all the `<enum>` elements at the root of the bindings. fn write_enums<W>(registry: &Registry, dest: &mut W) -> io::Result<()> where W: io::Write { for e in registry.enum_iter() { try!(super::gen_enum_item(e, "types::", dest)); } Ok(()) } /// Creates the functions corresponding to th...
writeln!(dest, " }} ")
random_line_split
global_gen.rs
// Copyright 2013-2014 The gl-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
<W>(ns: &Ns, dest: &mut W) -> io::Result<()> where W: io::Write { writeln!(dest, "#[inline(never)] fn missing_fn_panic() ->! {{ panic!(\"{ns} function was not loaded\") }} ", ns = ns) } /// Creates the `load_with` function. /// /// The function calls `load_with` in each ...
write_panicking_fns
identifier_name
serial.rs
//! Serde integration support. use std::fmt; use std::marker::PhantomData; use serde::de::{Error, Unexpected, Visitor}; use serde::*; fn i64_to_u64<'d, V: Visitor<'d>, E: Error>(v: V, n: i64) -> Result<V::Value, E> { if n >= 0 { v.visit_u64(n as u64) } else { Err(E::invalid_value(Unexpected::Signed(n), &v)) }...
<'d, D: Deserializer<'d>>(d: D) -> Result<Option<u16>, D::Error> { macro_rules! check { ($self:ident, $v:ident, $wrong:expr) => { if $v >= 0 && $v <= 9999 { Ok(Some($v as u16)) } else { Err(E::invalid_value($wrong, &$self)) } }; } struct DiscrimVisitor; impl<'d> Visitor<'d> for DiscrimVisitor...
deserialize_discrim_opt
identifier_name
serial.rs
//! Serde integration support. use std::fmt; use std::marker::PhantomData; use serde::de::{Error, Unexpected, Visitor}; use serde::*; fn i64_to_u64<'d, V: Visitor<'d>, E: Error>(v: V, n: i64) -> Result<V::Value, E> { if n >= 0 { v.visit_u64(n as u64) } else { Err(E::invalid_value(Unexpected::Signed(n), &v)) }...
pub fn deserialize<'d, T: NamedEnum, D: Deserializer<'d>>(d: D) -> Result<T, D::Error> { struct NameVisitor<T>(PhantomData<T>); impl<'d, T: NamedEnum> Visitor<'d> for NameVisitor<T> { type Value = T; fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "a valid {} name", T::typen...
{ v.name().serialize(s) }
identifier_body
serial.rs
//! Serde integration support. use std::fmt; use std::marker::PhantomData; use serde::de::{Error, Unexpected, Visitor}; use serde::*; fn i64_to_u64<'d, V: Visitor<'d>, E: Error>(v: V, n: i64) -> Result<V::Value, E> { if n >= 0 { v.visit_u64(n as u64) } else { Err(E::invalid_value(Unexpected::Signed(n), &v)) }...
fn from_name(name: &str) -> Option<Self> { Self::from_name(name) } fn typename() -> &'static str { stringify!($typ) } } } } /// Support for numeric enums. pub mod numeric { use super::*; pub trait NumericEnum: Sized { fn num(&self) -> u64; fn from_num(num: u64) -> Option<Self>; fn type...
random_line_split
handleapi.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
pub fn GetHandleInformation( hObject: HANDLE, lpdwFlags: LPDWORD, ) -> BOOL; pub fn SetHandleInformation( hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD, ) -> BOOL; }
random_line_split
color_chooser_dialog.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use FFIWidget; use cast::{GTK_WINDOW}; use glib::translate::ToGlibPtr; struct_Widge...
None => ::std::ptr::null_mut() } ) }; if tmp_pointer.is_null() { None } else { Some(::FFIWidget::wrap_widget(tmp_pointer)) } } } impl_drop!(ColorChooserDialog); impl_TraitWidget!(ColorChooserDialog); impl ::Co...
pub fn new(title: &str, parent: Option<&::Window>) -> Option<ColorChooserDialog> { let tmp_pointer = unsafe { ffi::gtk_color_chooser_dialog_new(title.to_glib_none().0, match parent { Some(ref p) => GTK_WINDOW(p.unwrap_widget()),
random_line_split
color_chooser_dialog.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use FFIWidget; use cast::{GTK_WINDOW}; use glib::translate::ToGlibPtr; struct_Widge...
} impl_drop!(ColorChooserDialog); impl_TraitWidget!(ColorChooserDialog); impl ::ContainerTrait for ColorChooserDialog {} impl ::BinTrait for ColorChooserDialog {} impl ::WindowTrait for ColorChooserDialog {} impl ::DialogTrait for ColorChooserDialog {} impl ::ColorChooserTrait for ColorChooserDialog {}
{ let tmp_pointer = unsafe { ffi::gtk_color_chooser_dialog_new(title.to_glib_none().0, match parent { Some(ref p) => GTK_WINDOW(p.unwrap_widget()), None => ::std::ptr::null_mut() } ) }; if tmp_pointe...
identifier_body
color_chooser_dialog.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use FFIWidget; use cast::{GTK_WINDOW}; use glib::translate::ToGlibPtr; struct_Widge...
else { Some(::FFIWidget::wrap_widget(tmp_pointer)) } } } impl_drop!(ColorChooserDialog); impl_TraitWidget!(ColorChooserDialog); impl ::ContainerTrait for ColorChooserDialog {} impl ::BinTrait for ColorChooserDialog {} impl ::WindowTrait for ColorChooserDialog {} impl ::DialogTrait for ColorCh...
{ None }
conditional_block
color_chooser_dialog.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use FFIWidget; use cast::{GTK_WINDOW}; use glib::translate::ToGlibPtr; struct_Widge...
(title: &str, parent: Option<&::Window>) -> Option<ColorChooserDialog> { let tmp_pointer = unsafe { ffi::gtk_color_chooser_dialog_new(title.to_glib_none().0, match parent { Some(ref p) => GTK_WINDOW(p.unwrap_widget()), None => ::std::ptr::null_...
new
identifier_name
audio.rs
use super::error::Error; use ao; use earwax::{Earwax, Timestamp, LogLevel}; use std::sync::{Once, ONCE_INIT}; static START: Once = ONCE_INIT; /// Type for audio streaming audio that hides the details of earwax and ao-rs handling. pub struct Audio { earwax: Earwax, driver: ao::Driver, format: ao::Format,
device: ao::Device, } impl Audio { /// Tries to initialize a new stream for the given URL. pub fn new(url: &str) -> Result<Self, Error> { // #[cfg(not(debug_assertions))] START.call_once(|| { Earwax::set_log_level(LogLevel::Error); }); let earwax = try!(Earwax::new(url)); l...
random_line_split
audio.rs
use super::error::Error; use ao; use earwax::{Earwax, Timestamp, LogLevel}; use std::sync::{Once, ONCE_INIT}; static START: Once = ONCE_INIT; /// Type for audio streaming audio that hides the details of earwax and ao-rs handling. pub struct Audio { earwax: Earwax, driver: ao::Driver, format: ao::Format, ...
/// Plays the next chunk of the stream to the default audio device. /// # Returns /// If playback was successful (at getting next stream chunk), the value returned /// is a tuple where the first element is the current timestamp, and the second /// element is the total timestamp. pub fn play(&m...
{ // #[cfg(not(debug_assertions))] START.call_once(|| { Earwax::set_log_level(LogLevel::Error); }); let earwax = try!(Earwax::new(url)); let driver = try!(ao::Driver::new()); let format = ao::Format::new(); let device = try!(ao::Device::new(&driver, &format, None)); ...
identifier_body
audio.rs
use super::error::Error; use ao; use earwax::{Earwax, Timestamp, LogLevel}; use std::sync::{Once, ONCE_INIT}; static START: Once = ONCE_INIT; /// Type for audio streaming audio that hides the details of earwax and ao-rs handling. pub struct Audio { earwax: Earwax, driver: ao::Driver, format: ao::Format, ...
else { Err(()) } } /// Plays all the chunks remaining in the stream to the default audio the device. pub fn play_all(&mut self) { while let Some(chunk) = self.earwax.spit() { self.device.play(chunk.data); } } }
{ self.device.play(chunk.data); Ok((chunk.time, duration)) }
conditional_block
audio.rs
use super::error::Error; use ao; use earwax::{Earwax, Timestamp, LogLevel}; use std::sync::{Once, ONCE_INIT}; static START: Once = ONCE_INIT; /// Type for audio streaming audio that hides the details of earwax and ao-rs handling. pub struct Audio { earwax: Earwax, driver: ao::Driver, format: ao::Format, ...
(url: &str) -> Result<Self, Error> { // #[cfg(not(debug_assertions))] START.call_once(|| { Earwax::set_log_level(LogLevel::Error); }); let earwax = try!(Earwax::new(url)); let driver = try!(ao::Driver::new()); let format = ao::Format::new(); let device = try!(ao::Device:...
new
identifier_name
cssstylesheet.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::codegen::Bindings::CSSStyleSheetBinding; use crate::dom::bindings::codegen::Bindings::C...
Ok(self.rulelist()) } // https://drafts.csswg.org/cssom/#dom-cssstylesheet-insertrule fn InsertRule(&self, rule: DOMString, index: u32) -> Fallible<u32> { if!self.origin_clean.get() { return Err(Error::Security); } self.rulelist() .insert_rule(&rule, ...
{ return Err(Error::Security); }
conditional_block
cssstylesheet.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::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::cssrulelist::{CSSRuleList, RulesSource}; use crate::dom::element::Element; use crate::dom::stylesheet::StyleSheet; use crate::dom::window::Window; use dom_struct::dom_struct; use servo_arc::Arc; use...
use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding; use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate...
random_line_split
cssstylesheet.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::codegen::Bindings::CSSStyleSheetBinding; use crate::dom::bindings::codegen::Bindings::C...
(&self) -> Fallible<DomRoot<CSSRuleList>> { if!self.origin_clean.get() { return Err(Error::Security); } Ok(self.rulelist()) } // https://drafts.csswg.org/cssom/#dom-cssstylesheet-insertrule fn InsertRule(&self, rule: DOMString, index: u32) -> Fallible<u32> { if!s...
GetCssRules
identifier_name
cssstylesheet.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::codegen::Bindings::CSSStyleSheetBinding; use crate::dom::bindings::codegen::Bindings::C...
}
{ if !self.origin_clean.get() { return Err(Error::Security); } self.rulelist().remove_rule(index) }
identifier_body
test_generation_xflow_to_es5.rs
extern crate env_logger; extern crate ratel; use ratel::parser;
mod common; use crate::common::load_doc; // partof: TST-artifact-generation-xflow // #[test] fn test_load_basic_page_document() { let _ = env_logger::try_init(); let xflow = load_doc::<XFlowDocument>("resource/docs/xflow/flows/branch_boolean_condition.json"); let s_es5 = xflow_to_es5::output_es5(...
extern crate gears; use gears::structure::xflow::*; use gears::generation::xflow_to_es5;
random_line_split
test_generation_xflow_to_es5.rs
extern crate env_logger; extern crate ratel; use ratel::parser; extern crate gears; use gears::structure::xflow::*; use gears::generation::xflow_to_es5; mod common; use crate::common::load_doc; // partof: TST-artifact-generation-xflow // #[test] fn
() { let _ = env_logger::try_init(); let xflow = load_doc::<XFlowDocument>("resource/docs/xflow/flows/branch_boolean_condition.json"); let s_es5 = xflow_to_es5::output_es5(&xflow); let s_es = xflow_to_es5::output(&xflow); let _ = parser::parse(s_es5.to_string()).expect("Must compile"); ...
test_load_basic_page_document
identifier_name
test_generation_xflow_to_es5.rs
extern crate env_logger; extern crate ratel; use ratel::parser; extern crate gears; use gears::structure::xflow::*; use gears::generation::xflow_to_es5; mod common; use crate::common::load_doc; // partof: TST-artifact-generation-xflow // #[test] fn test_load_basic_page_document()
{ let _ = env_logger::try_init(); let xflow = load_doc::<XFlowDocument>("resource/docs/xflow/flows/branch_boolean_condition.json"); let s_es5 = xflow_to_es5::output_es5(&xflow); let s_es = xflow_to_es5::output(&xflow); let _ = parser::parse(s_es5.to_string()).expect("Must compile"); le...
identifier_body
ntcc.rs
// Copyright 2014 Pierre Talbot (IRCAM) // 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 agreed to...
par_body = oror expression tell = store_kw left_arrow constraint next = next_kw expression async = async_kw expression rep = rep_kw expression unless = unless_kw entailed_by next when = when_kw entails right_arrow expression entails = store_kw entail constraint ...
par = par_kw oror? expression par_body* end_kw?
random_line_split
mod.rs
//! Abstracts out the APIs necessary to `Runtime` for integrating the blocking //! pool. When the `blocking` feature flag is **not** enabled, these APIs are //! shells. This isolates the complexity of dealing with conditional //! compilation. mod pool; pub(crate) use pool::{spawn_blocking, BlockingPool, Mandatory, Spa...
/* cfg_not_blocking_impl! { use crate::runtime::Builder; use std::time::Duration; #[derive(Debug, Clone)] pub(crate) struct BlockingPool {} pub(crate) use BlockingPool as Spawner; pub(crate) fn create_blocking_pool(_builder: &Builder, _thread_cap: usize) -> BlockingPool { BlockingPo...
{ BlockingPool::new(builder, thread_cap) }
identifier_body
mod.rs
//! Abstracts out the APIs necessary to `Runtime` for integrating the blocking //! pool. When the `blocking` feature flag is **not** enabled, these APIs are //! shells. This isolates the complexity of dealing with conditional //! compilation. mod pool; pub(crate) use pool::{spawn_blocking, BlockingPool, Mandatory, Spa...
(builder: &Builder, thread_cap: usize) -> BlockingPool { BlockingPool::new(builder, thread_cap) } /* cfg_not_blocking_impl! { use crate::runtime::Builder; use std::time::Duration; #[derive(Debug, Clone)] pub(crate) struct BlockingPool {} pub(crate) use BlockingPool as Spawner; pub(crate)...
create_blocking_pool
identifier_name
mod.rs
//! Abstracts out the APIs necessary to `Runtime` for integrating the blocking //! pool. When the `blocking` feature flag is **not** enabled, these APIs are //! shells. This isolates the complexity of dealing with conditional //! compilation. mod pool; pub(crate) use pool::{spawn_blocking, BlockingPool, Mandatory, Spa...
pub(crate) use task::BlockingTask; use crate::runtime::Builder; pub(crate) fn create_blocking_pool(builder: &Builder, thread_cap: usize) -> BlockingPool { BlockingPool::new(builder, thread_cap) } /* cfg_not_blocking_impl! { use crate::runtime::Builder; use std::time::Duration; #[derive(Debug, Clone)...
mod task; pub(crate) use schedule::NoopSchedule;
random_line_split
mod.rs
// ColdFire Target // // This file is part of AEx. // Copyright (C) 2017 Jeffrey Sharp // // AEx is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published // by the Free Software Foundation, either version 3 of the License, // or (at your option) any la...
{ /// No associated size. Zero, /// Byte Byte, /// Word (2 bytes) Word, /// Longword (4 bytes) Long, /// Single-precision floating-point (4 bytes) Single, /// Double-precision floating-point (8 bytes) Double, }
Size
identifier_name
mod.rs
// ColdFire Target // // This file is part of AEx. // Copyright (C) 2017 Jeffrey Sharp // // AEx is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published // by the Free Software Foundation, either version 3 of the License, // or (at your option) any la...
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] pub enum Size { /// No associated size. Zero, /// Byte Byte, /// Word (2 bytes) Word, /// Longword (4 bytes) Long, /// Single-precision floating-point (4 bytes) Single, /// Double-precision floating-point (8 b...
pub use self::mnemonics::*; pub use self::opcodes::*; pub use self::operand::*; /// Operation sizes.
random_line_split
propagate-multiple-requirements.rs
// Test that we propagate *all* requirements to the caller, not just the first // one. #![feature(nll)] fn once<S, T, U, F: FnOnce(S, T) -> U>(f: F, s: S, t: T) -> U
pub fn dangle() -> &'static [i32] { let other_local_arr = [0, 2, 4]; let local_arr = other_local_arr; let mut out: &mut &'static [i32] = &mut (&[1] as _); once(|mut z: &[i32], mut out_val: &mut &[i32]| { // We unfortunately point to the first use in the closure in the error // message ...
{ f(s, t) }
identifier_body
propagate-multiple-requirements.rs
// Test that we propagate *all* requirements to the caller, not just the first // one. #![feature(nll)]
pub fn dangle() -> &'static [i32] { let other_local_arr = [0, 2, 4]; let local_arr = other_local_arr; let mut out: &mut &'static [i32] = &mut (&[1] as _); once(|mut z: &[i32], mut out_val: &mut &[i32]| { // We unfortunately point to the first use in the closure in the error // message ...
fn once<S, T, U, F: FnOnce(S, T) -> U>(f: F, s: S, t: T) -> U { f(s, t) }
random_line_split
propagate-multiple-requirements.rs
// Test that we propagate *all* requirements to the caller, not just the first // one. #![feature(nll)] fn
<S, T, U, F: FnOnce(S, T) -> U>(f: F, s: S, t: T) -> U { f(s, t) } pub fn dangle() -> &'static [i32] { let other_local_arr = [0, 2, 4]; let local_arr = other_local_arr; let mut out: &mut &'static [i32] = &mut (&[1] as _); once(|mut z: &[i32], mut out_val: &mut &[i32]| { // We unfortunately ...
once
identifier_name
lang_items.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 ...
BitAndTraitLangItem, "bitand", bitand_trait; BitOrTraitLangItem, "bitor", bitor_trait; ShlTraitLangItem, "shl", shl_trait; ShrTraitLangItem, "shr", shr_trait; IndexTraitL...
random_line_split
div.rs
#![feature(core, core_simd)]
#[cfg(test)] mod tests { use core::simd::u32x4; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[test] fn div_test1() { let x: u32x4 = u32x4( 0, 1, 2, 3 ); let y: u32x4 = u32x4( 2, 2, 2, 2 ); let z: u32x...
extern crate core;
random_line_split
div.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u32x4; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[test] fn div_test1()
}
{ let x: u32x4 = u32x4( 0, 1, 2, 3 ); let y: u32x4 = u32x4( 2, 2, 2, 2 ); let z: u32x4 = x / y; let result: String = format!("{:?}", z); assert_eq!(result, "u32x4(0, 0, 1, 1)".to_string()); }
identifier_body
div.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u32x4; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[test] fn
() { let x: u32x4 = u32x4( 0, 1, 2, 3 ); let y: u32x4 = u32x4( 2, 2, 2, 2 ); let z: u32x4 = x / y; let result: String = format!("{:?}", z); assert_eq!(result, "u32x4(0, 0, 1, 1)".to_string()); } }
div_test1
identifier_name
str.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 std::from_str::FromStr; use std::hash::{Hash, sip}; use std::path::BytesContainer; use std::str; #[deriving(E...
(&self) -> bool { // Classifications of characters necessary for the [CRLF] (SP|HT) rule #[deriving(PartialEq)] enum PreviousCharacter { Other, CR, LF, SPHT // SP or HT } let ByteString(ref vec) = *self; let mut prev = Other...
is_field_value
identifier_name
str.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 std::from_str::FromStr; use std::hash::{Hash, sip}; use std::path::BytesContainer; use std::str; #[deriving(E...
pub fn as_str<'a>(&'a self) -> Option<&'a str> { let ByteString(ref vec) = *self; str::from_utf8(vec.as_slice()) } pub fn as_slice<'a>(&'a self) -> &'a [u8] { let ByteString(ref vector) = *self; vector.as_slice() } pub fn len(&self) -> uint { let ByteString...
{ ByteString(value) }
identifier_body
str.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 std::from_str::FromStr; use std::hash::{Hash, sip}; use std::path::BytesContainer; use std::str; #[deriving(E...
pub fn to_lower(&self) -> ByteString { let ByteString(ref vec) = *self; ByteString::new(vec.iter().map(|&x| { if x > 'A' as u8 && x < 'Z' as u8 { x + ('a' as u8) - ('A' as u8) } else { x } }).collect()) } pub fn is...
// XXXManishearth make this more efficient self.to_lower() == other.to_lower() }
random_line_split
main.rs
#[derive(Debug, Clone)] struct Node { x: usize, y: usize, value: String, } #[derive(Debug, Clone)] struct Edge { edge: bool, node: Option<String>, } #[derive(Debug)] struct Graphadj { nodenums: usize, graphadj: Vec<Vec<Edge>>, } impl Node { fn new(x: usize, y:usize, value: String) -> ...
impl Graphadj { fn new(nums: usize) -> Self { Graphadj { nodenums: nums, graphadj: vec![vec![Edge::new();nums];nums] } } fn insert_edge(&mut self, v: Node) { match v.x < self.nodenums && v.y < self.nodenums { true => { self.graphad...
} }
random_line_split
main.rs
#[derive(Debug, Clone)] struct Node { x: usize, y: usize, value: String, } #[derive(Debug, Clone)] struct
{ edge: bool, node: Option<String>, } #[derive(Debug)] struct Graphadj { nodenums: usize, graphadj: Vec<Vec<Edge>>, } impl Node { fn new(x: usize, y:usize, value: String) -> Self { Node{ x: x, y: y, value: value, } } } impl Edge { fn ne...
Edge
identifier_name
main.rs
#[derive(Debug, Clone)] struct Node { x: usize, y: usize, value: String, } #[derive(Debug, Clone)] struct Edge { edge: bool, node: Option<String>, } #[derive(Debug)] struct Graphadj { nodenums: usize, graphadj: Vec<Vec<Edge>>, } impl Node { fn new(x: usize, y:usize, value: String) -> ...
fn insert_edge(&mut self, v: Node) { match v.x < self.nodenums && v.y < self.nodenums { true => { self.graphadj[v.x][v.y] = Edge::have_edge(v.value.clone()); self.graphadj[v.y][v.x] = Edge::have_edge(v.value); } false => { ...
{ Graphadj { nodenums: nums, graphadj: vec![vec![Edge::new();nums];nums] } }
identifier_body
main.rs
#[derive(Debug, Clone)] struct Node { x: usize, y: usize, value: String, } #[derive(Debug, Clone)] struct Edge { edge: bool, node: Option<String>, } #[derive(Debug)] struct Graphadj { nodenums: usize, graphadj: Vec<Vec<Edge>>, } impl Node { fn new(x: usize, y:usize, value: String) -> ...
} } } fn main() { let mut g = Graphadj::new(2); let v1 = Node::new(0, 1,"v1".to_string()); g.insert_edge(v1); println!("{:?}", g); }
{ panic!("your nodeid is bigger than nodenums!") }
conditional_block
urlsearchparams.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::URLSearchParamsBinding::...
else { k!= &name.0 } }); match index { Some(index) => list[index].1 = value.0, None => list.push((name.0, value.0)), // Step 2. }; } // Un-borrow self.list // Step 3. self.update_steps(); ...
{ if k == &name.0 { index = Some(i); } else { i += 1; } true }
conditional_block
urlsearchparams.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::URLSearchParamsBinding::...
// https://url.spec.whatwg.org/#dom-urlsearchparams-getall fn GetAll(&self, name: USVString) -> Vec<USVString> { let list = self.list.borrow(); list.iter() .filter_map(|&(ref k, ref v)| { if k == &name.0 { Some(USVString(v.clone())) ...
{ let list = self.list.borrow(); list.iter() .find(|&kv| kv.0 == name.0) .map(|ref kv| USVString(kv.1.clone())) }
identifier_body
urlsearchparams.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::URLSearchParamsBinding::...
global, URLSearchParamsWrap, ) } // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams pub fn Constructor( global: &GlobalScope, init: USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString, ) -> Fallible<DomRoot<URLSearchParams>> { ...
pub fn new(global: &GlobalScope, url: Option<&URL>) -> DomRoot<URLSearchParams> { reflect_dom_object( Box::new(URLSearchParams::new_inherited(url)),
random_line_split
urlsearchparams.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::URLSearchParamsBinding::...
(&self, name: USVString) -> bool { let list = self.list.borrow(); list.iter().any(|&(ref k, _)| k == &name.0) } // https://url.spec.whatwg.org/#dom-urlsearchparams-set fn Set(&self, name: USVString, value: USVString) { { // Step 1. let mut list = self.list.bo...
Has
identifier_name
stream.rs
use libc::c_int; use libc::c_uint; use libc::c_void; use format::format::Format; use format::sample::SampleType; use format::sample::Stream; use format::error::DriverError; use alsa::device::AlsaDevice; use alsa::device::create_error; use alsa::format::AlsaFormat; use alsa::mixer::Params; use alsa::ffi::*; pub struc...
pub fn output(&self, data: &[S]) -> Result<usize, DriverError> { let available = data.len(); let mut written: usize = 0; while written < available { let subdata = &data[written..data.len()]; match self.write_some(subdata) { Ok(count) => written += count, Err(err) => return Err(err), } } re...
{ let data_ptr = data.as_ptr() as *const c_void; let frames = data.len() as snd_pcm_uframes_t; let mut size = 0; unsafe { match self.wait() { Ok(status) => size = snd_pcm_writei(self.device.get_pcm(), data_ptr, frames), Err(err) => return Err(err), } } if size < 0 { return Err(create_error...
identifier_body
stream.rs
use libc::c_int; use libc::c_uint; use libc::c_void; use format::format::Format; use format::sample::SampleType; use format::sample::Stream; use format::error::DriverError; use alsa::device::AlsaDevice; use alsa::device::create_error; use alsa::format::AlsaFormat; use alsa::mixer::Params; use alsa::ffi::*; pub struc...
} impl<F: AlsaFormat, S: SampleType<Sample=F>> Stream<S> for AlsaStream<S> { fn push(&mut self, frames: &[S]) { self.output(frames).expect("Failed to output to device"); } }
} return Ok(written); }
random_line_split
stream.rs
use libc::c_int; use libc::c_uint; use libc::c_void; use format::format::Format; use format::sample::SampleType; use format::sample::Stream; use format::error::DriverError; use alsa::device::AlsaDevice; use alsa::device::create_error; use alsa::format::AlsaFormat; use alsa::mixer::Params; use alsa::ffi::*; pub struc...
(device: AlsaDevice) -> Result<Self, DriverError> { let sample_rate = 44100; let params = Params::new().expect("Failed to create hw params"); params.any(&device); params.format(&device, sample_rate, S::CHANNELS as c_uint, F::FORMAT_ID); params.apply(&device); //device.setup(&mut params); let buffer_siz...
open
identifier_name
bvlist.rs
use bap::high::bitvector::BitVector; use holmes::pg::dyn::values::{ValueT, ToValue}; use holmes::pg::dyn::types::TypeT; use postgres::types::{ToSql, IsNull}; use postgres_array::Array; use holmes::pg::RowIter; use holmes::pg::dyn::{Type, Value}; use bit_vec::BitVec; use std::any::Any; use std::sync::Arc; #[derive(Debu...
} #[derive(Debug, Clone, Hash, PartialEq)] pub struct BVListType; impl TypeT for BVListType { fn name(&self) -> Option<&'static str> { Some("bvlist") } fn extract(&self, rows: &mut RowIter) -> Option<Value> { let raw: Array<BitVec> = rows.next().unwrap(); Some(Arc::new( ...
{ use std::fmt::Debug; self.0.fmt(f) }
identifier_body
bvlist.rs
use bap::high::bitvector::BitVector; use holmes::pg::dyn::values::{ValueT, ToValue}; use holmes::pg::dyn::types::TypeT; use postgres::types::{ToSql, IsNull}; use postgres_array::Array; use holmes::pg::RowIter; use holmes::pg::dyn::{Type, Value}; use bit_vec::BitVec; use std::any::Any; use std::sync::Arc; #[derive(Debu...
vec![self] } valuet_boiler!(); } impl ToSql for BVList { accepts!(::postgres::types::VARBIT_ARRAY); to_sql_checked!(); fn to_sql( &self, ty: &::postgres::types::Type, out: &mut Vec<u8>, ) -> ::std::result::Result<IsNull, Box<::std::error::Error + Send + Sync>> { ...
} fn to_sql(&self) -> Vec<&ToSql> {
random_line_split
bvlist.rs
use bap::high::bitvector::BitVector; use holmes::pg::dyn::values::{ValueT, ToValue}; use holmes::pg::dyn::types::TypeT; use postgres::types::{ToSql, IsNull}; use postgres_array::Array; use holmes::pg::RowIter; use holmes::pg::dyn::{Type, Value}; use bit_vec::BitVec; use std::any::Any; use std::sync::Arc; #[derive(Debu...
(&self) -> Type { Arc::new(BVListType) } fn get(&self) -> &Any { self as &Any } fn to_sql(&self) -> Vec<&ToSql> { vec![self] } valuet_boiler!(); } impl ToSql for BVList { accepts!(::postgres::types::VARBIT_ARRAY); to_sql_checked!(); fn to_sql( &self, ...
type_
identifier_name