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
issue-2735-3.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 ...
} #[unsafe_destructor] impl<'a> Drop for defer<'a> { fn drop(&mut self) { self.b.set(true); } } fn defer(b: &Cell<bool>) -> defer { defer { b: b } } pub fn main() { let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); }
b: &'a Cell<bool>,
random_line_split
issue-2735-3.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 ...
<'a> { b: &'a Cell<bool>, } #[unsafe_destructor] impl<'a> Drop for defer<'a> { fn drop(&mut self) { self.b.set(true); } } fn defer(b: &Cell<bool>) -> defer { defer { b: b } } pub fn main() { let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); }
defer
identifier_name
issue-2735-3.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 fn main() { let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); }
{ defer { b: b } }
identifier_body
shadowed-argument.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 ...
(x: bool, y: bool) { zzz(); sentinel(); let x = 10; zzz(); sentinel(); let x = 10.5; let y = 20; zzz(); sentinel(); } fn main() { a_function(false, true); } fn zzz() {()} fn sentinel() {()}
a_function
identifier_name
shadowed-argument.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 a_function(x: bool, y: bool) { zzz(); sentinel(); let x = 10; zzz(); sentinel(); let x = 10.5; let y = 20; zzz(); sentinel(); } fn main() { a_function(false, true); } fn zzz() {()} fn sentinel() {()}
// debugger:print y // check:$6 = 20 // debugger:continue
random_line_split
shadowed-argument.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 sentinel() {()}
{()}
identifier_body
xcrate.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 ...
use f as f2; mod bar { pub fn g() {} use baz::h; pub macro test() { use std::mem; use foo::cell; ::f(); ::f2(); g(); h(); ::bar::h(); } } mod baz { pub fn h() {} }
{}
identifier_body
xcrate.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 ...
extern crate std as foo; pub fn f() {} use f as f2; mod bar { pub fn g() {} use baz::h; pub macro test() { use std::mem; use foo::cell; ::f(); ::f2(); g(); h(); ::bar::h(); } } mod baz { pub fn h() {} }
pub use bar::test;
random_line_split
xcrate.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 ...
() {} use baz::h; pub macro test() { use std::mem; use foo::cell; ::f(); ::f2(); g(); h(); ::bar::h(); } } mod baz { pub fn h() {} }
g
identifier_name
family.rs
//! Queue family and groups. use crate::{queue::QueueType, Backend}; use std::{any::Any, fmt::Debug}; /// General information about a queue family, available upon adapter discovery. /// /// Note that a backend can expose multiple queue families with the same properties. /// /// Can be obtained from an [adapter][crat...
/// Add a command queue to the group. /// /// The queue needs to be created from this queue family. pub fn add_queue(&mut self, queue: B::Queue) { self.queues.push(queue); } }
{ QueueGroup { family, queues: Vec::new(), } }
identifier_body
family.rs
//! Queue family and groups. use crate::{queue::QueueType, Backend}; use std::{any::Any, fmt::Debug}; /// General information about a queue family, available upon adapter discovery. /// /// Note that a backend can expose multiple queue families with the same properties. /// /// Can be obtained from an [adapter][crat...
(&mut self, queue: B::Queue) { self.queues.push(queue); } }
add_queue
identifier_name
family.rs
//! Queue family and groups. use crate::{queue::QueueType, Backend}; use std::{any::Any, fmt::Debug}; /// General information about a queue family, available upon adapter discovery. /// /// Note that a backend can expose multiple queue families with the same properties. /// /// Can be obtained from an [adapter][crat...
/// Identifier for a queue family of a physical device. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct QueueFamilyId(pub usize); /// Bare-metal queue group. /// /// Denotes all queues created from one queue family. #[derive(Debug)] pub struc...
random_line_split
all_examples3.rs
#![allow(dead_code)] extern crate nalgebra as na; extern crate ncollide3d; extern crate nphysics3d; extern crate nphysics_testbed3d; macro_rules! r( ($e: expr) => { nalgebra::convert::<f64, N>($e) } ); use inflector::Inflector; use nphysics_testbed3d::Testbed; mod balls3; mod boxes3; mod broad_phas...
#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))] fn demo_name_from_url() -> Option<String> { None } fn main() { type Real = f32; // simba::scalar::FixedI40F24; let demo = demo_name_from_command_line() .or_else(|| demo_name_from_url()) .unwrap_or(String::new()) .to_cam...
{ let window = stdweb::web::window(); let hash = window.location()?.search().ok()?; if !hash.is_empty() { Some(hash[1..].to_string()) } else { None } }
identifier_body
all_examples3.rs
#![allow(dead_code)] extern crate nalgebra as na; extern crate ncollide3d; extern crate nphysics3d; extern crate nphysics_testbed3d; macro_rules! r( ($e: expr) => { nalgebra::convert::<f64, N>($e) } ); use inflector::Inflector; use nphysics_testbed3d::Testbed; mod balls3; mod boxes3; mod broad_phas...
fn demo_name_from_url() -> Option<String> { None } fn main() { type Real = f32; // simba::scalar::FixedI40F24; let demo = demo_name_from_command_line() .or_else(|| demo_name_from_url()) .unwrap_or(String::new()) .to_camel_case(); let mut builders: Vec<(_, fn(&mut Testbed<Real>))>...
None } } #[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
random_line_split
all_examples3.rs
#![allow(dead_code)] extern crate nalgebra as na; extern crate ncollide3d; extern crate nphysics3d; extern crate nphysics_testbed3d; macro_rules! r( ($e: expr) => { nalgebra::convert::<f64, N>($e) } ); use inflector::Inflector; use nphysics_testbed3d::Testbed; mod balls3; mod boxes3; mod broad_phas...
} None } #[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))] fn demo_name_from_url() -> Option<String> { let window = stdweb::web::window(); let hash = window.location()?.search().ok()?; if!hash.is_empty() { Some(hash[1..].to_string()) } else { None } } #[cfg(not(a...
{ return args.next(); }
conditional_block
all_examples3.rs
#![allow(dead_code)] extern crate nalgebra as na; extern crate ncollide3d; extern crate nphysics3d; extern crate nphysics_testbed3d; macro_rules! r( ($e: expr) => { nalgebra::convert::<f64, N>($e) } ); use inflector::Inflector; use nphysics_testbed3d::Testbed; mod balls3; mod boxes3; mod broad_phas...
() -> Option<String> { let mut args = std::env::args(); while let Some(arg) = args.next() { if &arg[..] == "--example" { return args.next(); } } None } #[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))] fn demo_name_from_url() -> Option<String> { let window = s...
demo_name_from_command_line
identifier_name
nameable.rs
use crate::view::View; use crate::views::NamedView; /// Makes a view wrappable in an [`NamedView`]. /// /// [`NamedView`]:../views/struct.NamedView.html pub trait Nameable: View + Sized { /// Wraps this view into an `NamedView` with the given id. /// /// This is just a shortcut for `NamedView::new(id, self...
/// Same as [`with_name`](Nameable::with_name) #[deprecated(note = "`with_id` is being renamed to `with_name`")] fn with_id<S: Into<String>>(self, id: S) -> NamedView<Self> { self.with_name(id) } } /// Any `View` implements this trait. impl<T: View> Nameable for T {}
{ NamedView::new(name, self) }
identifier_body
nameable.rs
use crate::view::View; use crate::views::NamedView; /// Makes a view wrappable in an [`NamedView`]. /// /// [`NamedView`]:../views/struct.NamedView.html pub trait Nameable: View + Sized { /// Wraps this view into an `NamedView` with the given id. /// /// This is just a shortcut for `NamedView::new(id, self...
self.with_name(id) } } /// Any `View` implements this trait. impl<T: View> Nameable for T {}
/// Same as [`with_name`](Nameable::with_name) #[deprecated(note = "`with_id` is being renamed to `with_name`")] fn with_id<S: Into<String>>(self, id: S) -> NamedView<Self> {
random_line_split
nameable.rs
use crate::view::View; use crate::views::NamedView; /// Makes a view wrappable in an [`NamedView`]. /// /// [`NamedView`]:../views/struct.NamedView.html pub trait Nameable: View + Sized { /// Wraps this view into an `NamedView` with the given id. /// /// This is just a shortcut for `NamedView::new(id, self...
<S: Into<String>>(self, id: S) -> NamedView<Self> { self.with_name(id) } } /// Any `View` implements this trait. impl<T: View> Nameable for T {}
with_id
identifier_name
from_bytes.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::cmp; use encoding::label::encoding_from_whatwg_label; use encoding::all::UTF_8; use encoding::{EncodingR...
(css: &[u8], protocol_encoding_label: Option<&str>, environment_encoding: Option<EncodingRef>) -> (String, EncodingRef) { // https://drafts.csswg.org/css-syntax/#the-input-byte-stream match protocol_encoding_label { None => (), Some(labe...
decode_stylesheet_bytes
identifier_name
from_bytes.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::cmp; use encoding::label::encoding_from_whatwg_label; use encoding::all::UTF_8; use encoding::{EncodingR...
Some(fallback) => return decode_replace(css, fallback) } return decode_replace(css, UTF_8 as EncodingRef) } #[inline] fn decode_replace(input: &[u8], fallback_encoding: EncodingRef)-> (String, EncodingRef) { let (result, used_encoding) = decode(input, DecoderTrap::Replace, fallback_encoding); ...
match environment_encoding { None => (),
random_line_split
from_bytes.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::cmp; use encoding::label::encoding_from_whatwg_label; use encoding::all::UTF_8; use encoding::{EncodingR...
Some(fallback) => match fallback.name() { "utf-16be" | "utf-16le" => return decode_replace(css, UTF_8 as EncodingRef), _ => return decode_replace(css, fallback), } } } } ...
{ // https://drafts.csswg.org/css-syntax/#the-input-byte-stream match protocol_encoding_label { None => (), Some(label) => match encoding_from_whatwg_label(label) { None => (), Some(fallback) => return decode_replace(css, fallback) } } if css.starts_with("...
identifier_body
edges.rs
//! Edges representation in GIR. use prelude::{EdgeWeight, Idx}; /// Single edge representation. /// /// `Idx` indicates unique id of the endpoint node of the edge, assigned based on the /// GIR creation order. /// Last byte denotes last character in the kmer. pub type Edge = (Idx, EdgeWeight, u8); /// Stores informa...
} } impl Default for Edges { fn default() -> Edges { Edges { outgoing: Box::new([]), idx: 0, } } } #[cfg(test)] mod tests { use super::*; #[test] fn adds_edge() { let mut e: Edges = Edges::empty(0); assert_eq!(e.idx, 0); assert_e...
random_line_split
edges.rs
//! Edges representation in GIR. use prelude::{EdgeWeight, Idx}; /// Single edge representation. /// /// `Idx` indicates unique id of the endpoint node of the edge, assigned based on the /// GIR creation order. /// Last byte denotes last character in the kmer. pub type Edge = (Idx, EdgeWeight, u8); /// Stores informa...
/// Adds edge with the given endpoint. pub fn add_edge(&mut self, to: Idx, last_char: u8) { let mut out_ = Vec::new(); out_.extend_from_slice(&self.outgoing); out_.push((to, 1, last_char)); self.outgoing = out_.into_boxed_slice(); } /// Removes edges with weight below ...
{ Edges { outgoing: Box::new([]), idx: idx_, } }
identifier_body
edges.rs
//! Edges representation in GIR. use prelude::{EdgeWeight, Idx}; /// Single edge representation. /// /// `Idx` indicates unique id of the endpoint node of the edge, assigned based on the /// GIR creation order. /// Last byte denotes last character in the kmer. pub type Edge = (Idx, EdgeWeight, u8); /// Stores informa...
() { let mut e: Edges = Edges::empty(0); assert_eq!(e.idx, 0); assert_eq!(e.outgoing.len(), 0); e.add_edge(0, b'a'); assert_eq!(e.outgoing.len(), 1); } #[test] fn removes_weak_edges() { let mut e: Edges = Edges::empty(1); assert_eq!(e.idx, 1); ...
adds_edge
identifier_name
lib.rs
//! Lints, aka compiler warnings. //! //! A 'lint' check is a kind of miscellaneous constraint that a user _might_ //! want to enforce, but might reasonably want to permit as well, on a //! module-by-module basis. They contrast with static constraints enforced by //! other phases of the compiler, which are generally re...
(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { late::late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new()); } macro_rules! pre_expansion_lint_passes { ($macro:path, $args:tt) => { $macro!($args, [KeywordIdents: KeywordIdents,]); }; } macro_rules! early_lint_passes { ($mac...
lint_mod
identifier_name
lib.rs
//! Lints, aka compiler warnings. //! //! A 'lint' check is a kind of miscellaneous constraint that a user _might_ //! want to enforce, but might reasonably want to permit as well, on a //! module-by-module basis. They contrast with static constraints enforced by //! other phases of the compiler, which are generally re...
} if no_interleave_lints { pre_expansion_lint_passes!(register_passes, register_pre_expansion_pass); early_lint_passes!(register_passes, register_early_pass); late_lint_passes!(register_passes, register_late_pass); late_lint_mod_passes!(register_passes, register_late_mod_pass); ...
{ macro_rules! add_lint_group { ($name:expr, $($lint:ident),*) => ( store.register_group(false, $name, None, vec![$(LintId::of($lint)),*]); ) } macro_rules! register_pass { ($method:ident, $ty:ident, $constructor:expr) => { store.register_lints(&$ty::get_lint...
identifier_body
lib.rs
//! Lints, aka compiler warnings. //! //! A 'lint' check is a kind of miscellaneous constraint that a user _might_ //! want to enforce, but might reasonably want to permit as well, on a //! module-by-module basis. They contrast with static constraints enforced by //! other phases of the compiler, which are generally re...
lint_store } /// Tell the `LintStore` about all the built-in lints (the ones /// defined in this crate and the ones defined in /// `rustc_session::lint::builtin`). fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { macro_rules! add_lint_group { ($name:expr, $($lint:ident),*) => ...
{ register_internals(&mut lint_store); }
conditional_block
lib.rs
//! Lints, aka compiler warnings. //! //! A 'lint' check is a kind of miscellaneous constraint that a user _might_ //! want to enforce, but might reasonably want to permit as well, on a //! module-by-module basis. They contrast with static constraints enforced by //! other phases of the compiler, which are generally re...
store.register_renamed("bare_trait_object", "bare_trait_objects"); store.register_renamed("unstable_name_collision", "unstable_name_collisions"); store.register_renamed("unused_doc_comment", "unused_doc_comments"); store.register_renamed("async_idents", "keyword_idents"); store.register_renamed("exc...
// Register renamed and removed lints. store.register_renamed("single_use_lifetime", "single_use_lifetimes"); store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
random_line_split
rm.rs
#![crate_name = "rm"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ #![feature(macro_rules)] extern crate getopts; extern crate libc;...
(msg: &str) -> bool { print(msg); read_prompt() } fn read_prompt() -> bool { stdio::flush(); match BufferedReader::new(stdin()).read_line() { Ok(line) => { match line.as_slice().char_at(0) { 'y' | 'Y' => true, 'n' | 'N' => false, _ => ...
prompt
identifier_name
rm.rs
#![crate_name = "rm"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ #![feature(macro_rules)] extern crate getopts; extern crate libc;...
}
random_line_split
describe-endpoint.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iot::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. ...
println!(); } let shared_config = aws_config::from_env().region(region_provider).load().await; let client = Client::new(&shared_config); show_address(&client, &endpoint_type).await }
{ tracing_subscriber::fmt::init(); let Opt { region, endpoint_type, verbose, } = Opt::from_args(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() .or_else(Region::new("us-west-2")); println!(); if ver...
identifier_body
describe-endpoint.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iot::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. ...
let shared_config = aws_config::from_env().region(region_provider).load().await; let client = Client::new(&shared_config); show_address(&client, &endpoint_type).await }
{ println!("IoT client version: {}", PKG_VERSION); println!( "Region: {}", region_provider.region().await.unwrap().as_ref() ); println!("Endpoint type: {}", &endpoint_type); println!(); }
conditional_block
describe-endpoint.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iot::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. ...
// - iot:Jobs - Returns an AWS IoT device management Jobs API endpoint. /// * `[-r REGION]` - The Region in which the client is created. /// If not supplied, uses the value of the **AWS_REGION** environment variable. /// If the environment variable is not set, defaults to **us-west-2**. /// * `[-v]` - Whether to...
/// * `-e ENDPOINT-TYPE - The type of endpoint. /// Must be one of: /// - iot:Data - Returns a VeriSign signed data endpoint. /// - iot:Data-ATS - Returns an ATS signed data endpoint. /// - iot:CredentialProvider - Returns an AWS IoT credentials provider API endpoint.
random_line_split
describe-endpoint.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iot::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. ...
() -> Result<(), Error> { tracing_subscriber::fmt::init(); let Opt { region, endpoint_type, verbose, } = Opt::from_args(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() .or_else(Region::new("us-west-2")); p...
main
identifier_name
multiwindow.rs
mod support; use glutin::event::{Event, WindowEvent}; use glutin::event_loop::{ControlFlow, EventLoop}; use glutin::window::WindowBuilder; use glutin::ContextBuilder; use support::{ContextCurrentWrapper, ContextTracker, ContextWrapper}; fn main()
match event { Event::LoopDestroyed => return, Event::WindowEvent { event, window_id } => match event { WindowEvent::Resized(physical_size) => { let windowed_context = ct.get_current(windows[&window_id].0).unwrap(); let windowed_cont...
{ let el = EventLoop::new(); let mut ct = ContextTracker::default(); let mut windows = std::collections::HashMap::new(); for index in 0..3 { let title = format!("Charming Window #{}", index + 1); let wb = WindowBuilder::new().with_title(title); let windowed_context = ContextBuil...
identifier_body
multiwindow.rs
mod support; use glutin::event::{Event, WindowEvent}; use glutin::event_loop::{ControlFlow, EventLoop}; use glutin::window::WindowBuilder; use glutin::ContextBuilder; use support::{ContextCurrentWrapper, ContextTracker, ContextWrapper}; fn main() { let el = EventLoop::new(); let mut ct = ContextTracker::defau...
windows.insert(window_id, (context_id, gl, index)); } el.run(move |event, _, control_flow| { println!("{:?}", event); match event { Event::LoopDestroyed => return, Event::WindowEvent { event, window_id } => match event { WindowEvent::Resized(physi...
let context_id = ct.insert(ContextCurrentWrapper::PossiblyCurrent( ContextWrapper::Windowed(windowed_context), ));
random_line_split
multiwindow.rs
mod support; use glutin::event::{Event, WindowEvent}; use glutin::event_loop::{ControlFlow, EventLoop}; use glutin::window::WindowBuilder; use glutin::ContextBuilder; use support::{ContextCurrentWrapper, ContextTracker, ContextWrapper}; fn
() { let el = EventLoop::new(); let mut ct = ContextTracker::default(); let mut windows = std::collections::HashMap::new(); for index in 0..3 { let title = format!("Charming Window #{}", index + 1); let wb = WindowBuilder::new().with_title(title); let windowed_context = ContextB...
main
identifier_name
multiwindow.rs
mod support; use glutin::event::{Event, WindowEvent}; use glutin::event_loop::{ControlFlow, EventLoop}; use glutin::window::WindowBuilder; use glutin::ContextBuilder; use support::{ContextCurrentWrapper, ContextTracker, ContextWrapper}; fn main() { let el = EventLoop::new(); let mut ct = ContextTracker::defau...
else { *control_flow = ControlFlow::Wait } }); }
{ *control_flow = ControlFlow::Exit }
conditional_block
member.rs
use clap::ArgMatches; use rand::{thread_rng, Rng}; use std::fmt; pub fn build(matches: &ArgMatches) -> Vec<NewMember>
fn extract_names<'a>(matches: &'a ArgMatches) -> Vec<&'a str> { matches .value_of("members") .expect("members") .split(",") .collect() } #[derive(Debug, Serialize)] pub struct NewMember { name: String, position: i32, } impl NewMember { pub fn new(name: &str, position: i32...
{ let mut names = extract_names(matches); let mut rng = thread_rng(); rng.shuffle(&mut names); names .into_iter() .enumerate() .map(|(index, name)| { let position = index as i32 + 1; NewMember::new(name, position) }) .collect() }
identifier_body
member.rs
use clap::ArgMatches; use rand::{thread_rng, Rng}; use std::fmt; pub fn build(matches: &ArgMatches) -> Vec<NewMember> { let mut names = extract_names(matches); let mut rng = thread_rng(); rng.shuffle(&mut names); names .into_iter() .enumerate() .map(|(index, name)| { ...
(name: &str, position: i32) -> NewMember { NewMember { name: name.into(), position: position, } } } #[derive(Clone, Debug, Deserialize, PartialEq)] pub struct Member { pub id: i32, pub name: String, pub position: i32, pub active: bool, pub driver: bool, }...
new
identifier_name
member.rs
use clap::ArgMatches; use rand::{thread_rng, Rng}; use std::fmt; pub fn build(matches: &ArgMatches) -> Vec<NewMember> { let mut names = extract_names(matches); let mut rng = thread_rng(); rng.shuffle(&mut names); names .into_iter() .enumerate() .map(|(index, name)| { ...
.value_of("members") .expect("members") .split(",") .collect() } #[derive(Debug, Serialize)] pub struct NewMember { name: String, position: i32, } impl NewMember { pub fn new(name: &str, position: i32) -> NewMember { NewMember { name: name.into(), ...
matches
random_line_split
scan-negative-lookahead.rs
#![feature(phase)] #[phase(plugin)] extern crate scan; extern crate scan_util; const TEST_PAIRS: &'static [(&'static str, Result<&'static str, ()>)] = &[ ("words 'a b c'", Ok("[a, b, c]")), ("words 'a b c", Err(())), // for sinistersnare: ("def add x y: x y + end", Ok("def add [x, y]: [x, y, +] end")), ]; #[test...
(s: &str) -> Result<String, scan_util::ScanError> { scan! { s, "words '" [(?!"'") ws:&str]* "'" => format!("{}", ws), #[tokenizer="IdentsAndInts"] "def" name:&str [(?!":") args:&str]* ":" [(?!"end") body_toks:&str]* "end" => { format!("def {} {}: {} end", name, args, body_toks) }, } }
do_scan
identifier_name
scan-negative-lookahead.rs
#![feature(phase)] #[phase(plugin)] extern crate scan; extern crate scan_util; const TEST_PAIRS: &'static [(&'static str, Result<&'static str, ()>)] = &[ ("words 'a b c'", Ok("[a, b, c]")), ("words 'a b c", Err(())), // for sinistersnare: ("def add x y: x y + end", Ok("def add [x, y]: [x, y, +] end")), ]; #[test...
fn do_scan(s: &str) -> Result<String, scan_util::ScanError> { scan! { s, "words '" [(?!"'") ws:&str]* "'" => format!("{}", ws), #[tokenizer="IdentsAndInts"] "def" name:&str [(?!":") args:&str]* ":" [(?!"end") body_toks:&str]* "end" => { format!("def {} {}: {} end", name, args, body_toks) }, } }
{ for &(inp, exp) in TEST_PAIRS.iter() { let got = do_scan(inp); match exp { Ok(exp_str) => assert_eq!(got, Ok(exp_str.into_string())), Err(()) => assert!(got.is_err()), } } }
identifier_body
scan-negative-lookahead.rs
#![feature(phase)] #[phase(plugin)] extern crate scan; extern crate scan_util; const TEST_PAIRS: &'static [(&'static str, Result<&'static str, ()>)] = &[ ("words 'a b c'", Ok("[a, b, c]")), ("words 'a b c", Err(())), // for sinistersnare: ("def add x y: x y + end", Ok("def add [x, y]: [x, y, +] end")), ]; #[test...
Ok(exp_str) => assert_eq!(got, Ok(exp_str.into_string())), Err(()) => assert!(got.is_err()), } } } fn do_scan(s: &str) -> Result<String, scan_util::ScanError> { scan! { s, "words '" [(?!"'") ws:&str]* "'" => format!("{}", ws), #[tokenizer="IdentsAndInts"] "def" name:&str [(?!":") args:&str]* ":" [(?...
fn test_scan() { for &(inp, exp) in TEST_PAIRS.iter() { let got = do_scan(inp); match exp {
random_line_split
release.rs
use { Button, Event, Input }; /// The release of a button pub trait ReleaseEvent: Sized { /// Creates a release event. fn from_button(button: Button, old_event: &Self) -> Option<Self>; /// Calls closure if this is a release event. fn release<U, F>(&self, f: F) -> Option<U> where F: FnMut(Button...
} impl<I: ReleaseEvent> ReleaseEvent for Event<I> { fn from_button(button: Button, old_event: &Self) -> Option<Self> { if let &Event::Input(ref old_input) = old_event { <I as ReleaseEvent>::from_button(button, old_input) .map(|x| Event::Input(x)) } else { Non...
{ match *self { Input::Release(button) => Some(f(button)), _ => None } }
identifier_body
release.rs
use { Button, Event, Input }; /// The release of a button pub trait ReleaseEvent: Sized { /// Creates a release event. fn from_button(button: Button, old_event: &Self) -> Option<Self>; /// Calls closure if this is a release event. fn release<U, F>(&self, f: F) -> Option<U> where F: FnMut(Button...
(button: Button, _old_event: &Self) -> Option<Self> { Some(Input::Release(button)) } fn release<U, F>(&self, mut f: F) -> Option<U> where F: FnMut(Button) -> U { match *self { Input::Release(button) => Some(f(button)), _ => None } } } impl<I: Rel...
from_button
identifier_name
release.rs
use { Button, Event, Input }; /// The release of a button pub trait ReleaseEvent: Sized { /// Creates a release event. fn from_button(button: Button, old_event: &Self) -> Option<Self>; /// Calls closure if this is a release event. fn release<U, F>(&self, f: F) -> Option<U> where F: FnMut(Button...
fn release<U, F>(&self, mut f: F) -> Option<U> where F: FnMut(Button) -> U { match *self { Input::Release(button) => Some(f(button)), _ => None } } } impl<I: ReleaseEvent> ReleaseEvent for Event<I> { fn from_button(button: Button, old_event: &Self) -> Op...
random_line_split
argument-passing.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// option. This file may not be copied, modified, or distributed // except according to those terms. // pretty-expanded FIXME #23616 struct X { x: isize } fn f1(a: &mut X, b: &mut isize, c: isize) -> isize { let r = a.x + *b + c; a.x = 0; *b = 10; return r; } fn f2<F>(a: isize, f: F) -> isize w...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
argument-passing.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ let mut a = X {x: 1}; let mut b = 2; let c = 3; assert_eq!(f1(&mut a, &mut b, c), 6); assert_eq!(a.x, 0); assert_eq!(b, 10); assert_eq!(f2(a.x, |_| a.x = 50), 0); assert_eq!(a.x, 50); }
identifier_body
argument-passing.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(a: &mut X, b: &mut isize, c: isize) -> isize { let r = a.x + *b + c; a.x = 0; *b = 10; return r; } fn f2<F>(a: isize, f: F) -> isize where F: FnOnce(isize) { f(1); return a; } pub fn main() { let mut a = X {x: 1}; let mut b = 2; let c = 3; assert_eq!(f1(&mut a, &mut b, c), 6); ass...
f1
identifier_name
lib.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). #![deny(unused_must_use)] mod conversions; pub use conversions::require_digest; #[cfg(test)] mod conversions_tests; pub mod gen { // NOTE: Prost automatically relies on the existenc...
} } } pub mod semver { tonic::include_proto!("build.bazel.semver"); } } } pub mod buildbarn { pub mod cas { tonic::include_proto!("buildbarn.cas"); } } pub mod pants { pub mod cache { tonic::include_proto!("pants.cache"); } } } mod ...
{ Digest { hash: String::from( "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", ), size_bytes: 0, } }
identifier_body
lib.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). #![deny(unused_must_use)] mod conversions; pub use conversions::require_digest; #[cfg(test)] mod conversions_tests; pub mod gen { // NOTE: Prost automatically relies on the existenc...
() -> Digest { Digest { hash: String::from( "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", ), size_bytes: 0, } } } } } pub mod semver { tonic::include_prot...
empty_digest
identifier_name
lib.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). #![deny(unused_must_use)] mod conversions; pub use conversions::require_digest; #[cfg(test)] mod conversions_tests; pub mod gen { // NOTE: Prost automatically relies on the existenc...
} } } pub mod buildbarn { pub mod cas { tonic::include_proto!("buildbarn.cas"); } } pub mod pants { pub mod cache { tonic::include_proto!("pants.cache"); } } } mod verification; pub use crate::verification::verify_directory_canonical; #[cfg(test)] mod verification_tests;
} } pub mod semver { tonic::include_proto!("build.bazel.semver");
random_line_split
call.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...
() { let s = r#"{ "data" : "0x1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff", "destination" : "", "gasLimit" : "0x1748766aa5", "value" : "0x00" }"#; let call: Call = serde_json::from_str(s).unwrap(); assert_eq!(&call.data[..], &[0x11, 0x11, 0x22, 0x22, 0x33, 0x33, 0x44, 0x44, ...
call_deserialization_empty_dest
identifier_name
call.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...
assert_eq!(&call.data[..], &[0x11, 0x11, 0x22, 0x22, 0x33, 0x33, 0x44, 0x44, 0x55, 0x55, 0x66, 0x66, 0x77, 0x77, 0x88, 0x88, 0x99, 0x99, 0x00, 0x00, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0xff, 0xff]); assert_eq!(call.destination, MaybeEmpty::None); assert_eq!(call.gas_limit, U...
random_line_split
call.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...
}
{ let s = r#"{ "data" : "0x1234", "destination" : "5a39ed1020c04d4d84539975b893a4e7c53eab6c", "gasLimit" : "0x1748766aa5", "value" : "0x00" }"#; let call: Call = serde_json::from_str(s).unwrap(); assert_eq!(&call.data[..], &[0x12, 0x34]); assert_eq!(call.destination, MaybeEmpty::Some(Address(Has...
identifier_body
p051.rs
//! [Problem 51](https://projecteuler.net/problem=51) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn compute(num_value: usize) -> u64 { let radix = 10; let ps = Prim...
} }
random_line_split
p051.rs
//! [Problem 51](https://projecteuler.net/problem=51) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn compute(num_value: usize) -> u64 { let radix = 10; let ps = Prim...
else { d }); if ps.contains(Integer::from_digits(it, radix as u64)) { num_prime += 1; } } if num_prime >= num_value { return p; } } } unreachable!() } fn solve() -> String { compute(8).to_strin...
{ d_dst as u64 }
conditional_block
p051.rs
//! [Problem 51](https://projecteuler.net/problem=51) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn compute(num_value: usize) -> u64 { let radix = 10; let ps = Prim...
common::problem!("121313", solve); #[cfg(test)] mod tests { #[test] fn seven() { assert_eq!(56003, super::compute(7)) } }
{ compute(8).to_string() }
identifier_body
p051.rs
//! [Problem 51](https://projecteuler.net/problem=51) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn compute(num_value: usize) -> u64 { let radix = 10; let ps = Prim...
() -> String { compute(8).to_string() } common::problem!("121313", solve); #[cfg(test)] mod tests { #[test] fn seven() { assert_eq!(56003, super::compute(7)) } }
solve
identifier_name
lib.rs
//! librsync bindings for Rust. //! //! This library contains bindings to librsync [1], encapsulating the algorithms of the rsync //! protocol, which computes differences between files efficiently. //! //! The rsync protocol, when computes differences, does not require the presence of both files. //! It needs instead t...
} impl<'a, B: Read + Seek + 'a, D: Read> Patch<'a, B, BufReader<D>> { /// Creates a new patch stream. /// /// This constructor takes a `Read + Seek` stream for the basis file (`base` parameter), and a /// `Read` stream for the delta file (`delta` parameter). It produces a stream from which read //...
{ self.driver.read(buf) }
identifier_body
lib.rs
//! librsync bindings for Rust. //! //! This library contains bindings to librsync [1], encapsulating the algorithms of the rsync //! protocol, which computes differences between files efficiently. //! //! The rsync protocol, when computes differences, does not require the presence of both files. //! It needs instead t...
(*mut raw::rs_signature_t); // workaround for E0225 trait ReadAndSeek: Read + Seek {} impl<T: Read + Seek> ReadAndSeek for T {} impl<R: Read> Signature<BufReader<R>> { /// Creates a new signature stream with default parameters. /// /// This constructor takes an input stream for the file from which compute...
Sumset
identifier_name
lib.rs
//! librsync bindings for Rust. //! //! This library contains bindings to librsync [1], encapsulating the algorithms of the rsync //! protocol, which computes differences between files efficiently. //! //! The rsync protocol, when computes differences, does not require the presence of both files. //! It needs instead t...
pub type Result<T> = std::result::Result<T, Error>; /// A struct to generate a signature. /// /// This type takes a `Read` stream for the input from which compute the signatures, and implements /// another `Read` stream from which get the result. pub struct Signature<R> { driver: JobDriver<R>, } /// A struct to g...
Unknown(i32), } /// A `Result` type alias for this crate's `Error` type.
random_line_split
game_state.rs
use engine::state::{StateData, State, EngineState}; use engine::state::StateData::*; use engine::state::EngineState::*; use engine::resource_loader::{ResourceLoader}; use engine::settings::Settings; use engine::rendering::{RenderContext, RenderQueue}; use engine::event_queue::{EventQueue}; use game::colors; use game:...
} }
{ NoChange }
conditional_block
game_state.rs
use engine::state::{StateData, State, EngineState}; use engine::state::StateData::*; use engine::state::EngineState::*; use engine::resource_loader::{ResourceLoader}; use engine::settings::Settings; use engine::rendering::{RenderContext, RenderQueue}; use engine::event_queue::{EventQueue}; use game::colors; use game:...
} impl<'a> State for GameState<'a> { fn startup(&mut self, data: StateData) { let value = match data { IntStateData(i) => i, _ => panic!() }; } fn queue_event_handlers(&mut self, event_queue: &mut EventQueue){ event_queue.push(&mut self.event_layer); } fn queue_renderers(&mut self, render_queue:...
{ GameState { active: true, level: Level::new(), event_layer: GameEventLayer::new(settings), } }
identifier_body
game_state.rs
use engine::state::{StateData, State, EngineState}; use engine::state::StateData::*; use engine::state::EngineState::*; use engine::resource_loader::{ResourceLoader}; use engine::settings::Settings; use engine::rendering::{RenderContext, RenderQueue}; use engine::event_queue::{EventQueue}; use game::colors; use game:...
(loader: &ResourceLoader, _render_ctx: &RenderContext, settings: &Settings) -> GameState<'a> { GameState { active: true, level: Level::new(), event_layer: GameEventLayer::new(settings), } } } impl<'a> State for GameState<'a> { fn startup(&mut self, data: StateData) { let value = match data { Int...
new
identifier_name
game_state.rs
use engine::state::{StateData, State, EngineState}; use engine::state::StateData::*; use engine::state::EngineState::*; use engine::resource_loader::{ResourceLoader}; use engine::settings::Settings; use engine::rendering::{RenderContext, RenderQueue}; use engine::event_queue::{EventQueue}; use game::colors; use game:...
impl<'a> GameState<'a> { pub fn new(loader: &ResourceLoader, _render_ctx: &RenderContext, settings: &Settings) -> GameState<'a> { GameState { active: true, level: Level::new(), event_layer: GameEventLayer::new(settings), } } } impl<'a> State for GameState<'a> { fn startup(&mut self, data: StateData)...
active: bool, level: Level<'a>, event_layer: GameEventLayer, }
random_line_split
filelock.rs
//! Lock files for editing. use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, remacs_sys::Qstringp, remacs_sys::{lock_file, unlock_file}, threads::ThreadState, }; /// Lock FILE, if current buffer is modified. /// FILE defaults to current buffer's visited file, /// or else nothing is done if ...
() { let cur_buf = ThreadState::current_buffer_unchecked(); let truename = cur_buf.truename(); if cur_buf.modified_since_save() && truename.is_string() { unsafe { unlock_file(truename) } } } include!(concat!(env!("OUT_DIR"), "/filelock_exports.rs"));
unlock_buffer_lisp
identifier_name
filelock.rs
//! Lock files for editing. use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, remacs_sys::Qstringp, remacs_sys::{lock_file, unlock_file}, threads::ThreadState, }; /// Lock FILE, if current buffer is modified. /// FILE defaults to current buffer's visited file, /// or else nothing is done if ...
include!(concat!(env!("OUT_DIR"), "/filelock_exports.rs"));
{ let cur_buf = ThreadState::current_buffer_unchecked(); let truename = cur_buf.truename(); if cur_buf.modified_since_save() && truename.is_string() { unsafe { unlock_file(truename) } } }
identifier_body
filelock.rs
//! Lock files for editing. use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, remacs_sys::Qstringp, remacs_sys::{lock_file, unlock_file}, threads::ThreadState, }; /// Lock FILE, if current buffer is modified. /// FILE defaults to current buffer's visited file, /// or else nothing is done if ...
/// Unlock the file visited in the current buffer. /// If the buffer is not modified, this does nothing because the file /// should not be locked in that case. #[lisp_fn(name = "unlock-buffer")] pub fn unlock_buffer_lisp() { let cur_buf = ThreadState::current_buffer_unchecked(); let truename = cur_buf.truename(...
}
random_line_split
filelock.rs
//! Lock files for editing. use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, remacs_sys::Qstringp, remacs_sys::{lock_file, unlock_file}, threads::ThreadState, }; /// Lock FILE, if current buffer is modified. /// FILE defaults to current buffer's visited file, /// or else nothing is done if ...
else if file.is_string() { file } else { wrong_type!(Qstringp, file) }; if cur_buf.modified_since_save() &&!file.is_nil() { unsafe { lock_file(file) } } } /// Unlock the file visited in the current buffer. /// If the buffer is not modified, this does nothing because the file /...
{ cur_buf.truename() }
conditional_block
macro-backtrace-nested.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 ...
() { 1 + call_nested_expr!(); //~ ERROR unresolved name call_nested_expr_sum!(); //~ NOTE expansion site }
main
identifier_name
macro-backtrace-nested.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 ...
{ 1 + call_nested_expr!(); //~ ERROR unresolved name call_nested_expr_sum!(); //~ NOTE expansion site }
identifier_body
macro-backtrace-nested.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 ...
call_nested_expr_sum!(); //~ NOTE expansion site }
1 + call_nested_expr!(); //~ ERROR unresolved name
random_line_split
overloaded-calls-nontuple.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, z: int) -> int { self.x + self.y + z } } fn main() { let mut s = S { x: 1, y: 2, }; drop(s(3)) //~ ERROR cannot use call notation }
call_mut
identifier_name
overloaded-calls-nontuple.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use std::ops::FnMut; struct S { x: int, y: int, } impl FnMut<int,int> for S { fn call_mut(&mut self, z: int) -> int { self.x + self.y + z } } fn main() { let mut s = S { x: 1, y: 2, }; drop(s(3)) //~ ERROR cannot use call notation }
// except according to those terms. #![feature(overloaded_calls)]
random_line_split
mod.rs
//!Routers stores request handlers, using an HTTP method and a path as keys. //! //!Rustful provides a tree structured all-round router called `TreeRouter`, //!but any other type of router can be used, as long as it implements the //!`Router` trait. This will also make it possible to initialize it using the //![`insert...
(handler: Option<&'a T>) -> Endpoint<'a, T> { Endpoint { handler: handler, variables: HashMap::new(), hypermedia: Hypermedia::new() } } } ///A common trait for routers. /// ///A router must to implement this trait to be usable in a Rustful server. This ///trait w...
from
identifier_name
mod.rs
//!Routers stores request handlers, using an HTTP method and a path as keys. //! //!Rustful provides a tree structured all-round router called `TreeRouter`, //!but any other type of router can be used, as long as it implements the //!`Router` trait. This will also make it possible to initialize it using the //![`insert...
impl<'a> Route<'a> for str { type Segments = RouteIter<Split<'a, u8, fn(&u8) -> bool>>; fn segments(&'a self) -> <Self as Route<'a>>::Segments { self.as_bytes().segments() } } impl<'a> Route<'a> for [u8] { type Segments = RouteIter<Split<'a, u8, fn(&u8) -> bool>>; fn segments(&'a self) ...
{ *c == b'/' }
identifier_body
mod.rs
//!Routers stores request handlers, using an HTTP method and a path as keys. //! //!Rustful provides a tree structured all-round router called `TreeRouter`, //!but any other type of router can be used, as long as it implements the //!`Router` trait. This will also make it possible to initialize it using the //![`insert...
//!multiple times. This can be useful to lower the risk of typing errors, //!among other things. //! //!Routes may also be added using the insert method, like this: //! //!``` //!extern crate rustful; //!use rustful::Method::Get; //!use rustful::{Router, TreeRouter}; //!# use rustful::{Handler, Context, Response}; //! ...
//!``` //! //!This macro creates the same structure as the example below, but it allows //!tree structures to be defined without the need to write the same paths
random_line_split
assign_mutable_fields.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut x: (u32, u32); x.0 = 1; x.1 = 22; drop(x); //~ ERROR } fn main() { }
assign_both_fields_the_use_var
identifier_name
assign_mutable_fields.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 ...
// Currently, we permit you to assign to individual fields of a mut // var, but we do not permit you to use the complete var afterwards. // We hope to fix this at some point. // // FIXME(#21232) fn assign_both_fields_and_use() { let mut x: (u32, u32); x.0 = 1; x.1 = 22; drop(x.0); //~ ERROR drop(x...
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
assign_mutable_fields.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 ...
{ }
identifier_body
vec_map.rs
#[derive(Clone)] pub struct VecMap<K, V> { vec: Vec<(K, V)>, } impl<K: PartialEq, V> VecMap<K, V> { pub fn new() -> VecMap<K, V> { VecMap { vec: Vec::new() } } pub fn insert(&mut self, key: K, value: V) { match self.find(&key) { Some(pos) => self.vec[pos...
(&self, key: &K) -> bool { self.find(key).is_some() } pub fn len(&self) -> usize { self.vec.len() } pub fn iter(&self) -> ::std::slice::Iter<(K, V)> { self.vec.iter() } pub fn remove(&mut self, key: &K) -> Option<V> { self.find(key).map(|pos| self.vec.remove(pos)).map(|(_, v...
contains_key
identifier_name
vec_map.rs
#[derive(Clone)] pub struct VecMap<K, V> { vec: Vec<(K, V)>, } impl<K: PartialEq, V> VecMap<K, V> { pub fn new() -> VecMap<K, V> { VecMap { vec: Vec::new() } } pub fn insert(&mut self, key: K, value: V)
pub fn entry(&mut self, key: K) -> Entry<K, V> { match self.find(&key) { Some(pos) => Entry::Occupied(OccupiedEntry { vec: self, pos: pos, }), None => Entry::Vacant(VacantEntry { vec: self, key: key, ...
{ match self.find(&key) { Some(pos) => self.vec[pos] = (key, value), None => self.vec.push((key, value)) } }
identifier_body
vec_map.rs
#[derive(Clone)] pub struct VecMap<K, V> { vec: Vec<(K, V)>, } impl<K: PartialEq, V> VecMap<K, V> { pub fn new() -> VecMap<K, V> { VecMap { vec: Vec::new() } } pub fn insert(&mut self, key: K, value: V) { match self.find(&key) { Some(pos) => self.vec[pos...
self.find(key).is_some() } pub fn len(&self) -> usize { self.vec.len() } pub fn iter(&self) -> ::std::slice::Iter<(K, V)> { self.vec.iter() } pub fn remove(&mut self, key: &K) -> Option<V> { self.find(key).map(|pos| self.vec.remove(pos)).map(|(_, v)| v) } pub fn clea...
pub fn contains_key(&self, key: &K) -> bool {
random_line_split
reftest.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
let mut tests = parse_lists(&file, testnames, servo_args, render_mode, len); println!("\t{} [{} tests]", file.display(), tests.len()); all_tests.append(&mut tests); } } _ => {} } } let test_opts = TestOp...
if extension == OsStr::new("list") && file.is_file() { let len = all_tests.len();
random_line_split
reftest.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
(file: &Path, filters: &[String], servo_args: &[String], render_mode: RenderMode, id_offset: usize) -> Vec<TestDescAndFn> { let mut tests = Vec::new(); let contents = { let mut f = File::open(file).unwrap(); let mut conte...
parse_lists
identifier_name
check_button.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Create widgets with a discrete toggle button use glib::translate::ToGlibPtr; use ffi; /...
nemonic: &str) -> Option<CheckButton> { let tmp_pointer = unsafe { ffi::gtk_check_button_new_with_mnemonic(mnemonic.to_glib_none().0) }; check_pointer!(tmp_pointer, CheckButton) } } impl_drop!(CheckButton); impl_TraitWidget!(CheckButton); impl ::ContainerTrait for CheckButton {...
w_with_mnemonic(m
identifier_name
check_button.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Create widgets with a discrete toggle button use glib::translate::ToGlibPtr; use ffi; /...
pub fn new_with_mnemonic(mnemonic: &str) -> Option<CheckButton> { let tmp_pointer = unsafe { ffi::gtk_check_button_new_with_mnemonic(mnemonic.to_glib_none().0) }; check_pointer!(tmp_pointer, CheckButton) } } impl_drop!(CheckButton); impl_TraitWidget!(CheckButton); impl ::Co...
let tmp_pointer = unsafe { ffi::gtk_check_button_new_with_label(label.to_glib_none().0) }; check_pointer!(tmp_pointer, CheckButton) }
identifier_body
check_button.rs
// Copyright 2013-2015, The Gtk-rs Project Developers.
use glib::translate::ToGlibPtr; use ffi; /// CheckButton — Create widgets with a discrete toggle button struct_Widget!(CheckButton); impl CheckButton { pub fn new() -> Option<CheckButton> { let tmp_pointer = unsafe { ffi::gtk_check_button_new() }; check_pointer!(tmp_pointer, CheckButton) } ...
// See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Create widgets with a discrete toggle button
random_line_split
echo.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...
use hyper::{server, Decoder, Encoder, Next}; use hyper::net::HttpStream; use super::ContentHandler; #[derive(Default)] pub struct EchoHandler { content: String, handler: Option<ContentHandler>, } impl server::Handler<HttpStream> for EchoHandler { fn on_request(&mut self, _: server::Request<HttpStream>) -> Next { ...
//! Echo Handler use std::io::Read;
random_line_split
echo.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...
(&mut self, _: server::Request<HttpStream>) -> Next { Next::read() } fn on_request_readable(&mut self, decoder: &mut Decoder<HttpStream>) -> Next { match decoder.read_to_string(&mut self.content) { Ok(0) => { self.handler = Some(ContentHandler::ok(self.content.clone(), mime!(Application/Json))); Next:...
on_request
identifier_name
problem20.rs
extern crate num; use num::bigint::BigUint; fn to_biguint(num_str: &str) -> BigUint { return num_str.parse::<BigUint>().unwrap(); } fn factorial(num: BigUint) -> BigUint { if num == to_biguint("1")
let num2 = num.clone(); // TODO: avoid this ugly line return num * factorial(num2 - to_biguint("1")); } fn sum_of_digits(num: BigUint) -> u64 { let mut sum = 0u64; for ch in num.to_string().chars() { sum += ch.to_digit(10).unwrap() as u64; } return sum } pub fn main() { let answer...
{ return to_biguint("1") }
conditional_block
problem20.rs
extern crate num; use num::bigint::BigUint; fn to_biguint(num_str: &str) -> BigUint { return num_str.parse::<BigUint>().unwrap(); } fn factorial(num: BigUint) -> BigUint { if num == to_biguint("1") { return to_biguint("1") } let num2 = num.clone(); // TODO: avoid this ugly line return num...
}
{ assert_eq!(factorial(to_biguint("10")), to_biguint("3628800")); assert_eq!(sum_of_digits(factorial(to_biguint("10"))), 27); }
identifier_body
problem20.rs
extern crate num; use num::bigint::BigUint; fn to_biguint(num_str: &str) -> BigUint { return num_str.parse::<BigUint>().unwrap(); }
fn factorial(num: BigUint) -> BigUint { if num == to_biguint("1") { return to_biguint("1") } let num2 = num.clone(); // TODO: avoid this ugly line return num * factorial(num2 - to_biguint("1")); } fn sum_of_digits(num: BigUint) -> u64 { let mut sum = 0u64; for ch in num.to_string().char...
random_line_split
problem20.rs
extern crate num; use num::bigint::BigUint; fn to_biguint(num_str: &str) -> BigUint { return num_str.parse::<BigUint>().unwrap(); } fn factorial(num: BigUint) -> BigUint { if num == to_biguint("1") { return to_biguint("1") } let num2 = num.clone(); // TODO: avoid this ugly line return num...
(num: BigUint) -> u64 { let mut sum = 0u64; for ch in num.to_string().chars() { sum += ch.to_digit(10).unwrap() as u64; } return sum } pub fn main() { let answer = sum_of_digits(factorial(to_biguint("100"))); println!("answer = {}", answer); } #[cfg(test)] mod test { use super::{f...
sum_of_digits
identifier_name
output.rs
use std::io; use std::io::{BufRead, BufReader, Write, Seek}; use std::io::SeekFrom::{Start, Current}; use std::fs::File; use std::path::Path; use self::PadSide::*; use self::Content::*; use definitions::Definition; use interpreter::extract_line; #[derive(PartialEq)] pub enum PadSide { Left, Right } #[derive(P...
t_eq!(" pâté", "pâté".pad(' ', 8, Left, Chars)) } }
_wide_l() { asser
identifier_name
output.rs
use std::io; use std::io::{BufRead, BufReader, Write, Seek}; use std::io::SeekFrom::{Start, Current}; use std::fs::File; use std::path::Path; use self::PadSide::*; use self::Content::*; use definitions::Definition; use interpreter::extract_line; #[derive(PartialEq)] pub enum PadSide { Left, Right } #[derive(P...
t] fn char_padding_wide_r() { assert_eq!("pâté ", "pâté".pad(' ', 8, Right, Chars)) } #[test] fn char_padding_wide_l() { assert_eq!(" pâté", "pâté".pad(' ', 8, Left, Chars)) } }
assert_eq!(" pâté", "pâté".pad(' ', 8, Left, Bytes)) } #[tes
identifier_body
output.rs
use std::io; use std::io::{BufRead, BufReader, Write, Seek}; use std::io::SeekFrom::{Start, Current}; use std::fs::File; use std::path::Path; use self::PadSide::*; use self::Content::*; use definitions::Definition; use interpreter::extract_line; #[derive(PartialEq)] pub enum PadSide { Left, Right } #[derive(P...
pub fn display_extract(input_file_name: &str, definition: &Definition) -> io::Result<()> { let input_file = try!(File::open(Path::new(input_file_name))); let max_name_len = definition.fields.iter().map(|field| field.len()).max().unwrap(); let max_value_len = definition.lengths.iter().max().unwrap(); let mut index...
if side == Left { padded_str.push_str(self) } padded_str } }
random_line_split