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
service.rs
use std::future::Future; use std::net::SocketAddr; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use crate::futures; use crate::jsonrpc::{middleware, MetaIoHandler, Metadata, Middleware}; pub struct Service<M: Metadata = (), S: Middleware<M> = middleware::Noop> { handler: Arc<MetaIoHandler<M...
} impl<M: Metadata, S: Middleware<M>> tower_service::Service<String> for Service<M, S> where S::Future: Unpin, S::CallFuture: Unpin, { // These types must match the corresponding protocol types: type Response = Option<String>; // For non-streaming protocols, service errors are always io::Error type Error = (); ...
{ Service { handler, peer_addr, meta, } }
identifier_body
deriving-primitive.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let x: Option<A> = FromPrimitive::from_int(int::max_value); assert_eq!(x, Some(Foo)); let x: Option<A> = FromPrimitive::from_int(1); assert_eq!(x, Some(Bar)); let x: Option<A> = FromPrimitive::from_int(3); assert_eq!(x, Some(Baz)); let x: Option<A> = FromPrimitive::from_i...
Baz = 3, Qux, }
random_line_split
deriving-primitive.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 ...
{ Foo = int::max_value, Bar = 1, Baz = 3, Qux, } pub fn main() { let x: Option<A> = FromPrimitive::from_int(int::max_value); assert_eq!(x, Some(Foo)); let x: Option<A> = FromPrimitive::from_int(1); assert_eq!(x, Some(Bar)); let x: Option<A> = FromPrimitive::from_int(3); asser...
A
identifier_name
context.rs
use std::path::Path; use std::fs; use std::io; use std::path::PathBuf; use std::result; use std::time::Duration; use uuid; pub use io::KeyWrapper; use io::{FileExtensions, Disks, TerminalPrompt}; use model::{DbLocation, PeroxideDb, YubikeySlot, YubikeyEntryType}; use cryptsetup_rs::device::CryptDevice; pub type Resu...
db_location: DbLocation, password_input_timeout: Option<Duration>, } impl MainContext { pub fn new(location: DbLocation) -> MainContext { MainContext { db_location: location, password_input_timeout: Some(Duration::new(30, 0)), } } pub fn trace_on() { ...
fn save_peroxide_db(&self, db: &PeroxideDb) -> Result<()>; } #[derive(Debug)] pub struct MainContext {
random_line_split
context.rs
use std::path::Path; use std::fs; use std::io; use std::path::PathBuf; use std::result; use std::time::Duration; use uuid; pub use io::KeyWrapper; use io::{FileExtensions, Disks, TerminalPrompt}; use model::{DbLocation, PeroxideDb, YubikeySlot, YubikeyEntryType}; use cryptsetup_rs::device::CryptDevice; pub type Resu...
<'a>(&'a self) -> &'a DbLocation { &self.db_location } } impl KeyfileInput for MainContext { fn read_keyfile(&self, path: &Path) -> Result<KeyWrapper> { self.db_location .open_relative_path(path) .and_then(|mut file| KeyWrapper::read(&mut file)) .map_err(|err| E...
db_location
identifier_name
context.rs
use std::path::Path; use std::fs; use std::io; use std::path::PathBuf; use std::result; use std::time::Duration; use uuid; pub use io::KeyWrapper; use io::{FileExtensions, Disks, TerminalPrompt}; use model::{DbLocation, PeroxideDb, YubikeySlot, YubikeyEntryType}; use cryptsetup_rs::device::CryptDevice; pub type Resu...
pub fn trace_on() { CryptDevice::enable_debug(true); } } impl HasDbLocation for MainContext { fn db_location<'a>(&'a self) -> &'a DbLocation { &self.db_location } } impl KeyfileInput for MainContext { fn read_keyfile(&self, path: &Path) -> Result<KeyWrapper> { self.db_loc...
{ MainContext { db_location: location, password_input_timeout: Some(Duration::new(30, 0)), } }
identifier_body
macro-crate-does-hygiene-work.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ let x = 3; assert_eq!(3, identity!(x)); assert_eq!(6, identity!(x+x)); let x = 4; assert_eq!(4, identity!(x)); }
identifier_body
macro-crate-does-hygiene-work.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// Issue #15750: a macro that internally parses its input and then // uses `quote_expr!` to rearrange it should be hygiene-preserving. #![feature(plugin)] #![plugin(macro_crate_test)] fn main() { let x = 3; assert_eq!(3, identity!(x)); assert_eq!(6, identity!(x+x)); let x = 4; assert_eq!(4, identi...
random_line_split
macro-crate-does-hygiene-work.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let x = 3; assert_eq!(3, identity!(x)); assert_eq!(6, identity!(x+x)); let x = 4; assert_eq!(4, identity!(x)); }
main
identifier_name
sphere.rs
// Copyright Colin Sherratt 2014 // // 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 o...
(&self, u: usize, v: usize) -> (f32, f32, f32) { let u = (u as f32 / self.sub_u as f32) * PI * 2.; let v = (v as f32 / self.sub_v as f32) * PI; (u.cos() * v.sin(), u.sin() * v.sin(), v.cos()) } } impl Iterator for SphereUV { type Item = Polygon<(f32, f32, f32)>; ...
vert
identifier_name
sphere.rs
// Copyright Colin Sherratt 2014 // // 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 o...
} impl Iterator for SphereUV { type Item = Polygon<(f32, f32, f32)>; fn size_hint(&self) -> (usize, Option<usize>) { let n = (self.sub_v - self.v) * self.sub_u + (self.sub_u - self.u); (n, Some(n)) } fn next(&mut self) -> Option<Polygon<(f32, f32, f32)>> { if self.u == self....
{ let u = (u as f32 / self.sub_u as f32) * PI * 2.; let v = (v as f32 / self.sub_v as f32) * PI; (u.cos() * v.sin(), u.sin() * v.sin(), v.cos()) }
identifier_body
sphere.rs
// Copyright Colin Sherratt 2014 // // 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 o...
pub fn new(u: usize, v: usize) -> SphereUV { SphereUV { u: 0, v: 0, sub_u: u, sub_v: v } } fn vert(&self, u: usize, v: usize) -> (f32, f32, f32) { let u = (u as f32 / self.sub_u as f32) * PI * 2.; let v = (v as f32 / self.sub_v...
/// Create a new sphere. /// `u` is the number of points across the equator of the sphere. /// `v` is the number of points from pole to pole.
random_line_split
mod.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
//! //! Several other collection methods also return iterators to yield a sequence //! of results but avoid allocating an entire collection to store the result in. //! This provides maximum flexibility as `collect` or `extend` can be called to //! "pipe" the sequence into any collection if desired. Otherwise, the seque...
//! } //! ```
random_line_split
resolve_lock_lite.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use crate::storage::kv::WriteData; use crate::storage::lock_manager::LockManager; use crate::storage::mvcc::MvccTxn; use crate::storage::txn::commands::{ Command, CommandExt, ReleasedLocks, ResponsePolicy, TypedCommand, WriteCommand, WriteContext, ...
context.statistics.add(&txn.take_statistics()); let write_data = WriteData::from_modifies(txn.into_modifies()); Ok(WriteResult { ctx: self.ctx, to_be_write: write_data, rows, pr: ProcessResult::Res, lock_info: None, lock_gu...
{ let mut txn = MvccTxn::new( snapshot, self.start_ts, !self.ctx.get_not_fill_cache(), context.concurrency_manager, ); let rows = self.resolve_keys.len(); // ti-client guarantees the size of resolve_keys will not too large, so no necessary...
identifier_body
resolve_lock_lite.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use crate::storage::kv::WriteData; use crate::storage::lock_manager::LockManager; use crate::storage::mvcc::MvccTxn; use crate::storage::txn::commands::{ Command, CommandExt, ReleasedLocks, ResponsePolicy, TypedCommand, WriteCommand, WriteContext, ...
(self, snapshot: S, context: WriteContext<'_, L>) -> Result<WriteResult> { let mut txn = MvccTxn::new( snapshot, self.start_ts, !self.ctx.get_not_fill_cache(), context.concurrency_manager, ); let rows = self.resolve_keys.len(); // ti-client...
process_write
identifier_name
resolve_lock_lite.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use crate::storage::kv::WriteData; use crate::storage::lock_manager::LockManager; use crate::storage::mvcc::MvccTxn; use crate::storage::txn::commands::{ Command, CommandExt, ReleasedLocks, ResponsePolicy, TypedCommand, WriteCommand, WriteContext, ...
); } released_locks.wake_up(context.lock_mgr); context.statistics.add(&txn.take_statistics()); let write_data = WriteData::from_modifies(txn.into_modifies()); Ok(WriteResult { ctx: self.ctx, to_be_write: write_data, rows, pr: Proce...
{ cleanup(&mut txn, key, TimeStamp::zero(), false)? }
conditional_block
resolve_lock_lite.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use crate::storage::kv::WriteData; use crate::storage::lock_manager::LockManager;
WriteResult, }; use crate::storage::txn::{cleanup, commit, Result}; use crate::storage::{ProcessResult, Snapshot}; use txn_types::{Key, TimeStamp}; command! { /// Resolve locks on `resolve_keys` according to `start_ts` and `commit_ts`. ResolveLockLite: cmd_ty => (), display => "kv::resolve_...
use crate::storage::mvcc::MvccTxn; use crate::storage::txn::commands::{ Command, CommandExt, ReleasedLocks, ResponsePolicy, TypedCommand, WriteCommand, WriteContext,
random_line_split
thread.rs
// Testing the the display of JoinHandle and Thread in cdb. // cdb-only // min-cdb-version: 10.0.18317.1001 // compile-flags:-g // === CDB TESTS ================================================================================== // // cdb-command:g // // cdb-command:dx join_handle,d // cdb-check:join_handle,d [Type...
() {}
zzz
identifier_name
thread.rs
// Testing the the display of JoinHandle and Thread in cdb. // cdb-only // min-cdb-version: 10.0.18317.1001 // compile-flags:-g // === CDB TESTS ================================================================================== // // cdb-command:g // // cdb-command:dx join_handle,d // cdb-check:join_handle,d [Type...
{}
identifier_body
thread.rs
// Testing the the display of JoinHandle and Thread in cdb.
// min-cdb-version: 10.0.18317.1001 // compile-flags:-g // === CDB TESTS ================================================================================== // // cdb-command:g // // cdb-command:dx join_handle,d // cdb-check:join_handle,d [Type: std::thread::JoinHandle<tuple$<> >] // cdb-check: [...] __0 ...
// cdb-only
random_line_split
remove.rs
use libc::{c_ulong, c_ulonglong, c_void}; use super::super::error_type::ErrorType; use super::super::instance::Instance; use super::format_error; #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct RemoveInternal { pub cookie: *mut c_void, pub key: *const c_void, pub nkey: c_ulong, pub cas: c_ulonglo...
key: internal.key(), cas: internal.cas, rc: internal.rc, version: internal.version, rflags: internal.rflags } } }
Remove {
random_line_split
remove.rs
use libc::{c_ulong, c_ulonglong, c_void}; use super::super::error_type::ErrorType; use super::super::instance::Instance; use super::format_error; #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct RemoveInternal { pub cookie: *mut c_void, pub key: *const c_void, pub nkey: c_ulong, pub cas: c_ulonglo...
{ pub key: Option<String>, pub cas: u64, pub rc: ErrorType, pub version: u16, pub rflags: u16, } impl Remove { pub fn new(internal: &RemoveInternal) -> Remove { Remove { key: internal.key(), cas: internal.cas, rc: internal.rc, version: in...
Remove
identifier_name
remove.rs
use crate::database::models::ToU64; use diesel::prelude::*; use lalafell::commands::prelude::*; use lalafell::error::*; use serenity::model::id::GuildId; pub struct RemoveCommand; #[derive(Debug, StructOpt)] pub struct Params { #[structopt(help = "The ID of the auto reply to remove")] id: i32 } impl<'a> Remov...
if affected > 0 { Ok(CommandSuccess::default()) } else { Err("No auto replies were deleted.".into()) } } }
diesel::delete( dsl::auto_replies.filter(dsl::id.eq(params.id).and(dsl::server_id.eq(guild.to_u64()))) ) .execute(c) }).chain_err(|| "could not delete auto_replies")?;
random_line_split
remove.rs
use crate::database::models::ToU64; use diesel::prelude::*; use lalafell::commands::prelude::*; use lalafell::error::*; use serenity::model::id::GuildId; pub struct RemoveCommand; #[derive(Debug, StructOpt)] pub struct Params { #[structopt(help = "The ID of the auto reply to remove")] id: i32 } impl<'a> Remov...
} }
{ Err("No auto replies were deleted.".into()) }
conditional_block
remove.rs
use crate::database::models::ToU64; use diesel::prelude::*; use lalafell::commands::prelude::*; use lalafell::error::*; use serenity::model::id::GuildId; pub struct
; #[derive(Debug, StructOpt)] pub struct Params { #[structopt(help = "The ID of the auto reply to remove")] id: i32 } impl<'a> RemoveCommand { #[allow(clippy::needless_pass_by_value)] pub fn run(&self, guild: GuildId, params: Params) -> CommandResult<'a> { let affected = crate::bot::with_connection(|c| { ...
RemoveCommand
identifier_name
privacy-ns.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) { } } pub struct Baz; pub fn Bar() { } } fn test_unused2() { use foo2::*; } fn test_single2() { use foo2::Bar; Bar(); } fn test_list2() { use foo2::{Bar,Baz}; Bar(); } fn test_glob2() { use foo2::*; Bar(); } // public type, public value pub mod foo3 { pub tra...
dummy
identifier_name
privacy-ns.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test_unused2() { use foo2::*; } fn test_single2() { use foo2::Bar; Bar(); } fn test_list2() { use foo2::{Bar,Baz}; Bar(); } fn test_glob2() { use foo2::*; Bar(); } // public type, public value pub mod foo3 { pub trait Bar { fn dummy(&self) { } } pub struct Baz;...
}
random_line_split
privacy-ns.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test_single3() { use foo3::Bar; Bar(); let _x: Box<Bar>; } fn test_list3() { use foo3::{Bar,Baz}; Bar(); let _x: Box<Bar>; } fn test_glob3() { use foo3::*; Bar(); let _x: Box<Bar>; } fn main() { }
{ use foo3::*; }
identifier_body
v1.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 ...
// NB: remove when path reform lands //#[doc(no_inline)] pub use path::{Path, GenericPath}; // NB: remove when I/O reform lands //#[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek, BufferPrelude}; // NB: remove when range syntax lands #[doc(no_inline)] pub use iter::range;
#[stable] #[doc(no_inline)] pub use vec::Vec;
random_line_split
region.rs
*/
} } pub fn temporary_scope(&self, expr_id: ast::NodeId) -> Option<ast::NodeId> { //! Returns the scope when temp created by expr_id will be cleaned up // check for a designated rvalue scope let rvalue_scopes = self.rvalue_scopes.borrow(); match rvalue_scopes.get().find(...
let var_map = self.var_map.borrow(); match var_map.get().find(&var_id) { Some(&r) => r, None => { fail!("No enclosing scope for id {}", var_id); }
random_line_split
region.rs
let scope_map = this.scope_map.borrow(); match scope_map.get().find(&scope) { None => return result, Some(&superscope) => { result.push(superscope); scope = superscope; } ...
{ resolve_arm(self, a, cx); }
identifier_body
region.rs
scope_a: ast::NodeId, scope_b: ast::NodeId) -> Option<ast::NodeId> { /*! * Finds the nearest common ancestor (if any) of two scopes. That * is, finds the smallest scope which is greater than or ...
resolve_fn
identifier_name
main.rs
#![feature(plugin)] #![plugin(rocket_codegen)] #[macro_use] extern crate lazy_static; extern crate uuid; extern crate rocket; extern crate rocket_contrib; use std::collections::HashMap; use uuid::Uuid; use rocket_contrib::UUID; #[cfg(test)] mod tests; lazy_static! {
static ref PEOPLE: HashMap<Uuid, &'static str> = { let mut m = HashMap::new(); let lacy_id = Uuid::parse_str("7f205202-7ba1-4c39-b2fc-3e630722bf9f").unwrap(); let bob_id = Uuid::parse_str("4da34121-bc7d-4fc1-aee6-bf8de0795333").unwrap(); let george_id = Uuid::parse_str("ad962969-4e3d...
// A small people lookup table for the sake of this example. In a real // application this could be a database lookup. Notice that we use the // uuid::Uuid type here and not the rocket_contrib::UUID type.
random_line_split
main.rs
#![feature(plugin)] #![plugin(rocket_codegen)] #[macro_use] extern crate lazy_static; extern crate uuid; extern crate rocket; extern crate rocket_contrib; use std::collections::HashMap; use uuid::Uuid; use rocket_contrib::UUID; #[cfg(test)] mod tests; lazy_static! { // A small people lookup table for the sake o...
() { rocket::ignite() .mount("/", routes![people]) .launch(); }
main
identifier_name
main.rs
#![feature(plugin)] #![plugin(rocket_codegen)] #[macro_use] extern crate lazy_static; extern crate uuid; extern crate rocket; extern crate rocket_contrib; use std::collections::HashMap; use uuid::Uuid; use rocket_contrib::UUID; #[cfg(test)] mod tests; lazy_static! { // A small people lookup table for the sake o...
{ rocket::ignite() .mount("/", routes![people]) .launch(); }
identifier_body
account.rs
extern crate meg; use std::env; use std::clone::Clone; use turbo::util::{CliResult, Config}; use self::meg::ops::meg_account_create as Act; use self::meg::ops::meg_account_show as Show; #[derive(RustcDecodable, Clone)] pub struct Options { pub arg_email: String, pub flag_show: bool, } pub const USAGE: &'static s...
}
random_line_split
account.rs
extern crate meg; use std::env; use std::clone::Clone; use turbo::util::{CliResult, Config}; use self::meg::ops::meg_account_create as Act; use self::meg::ops::meg_account_show as Show; #[derive(RustcDecodable, Clone)] pub struct
{ pub arg_email: String, pub flag_show: bool, } pub const USAGE: &'static str = " Usage: meg account [options] [<email>] Options: -h, --help Print this message --create Provide an email to create a new account --show Provide an email to show the accoun...
Options
identifier_name
account.rs
extern crate meg; use std::env; use std::clone::Clone; use turbo::util::{CliResult, Config}; use self::meg::ops::meg_account_create as Act; use self::meg::ops::meg_account_show as Show; #[derive(RustcDecodable, Clone)] pub struct Options { pub arg_email: String, pub flag_show: bool, } pub const USAGE: &'static s...
} return Ok(None) }
{ let mut acct: Show::Showoptions = Show::ShowAcc::new(); //Not reqd - to expand later if acct.email = options.arg_email.clone(); //multiple accounts needs to be showed let x = acct.show(); }
conditional_block
non_terminal.rs
// Copyright 2016 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...
#success } else { #failure } } )) .unwrap_success() } } pub struct NonTerminalParserCompiler { path: syn::Path, this_idx: usize } impl CompileExpr for NonTerminalParserCompiler { fn compile_expr<'a>(&self, context: &mut Context<'a>, ...
state = #recognizer_fn(state); if state.is_successful() { state.discard_data();
random_line_split
non_terminal.rs
// Copyright 2016 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...
state = stateful.failure(); #failure } } )) .unwrap_success() } }
{ let parser_fn = parser_name(self.path.clone()); let cardinality = context.expr_cardinality(self.this_idx); let mut vars_names: Vec<_> = (0..cardinality) .map(|_| context.next_free_var()) .collect(); // Due to the reverse compilation scheme, variables are given as `a3, a2,...`, however we n...
identifier_body
non_terminal.rs
// Copyright 2016 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...
<'a>(&self, _context: &mut Context<'a>, continuation: Continuation) -> syn::Expr { let recognizer_fn = recognizer_name(self.path.clone()); continuation .map_success(|success, failure| parse_quote!( { state = #recognizer_fn(state); if state.is_successful() { sta...
compile_expr
identifier_name
issue-38147-1.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
struct Foo<'a> { s: &'a mut String } impl<'a> Foo<'a> { fn f(&self) { self.s.push('x'); //~ ERROR cannot borrow data mutably } } fn main() {}
random_line_split
issue-38147-1.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() {}
{ self.s.push('x'); //~ ERROR cannot borrow data mutably }
identifier_body
issue-38147-1.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a> { s: &'a mut String } impl<'a> Foo<'a> { fn f(&self) { self.s.push('x'); //~ ERROR cannot borrow data mutably } } fn main() {}
Foo
identifier_name
submessage.rs
use std::io::{ self, Write }; use byteorder::{ LittleEndian, WriteBytesExt}; pub struct
(pub SubmessageType, pub Vec<u8>); bitflags! { flags SubmessageType : u8 { // const PAD = 0x01, /* Pad */ const LITTLEENDIAN = 0x01, /* Xavier's Endianness hack? */ const ACKNACK = 0x06, /* AckNack */ const HEARTBEAT = 0x07, /* Heartbeat */ const GAP = 0x08, /* Gap */ const INFO_TS = 0x09, /*...
Submessage
identifier_name
submessage.rs
use std::io::{ self, Write }; use byteorder::{ LittleEndian, WriteBytesExt}; pub struct Submessage(pub SubmessageType, pub Vec<u8>); bitflags! { flags SubmessageType : u8 { // const PAD = 0x01, /* Pad */
const HEARTBEAT = 0x07, /* Heartbeat */ const GAP = 0x08, /* Gap */ const INFO_TS = 0x09, /* InfoTimestamp */ const INFO_SRC = 0x0c, /* InfoSource */ const INFO_REPLY_IP4 = 0x0d, /* InfoReplyIp4 */ const INFO_DST = 0x0e, /* InfoDestination */ const INFO_REPLY = 0x0f, /* InfoReply */ cons...
const LITTLEENDIAN = 0x01, /* Xavier's Endianness hack? */ const ACKNACK = 0x06, /* AckNack */
random_line_split
into_matcher.rs
use super::Matcher; use regex::{Regex, Captures}; impl From<Regex> for Matcher { fn from(regex: Regex) -> Matcher { let path = regex.as_str().to_string(); Matcher::new(path, regex) } } impl<'a> From<&'a str> for Matcher { fn from(s: &'a str) -> Matcher { From::from(s.to_string()) ...
(s: String) -> Matcher { let with_format = if s.contains(FORMAT_VAR) { s } else { format!("{}(\\.{})?", s, FORMAT_VAR) }; // First mark all double wildcards for replacement. We can't directly // replace them since the replacement does contain the * symbol...
from
identifier_name
into_matcher.rs
use super::Matcher; use regex::{Regex, Captures}; impl From<Regex> for Matcher { fn from(regex: Regex) -> Matcher { let path = regex.as_str().to_string(); Matcher::new(path, regex) } } impl<'a> From<&'a str> for Matcher { fn from(s: &'a str) -> Matcher { From::from(s.to_string()) ...
else { format!("{}(\\.{})?", s, FORMAT_VAR) }; // First mark all double wildcards for replacement. We can't directly // replace them since the replacement does contain the * symbol as well, // which would get overwritten with the next replace call let with_placehold...
{ s }
conditional_block
into_matcher.rs
use super::Matcher; use regex::{Regex, Captures}; impl From<Regex> for Matcher { fn from(regex: Regex) -> Matcher
} impl<'a> From<&'a str> for Matcher { fn from(s: &'a str) -> Matcher { From::from(s.to_string()) } } lazy_static! { static ref REGEX_VAR_SEQ: Regex = Regex::new(r":([,a-zA-Z0-9_-]*)").unwrap(); } pub static FORMAT_PARAM: &'static str = "format"; // FIXME: Once const fn lands this could be ...
{ let path = regex.as_str().to_string(); Matcher::new(path, regex) }
identifier_body
into_matcher.rs
use super::Matcher; use regex::{Regex, Captures}; impl From<Regex> for Matcher { fn from(regex: Regex) -> Matcher { let path = regex.as_str().to_string(); Matcher::new(path, regex) } }
fn from(s: &'a str) -> Matcher { From::from(s.to_string()) } } lazy_static! { static ref REGEX_VAR_SEQ: Regex = Regex::new(r":([,a-zA-Z0-9_-]*)").unwrap(); } pub static FORMAT_PARAM: &'static str = "format"; // FIXME: Once const fn lands this could be defined in terms of the above static FORM...
impl<'a> From<&'a str> for Matcher {
random_line_split
is_integer.rs
use malachite_base::num::conversion::traits::IsInteger; use Rational; impl<'a> IsInteger for &'a Rational { /// Determines whether a `Rational` is an integer. /// /// $f(x) = x \in \Z$. /// /// # Worst-case complexity /// Constant time and additional memory. /// /// # Examples /// `...
}
{ self.denominator == 1u32 }
identifier_body
is_integer.rs
use malachite_base::num::conversion::traits::IsInteger; use Rational; impl<'a> IsInteger for &'a Rational { /// Determines whether a `Rational` is an integer. /// /// $f(x) = x \in \Z$. /// /// # Worst-case complexity /// Constant time and additional memory. /// /// # Examples /// `...
(self) -> bool { self.denominator == 1u32 } }
is_integer
identifier_name
is_integer.rs
use malachite_base::num::conversion::traits::IsInteger; use Rational; impl<'a> IsInteger for &'a Rational { /// Determines whether a `Rational` is an integer. /// /// $f(x) = x \in \Z$. /// /// # Worst-case complexity /// Constant time and additional memory.
/// extern crate malachite_q; /// /// use malachite_base::num::basic::traits::{One, Zero}; /// use malachite_base::num::conversion::traits::IsInteger; /// use malachite_q::Rational; /// use std::str::FromStr; /// /// assert_eq!(Rational::ZERO.is_integer(), true); /// assert_eq!(Ratio...
/// /// # Examples /// ``` /// extern crate malachite_base;
random_line_split
mem_size_tbl.rs
// SPDX-License-Identifier: MIT // Copyright wtfsckgh@gmail.com // Copyright iced contributors use super::super::super::iced_constants::IcedConstants; use alloc::vec::Vec; // GENERATOR-BEGIN: MemorySizes // ⚠️This was generated by GENERATOR!🦹‍♂️ #[rustfmt::skip] static MEM_SIZE_TBL_DATA: [u8; 141] = [ 0x00, 0x01, ...
0x08, 0x0C, 0x0D, 0x03, 0x0B, 0x03, 0x0B, 0x0B, 0x09, 0x08, 0x08, 0x0D, 0x03, 0x0B, 0x0C, 0x0E, 0x0D, 0x04, 0x05, 0x07, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x10, 0x00, 0x0C, 0x11, 0x10, 0x0D, 0x0D, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B...
0x03,
random_line_split
enable_stratagem_button.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{ components::{ font_awesome_outline, stratagem::{Command, StratagemEnable}, }, extensions::{MergeAttrs, NodeExt, RequestExt}, ...
}
{ btn.merge_attrs(attrs! {At::Disabled => "disabled"}) .merge_attrs(class![C.opacity_50, C.cursor_not_allowed]) }
conditional_block
enable_stratagem_button.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{ components::{ font_awesome_outline, stratagem::{Command, StratagemEnable}, }, extensions::{MergeAttrs, NodeExt, RequestExt}, ...
pub fn view(is_valid: bool, disabled: bool) -> Node<Command> { let btn = button![ class![ C.bg_blue_500, C.hover__bg_blue_700, C.text_white, C.font_bold, C.p_2, C.rounded, C.w_full, C.text_sm, C.col...
{ fetch::Request::api_call(StratagemConfiguration::endpoint_name()) .method(fetch::Method::Post) .with_auth() .send_json(&model) .fetch_json(std::convert::identity) .await }
identifier_body
enable_stratagem_button.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{ components::{ font_awesome_outline, stratagem::{Command, StratagemEnable}, }, extensions::{MergeAttrs, NodeExt, RequestExt}, ...
C.font_bold, C.p_2, C.rounded, C.w_full, C.text_sm, C.col_span_2, ], "Enable Scan Interval", font_awesome_outline(class![C.inline, C.h_4, C.w_4, C.ml_2], "clock") ]; if is_valid &&!disabled { btn.with_listen...
C.bg_blue_500, C.hover__bg_blue_700, C.text_white,
random_line_split
enable_stratagem_button.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{ components::{ font_awesome_outline, stratagem::{Command, StratagemEnable}, }, extensions::{MergeAttrs, NodeExt, RequestExt}, ...
(is_valid: bool, disabled: bool) -> Node<Command> { let btn = button![ class![ C.bg_blue_500, C.hover__bg_blue_700, C.text_white, C.font_bold, C.p_2, C.rounded, C.w_full, C.text_sm, C.col_span_2, ...
view
identifier_name
constants.rs
pub const MH_MAGIC_64: u32 = 0xfeedfacf; pub const MH_CIGAM_64: u32 = 0xcffaedfe; const LC_REQ_DYLD: u32 = 0x80000000; #[repr(u32)] #[derive(Eq,PartialEq)] #[allow(non_camel_case_types)] pub enum
{ /// After MacOS X 10.1 when a new load command is added that is required to be /// understood by the dynamic linker for the image to execute properly the /// LC_REQ_DYLD bit will be or'ed into the load command constant. If the dynamic /// linker sees such a load command it it does not understand wil...
LcType
identifier_name
constants.rs
pub const MH_MAGIC_64: u32 = 0xfeedfacf; pub const MH_CIGAM_64: u32 = 0xcffaedfe; const LC_REQ_DYLD: u32 = 0x80000000; #[repr(u32)] #[derive(Eq,PartialEq)] #[allow(non_camel_case_types)] pub enum LcType { /// After MacOS X 10.1 when a new load command is added that is required to be /// understood by the dyna...
/// two-level namespace lookup hints LC_TWOLEVEL_HINTS = 0x16, /// prebind checksum LC_PREBIND_CKSUM = 0x17, /// load a dynamically linked shared library that is allowed to be missing /// (all symbols are weak imported). LC_LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD), /// 64-bit segment o...
LC_SUB_LIBRARY = 0x15,
random_line_split
lib.rs
// Definitions mod definitions { // // Each encoded block begins with the varint-encoded length of the decoded data, // followed by a sequence of chunks. Chunks begin and end on byte boundaries. // The // first byte of each chunk is broken into its 2 least and 6 most significant // bits // called l and m: l ran...
// - For l == 3, this tag is a legacy format that is no longer supported. // pub const TAG_LITERAL: u8 = 0x00; pub const TAG_COPY_1: u8 = 0x01; pub const TAG_COPY_2: u8 = 0x02; pub const TAG_COPY_4: u8 = 0x03; pub const CHECK_SUM_SIZE: u8 = 4; pub const CHUNK_HEADER_SIZE: u8 = 4; pub cons...
// - For l == 2, the offset ranges in [0, 1<<16) and the length in [1, 65). // The length is 1 + m. The offset is the little-endian unsigned integer // denoted by the next 2 bytes.
random_line_split
main.rs
use std::io; pub struct JiaeHomework { index: usize, value: i32, } fn stdinln_i32() -> i32 { // 이 함수는 하나의 줄을 stdin으로 받아 단 하나의 integer를 리턴합니다. let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("Failed to read stdin."); buffer.trim().parse::<i32>().unwrap() } fn stdinln_vec_i32() -> ...
를 완성해주세요! let mut problem = JiaeHomework::new(); problem.solve(&inputs, nr_case); problem.print(); }
ts = stdinln_vec_i32(); // JiaeHomework.solve(...)
conditional_block
main.rs
use std::io; pub struct JiaeHomework { index: usize, value: i32, } fn stdinln_i32() -> i32 { // 이 함수는 하나의 줄을 stdin으로 받아 단 하나의 integer를 리턴합니다. let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("Failed to read stdin."); buffer.trim().parse::<i32>().unwrap() } fn stdinln_vec_i32() -> ...
identifier_body
main.rs
use std::io; pub struct JiaeHomework { index: usize, value: i32, } fn stdinln_i32() -> i32 { // 이 함수는 하나의 줄을 stdin으로 받아 단 하나의 integer를 리턴합니다. let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("Failed to read stdin."); buffer.trim().parse::<i32>().unwrap() } fn stdinln_vec_i32() -> ...
; } let avg = sum/nr_items as i32; // Rust 2018에서는 (source[0]-avg).abs() 를 해도 되나. // 현재 구름은 rustc 2017년대 버젼을 쓰고있다. 따라서 이와같이 해결한다. // i32::abs(...) let mut near_gap = i32::abs(source[0]-avg); for i in 1..nr_items { let current_gap = i32::abs(source[i]-avg); if current_gap < near_gap { self.index ...
ce[i]
identifier_name
main.rs
use std::io; pub struct JiaeHomework { index: usize, value: i32, } fn stdinln_i32() -> i32 { // 이 함수는 하나의 줄을 stdin으로 받아 단 하나의 integer를 리턴합니다. let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("Failed to read stdin."); buffer.trim().parse::<i32>().unwrap() } fn stdinln_vec_i32() -> ...
.collect(); ret } /* 이번 문제는 Method 스타일로 풀어봅시다.! https://doc.rust-lang.org/rust-by-example/fn/methods.html 이번 문제는 Rust-Ownership 문제가 야기될 수 있습니다. 한번 읽어보세요. https://rinthel.github.io/rust-lang-book-ko/ch04-02-references-and-borrowing.html */ impl JiaeHomework { fn new() -> JiaeHomework { JiaeHomework{index:0, v...
// 이 함수는 하나의 줄을 stdin으로 받아 여러개의 integer 을 vector로 리턴합니다. let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect("Failed to read line"); let ret: Vec<i32> = buffer.split(" ") .map(|x| x.trim().parse().expect("Unexpected Integer Pattern"))
random_line_split
player.rs
use diesel::prelude::*; use diesel::pg::PgConnection; use video::Video; use room::Room; use std::{thread, time}; use schema; use std::time::SystemTime; use std::collections::HashMap; use std::sync::Mutex; use establish_connection; lazy_static! { static ref PLAYLIST_THREADS: Mutex<HashMap<i64, VideoStatus>> = Mute...
pub fn stop_playing(room: &Room) { PLAYLIST_THREADS.lock().unwrap().remove(&room.id); } // Returns a duration string as seconds // EG: "PT1H10M10S" -> 4210 pub fn duration_to_seconds(duration: &str) -> u64 { let v: Vec<&str> = duration.split(|c: char|!c.is_numeric()).collect(); let mut index: u32 = 0; ...
{ let mut hashmap = PLAYLIST_THREADS.lock().unwrap(); if !hashmap.contains_key(&room.id) { hashmap.insert(room.id, VideoStatus::Play); play_video_thread(room); } }
identifier_body
player.rs
use diesel::prelude::*; use diesel::pg::PgConnection; use video::Video; use room::Room; use std::{thread, time}; use schema; use std::time::SystemTime; use std::collections::HashMap; use std::sync::Mutex; use establish_connection; lazy_static! { static ref PLAYLIST_THREADS: Mutex<HashMap<i64, VideoStatus>> = Mute...
{ Play, Skip, } /// Fetches the current video from the playlist and waits for the duration of the video /// Afterwards it updates the database and marks the video as played. pub fn play_current_video(conn: &PgConnection, room: &Room) -> bool { use self::schema::videos::dsl::*; let video = Video::belo...
VideoStatus
identifier_name
player.rs
use diesel::prelude::*; use diesel::pg::PgConnection; use video::Video; use room::Room; use std::{thread, time}; use schema; use std::time::SystemTime; use std::collections::HashMap; use std::sync::Mutex; use establish_connection;
enum VideoStatus { Play, Skip, } /// Fetches the current video from the playlist and waits for the duration of the video /// Afterwards it updates the database and marks the video as played. pub fn play_current_video(conn: &PgConnection, room: &Room) -> bool { use self::schema::videos::dsl::*; let vi...
lazy_static! { static ref PLAYLIST_THREADS: Mutex<HashMap<i64, VideoStatus>> = Mutex::new(HashMap::new()); }
random_line_split
player.rs
use diesel::prelude::*; use diesel::pg::PgConnection; use video::Video; use room::Room; use std::{thread, time}; use schema; use std::time::SystemTime; use std::collections::HashMap; use std::sync::Mutex; use establish_connection; lazy_static! { static ref PLAYLIST_THREADS: Mutex<HashMap<i64, VideoStatus>> = Mute...
None => { PLAYLIST_THREADS .lock() .unwrap() .insert(room.id, VideoStatus::Play); } } // Check if the video has ran out of time ...
{ playing = handle_video_event(status); }
conditional_block
issue_3979_traits.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self, dx: int) { let x = self.X() + dx; self.SetX(x); } }
translate
identifier_name
issue_3979_traits.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
{ let x = self.X() + dx; self.SetX(x); }
identifier_body
issue_3979_traits.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.SetX(x); } }
random_line_split
blob_records.rs
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
correlation_id, &src, response.is_success(), ) { // If a full adult responds with error. Drop the response if!response.is_success() && self.capacity.is_full(&src).await { // We've already responded already with a success ...
} let mut duties = vec![]; if let Some((_address, end_user)) = self.adult_liveness.record_adult_read_liveness(
random_line_split
blob_records.rs
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
(&mut self, node_id: PublicKey) { info!( "No. of full Adults: {:?}", self.capacity.full_adults_count().await ); info!("Increasing full Adults count"); self.capacity .insert_full_adults(btree_set!(XorName::from(node_id))) .await; } //...
increase_full_node_count
identifier_name
blob_records.rs
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
pub async fn record_adult_read_liveness( &mut self, correlation_id: MessageId, response: QueryResponse, src: XorName, ) -> Result<NodeDuties> { if!matches!(response, QueryResponse::GetBlob(_)) { return Err(Error::Logic(format!( "Got {:?}, but...
{ if let Err(error) = validate_data_owner(&data, &client_signed.public_key) { return self.send_error(error, msg_id, origin).await; } self.send_chunks_to_adults(data, msg_id, client_signed, origin) .await }
identifier_body
fmt.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. */ //! Handles nested padding in `Debug::fmt` output. //! //! `PadAdapter` is taken from rustc: //! https://github.com/rust-lang/rust/commit/e...
}; self.fmt.write_str(&s[..split])?; s = &s[split..]; } Ok(()) } } /// Write Debug output with alternative form considered. pub fn write_debug(formatter: &mut fmt::Formatter, value: impl fmt::Debug) -> fmt::Result { if formatter.alternate() { let mu...
{ self.on_newline = false; s.len() }
conditional_block
fmt.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. */ //! Handles nested padding in `Debug::fmt` output. //! //! `PadAdapter` is taken from rustc: //! https://github.com/rust-lang/rust/commit/e...
fn new(fmt: &'a mut fmt::Formatter<'b>) -> PadAdapter<'a, 'b> { PadAdapter { fmt, on_newline: false, } } } impl<'a, 'b: 'a> fmt::Write for PadAdapter<'a, 'b> { fn write_str(&mut self, mut s: &str) -> fmt::Result { while!s.is_empty() { if self.on_n...
random_line_split
fmt.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. */ //! Handles nested padding in `Debug::fmt` output. //! //! `PadAdapter` is taken from rustc: //! https://github.com/rust-lang/rust/commit/e...
Ok(()) } } /// Write Debug output with alternative form considered. pub fn write_debug(formatter: &mut fmt::Formatter, value: impl fmt::Debug) -> fmt::Result { if formatter.alternate() { let mut writer = PadAdapter::new(formatter); fmt::write(&mut writer, format_args!("\n{:#?}", value)...
{ while !s.is_empty() { if self.on_newline { self.fmt.write_str(" ")?; } let split = match s.find('\n') { Some(pos) => { self.on_newline = true; pos + 1 } None => { ...
identifier_body
fmt.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. */ //! Handles nested padding in `Debug::fmt` output. //! //! `PadAdapter` is taken from rustc: //! https://github.com/rust-lang/rust/commit/e...
<'a, 'b: 'a> { fmt: &'a mut fmt::Formatter<'b>, on_newline: bool, } impl<'a, 'b: 'a> PadAdapter<'a, 'b> { fn new(fmt: &'a mut fmt::Formatter<'b>) -> PadAdapter<'a, 'b> { PadAdapter { fmt, on_newline: false, } } } impl<'a, 'b: 'a> fmt::Write for PadAdapter<'a, 'b...
PadAdapter
identifier_name
deque.rs
} /// When stealing some data, this is an enumeration of the possible outcomes. #[deriving(Eq)] pub enum Stolen<T> { /// The deque was empty at the time of stealing Empty, /// The stealer lost the race for stealing data, and a retry may return more /// data. Abort, /// The stealer has successfu...
{ static AMT: int = 10000; static NTHREADS: int = 4; static mut DONE: AtomicBool = INIT_ATOMIC_BOOL; let mut pool = BufferPool::<(int, uint)>::new(); let (mut w, s) = pool.deque(); let (threads, hits) = vec::unzip(range(0, NTHREADS).map(|_| { let s = s.clone(...
identifier_body
deque.rs
// XXX: all atomic operations in this module use a SeqCst ordering. That is // probably overkill use cast; use clone::Clone; use iter::range; use kinds::Send; use libc; use mem; use ops::Drop; use option::{Option, Some, None}; use ptr; use unstable::atomics::{AtomicInt, AtomicPtr, SeqCst}; use unstable::sync::{U...
// NB: the "buffer pool" strategy is not done for speed, but rather for // correctness. For more info, see the comment on `swap_buffer`
random_line_split
deque.rs
is // probably overkill use cast; use clone::Clone; use iter::range; use kinds::Send; use libc; use mem; use ops::Drop; use option::{Option, Some, None}; use ptr; use unstable::atomics::{AtomicInt, AtomicPtr, SeqCst}; use unstable::sync::{UnsafeArc, Exclusive}; // Once the queue is less than 1/K full, then it w...
(&self, b: int, t: int, delta: int) -> Buffer<T> { let mut buf = Buffer::new(self.log_size + delta); for i in range(t, b) { buf.put(i, self.get(i)); } return buf; } } #[unsafe_destructor] impl<T: Send> Drop for Buffer<T> { fn drop(&mut self) { // It is assume...
resize
identifier_name
deque.rs
is // probably overkill use cast; use clone::Clone; use iter::range; use kinds::Send; use libc; use mem; use ops::Drop; use option::{Option, Some, None}; use ptr; use unstable::atomics::{AtomicInt, AtomicPtr, SeqCst}; use unstable::sync::{UnsafeArc, Exclusive}; // Once the queue is less than 1/K full, then it w...
else { cast::forget(data); // someone else stole this value Abort } } unsafe fn maybe_shrink(&mut self, b: int, t: int) { let a = self.array.load(SeqCst); if b - t < (*a).size() / K && b - t > (1 << MIN_BITS) { self.swap_buffer(b, a, (*a).resize(b, t...
{ Data(data) }
conditional_block
show_off.rs
use data_type::data_type::Data; pub struct ShowOff; impl ShowOff { pub fn
(host: &str, data: Data) -> String { "".to_string() // html!{ // link rel="stylesheet" type="text/css" // href={"http://" (host) "/style/style.css"} / // // div.gallery { // @for image in &data.data { // a.super-item href=...
get_page
identifier_name
show_off.rs
use data_type::data_type::Data; pub struct ShowOff; impl ShowOff { pub fn get_page(host: &str, data: Data) -> String
// } // } // } // (PreEscaped("<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js\"></script>")) // (PreEscaped("<script src=\"http://".to_string() + host+"/js/jquery.lazyload.min.js\"></script>")) // ...
{ "".to_string() // html!{ // link rel="stylesheet" type="text/css" // href={"http://" (host) "/style/style.css"} / // // div.gallery { // @for image in &data.data { // a.super-item href={"http://" (host) "/" (&image.id)} ...
identifier_body
show_off.rs
use data_type::data_type::Data; pub struct ShowOff; impl ShowOff { pub fn get_page(host: &str, data: Data) -> String { "".to_string() // html!{
// href={"http://" (host) "/style/style.css"} / // // div.gallery { // @for image in &data.data { // a.super-item href={"http://" (host) "/" (&image.id)} id={(&image.id)}{ // img.item.lazy data-original={"http://" (host) ...
// link rel="stylesheet" type="text/css"
random_line_split
empty.rs
use consumer::*; use parallel_stream::*; use stream::*; /// A [`Stream`](./trait.Stream.html) that do not emits any element. /// /// # Examples /// /// ``` /// use asyncplify::*; /// /// let mut count = 0; /// /// Empty /// .inspect(|_| count += 1) /// .subscribe(); /// /// assert!(count == 0, "count = {}", coun...
/// A [`ParallelStream`](./trait.ParallelStream.html) that do not emits any element. /// /// # Examples /// /// ``` /// use asyncplify::*; /// use std::sync::atomic::{AtomicBool, Ordering}; /// use std::sync::Arc; /// /// let found = Arc::new(AtomicBool::new(false)); /// /// ParallelEmpty /// .inspect(|_| found.sto...
}
random_line_split
empty.rs
use consumer::*; use parallel_stream::*; use stream::*; /// A [`Stream`](./trait.Stream.html) that do not emits any element. /// /// # Examples /// /// ``` /// use asyncplify::*; /// /// let mut count = 0; /// /// Empty /// .inspect(|_| count += 1) /// .subscribe(); /// /// assert!(count == 0, "count = {}", coun...
; impl ParallelStream for ParallelEmpty { type Item = (); fn consume<C: ParallelConsumer<()>>(self, _: C) {} }
ParallelEmpty
identifier_name
empty.rs
use consumer::*; use parallel_stream::*; use stream::*; /// A [`Stream`](./trait.Stream.html) that do not emits any element. /// /// # Examples /// /// ``` /// use asyncplify::*; /// /// let mut count = 0; /// /// Empty /// .inspect(|_| count += 1) /// .subscribe(); /// /// assert!(count == 0, "count = {}", coun...
}
{}
identifier_body
reexported_static_methods.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
impl Bort { pub fn bort() -> String { "bort()".to_string() } } }
random_line_split
reexported_static_methods.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 ...
{ unused_str: String } impl Boz { pub fn boz(i: int) -> bool { i > 0 } } pub enum Bort { Bort1, Bort2 } impl Bort { pub fn bort() -> String { "bort()".to_string() } } }
Boz
identifier_name
reexported_static_methods.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 ...
} pub mod sub_foo { pub trait Foo { fn foo() -> Self; } impl Foo for int { fn foo() -> int { 42 } } pub struct Boz { unused_str: String } impl Boz { pub fn boz(i: int) -> bool { i > 0 } } pub enum Bort { Bort1, ...
{ 84 }
identifier_body
example2.rs
#[feature(link_args)]; extern crate cairo; #[link_args = "-L /Users/Jens/.homebrew/lib"] extern {} fn
() { use cairo; use cairo::surface; use cairo::surface::Surface; let (width, height) = (500.0, 500.0); let mut s = Surface::create_image(surface::format::ARGB32, width as i32, height as i32); let mut cairo = cairo::Cairo::create(&mut s); cairo.save(); cairo.set_source_rgb(0.3, 0.3, 1.0); cairo.pain...
main
identifier_name
example2.rs
#[feature(link_args)]; extern crate cairo; #[link_args = "-L /Users/Jens/.homebrew/lib"] extern {} fn main()
cairo.close_path(); cairo.save(); cairo.set_line_width(6.0); cairo.stroke_preserve(); cairo.set_source_rgb(0.3, 0.3, 0.3); cairo.fill(); cairo.restore(); cairo.save(); cairo.set_line_width(6.0); cairo.arc(1.0 * width / 6.0, 3.0 * height / 6.0, 0.5 * width / 6.0, 0.0 * height / 6.0, 2.0 * std::f64::...
{ use cairo; use cairo::surface; use cairo::surface::Surface; let (width, height) = (500.0, 500.0); let mut s = Surface::create_image(surface::format::ARGB32, width as i32, height as i32); let mut cairo = cairo::Cairo::create(&mut s); cairo.save(); cairo.set_source_rgb(0.3, 0.3, 1.0); cairo.paint()...
identifier_body
example2.rs
#[feature(link_args)]; extern crate cairo; #[link_args = "-L /Users/Jens/.homebrew/lib"] extern {} fn main() { use cairo; use cairo::surface; use cairo::surface::Surface; let (width, height) = (500.0, 500.0);
let mut cairo = cairo::Cairo::create(&mut s); cairo.save(); cairo.set_source_rgb(0.3, 0.3, 1.0); cairo.paint(); cairo.restore(); cairo.move_to(0.0, 0.0); cairo.line_to(2.0 * width / 6.0, 2.0 * height / 6.0); cairo.line_to(3.0 * width / 6.0, 1.0 * height / 6.0); cairo.line_to(4.0 * width / 6.0, 2.0 ...
let mut s = Surface::create_image(surface::format::ARGB32, width as i32, height as i32);
random_line_split
util.rs
use std::io::{Cursor, Read}; use std::io; use psoserial::Serial; use psomsg::util::*; static COLOR_RED: &'static str = "\x1B[31m"; static COLOR_RESET: &'static str = "\x1B[0m"; /// Creates a 3-column view of the buffer with index, bytes, and ASCII /// representation. pub fn hex_view(buf: &[u8]) -> String { let r...
/// Shows the serialized hex view of the first argument, with different bytes /// in ANSI escaped red. pub fn hex_view_diff<S: Serial>(s: &S, buf: &[u8]) -> String { let mut cursor = Cursor::new(Vec::new()); s.serialize(&mut cursor).unwrap(); let array = cursor.into_inner(); let rows = array.len() / ...
{ let mut cursor = Cursor::new(Vec::new()); s.serialize(&mut cursor).unwrap(); let array = cursor.into_inner(); hex_view(&array) }
identifier_body
util.rs
use std::io::{Cursor, Read}; use std::io; use psoserial::Serial; use psomsg::util::*; static COLOR_RED: &'static str = "\x1B[31m"; static COLOR_RESET: &'static str = "\x1B[0m"; /// Creates a 3-column view of the buffer with index, bytes, and ASCII /// representation. pub fn hex_view(buf: &[u8]) -> String { let r...
else { leftover = row * 16 + 16 - array.len(); array.len() } }; for i in (row * 16)..end { if (buf.len() > i && buf[i]!= array[i]) || buf.len() <= i { output.push_str(&format!("{}{:02X}{} ", COLOR_RED, array[i], COLOR_RESET)); ...
{ leftover = 0; row * 16 + 16 }
conditional_block
util.rs
use std::io::{Cursor, Read}; use std::io; use psoserial::Serial; use psomsg::util::*; static COLOR_RED: &'static str = "\x1B[31m"; static COLOR_RESET: &'static str = "\x1B[0m"; /// Creates a 3-column view of the buffer with index, bytes, and ASCII /// representation. pub fn hex_view(buf: &[u8]) -> String { let r...
<S: Serial>(s: &S, buf: &[u8]) -> String { let mut cursor = Cursor::new(Vec::new()); s.serialize(&mut cursor).unwrap(); let array = cursor.into_inner(); let rows = array.len() / 16 + { if array.len() % 16 > 0 {1} else {0} }; let mut output = String::new(); for row in 0..rows { // First ...
hex_view_diff
identifier_name
util.rs
use std::io::{Cursor, Read}; use std::io; use psoserial::Serial; use psomsg::util::*; static COLOR_RED: &'static str = "\x1B[31m"; static COLOR_RESET: &'static str = "\x1B[0m"; /// Creates a 3-column view of the buffer with index, bytes, and ASCII /// representation. pub fn hex_view(buf: &[u8]) -> String { let r...
hex_view(&array) } /// Shows the serialized hex view of the first argument, with different bytes /// in ANSI escaped red. pub fn hex_view_diff<S: Serial>(s: &S, buf: &[u8]) -> String { let mut cursor = Cursor::new(Vec::new()); s.serialize(&mut cursor).unwrap(); let array = cursor.into_inner(); let...
let mut cursor = Cursor::new(Vec::new()); s.serialize(&mut cursor).unwrap(); let array = cursor.into_inner();
random_line_split
last-use-in-block.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T { fn g<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T {f(s)} g(s, |v| { let r = f(v); r }) } pub fn main() {}
apply
identifier_name