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
worker.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::WorkerBinding; use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMe...
pub fn new(global: GlobalRef, sender: Sender<(TrustedWorkerAddress, ScriptMsg)>) -> Temporary<Worker> { reflect_dom_object(box Worker::new_inherited(global, sender), global, WorkerBinding::Wrap) } // http://www.whatwg.org/html/#dom-worker ...
{ Worker { eventtarget: EventTarget::new_inherited(EventTargetTypeId::Worker), refcount: Cell::new(0), global: GlobalField::from_rooted(&global), sender: sender, } }
identifier_body
issue-6128.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 ...
fn g(&self, _e: isize) { panic!(); } } pub fn main() { let g : Box<HashMap<isize,isize>> = box HashMap::new(); let _g2 : Box<Graph<isize,isize>> = g as Box<Graph<isize,isize>>; }
{ panic!(); }
identifier_body
issue-6128.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 ...
extern crate collections; use std::collections::HashMap; trait Graph<Node, Edge> { fn f(&self, Edge); fn g(&self, Node); } impl<E> Graph<isize, E> for HashMap<isize, isize> { fn f(&self, _e: E) { panic!(); } fn g(&self, _e: isize) { panic!(); } } pub fn main() { let g : ...
#![allow(unknown_features)] #![feature(box_syntax, collections)]
random_line_split
issue-6128.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 ...
(&self, _e: E) { panic!(); } fn g(&self, _e: isize) { panic!(); } } pub fn main() { let g : Box<HashMap<isize,isize>> = box HashMap::new(); let _g2 : Box<Graph<isize,isize>> = g as Box<Graph<isize,isize>>; }
f
identifier_name
const-eval-overflow2c.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 ...
<T>(_: T) { }
foo
identifier_name
const-eval-overflow2c.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() { foo(VALS_I8); foo(VALS_I16); foo(VALS_I32); foo(VALS_I64); foo(VALS_U8); foo(VALS_U16); foo(VALS_U32); foo(VALS_U64); } fn foo<T>(_: T) { }
u64::MAX * 2,
random_line_split
const-eval-overflow2c.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 ...
{ }
identifier_body
stream.rs
//! Convenience wrapper for streams to switch between plain TCP and TLS at runtime. //! //! There is no dependency on actual TLS implementations. Everything like //! `native_tls` or `openssl` will work as long as there is a TLS stream supporting standard //! `Read + Write` traits. use std::{ pin::Pin, task::{C...
} impl<S: AsyncRead + AsyncWrite + Unpin> AsyncWrite for MaybeTlsStream<S> { fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, std::io::Error>> { match self.get_mut() { MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll...
{ match self.get_mut() { MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_read(cx, buf), #[cfg(feature = "native-tls")] MaybeTlsStream::NativeTls(s) => Pin::new(s).poll_read(cx, buf), #[cfg(feature = "__rustls-tls")] MaybeTlsStream::Rustls(s) => Pi...
identifier_body
stream.rs
//! Convenience wrapper for streams to switch between plain TCP and TLS at runtime. //! //! There is no dependency on actual TLS implementations. Everything like //! `native_tls` or `openssl` will work as long as there is a TLS stream supporting standard //! `Read + Write` traits. use std::{ pin::Pin, task::{C...
match self.get_mut() { MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_shutdown(cx), #[cfg(feature = "native-tls")] MaybeTlsStream::NativeTls(s) => Pin::new(s).poll_shutdown(cx), #[cfg(feature = "__rustls-tls")] MaybeTlsStream::Rustls(s) => Pin::n...
fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), std::io::Error>> {
random_line_split
stream.rs
//! Convenience wrapper for streams to switch between plain TCP and TLS at runtime. //! //! There is no dependency on actual TLS implementations. Everything like //! `native_tls` or `openssl` will work as long as there is a TLS stream supporting standard //! `Read + Write` traits. use std::{ pin::Pin, task::{C...
(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), std::io::Error>> { match self.get_mut() { MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_flush(cx), #[cfg(feature = "native-tls")] MaybeTlsStream::NativeTls(s) => Pin::new(s).poll_flush(cx), #[c...
poll_flush
identifier_name
lib.rs
#![cfg_attr(feature = "unstable", feature(plugin))] #![cfg_attr(feature = "unstable", plugin(clippy))] //! The purpose of this crate is to provide an easy way to query the runtime type //! information (such as field names, offsets and types) for POD (*plain old data*) types, //! and to allow creating such types withou...
(&self) -> usize { match *self { Type::Int8 | Type::UInt8 | Type::Bool => 1, Type::Int16 | Type::UInt16 => 2, Type::Int32 | Type::UInt32 | Type::Float32 | Type::Char => 4, Type::Int64 | Type::UInt64 | Type::Float64 => 8, Type::Array(ref ty, num) => ty....
size
identifier_name
lib.rs
#![cfg_attr(feature = "unstable", feature(plugin))] #![cfg_attr(feature = "unstable", plugin(clippy))] //! The purpose of this crate is to provide an easy way to query the runtime type //! information (such as field names, offsets and types) for POD (*plain old data*) types, //! and to allow creating such types withou...
/// fixed-size array with POD elements Array(Box<Type>, usize), /// compound type whose fields are POD Compound(Vec<Field>, usize), } impl Type { /// Returns the total size of a type value in bytes. pub fn size(&self) -> usize { match *self { Type::Int8 | Type::UInt8 | Type:...
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.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::MRExpr(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 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
}
base::MRExpr(ecx.expr_uint(sp, 2))
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 documenta...
expand_syntax_ext
identifier_name
util.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
() { let content = r#"Hai --- barbar --- "#; let file = mkfile(&content); let res = entry_buffer_to_header_content(&file); assert!(res.is_ok()); let (_, res_content) = res.unwrap(); assert_eq!(res_content, content) } #[test] fn te...
test_entry_buffer_to_header_content_4
identifier_name
util.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
#[test] fn test_entry_buffer_to_header_content_3() { let content = r#"Hai barbar "#; let file = mkfile(&content); let res = entry_buffer_to_header_content(&file); assert!(res.is_ok()); let (_, res_content) = res.unwrap(); assert_eq!(res_content, content) ...
{ setup_logging(); let content = r#"Hai "#; let file = mkfile(&content); debug!("FILE: <<<{}>>>", file); let res = entry_buffer_to_header_content(&file); assert!(res.is_ok()); let (_, res_content) = res.unwrap(); debug!("CONTENT: <<<{}>>>", res_content)...
identifier_body
util.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
fn setup_logging() { let _ = env_logger::try_init(); } fn mkfile(content: &str) -> String { format!(r#"--- [imag] version = '{version}' --- {content}"#, version = env!("CARGO_PKG_VERSION"), content = content) } #[test] fn test_entry_buffer_to_header_content_1() { let c...
#[cfg(test)] mod test { extern crate env_logger; use super::entry_buffer_to_header_content;
random_line_split
util.rs
// This file is made up largely of utility methods which are invoked by the // session in its interpret method. They are separate because they don't rely // on the session (or take what they do need as arguments) and/or they are // called by the session in multiple places. use std::env::current_dir; use std::fs; use s...
(dir: &Path) -> String { match current_dir() { Err(_) => dir.display().to_string(), Ok(absp) => { let mut abs_path = absp.clone(); abs_path.push(dir); abs_path.display().to_string() } } } pub fn perform_select(maildir: &str, select_args: &[&str], exam...
make_absolute
identifier_name
util.rs
// This file is made up largely of utility methods which are invoked by the // session in its interpret method. They are separate because they don't rely // on the session (or take what they do need as arguments) and/or they are // called by the session in multiple places. use std::env::current_dir; use std::fs; use s...
{ let maildir_path = Path::new(maildir); let mut responses = Vec::new(); if let Some(list_response) = list_dir(maildir_path, regex, maildir_path) { responses.push(list_response); } for dir_res in WalkDir::new(&maildir_path) { if let Ok(dir) = dir_res { if let Some(list_re...
identifier_body
util.rs
// This file is made up largely of utility methods which are invoked by the // session in its interpret method. They are separate because they don't rely // on the session (or take what they do need as arguments) and/or they are // called by the session in multiple places. use std::env::current_dir; use std::fs; use s...
} responses }
{ if let Some(list_response) = list_dir(dir.path(), regex, maildir_path) { responses.push(list_response); } }
conditional_block
util.rs
// This file is made up largely of utility methods which are invoked by the // session in its interpret method. They are separate because they don't rely // on the session (or take what they do need as arguments) and/or they are // called by the session in multiple places. use std::env::current_dir; use std::fs; use s...
continue; } if fs::read_dir(&subdir.path().join("new")).is_err() { continue; } children = true; break; ...
let subdir_str = path_filename_to_str!(subdir_path); if subdir_str != "cur" && subdir_str != "new" && subdir_str != "tmp" { if fs::read_dir(&subdir.path().join("cur")).is_err() {
random_line_split
liquid.rs
use std::io::Write; use std::sync::{Arc, RwLock}; use world::{self, block}; use shared::Direction; use model::BlockVertex; use render; pub fn render_liquid<W: Write>(textures: Arc<RwLock<render::TextureManager>>,lava: bool, snapshot: &world::Snapshot, x: i32, y: i32, z: i32, buf: &mut W) -> usize { let get_liquid...
(snapshot: &world::Snapshot, x: i32, y: i32, z: i32) -> Option<i32> { match snapshot.get_block(x, y, z) { block::Block::Water{level} | block::Block::FlowingWater{level} => Some(level as i32), _ => None, } } fn get_lava_level(snapshot: &world::Snapshot, x: i32, y: i32, z: i32) -> Option<i32> { ...
get_water_level
identifier_name
liquid.rs
use std::io::Write; use std::sync::{Arc, RwLock}; use world::{self, block}; use shared::Direction; use model::BlockVertex; use render; pub fn render_liquid<W: Write>(textures: Arc<RwLock<render::TextureManager>>,lava: bool, snapshot: &world::Snapshot, x: i32, y: i32, z: i32, buf: &mut W) -> usize { let get_liquid...
(_, _) => ((16.0 / 8.0) * (br as f32)) as i32, }; vert.y = (height as f32)/16.0 + (y as f32); } vert.x += x as f32; vert.z += z as f32; let (bl, sl) = super::calculate_light( ...
{ let verts = BlockVertex::face_by_direction(dir); for vert in verts { let mut vert = vert.clone(); vert.tx = tex.get_x() as u16; vert.ty = tex.get_y() as u16; vert.tw = tex.get_width() as u16; vert.th = tex.get_heig...
conditional_block
liquid.rs
use std::io::Write; use std::sync::{Arc, RwLock}; use world::{self, block}; use shared::Direction; use model::BlockVertex; use render;
let get_liquid = if lava { get_lava_level } else { get_water_level }; let mut count = 0; let (tl, tr, bl, br) = if get_liquid(snapshot, x, y + 1, z).is_some() { (8, 8, 8, 8) } else { ( average_liquid_level(get_liquid, snapshot, x, y, z), ...
pub fn render_liquid<W: Write>(textures: Arc<RwLock<render::TextureManager>>,lava: bool, snapshot: &world::Snapshot, x: i32, y: i32, z: i32, buf: &mut W) -> usize {
random_line_split
liquid.rs
use std::io::Write; use std::sync::{Arc, RwLock}; use world::{self, block}; use shared::Direction; use model::BlockVertex; use render; pub fn render_liquid<W: Write>(textures: Arc<RwLock<render::TextureManager>>,lava: bool, snapshot: &world::Snapshot, x: i32, y: i32, z: i32, buf: &mut W) -> usize { let get_liquid...
fn get_water_level(snapshot: &world::Snapshot, x: i32, y: i32, z: i32) -> Option<i32> { match snapshot.get_block(x, y, z) { block::Block::Water{level} | block::Block::FlowingWater{level} => Some(level as i32), _ => None, } } fn get_lava_level(snapshot: &world::Snapshot, x: i32, y: i32, z: i32...
{ let mut level = 0; for xx in -1 .. 1 { for zz in -1 .. 1 { if get(snapshot, x+xx, y+1, z+zz).is_some() { return 8; } if let Some(l) = get(snapshot, x+xx, y, z+zz) { let nl = 7 - (l & 0x7); if nl > level { ...
identifier_body
sub.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 ...
(&self, a: BuiltinBounds, b: BuiltinBounds) -> cres<BuiltinBounds> { // More bounds is a subtype of fewer bounds. // // e.g., fn:Copy() <: fn(), because the former is a function // that only closes over copyable things, but the latter is // any function at all. if a.conta...
bounds
identifier_name
sub.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 ...
if_ok!(self.get_ref().var_sub_t(a_id, b)); Ok(a) } (_, &ty::ty_infer(TyVar(b_id))) => { if_ok!(self.get_ref().t_sub_var(a, b_id)); Ok(a) } (_, &ty::ty_bot) => { Err(ty::terr_sorts(expected_fo...
(&ty::ty_infer(TyVar(a_id)), &ty::ty_infer(TyVar(b_id))) => { if_ok!(self.get_ref().var_sub_var(a_id, b_id)); Ok(a) } (&ty::ty_infer(TyVar(a_id)), _) => {
random_line_split
sub.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 tag(&self) -> ~str { ~"sub" } fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected } fn trace(&self) -> TypeTrace { self.get_ref().trace } fn sub<'a>(&'a self) -> Sub<'a> { Sub(*self.get_ref()) } fn lub<'a>(&'a self) -> Lub<'a> { Lub(*self.get_ref()) } fn glb<'a>(&'a self) -> Glb<...
{ self.get_ref().infcx }
identifier_body
sub.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 ...
(_, &ty::ty_infer(TyVar(b_id))) => { if_ok!(self.get_ref().t_sub_var(a, b_id)); Ok(a) } (_, &ty::ty_bot) => { Err(ty::terr_sorts(expected_found(self, a, b))) } _ => { super_tys(self, a, b) ...
{ if_ok!(self.get_ref().var_sub_t(a_id, b)); Ok(a) }
conditional_block
helpers.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 fn init_server(hosts: Option<Vec<String>>, is_syncing: bool) -> (Server, Arc<FakeRegistrar>) { init_logger(); let registrar = Arc::new(FakeRegistrar::new()); let mut dapps_path = env::temp_dir(); dapps_path.push("non-existent-dir-to-prevent-fs-files-from-loading"); let mut builder = ServerBuilder::new(dapp...
{ let mut builder = LogBuilder::new(); builder.parse(&log); builder.init().expect("Logger is initialized only once."); }
conditional_block
helpers.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 fn assert_security_headers(headers: &[String]) { http_client::assert_security_headers_present(headers, None) } pub fn assert_security_headers_for_embed(headers: &[String]) { http_client::assert_security_headers_present(headers, Some(SIGNER_PORT)) }
{ http_client::request(server.addr(), request) }
identifier_body
helpers.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 fn init_server(hosts: Option<Vec<String>>, is_syncing: bool) -> (Server, Arc<FakeRegistrar>) { init_logger(); let registrar = Arc::new(FakeRegistrar::new()); let mut dapps_path = env::temp_dir(); dapps_path.push("non-existent-dir-to-prevent-fs-files-from-loading"); let mut builder = ServerBuilder::new(da...
random_line_split
helpers.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...
(&self, address: Address, data: Bytes) -> Result<Bytes, String> { self.calls.lock().push((address.to_hex(), data.to_hex())); self.responses.lock().remove(0) } } fn init_logger() { // Initialize logger if let Ok(log) = env::var("RUST_LOG") { let mut builder = LogBuilder::new(); builder.parse(&log); builder...
call
identifier_name
feature_flags.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::helpers::create_inode_file_attributes; use fs::item; use fs::inode; use helpers; use object; use std::path::Path; use super::project_from_inode; fn getattr(fs: &mut GoodDataFS, _req: &Request, ino: u64, r...
(fs: &mut GoodDataFS, inode: inode::Inode, reply: ReplyData, offset: u64, size: u32) { debug!("read() - Reading {}", constants::FEATURE_FLAGS_JSON_FILENAME); let project: &object::Project = &project_from_inode(fs, inode); let feature_flags = project.feature_flags(&mut fs.client.connector); ...
read
identifier_name
feature_flags.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::helpers::create_inode_file_attributes; use fs::item; use fs::inode; use helpers; use object; use std::path::Path; use super::project_from_inode; fn getattr(fs: &mut GoodDataFS, _req: &Request, ino: u64, r...
fn lookup(fs: &mut GoodDataFS, _req: &Request, parent: u64, _name: &Path, reply: ReplyEntry) { let inode_parent = inode::Inode::deserialize(parent); let inode = inode::Inode::create(inode_parent.project, constants::Category::Internal as u8, ...
{ let project: &object::Project = &project_from_inode(fs, ino); let feature_flags = project.feature_flags(&mut fs.client.connector); if feature_flags.is_some() { let json: String = feature_flags.unwrap().into(); let attr = create_inode_file_attributes(ino, json.len() as u64, co...
identifier_body
feature_flags.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::helpers::create_inode_file_attributes; use fs::item; use fs::inode; use helpers; use object; use std::path::Path; use super::project_from_inode; fn getattr(fs: &mut GoodDataFS, _req: &Request, ino: u64, r...
} fn read(fs: &mut GoodDataFS, inode: inode::Inode, reply: ReplyData, offset: u64, size: u32) { debug!("read() - Reading {}", constants::FEATURE_FLAGS_JSON_FILENAME); let project: &object::Project = &project_from_inode(fs, inode); let feature_flags = project.feature_flags(&mut fs.client.conne...
{ let json: String = feature_flags.unwrap().into(); let attr = create_inode_file_attributes(inode, json.len() as u64, constants::DEFAULT_CREATE_TIME); reply.entry(&constants::DEFAULT_TTL, &attr, 0); }
conditional_block
feature_flags.rs
use fuse::{FileType, ReplyAttr, ReplyData, ReplyEntry, Request}; use fs::constants; use fs::GoodDataFS; use fs::helpers::create_inode_file_attributes; use fs::item; use fs::inode; use helpers; use object; use std::path::Path; use super::project_from_inode; fn getattr(fs: &mut GoodDataFS, _req: &Request, ino: u64, r...
pub const ITEM: item::ProjectItem = item::ProjectItem { category: constants::Category::Internal as u8, reserved: constants::ReservedFile::FeatureFlagsJson as u8, item_type: FileType::RegularFile, path: constants::FEATURE_FLAGS_JSON_FILENAME, getattr: getattr, lookup: lookup, read: read, };
let json: String = feature_flags.unwrap().into(); reply.data(helpers::read_bytes(&json, offset, size)); } }
random_line_split
mod.rs
// Copyright 2015-2017 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 lat...
_ => false, } } /// Returns all algorithm types. pub fn all_types() -> Vec<Algorithm> { vec![Algorithm::Archive, Algorithm::EarlyMerge, Algorithm::OverlayRecent, Algorithm::RefCounted] } } impl fmt::Display for Algorithm { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::R...
/// Returns true if pruning strategy is stable pub fn is_stable(&self) -> bool { match *self { Algorithm::Archive | Algorithm::OverlayRecent => true,
random_line_split
mod.rs
// Copyright 2015-2017 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 lat...
(&self) -> &'static str { match *self { Algorithm::Archive => "archive", Algorithm::EarlyMerge => "earlymerge", Algorithm::OverlayRecent => "overlayrecent", Algorithm::RefCounted => "refcounted", } } /// Returns true if pruning strategy is stable ...
as_internal_name_str
identifier_name
mod.rs
// Copyright 2015-2017 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 lat...
#[test] fn test_journal_algorithm_is_stable() { assert!(Algorithm::Archive.is_stable()); assert!(Algorithm::OverlayRecent.is_stable()); assert!(!Algorithm::EarlyMerge.is_stable()); assert!(!Algorithm::RefCounted.is_stable()); } #[test] fn test_journal_algorithm_def...
{ assert_eq!(Algorithm::Archive.to_string(), "archive".to_owned()); assert_eq!(Algorithm::EarlyMerge.to_string(), "light".to_owned()); assert_eq!(Algorithm::OverlayRecent.to_string(), "fast".to_owned()); assert_eq!(Algorithm::RefCounted.to_string(), "basic".to_owned()); }
identifier_body
rm_elems.rs
// svgcleaner could help you to clean up your SVG files // from unnecessary data. // Copyright (C) 2012-2018 Evgeniy Reizner // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version ...
use task::short::EId; // TODO: to mod::utils pub fn remove_element(doc: &mut Document, id: EId) { doc.drain(|n| n.is_tag_name(id)); } #[cfg(test)] mod tests { use super::*; use svgdom::{Document, ToStringWithOptions, ElementId}; macro_rules! test { ($name:ident, $id:expr, $in_text:expr, $out_...
use svgdom::Document;
random_line_split
rm_elems.rs
// svgcleaner could help you to clean up your SVG files // from unnecessary data. // Copyright (C) 2012-2018 Evgeniy Reizner // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version ...
#[cfg(test)] mod tests { use super::*; use svgdom::{Document, ToStringWithOptions, ElementId}; macro_rules! test { ($name:ident, $id:expr, $in_text:expr, $out_text:expr) => ( #[test] fn $name() { let mut doc = Document::from_str($in_text).unwrap(); ...
{ doc.drain(|n| n.is_tag_name(id)); }
identifier_body
rm_elems.rs
// svgcleaner could help you to clean up your SVG files // from unnecessary data. // Copyright (C) 2012-2018 Evgeniy Reizner // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version ...
(doc: &mut Document, id: EId) { doc.drain(|n| n.is_tag_name(id)); } #[cfg(test)] mod tests { use super::*; use svgdom::{Document, ToStringWithOptions, ElementId}; macro_rules! test { ($name:ident, $id:expr, $in_text:expr, $out_text:expr) => ( #[test] fn $name() { ...
remove_element
identifier_name
main.rs
use std::fs::File; extern crate rustc_serialize; extern crate docopt;
mod vm; static USAGE: &'static str = " Usage: norn_rust <file> norn_rust (--help | --version) Options: -h, --help Show this message. -v, --version Show version of norn_rust. "; #[derive(RustcDecodable, Debug)] struct Args { arg_file: String, flag_help: bool, flag_version: bool } ...
use docopt::Docopt;
random_line_split
main.rs
use std::fs::File; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; mod vm; static USAGE: &'static str = " Usage: norn_rust <file> norn_rust (--help | --version) Options: -h, --help Show this message. -v, --version Show version of norn_rust. "; #[derive(RustcDecodable...
}) .and_then(|program| Ok(vm::execute(&program))) .unwrap(); }
{ let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); if args.flag_help { println!("{}", USAGE); return; } if args.flag_version { println!("norn_rust 0.0.3"); return; ...
identifier_body
main.rs
use std::fs::File; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; mod vm; static USAGE: &'static str = " Usage: norn_rust <file> norn_rust (--help | --version) Options: -h, --help Show this message. -v, --version Show version of norn_rust. "; #[derive(RustcDecodable...
{ arg_file: String, flag_help: bool, flag_version: bool } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); if args.flag_help { println!("{}", USAGE); return; } ...
Args
identifier_name
main.rs
use std::fs::File; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; mod vm; static USAGE: &'static str = " Usage: norn_rust <file> norn_rust (--help | --version) Options: -h, --help Show this message. -v, --version Show version of norn_rust. "; #[derive(RustcDecodable...
if args.flag_version { println!("norn_rust 0.0.3"); return; } File::open(args.arg_file) .map_err(|err| err.to_string()) .and_then(|file| { vm::ir::programs::Program::parse_textual_bytecode(file) .map_err(|err| err.to_string()) }) ...
{ println!("{}", USAGE); return; }
conditional_block
timestamp.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashSet; use std::fmt; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct TimeStamp(u64); const TSO_PHYSICAL_SHIFT_BITS: u64 = 18; imp...
pub const fn max() -> TimeStamp { TimeStamp(std::u64::MAX) } pub const fn new(ts: u64) -> TimeStamp { TimeStamp(ts) } /// Extracts physical part of a timestamp, in milliseconds. pub fn physical(self) -> u64 { self.0 >> TSO_PHYSICAL_SHIFT_BITS } pub fn next(se...
{ TimeStamp(0) }
identifier_body
timestamp.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashSet; use std::fmt; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct TimeStamp(u64); const TSO_PHYSICAL_SHIFT_BITS: u64 = 18; imp...
let big_ts_list: Vec<TimeStamp> = (0..=TS_SET_USE_VEC_LIMIT as u64).map(Into::into).collect(); let s = TsSet::new(big_ts_list.clone()); assert_eq!( s, TsSet::Set(Arc::new(big_ts_list.clone().into_iter().collect())) ); assert!(s.contains(1.into...
random_line_split
timestamp.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashSet; use std::fmt; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct TimeStamp(u64); const TSO_PHYSICAL_SHIFT_BITS: u64 = 18; imp...
() -> TimeStamp { TimeStamp(0) } pub const fn max() -> TimeStamp { TimeStamp(std::u64::MAX) } pub const fn new(ts: u64) -> TimeStamp { TimeStamp(ts) } /// Extracts physical part of a timestamp, in milliseconds. pub fn physical(self) -> u64 { self.0 >> TSO_P...
zero
identifier_name
timestamp.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashSet; use std::fmt; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct TimeStamp(u64); const TSO_PHYSICAL_SHIFT_BITS: u64 = 18; imp...
else { TsSet::Vec(ts.into()) } } /// Query whether the given timestamp is contained in the set. #[inline] pub fn contains(&self, ts: TimeStamp) -> bool { match self { TsSet::Empty => false, TsSet::Vec(vec) => vec.contains(&ts), TsSet::Set...
{ TsSet::Empty }
conditional_block
font_list.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 collections::hashmap::HashMap; use font::SpecifiedFontStyle; use gfx_font::FontHandleMethods; use platform::fo...
family_map: FontFamilyMap, handle: FontListHandle, prof_chan: ProfilerChan, } impl FontList { pub fn new(fctx: &FontContextHandle, prof_chan: ProfilerChan) -> FontList { let handle = FontListHandle::new(fctx); let mut list = FontList { handle: handle, ...
/// The platform-independent font list abstraction. pub struct FontList {
random_line_split
font_list.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 collections::hashmap::HashMap; use font::SpecifiedFontStyle; use gfx_font::FontHandleMethods; use platform::fo...
{ family_name: ~str, entries: ~[FontEntry], } impl FontFamily { pub fn new(family_name: &str) -> FontFamily { FontFamily { family_name: family_name.to_str(), entries: ~[], } } fn load_family_variations(&mut self, list: &FontListHandle) { if self.ent...
FontFamily
identifier_name
font_list.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 collections::hashmap::HashMap; use font::SpecifiedFontStyle; use gfx_font::FontHandleMethods; use platform::fo...
} None } } /// This struct summarizes an available font's features. In the future, this will include fiddly /// settings such as special font table handling. /// /// In the common case, each FontFamily will have a singleton FontEntry, or it will have the /// standard four faces: Normal, Bold, Ita...
{ return Some(entry); }
conditional_block
font_list.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 collections::hashmap::HashMap; use font::SpecifiedFontStyle; use gfx_font::FontHandleMethods; use platform::fo...
}
{ self.italic }
identifier_body
pattern-in-closure.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 ...
{ x: int, y: int } pub fn main() { let f = |(x, _): (int, int)| println((x + 1).to_str()); let g = |Foo { x: x, y: _y }: Foo| println((x + 1).to_str()); f((2, 3)); g(Foo { x: 1, y: 2 }); }
Foo
identifier_name
pattern-in-closure.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct Foo { x: int, y: int } pub fn main() { let f = |(x, _): (int, int)| ...
// 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
random_line_split
dns_query.rs
// http://rosettacode.org/wiki/DNS_query #![feature(lookup_host)] use std::io; use std::net::{Ipv4Addr, Ipv6Addr}; #[derive(PartialEq)] enum Ips { IpV4(Ipv4Addr), IpV6(Ipv6Addr), } fn get_ips(host: &str) -> io::Result<Vec<Ips>>
#[cfg(not(test))] fn main() { for ip in &(get_ips("www.kame.net").unwrap()) { match ip { &Ips::IpV4(ip) => println!("ip v4: {}", ip), &Ips::IpV6(ip) => println!("ip v6: {}", ip) } } } #[cfg(test)] mod test { use super::{Ips, get_ips}; use std::net::{Ipv4Addr, I...
{ use std::net::{self, SocketAddr}; use Ips::{IpV4, IpV6}; let hosts = try!(net::lookup_host(host)); let ips: Vec<_> = hosts.filter_map(|h| match h { Ok(SocketAddr::V4(s_v4)) => Some(IpV4(s_v4.ip().clone())), Ok(SocketAddr::V6(s_v6)) => Some(IpV6(s_v6.ip().clone())), ...
identifier_body
dns_query.rs
// http://rosettacode.org/wiki/DNS_query #![feature(lookup_host)] use std::io; use std::net::{Ipv4Addr, Ipv6Addr}; #[derive(PartialEq)] enum Ips { IpV4(Ipv4Addr), IpV6(Ipv6Addr), } fn get_ips(host: &str) -> io::Result<Vec<Ips>> { use std::net::{self, SocketAddr}; use Ips::{IpV4, IpV6}; let hosts ...
Ok(ips) } #[cfg(not(test))] fn main() { for ip in &(get_ips("www.kame.net").unwrap()) { match ip { &Ips::IpV4(ip) => println!("ip v4: {}", ip), &Ips::IpV6(ip) => println!("ip v6: {}", ip) } } } #[cfg(test)] mod test { use super::{Ips, get_ips}; use std::net:...
random_line_split
dns_query.rs
// http://rosettacode.org/wiki/DNS_query #![feature(lookup_host)] use std::io; use std::net::{Ipv4Addr, Ipv6Addr}; #[derive(PartialEq)] enum
{ IpV4(Ipv4Addr), IpV6(Ipv6Addr), } fn get_ips(host: &str) -> io::Result<Vec<Ips>> { use std::net::{self, SocketAddr}; use Ips::{IpV4, IpV6}; let hosts = try!(net::lookup_host(host)); let ips: Vec<_> = hosts.filter_map(|h| match h { Ok(SocketAddr::V4(s_v4)) => Some(IpV4(s_...
Ips
identifier_name
token_client.rs
extern crate apns2; extern crate argparse; use argparse::{ArgumentParser, Store, StoreTrue}; use apns2::client::TokenClient; use apns2::apns_token::APNSToken; use apns2::payload::{Payload, APSAlert}; use apns2::notification::{Notification, NotificationOptions}; use std::fs::File; use std::time::Duration; // An exampl...
() { let mut der_file_location = String::new(); let mut team_id = String::new(); let mut key_id = String::new(); let mut device_token = String::new(); let mut message = String::from("Ch-check it out!"); let mut ca_certs = String::from("/etc/ssl/cert.pem"); let mut sandbox = false; { ...
main
identifier_name
token_client.rs
extern crate apns2; extern crate argparse; use argparse::{ArgumentParser, Store, StoreTrue}; use apns2::client::TokenClient; use apns2::apns_token::APNSToken; use apns2::payload::{Payload, APSAlert}; use apns2::notification::{Notification, NotificationOptions}; use std::fs::File; use std::time::Duration; // An exampl...
} // Read the private key from disk let der_file = File::open(der_file_location).unwrap(); // Create a new token struct with the private key, team id and key id // The token is valid for an hour and needs to be renewed after that let apns_token = APNSToken::new(der_file, team_id.as_ref(), key_...
{ let mut der_file_location = String::new(); let mut team_id = String::new(); let mut key_id = String::new(); let mut device_token = String::new(); let mut message = String::from("Ch-check it out!"); let mut ca_certs = String::from("/etc/ssl/cert.pem"); let mut sandbox = false; { ...
identifier_body
token_client.rs
extern crate apns2; extern crate argparse; use argparse::{ArgumentParser, Store, StoreTrue}; use apns2::client::TokenClient; use apns2::apns_token::APNSToken; use apns2::payload::{Payload, APSAlert}; use apns2::notification::{Notification, NotificationOptions}; use std::fs::File; use std::time::Duration;
let mut key_id = String::new(); let mut device_token = String::new(); let mut message = String::from("Ch-check it out!"); let mut ca_certs = String::from("/etc/ssl/cert.pem"); let mut sandbox = false; { let mut ap = ArgumentParser::new(); ap.set_description("APNs token-based pus...
// An example client connectiong to APNs with a JWT token fn main() { let mut der_file_location = String::new(); let mut team_id = String::new();
random_line_split
invalidation_map.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 {Atom, LocalName, Namespace}; use context::QuirksMode; use element_state::ElementState; use selector_map::{MaybeCaseInsensitiveHashMap, SelectorMap, SelectorMapEntry}; use selector_parser::SelectorImpl; use selectors::attr::NamespaceConstraint; use selectors::parser::{Combinator, Component}; use selectors::parser:...
//! Code for invalidations due to state or attribute changes.
random_line_split
invalidation_map.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/. */ //! Code for invalidations due to state or attribute changes. use {Atom, LocalName, Namespace}; use context::Quir...
(&self) -> bool { matches!(self.combinator(), Some(Combinator::NextSibling) | Some(Combinator::LaterSibling)) } } impl SelectorMapEntry for Dependency { fn selector(&self) -> SelectorIter<SelectorImpl> { self.selector.iter_from(self.selector_offset) } } ...
affects_later_siblings
identifier_name
invalidation_map.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/. */ //! Code for invalidations due to state or attribute changes. use {Atom, LocalName, Namespace}; use context::Quir...
} /// A map where we store invalidations. /// /// This is slightly different to a SelectorMap, in the sense of that the same /// selector may appear multiple times. /// /// In particular, we want to lookup as few things as possible to get the fewer /// selectors the better, so this looks up by id, class, or looks at ...
{ self.dep.selector() }
identifier_body
main.rs
extern crate nanomsg; use nanomsg::{Socket, Protocol}; use std::io::{Read, Write}; const ADDRESS: &'static str = "ipc:///tmp/a.ipc"; fn main() { let mut socket = Socket::new(Protocol::Rep).unwrap(); println!("Connecting to address '{}'", ADDRESS); let mut endpoint = socket.bind(ADDRESS).unwrap(); ...
(socket: &mut Socket, reply: &str) { socket.write_all(reply.as_bytes()).expect("Failed to send reply"); println!("Replied with '{}'", reply) }
reply
identifier_name
main.rs
extern crate nanomsg; use nanomsg::{Socket, Protocol}; use std::io::{Read, Write}; const ADDRESS: &'static str = "ipc:///tmp/a.ipc"; fn main() { let mut socket = Socket::new(Protocol::Rep).unwrap(); println!("Connecting to address '{}'", ADDRESS); let mut endpoint = socket.bind(ADDRESS).unwrap(); ...
{ socket.write_all(reply.as_bytes()).expect("Failed to send reply"); println!("Replied with '{}'", reply) }
identifier_body
main.rs
extern crate nanomsg; use nanomsg::{Socket, Protocol}; use std::io::{Read, Write}; const ADDRESS: &'static str = "ipc:///tmp/a.ipc"; fn main() { let mut socket = Socket::new(Protocol::Rep).unwrap(); println!("Connecting to address '{}'", ADDRESS); let mut endpoint = socket.bind(ADDRESS).unwrap(); ...
} "STOP" => { reply(&mut socket, "OK"); println!("Shutting down"); break; }, _ => reply(&mut socket, "UNKNOWN REQUEST") } request.clear(); } endpoint.shutdown().expect("Failed to shutdown graceful...
random_line_split
memory_io.rs
extern crate openexr; use std::io::Cursor; use openexr::{FrameBuffer, FrameBufferMut, Header, InputFile, PixelType, ScanlineOutputFile}; #[test] fn
() { // Target memory for writing let mut in_memory_buffer = Cursor::new(Vec::<u8>::new()); // Write file to memory { let pixel_data = vec![(0.82f32, 1.78f32, 0.21f32); 256 * 256]; let mut exr_file = ScanlineOutputFile::new( &mut in_memory_buffer, Header::new() ...
memory_io
identifier_name
memory_io.rs
extern crate openexr; use std::io::Cursor; use openexr::{FrameBuffer, FrameBufferMut, Header, InputFile, PixelType, ScanlineOutputFile}; #[test] fn memory_io()
exr_file.write_pixels(&fb).unwrap(); } // Read file from memory, and verify its contents { let mut pixel_data = vec![(0.0f32, 0.0f32, 0.0f32); 256 * 256]; let mut exr_file = InputFile::from_slice(in_memory_buffer.get_ref()).unwrap(); let (width, height) = exr_file.header()...
{ // Target memory for writing let mut in_memory_buffer = Cursor::new(Vec::<u8>::new()); // Write file to memory { let pixel_data = vec![(0.82f32, 1.78f32, 0.21f32); 256 * 256]; let mut exr_file = ScanlineOutputFile::new( &mut in_memory_buffer, Header::new() ...
identifier_body
memory_io.rs
extern crate openexr; use std::io::Cursor; use openexr::{FrameBuffer, FrameBufferMut, Header, InputFile, PixelType, ScanlineOutputFile}; #[test] fn memory_io() { // Target memory for writing let mut in_memory_buffer = Cursor::new(Vec::<u8>::new()); // Write file to memory { let pixel_data = ...
exr_file.write_pixels(&fb).unwrap(); } // Read file from memory, and verify its contents { let mut pixel_data = vec![(0.0f32, 0.0f32, 0.0f32); 256 * 256]; let mut exr_file = InputFile::from_slice(in_memory_buffer.get_ref()).unwrap(); let (width, height) = exr_file.header()....
let mut fb = FrameBuffer::new(256, 256); fb.insert_channels(&["R", "G", "B"], &pixel_data);
random_line_split
column.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use super::*; use tidb_query_datatype::codec::{datum, Datum}; use tidb_query_datatype::expr::EvalContext; use tipb::{ColumnInfo, FieldType}; pub const TYPE_VAR_CHAR: i32 = 1; pub const TYPE_LONG: i32 = 2; #[derive(Clone)] pub struct Column { pub...
pub fn as_field_type(&self) -> FieldType { let mut ft = FieldType::default(); ft.set_tp(self.col_field_type()); ft } pub fn col_field_type(&self) -> i32 { match self.col_type { TYPE_LONG => 8, // FieldTypeTp::LongLong TYPE_VAR_CHAR => 15, // Fiel...
}
random_line_split
column.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use super::*; use tidb_query_datatype::codec::{datum, Datum}; use tidb_query_datatype::expr::EvalContext; use tipb::{ColumnInfo, FieldType}; pub const TYPE_VAR_CHAR: i32 = 1; pub const TYPE_LONG: i32 = 2; #[derive(Clone)] pub struct
{ pub id: i64, pub(crate) col_type: i32, // negative means not a index key, 0 means primary key, positive means normal index key. pub index: i64, pub(crate) default_val: Option<Datum>, } impl Column { pub fn as_column_info(&self) -> ColumnInfo { let mut c_info = ColumnInfo::default(); ...
Column
identifier_name
procedural_mbe_matching.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 ...
$arm _ => false } ) } _ => unreachable!() } } Failure(_, s) | Error(_, s) => { panic!("expected Success, but got Error/Failure: {}", s); } ...
{ let mbe_matcher = quote_matcher!(cx, $matched:expr, $($pat:pat)|+); let mac_expr = match TokenTree::parse(cx, &mbe_matcher[..], args) { Success(map) => { match (&*map[str_to_ident("matched")], &*map[str_to_ident("pat")]) { (&MatchedNonterminal(NtExpr(ref matched_expr)), ...
identifier_body
procedural_mbe_matching.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 ...
reg.register_macro("matches", expand_mbe_matches); }
#[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) {
random_line_split
procedural_mbe_matching.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 ...
(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult +'static> { let mbe_matcher = quote_matcher!(cx, $matched:expr, $($pat:pat)|+); let mac_expr = match TokenTree::parse(cx, &mbe_matcher[..], args) { Success(map) => { match (&*map[str_to_ident("matched")], &*map[str_t...
expand_mbe_matches
identifier_name
procedural_mbe_matching.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 ...
).collect(); let arm = cx.arm(seq_sp, pats, cx.expr_bool(seq_sp, true)); quote_expr!(cx, match $matched_expr { $arm _ => false } ) ...
{ unreachable!() }
conditional_block
fetch.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 crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInfo; use crate::dom::bindings::codegen::Bindi...
/// Obtain an IpcReceiver to send over to Fetch, and initialize /// the internal sender pub fn initialize(&mut self) -> ipc::IpcReceiver<()> { // cancel previous fetch self.cancel(); let (rx, tx) = ipc::channel().unwrap(); self.cancel_chan = Some(rx); tx } ...
{ Default::default() }
identifier_body
fetch.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 crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInfo; use crate::dom::bindings::codegen::Bindi...
(&mut self) { self.cancel() } } fn from_referrer_to_referrer_url(request: &NetTraitsRequest) -> Option<ServoUrl> { request.referrer.to_url().map(|url| url.clone()) } fn request_init_from_request(request: NetTraitsRequest) -> NetTraitsRequestInit { NetTraitsRequestInit { method: request.met...
drop
identifier_name
fetch.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 crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInfo; use crate::dom::bindings::codegen::Bindi...
// Step 5 let (action_sender, action_receiver) = ipc::channel().unwrap(); let fetch_context = Arc::new(Mutex::new(FetchContext { fetch_promise: Some(TrustedPromise::new(promise.clone())), response_object: Trusted::new(&*response), body: vec![], })); let listener = NetworkLis...
// Step 4 response.Headers().set_guard(Guard::Immutable);
random_line_split
fetch.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 crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInfo; use crate::dom::bindings::codegen::Bindi...
, // Step 4.2 Ok(metadata) => match metadata { FetchMetadata::Unfiltered(m) => { fill_headers_with_metadata(self.response_object.root(), m); self.response_object .root() .set_type(DOMResponseTyp...
{ promise.reject_error(Error::Type("Network error occurred".to_string())); self.fetch_promise = Some(TrustedPromise::new(promise)); self.response_object.root().set_type(DOMResponseType::Error); return; }
conditional_block
details_window.rs
// Copyright 2015 Virgil Dupras // // This software is licensed under the "GPLv3" License as described in the "LICENSE" file, // which should be included with this package. The terms are also available at // http://www.gnu.org/licenses/gpl-3.0.html // use rustty::{CellAccessor, Cell, HasSize}; use rustty::ui::{Painter...
{ window: Widget, } impl DetailsWindow { pub fn new(parent: &HasSize) -> DetailsWindow { let mut window = Widget::new(16, 7); window.align(parent, HorizontalAlign::Right, VerticalAlign::Bottom, 0); DetailsWindow { window: window } } pub fn draw_into(&self, cells: &mut CellAcce...
DetailsWindow
identifier_name
details_window.rs
// Copyright 2015 Virgil Dupras // // This software is licensed under the "GPLv3" License as described in the "LICENSE" file, // which should be included with this package. The terms are also available at // http://www.gnu.org/licenses/gpl-3.0.html // use rustty::{CellAccessor, Cell, HasSize}; use rustty::ui::{Painter...
pub fn draw_into(&self, cells: &mut CellAccessor) { self.window.draw_into(cells); } pub fn update(&mut self, selected_pos: Option<Pos>, map: &LiveMap, turn: u16, movemode: &str) { let turn_line = format!("Turn {}", turn); let (terrain_name, maybe_unit_id) = match selected_pos { ...
{ let mut window = Widget::new(16, 7); window.align(parent, HorizontalAlign::Right, VerticalAlign::Bottom, 0); DetailsWindow { window: window } }
identifier_body
details_window.rs
// Copyright 2015 Virgil Dupras // // This software is licensed under the "GPLv3" License as described in the "LICENSE" file, // which should be included with this package. The terms are also available at // http://www.gnu.org/licenses/gpl-3.0.html // use rustty::{CellAccessor, Cell, HasSize}; use rustty::ui::{Painter...
("", "".to_owned()) }; let lines = [unit_name, &unit_stats[..], &terrain_name[..], &turn_line[..], movemode]; self.window.clear(Cell::default()); for (index, line) in lines.iter().enumerate() { self.window.printline(2, index + 1, line); } self.wind...
(unit.name(), format!("MV {} / HP {}", unit.movements(), unit.hp())) } else {
random_line_split
column.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <%helpers:shorthand name="columns" sub_properties="column-c...
} </%helpers:shorthand>
{ self.column_rule_width.to_css(dest)?; dest.write_str(" ")?; self.column_rule_style.to_css(dest)?; dest.write_str(" ")?; self.column_rule_color.to_css(dest) }
identifier_body
column.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <%helpers:shorthand name="columns" sub_properties="column-c...
<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Longhands, ParseError<'i>> { % for name in "width style color".split(): let mut column_rule_${name} = None; % endfor let mut any = false; loop { % for name in "widt...
parse_value
identifier_name
column.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <%helpers:shorthand name="columns" sub_properties="column-c...
// Leave the options to None, 'auto' is the initial value. autos += 1; continue } if column_count.is_none() { if let Ok(value) = input.try(|input| column_count::parse(context, input)) { column_count = Some(value...
loop { if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
random_line_split
column.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <%helpers:shorthand name="columns" sub_properties="column-c...
} impl<'a> ToCss for LonghandsToSerialize<'a> { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { try!(self.column_width.to_css(dest)); try!(write!(dest, " ")); self.column_count.to_css(dest) } } </%helpers:shorthand> <%helpers:sh...
{ Ok(expanded! { column_count: unwrap_or_initial!(column_count), column_width: unwrap_or_initial!(column_width), }) }
conditional_block
mod.rs
//! Various code related to computing outlives relations. pub mod env; pub mod obligations; pub mod verify; use rustc_middle::traits::query::OutlivesBound; use rustc_middle::ty;
param_env: ty::ParamEnv<'tcx>, ) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx { debug!("explicit_outlives_bounds()"); param_env .caller_bounds() .into_iter() .map(ty::Predicate::kind) .filter_map(ty::Binder::no_bound_vars) .filter_map(move |kind| match kind { ...
pub fn explicit_outlives_bounds<'tcx>(
random_line_split
mod.rs
//! Various code related to computing outlives relations. pub mod env; pub mod obligations; pub mod verify; use rustc_middle::traits::query::OutlivesBound; use rustc_middle::ty; pub fn explicit_outlives_bounds<'tcx>( param_env: ty::ParamEnv<'tcx>, ) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx
Some(OutlivesBound::RegionSubRegion(r_b, r_a)) } }) }
{ debug!("explicit_outlives_bounds()"); param_env .caller_bounds() .into_iter() .map(ty::Predicate::kind) .filter_map(ty::Binder::no_bound_vars) .filter_map(move |kind| match kind { ty::PredicateKind::Projection(..) | ty::PredicateKind::Trait(..) ...
identifier_body
mod.rs
//! Various code related to computing outlives relations. pub mod env; pub mod obligations; pub mod verify; use rustc_middle::traits::query::OutlivesBound; use rustc_middle::ty; pub fn
<'tcx>( param_env: ty::ParamEnv<'tcx>, ) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx { debug!("explicit_outlives_bounds()"); param_env .caller_bounds() .into_iter() .map(ty::Predicate::kind) .filter_map(ty::Binder::no_bound_vars) .filter_map(move |kind| match kind ...
explicit_outlives_bounds
identifier_name
files.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::num::NonZeroU64; use anyhow::{format_err, Context, Error}; use async_trait::async_trait; use bytes::Bytes; use context::PerfCount...
Ok(stream::iter(fetches) .buffer_unordered(MAX_CONCURRENT_FILE_FETCHES_PER_REQUEST) .inspect(move |response| { if let Ok(result) = &response { if result.result.is_ok() { ctx.session().bump_load(Metric::GetpackFiles, 1.0); ...
{ let ctx = repo.ctx().clone(); let len = request.keys.len() + request.reqs.len(); let reqs = request .keys .into_iter() .map(|key| FileSpec { key, attrs: FileAttributes { content: true, ...
identifier_body
files.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::num::NonZeroU64; use anyhow::{format_err, Context, Error}; use async_trait::async_trait; use bytes::Bytes; use context::PerfCount...
const ENDPOINT: &'static str = "/upload/filenodes"; async fn handler( repo: HgRepoContext, _path: Self::PathExtractor, _query: Self::QueryStringExtractor, request: Self::Request, ) -> HandlerResult<'async_trait, Self::Response> { let tokens = request .batc...
random_line_split
files.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::num::NonZeroU64; use anyhow::{format_err, Context, Error}; use async_trait::async_trait; use bytes::Bytes; use context::PerfCount...
} }) .boxed()) } } async fn fetch_file_response( repo: HgRepoContext, key: Key, attrs: FileAttributes, ) -> Result<FileResponse, Error> { let result = fetch_file(repo, key.clone(), attrs) .await .map_err(|e| ServerError::generic(format!("{}", e)...
{ ctx.session().bump_load(Metric::GetpackFiles, 1.0); }
conditional_block
files.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::num::NonZeroU64; use anyhow::{format_err, Context, Error}; use async_trait::async_trait; use bytes::Bytes; use context::PerfCount...
; #[async_trait] impl EdenApiHandler for DownloadFileHandler { type Request = UploadToken; type Response = Bytes; const HTTP_METHOD: hyper::Method = hyper::Method::POST; const API_METHOD: EdenApiMethod = EdenApiMethod::DownloadFile; const ENDPOINT: &'static str = "/download/file"; async fn ha...
DownloadFileHandler
identifier_name
errors.rs
use tokio_timer::TimerError; use getopts; use log; use nom; use std::cell; use std::io; use std::sync; use toml; use serde_json; error_chain! { foreign_links { Timer(TimerError); IO(io::Error); SetLogger(log::SetLoggerError); Getopts(getopts::Fail); BorrowMut(cell::BorrowMu...
ConfigSection(section: String) { description("error in section") display("error in section: {}", section) } ConfigField(field: String, reason: String) { description("error in field") display("error in field: {}: {}", field, reason) } ...
description("error in config") display("error in config: {}", path) }
random_line_split
errors.rs
use tokio_timer::TimerError; use getopts; use log; use nom; use std::cell; use std::io; use std::sync; use toml; use serde_json; error_chain! { foreign_links { Timer(TimerError); IO(io::Error); SetLogger(log::SetLoggerError); Getopts(getopts::Fail); BorrowMut(cell::BorrowMu...
(err: toml::DecodeError) -> Error { if let Some(ref field) = err.field { ErrorKind::ConfigField(field.clone(), format!("{}", err)).into() } else { ErrorKind::Message(format!("{}", err)).into() } } }
from
identifier_name
errors.rs
use tokio_timer::TimerError; use getopts; use log; use nom; use std::cell; use std::io; use std::sync; use toml; use serde_json; error_chain! { foreign_links { Timer(TimerError); IO(io::Error); SetLogger(log::SetLoggerError); Getopts(getopts::Fail); BorrowMut(cell::BorrowMu...
} impl From<nom::IError> for Error { fn from(err: nom::IError) -> Error { match err { nom::IError::Error(err) => ErrorKind::Nom(err.to_string()).into(), nom::IError::Incomplete(_) => ErrorKind::Nom("input incomplete".to_owned()).into(), } } } impl From<toml::DecodeErro...
{ ErrorKind::Poison(err.to_string()).into() }
identifier_body