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
csv.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
} /// Iterator over CSV batches // TODO: usage example (rather than documenting `new()`) pub struct CsvBatchIterator { schema: Arc<Schema>, reader: csv::Reader<File>, } impl CsvBatchIterator { #[allow(missing_docs)] pub fn try_new( filename: &str, schema: Arc<Schema>, has_head...
{ let exec = CsvExec::try_new( &self.filename, self.schema.clone(), self.has_header, projection.clone(), batch_size, )?; let partitions = exec.partitions()?; let iterators = partitions .iter() .map(|p| p....
identifier_body
csv.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
None => schema, }; Ok(Self { schema: projected_schema, reader, }) } } impl BatchIterator for CsvBatchIterator { fn schema(&self) -> Arc<Schema> { self.schema.clone() } fn next(&mut self) -> Result<Option<RecordBatch>> { Ok(s...
{ let projected_fields: Vec<Field> = p.iter().map(|i| schema.fields()[*i].clone()).collect(); Arc::new(Schema::new(projected_fields)) }
conditional_block
csv.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
(&mut self) -> Result<Option<RecordBatch>> { Ok(self.reader.next()?) } }
next
identifier_name
csv.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
// TODO: usage example (rather than documenting `new()`) pub struct CsvBatchIterator { schema: Arc<Schema>, reader: csv::Reader<File>, } impl CsvBatchIterator { #[allow(missing_docs)] pub fn try_new( filename: &str, schema: Arc<Schema>, has_header: bool, projection: &Opt...
Ok(iterators) } } /// Iterator over CSV batches
random_line_split
lib.rs
mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; use vt::VT; #[wasm_bindgen] pub struct
{ vt: VT, } #[wasm_bindgen] pub fn create(w: usize, h: usize) -> VtWrapper { utils::set_panic_hook(); VtWrapper { vt: VT::new(w, h) } } #[wasm_bindgen] impl VtWrapper { pub fn feed(&mut self, s: &str) -> Vec<usize> { self.vt.feed_str(s) } pub fn inspect(&self) -> String { for...
VtWrapper
identifier_name
lib.rs
mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; use vt::VT; #[wasm_bindgen] pub struct VtWrapper { vt: VT, } #[wasm_bi...
let cursor = self.vt.get_cursor(); serde_wasm_bindgen::to_value(&cursor).unwrap() } }
random_line_split
trivial.rs
// No-op test #[test="test_trivial"] fn test_trivial() { bb0: { ASSIGN retval = (); } RETURN; } // Dead code elimination, should remove any useless code // - Unused assignments // - Unused locals // - Unused drop flags // - Unused blocks #[test="dce_exp"] fn dce() { let df0 = false; let useless: (); bb0: { A...
RETURN; } fn inlining_exp() { bb0: { ASSIGN retval = (); } RETURN; } // Constant propagation leading to DCE #[test="constprop_exp"] fn constprop() { let v1: bool; bb0: { ASSIGN v1 = true; } IF v1 => bb1 else bb2; bb1: { ASSIGN retval = (); } RETURN; bb2: { } DIVERGE; } fn constprop_exp() { bb0: { AS...
{ bb0: { ASSIGN retval = (); }
identifier_body
trivial.rs
// No-op test #[test="test_trivial"] fn test_trivial() { bb0: { ASSIGN retval = (); } RETURN; } // Dead code elimination, should remove any useless code // - Unused assignments // - Unused locals // - Unused drop flags // - Unused blocks #[test="dce_exp"] fn
() { let df0 = false; let useless: (); bb0: { ASSIGN useless = (); ASSIGN useless = useless; // Never read, so will be removed ASSIGN retval = (); //ASSIGN retval = (); // Note: won't be de-duplicated (TODO) } RETURN; // Never referenced, will be removed bb_unused: { } GOTO bb_unused_indir; // Indirectl...
dce
identifier_name
trivial.rs
// No-op test #[test="test_trivial"] fn test_trivial() { bb0: { ASSIGN retval = (); } RETURN; } // Dead code elimination, should remove any useless code // - Unused assignments // - Unused locals // - Unused drop flags // - Unused blocks #[test="dce_exp"] fn dce() { let df0 = false; let useless: (); bb0: {
//ASSIGN retval = (); // Note: won't be de-duplicated (TODO) } RETURN; // Never referenced, will be removed bb_unused: { } GOTO bb_unused_indir; // Indirectly unused, will still be removed bb_unused_indir: { } DIVERGE; // References itself without other reference, will be removed bb_unused_self: { } GOTO bb...
ASSIGN useless = (); ASSIGN useless = useless; // Never read, so will be removed ASSIGN retval = ();
random_line_split
issue-14959.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 ...
<T>(&self) -> Option<T> { None } } impl<'a, 'b> Fn<(&'b mut Response,),()> for SendFile<'a> { extern "rust-call" fn call(&self, (_res,): (&'b mut Response,)) {} } impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld { fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> S...
find
identifier_name
issue-14959.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 ...
send_file(res); Continue } } fn main() {}
impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld { fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status { let send_file = alloy.find::<SendFile>().unwrap();
random_line_split
issue-14959.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{}
identifier_body
str-append.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 ...
() { test1(); test2(); }
main
identifier_name
str-append.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 ...
{ test1(); test2(); }
identifier_body
str-append.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 mut s: ~str = ~"hello"; s.push_str("world"); debug!(s.clone()); assert_eq!(s[9], 'd' as u8); } fn test2() { // This tests for issue #163 let ff: ~str = ~"abc"; let a: ~str = ff + ~"ABC" + ff; let b: ~str = ~"ABC" + ff + ~"ABC"; debug!(a.clone()); debug!(b.clone()); asse...
fn test1() {
random_line_split
lib.rs
// Copyright 2015 Corey Farwell // // 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 in wr...
pub fn add_edge(&mut self, from: &str, to: &str) { self.buf.push_str(&format!("\"{}\" -> \"{}\";", from, to)); } pub fn finish(&mut self) { self.buf.push_str("}"); } pub fn png_bytes(&self) -> Vec<u8> { let child = Command::new("dot").arg("-Tpng") ...
pub fn set_node_attrs(&mut self, node: &str, attrs: &str) { self.buf.push_str(&format!("\"{}\" [{}];", node, attrs)); }
random_line_split
lib.rs
// Copyright 2015 Corey Farwell // // 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 in wr...
(&mut self, from: &str, to: &str) { self.buf.push_str(&format!("\"{}\" -> \"{}\";", from, to)); } pub fn finish(&mut self) { self.buf.push_str("}"); } pub fn png_bytes(&self) -> Vec<u8> { let child = Command::new("dot").arg("-Tpng") .stdin(...
add_edge
identifier_name
lib.rs
// Copyright 2015 Corey Farwell // // 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 in wr...
pub fn set_node_attrs(&mut self, node: &str, attrs: &str) { self.buf.push_str(&format!("\"{}\" [{}];", node, attrs)); } pub fn add_edge(&mut self, from: &str, to: &str) { self.buf.push_str(&format!("\"{}\" -> \"{}\";", from, to)); } pub fn finish(&mut self) { self.buf.pus...
{ self.buf.push_str(&format!("ratio={};", ratio)) }
identifier_body
expr-match-generic-unique1.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 ...
, _ => panic!("wat") }; assert!(eq(expected, actual)); } fn test_box() { fn compare_box(b1: Box<bool>, b2: Box<bool>) -> bool { return *b1 == *b2; } test_generic::<bool, _>(box true, compare_box); } pub fn main() { test_box(); }
{ expected.clone() }
conditional_block
expr-match-generic-unique1.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 ...
(b1: Box<bool>, b2: Box<bool>) -> bool { return *b1 == *b2; } test_generic::<bool, _>(box true, compare_box); } pub fn main() { test_box(); }
compare_box
identifier_name
expr-match-generic-unique1.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn test_box() { fn compare_box(b1: Box<bool>, b2: Box<bool>) -> bool { return *b1 == *b2; } test_generic::<bool, _>(box true, compare_box); } pub fn main() { test_box(); }
true => { expected.clone() }, _ => panic!("wat") }; assert!(eq(expected, actual));
random_line_split
expr-match-generic-unique1.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 ...
{ test_box(); }
identifier_body
issue-818.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 c = ctr::new(42); let c2 = ctr::inc(c); assert!(*c2 == 5); //~ ERROR can only dereference enums with a single, public variant }
identifier_body
issue-818.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
mod ctr { pub enum ctr { priv mkCtr(int) } pub fn new(i: int) -> ctr { mkCtr(i) } pub fn inc(c: ctr) -> ctr { mkCtr(*c + 1) } } fn main() { let c = ctr::new(42); let c2 = ctr::inc(c); assert!(*c2 == 5); //~ ERROR can only dereference enums with a single, public variant }
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
issue-818.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 ...
(c: ctr) -> ctr { mkCtr(*c + 1) } } fn main() { let c = ctr::new(42); let c2 = ctr::inc(c); assert!(*c2 == 5); //~ ERROR can only dereference enums with a single, public variant }
inc
identifier_name
lib.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 ...
(argc: int, argv: *const *const u8) { // FIXME: Derefing these pointers is not safe. // Need to propagate the unsafety to `start`. unsafe { args::init(argc, argv); local_ptr::init(); at_exit_imp::init(); } // FIXME(#14344) this shouldn't be necessary collections::fixme_1...
init
identifier_name
lib.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 ...
/// Enqueues a procedure to run when the runtime is cleaned up /// /// The procedure passed to this function will be executed as part of the /// runtime cleanup phase. For normal rust programs, this means that it will run /// after all other tasks have exited. /// /// The procedure is *not* executed with a local `Tas...
{ // FIXME: Derefing these pointers is not safe. // Need to propagate the unsafety to `start`. unsafe { args::init(argc, argv); local_ptr::init(); at_exit_imp::init(); } // FIXME(#14344) this shouldn't be necessary collections::fixme_14344_be_sure_to_link_to_collections(...
identifier_body
lib.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 ...
mod at_exit_imp; mod local_ptr; mod thread_local_storage; mod util; mod libunwind; pub mod args; pub mod bookkeeping; pub mod c_str; pub mod exclusive; pub mod local; pub mod local_data; pub mod local_heap; pub mod mutex; pub mod rtio; pub mod stack; pub mod task; pub mod thread; pub mod unwind; /// The interface to...
use task::{Task, BlockedTask, TaskOpts}; mod macros;
random_line_split
ports.rs
use core_foundation::base::OSStatus; use coremidi_sys::{MIDIPortConnectSource, MIDIPortDisconnectSource, MIDIPortDispose, MIDISend}; use std::ops::Deref; use std::ptr; use crate::callback::BoxedCallback; use crate::endpoints::destinations::Destination; use crate::endpoints::sources::Source; use crate::object::Object...
} } impl Deref for OutputPort { type Target = Port; fn deref(&self) -> &Port { &self.port } } /// An input [MIDI port](https://developer.apple.com/reference/coremidi/midiportref) owned by a client. /// /// A simple example to create an input port: /// /// ```rust,no_run /// let client = core...
{ Err(status) }
conditional_block
ports.rs
use core_foundation::base::OSStatus; use coremidi_sys::{MIDIPortConnectSource, MIDIPortDisconnectSource, MIDIPortDispose, MIDISend}; use std::ops::Deref; use std::ptr; use crate::callback::BoxedCallback; use crate::endpoints::destinations::Destination; use crate::endpoints::sources::Source; use crate::object::Object...
(&self, source: &Source) -> Result<(), OSStatus> { let status = unsafe { MIDIPortDisconnectSource(self.object.0, source.object.0) }; if status == 0 { Ok(()) } else { Err(status) } } } impl Deref for InputPort { type Target = Port; fn deref(&self) -> ...
disconnect_source
identifier_name
ports.rs
use core_foundation::base::OSStatus; use coremidi_sys::{MIDIPortConnectSource, MIDIPortDisconnectSource, MIDIPortDispose, MIDISend}; use std::ops::Deref; use std::ptr; use crate::callback::BoxedCallback; use crate::endpoints::destinations::Destination; use crate::endpoints::sources::Source; use crate::object::Object...
MIDISend( self.port.object.0, destination.endpoint.object.0, packet_list.as_ptr(), ) }; if status == 0 { Ok(()) } else { Err(status) } } } impl Deref for OutputPort { type Target = Po...
let status = unsafe {
random_line_split
lib.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
pub mod ast_util; pub mod attr; pub mod codemap; pub mod config; pub mod diagnostic; pub mod feature_gate; pub mod fold; pub mod owned_slice; pub mod parse; pub mod ptr; pub mod show_span; pub mod std_inject; pub mod test; pub mod visit; pub mod print { pub mod pp; pub mod pprust; } pub mod ext { pub mod ...
pub mod ast_map;
random_line_split
streaming.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, _decoder: &mut Decoder<HttpStream>) -> Next { Next::write() } fn on_response(&mut self, res: &mut server::Response) -> Next { res.set_status(self.status); res.headers_mut().set(header::ContentType(self.mimetype.clone())); add_security_headers(&mut res.headers_mut(), self.safe_to_embed_on.clone())...
on_request_readable
identifier_name
streaming.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...
fn on_response(&mut self, res: &mut server::Response) -> Next { res.set_status(self.status); res.headers_mut().set(header::ContentType(self.mimetype.clone())); add_security_headers(&mut res.headers_mut(), self.safe_to_embed_on.clone()); Next::write() } fn on_response_writable(&mut self, encoder: &mut Enco...
{ Next::write() }
identifier_body
streaming.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity.
// (at your option) any later version. // Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of t...
// 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
random_line_split
bound-lifetime-in-return-only.rs
// revisions: sig local structure ok elision #![allow(dead_code)] #![feature(rustc_attrs)] #![feature(unboxed_closures)] trait Foo { type Item; } #[cfg(sig)] fn sig1(_: for<'a> fn() -> &'a i32) { //[sig]~^ ERROR return type references lifetime `'a` } #[cfg(sig)] fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32...
(_: fn() -> &i32) { //[elision]~^ ERROR E0106 } struct Parameterized<'a> { x: &'a str } #[cfg(ok)] fn ok1(_: &dyn for<'a> Fn(&Parameterized<'a>) -> &'a i32) { } #[cfg(ok)] fn ok2(_: &dyn for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { } #[rustc_error] fn main() { } //[ok]~ ERROR fatal error triggered...
elision
identifier_name
bound-lifetime-in-return-only.rs
// revisions: sig local structure ok elision #![allow(dead_code)] #![feature(rustc_attrs)] #![feature(unboxed_closures)] trait Foo { type Item; } #[cfg(sig)]
fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32) { //[sig]~^ ERROR return type references lifetime `'a` } #[cfg(local)] fn local1() { let _: for<'a> fn() -> &'a i32 = loop { }; //[local]~^ ERROR return type references lifetime `'a` } #[cfg(structure)] struct Struct1 { x: for<'a> fn() -> &'a i32 //[s...
fn sig1(_: for<'a> fn() -> &'a i32) { //[sig]~^ ERROR return type references lifetime `'a` } #[cfg(sig)]
random_line_split
bound-lifetime-in-return-only.rs
// revisions: sig local structure ok elision #![allow(dead_code)] #![feature(rustc_attrs)] #![feature(unboxed_closures)] trait Foo { type Item; } #[cfg(sig)] fn sig1(_: for<'a> fn() -> &'a i32) { //[sig]~^ ERROR return type references lifetime `'a` } #[cfg(sig)] fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32...
#[cfg(structure)] struct Struct1 { x: for<'a> fn() -> &'a i32 //[structure]~^ ERROR return type references lifetime `'a` } #[cfg(elision)] fn elision(_: fn() -> &i32) { //[elision]~^ ERROR E0106 } struct Parameterized<'a> { x: &'a str } #[cfg(ok)] fn ok1(_: &dyn for<'a> Fn(&Parameterized<'a>) -> &'a i3...
{ let _: for<'a> fn() -> &'a i32 = loop { }; //[local]~^ ERROR return type references lifetime `'a` }
identifier_body
browse.rs
use std::{ io, os::raw::{ c_char, c_void, }, pin::Pin, task::{ Context, Poll, }, }; use crate::{ cstr, ffi, inner, interface::Interface, }; type CallbackStream = crate::stream::ServiceStream<inner::OwnedService, BrowseResult>; bitflags::bitflags! { /// Flags for [`BrowseResult`](struct.BrowseResul...
( _sd_ref: ffi::DNSServiceRef, flags: ffi::DNSServiceFlags, interface_index: u32, error_code: ffi::DNSServiceErrorType, service_name: *const c_char, reg_type: *const c_char, reply_domain: *const c_char, context: *mut c_void, ) { CallbackStream::run_callback(context, error_code, || { let service_name = cstr::...
browse_callback
identifier_name
browse.rs
use std::{ io, os::raw::{ c_char, c_void, }, pin::Pin, task::{ Context, Poll, }, }; use crate::{ cstr, ffi, inner, interface::Interface, }; type CallbackStream = crate::stream::ServiceStream<inner::OwnedService, BrowseResult>; bitflags::bitflags! { /// Flags for [`BrowseResult`](struct.BrowseResul...
} /// Browse for available services /// /// `reg_type` specifies the service type to search, e.g. `"_ssh._tcp"`. /// /// See [`DNSServiceBrowse`](https://developer.apple.com/documentation/dnssd/1804742-dnsservicebrowse). #[doc(alias = "DNSServiceBrowse")] pub fn browse_extended(reg_type: &str, data: BrowseData<'_>) ->...
}) .into(); Ok(Browse { stream })
random_line_split
ui.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import Method %> // CSS Basic User Interface M...
gecko_ffi_name="mUserSelect", gecko_enum_prefix="StyleUserSelect", gecko_inexhaustive=True, animatable=False, spec="https://drafts.csswg.org/css-ui-4/#propdef-user-select")}
animatable=False, spec="https://drafts.csswg.org/css-ui/#input-method-editor")} ${helpers.single_keyword("-moz-user-select", "auto text none all", products="gecko", alias="-webkit-user-select",
random_line_split
web_api.rs
#![deny(warnings)] extern crate futures; extern crate hyper; extern crate pretty_env_logger; extern crate serde_json; use futures::{future, Future, Stream}; use hyper::{Body, Chunk, Client, Method, Request, Response, Server, StatusCode, header}; use hyper::client::HttpConnector; use hyper::service::service_fn; #[all...
() { pretty_env_logger::init(); let addr = "127.0.0.1:1337".parse().unwrap(); hyper::rt::run(future::lazy(move || { // Share a `Client` with all `Service`s let client = Client::new(); let new_service = move || { // Move a clone of `client` into the `service_fn`. ...
main
identifier_name
web_api.rs
#![deny(warnings)] extern crate futures; extern crate hyper; extern crate pretty_env_logger; extern crate serde_json; use futures::{future, Future, Stream}; use hyper::{Body, Chunk, Client, Method, Request, Response, Server, StatusCode, header}; use hyper::client::HttpConnector; use hyper::service::service_fn; #[all...
// to show the difference let body = Body::wrap_stream(web_res.into_body().map(|b| { Chunk::from(format!("<b>before</b>: {}<br><b>after</b>: {}", std::str::from_utf8(LOWERCASE).unwrap(), s...
{ match (req.method(), req.uri().path()) { (&Method::GET, "/") | (&Method::GET, "/index.html") => { let body = Body::from(INDEX); Box::new(future::ok(Response::new(body))) }, (&Method::GET, "/test.html") => { // Run a web query against the web api below ...
identifier_body
web_api.rs
#![deny(warnings)] extern crate futures; extern crate hyper; extern crate pretty_env_logger; extern crate serde_json; use futures::{future, Future, Stream}; use hyper::{Body, Chunk, Client, Method, Request, Response, Server, StatusCode, header}; use hyper::client::HttpConnector; use hyper::service::service_fn; #[all...
// Return 404 not found response. let body = Body::from(NOTFOUND); Box::new(future::ok(Response::builder() .status(StatusCode::NOT_FOUND) .body(body) .unwrap())) ...
}; Box::new(future::ok(res)) } _ => {
random_line_split
issue-47646.rs
// Copyright 2018 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 ...
}; }
{}
conditional_block
issue-47646.rs
// Copyright 2018 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 heap: BinaryHeap<i32> = BinaryHeap::new(); let borrow = heap.peek_mut(); match (borrow, ()) { (Some(_), ()) => { println!("{:?}", heap); //~ ERROR cannot borrow `heap` as immutable } _ => {} }; }
identifier_body
issue-47646.rs
// Copyright 2018 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 heap: BinaryHeap<i32> = BinaryHeap::new(); let borrow = heap.peek_mut(); match (borrow, ()) { (Some(_), ()) => { println!("{:?}", heap); //~ ERROR cannot borrow `heap` as immutable } _ => {} }; }
main
identifier_name
issue-47646.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(warnings)] #![feature(nll)] use std::collections::BinaryHeap; fn main() { ...
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
style_adjuster.rs
are /// computed to 'absolute' if the element is in a top layer. /// fn adjust_for_top_layer(&mut self) { if!self.style.out_of_flow_positioned() && self.style.in_top_layer() { self.style.mutate_box().set_position(Position::Absolute); } } /// CSS 2.1 section 9.7: ...
/// <https://drafts.csswg.org/css-writing-modes-3/#block-flow:> /// /// If a box has a different writing-mode value than its containing /// block: /// /// - If the box has a specified display of inline, its display /// computes to inline-block. [CSS21] /// ///...
{ use properties::computed_value_flags::ComputedValueFlags; let parent_display = self.style.get_parent_box().clone_display(); if parent_display.is_ruby_type() { self.style.flags.insert(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK); } }
identifier_body
style_adjuster.rs
/// properties of the parent, you may need tweaking the /// `ChildCascadeRequirement` code in `matching.rs`. pub struct StyleAdjuster<'a, 'b: 'a> { style: &'a mut StyleBuilder<'b>, } impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// Trivially constructs a new StyleAdjuster. #[inline] pub fn new(style: &'a m...
/// /// NOTE(emilio): If new adjustments are introduced that depend on reset
random_line_split
style_adjuster.rs
are /// computed to 'absolute' if the element is in a top layer. /// fn adjust_for_top_layer(&mut self) { if!self.style.out_of_flow_positioned() && self.style.in_top_layer() { self.style.mutate_box().set_position(Position::Absolute); } } /// CSS 2.1 section 9.7: ...
} match self.style.get_box().clone_display() { // Ruby base and text are always non-breakable. Display::RubyBase | Display::RubyText => true, // Ruby base container and text container are breakable. // Note that, when certain HTML tags, e.g. f...
{ return true; }
conditional_block
style_adjuster.rs
are /// computed to 'absolute' if the element is in a top layer. /// fn adjust_for_top_layer(&mut self) { if!self.style.out_of_flow_positioned() && self.style.in_top_layer() { self.style.mutate_box().set_position(Position::Absolute); } } /// CSS 2.1 section 9.7: ...
(&mut self) { use properties::longhands::_moz_math_variant::computed_value::T as MozMathVariant; use properties::longhands::font_style::computed_value::T as FontStyle; use properties::longhands::font_weight::computed_value::T as FontWeight; if self.style.get_font().clone__moz_math_varian...
adjust_for_mathvariant
identifier_name
issue-4252.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() { let y = Y; let _z = Z{x: y}; }
self.x.call(); // Adding this statement causes an ICE. }
random_line_split
issue-4252.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T> { x: T } impl X for Y { fn call(&self) { } } impl<T: X> Drop for Z<T> { fn drop(&self) { self.x.call(); // Adding this statement causes an ICE. } } fn main() { let y = Y; let _z = Z{x: y}; }
Z
identifier_name
issue-4252.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} impl<T: X> Drop for Z<T> { fn drop(&self) { self.x.call(); // Adding this statement causes an ICE. } } fn main() { let y = Y; let _z = Z{x: y}; }
{ }
identifier_body
dump-fn-method.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 ...
<U>(&self, arg: T, arg2: U) { } } impl<T, U> Bazoom<U> for T { } fn foo<'a, T>(_: T) { } #[rustc_dump_user_substs] fn main() { // Here: nothing is given, so we don't have any annotation. let x = foo; x(22); // Here: `u32` is given. let x = foo::<u32>; //~ ERROR [u32] x(22); // Here: we ...
method
identifier_name
dump-fn-method.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 ...
} impl<T, U> Bazoom<U> for T { } fn foo<'a, T>(_: T) { } #[rustc_dump_user_substs] fn main() { // Here: nothing is given, so we don't have any annotation. let x = foo; x(22); // Here: `u32` is given. let x = foo::<u32>; //~ ERROR [u32] x(22); // Here: we only want the `T` to be given, ...
{ }
identifier_body
dump-fn-method.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 ...
x(&22, 44, 66); // Here: we want in particular that *only* the method `U` // annotation is given, the rest are variables. // // (`U` refers to the declaration of `Bazoom`) let y = 22_u32; y.method::<u32>(44, 66); //~ ERROR [^0, ^1, u32] // Here: nothing is given, so we don't have any a...
let x = <_ as Bazoom<u32>>::method::<_>; //~ ERROR [^0, u32, ^1] x(&22, 44, 66); // Here: all are given let x = <u8 as Bazoom<u16>>::method::<u32>; //~ ERROR [u8, u16, u32]
random_line_split
lib.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 ...
i += 1; } return 0; } #[cfg(test)] mod test { use core::str::StrSlice; use core::slice::{MutableSlice, ImmutableSlice}; use super::{memcmp, memset, memcpy, memmove}; #[test] fn memcmp_single_byte_pointers() { unsafe { assert_eq!(memcmp(&0xFAu8, &0xFAu8, 1), 0x...
{ return a as i32 - b as i32 }
conditional_block
lib.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 ...
} } } } }
{ { let mut buffer = [ b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9' ]; unsafe { memmove(&mut buffer[4], &buffer[0], 6); let mut i = 0; for byte in b"0123012345".iter() { assert_eq!(buffer[i], *byte); ...
identifier_body
lib.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 ...
() { let mut x: u8 = 0xFF; unsafe { memset(&mut x, 0xAA, 1); assert_eq!(x, 0xAA); memset(&mut x, 0x00, 1); assert_eq!(x, 0x00); x = 0x01; memset(&mut x, 0x12, 0); assert_eq!(x, 0x01); } } #[test] fn ...
memset_single_byte_pointers
identifier_name
lib.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 ...
#[test] fn memcmp_strings() { { let (x, z) = ("Hello!", "Good Bye."); let l = x.len(); unsafe { assert_eq!(memcmp(x.as_ptr(), x.as_ptr(), l), 0); assert!(memcmp(x.as_ptr(), z.as_ptr(), l) > 0); assert!(memcmp(z.as_ptr(),...
}
random_line_split
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
if let hir::TyPath(..) = f.node.ty.node { if let Some(&def::PathResolution { base_def: def::DefTy(def_id, _),.. }) = cx.tcx.def_map.borrow().get(&f.node.ty.id) { if cx.tcx.has_attr(def_id, "_dom_struct_marker") { ...
{ // Lints are run post expansion, so it's fine to use // #[_dom_struct_marker] here without also checking for #[dom_struct] if cx.tcx.has_attr(DefId::local(id), "_dom_struct_marker") { // Find the reflector, if any let reflector_span = def.fields.iter().enumerate() ...
identifier_body
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
if cx.tcx.has_attr(DefId::local(id), "_dom_struct_marker") { // Find the reflector, if any let reflector_span = def.fields.iter().enumerate() .find(|&(ctr, f)| { if match_lang_ty(cx, &*f.node.ty, "reflector") { ...
// #[_dom_struct_marker] here without also checking for #[dom_struct]
random_line_split
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
(&self) -> LintArray { lint_array!(INHERITANCE_INTEGRITY) } } impl LateLintPass for InheritancePass { fn check_struct_def(&mut self, cx: &LateContext, def: &hir::StructDef, _i: ast::Ident, _gen: &hir::Generics, id: ast::NodeId) { // Lints are run post expansion, so it's ...
get_lints
identifier_name
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
return Some(f.span) } } } None }).collect(); // We should not have both a reflector and a dom struct field if let Some(sp) = reflector_span { if dom_spans.len() >...
{ cx.span_lint(INHERITANCE_INTEGRITY, f.span, "Bare DOM structs should only be used as the first field of a \ DOM struct. Consider using JS<T> instead."); }
conditional_block
basic-types-metadata.rs
// min-lldb-version: 310 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // gdb-command:run // gdb-command:whatis unit // gdb-check:type = () // gdb-command:whatis b // gdb-check:type = bool // gdb-command:whatis i // gdb-check:type = isize // gdb-comma...
; }; _zzz(); // #break if 1 == 1 { _yyy(); } } fn _zzz() {()} fn _yyy() ->! {panic!()}
{ i }
conditional_block
basic-types-metadata.rs
// min-lldb-version: 310 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // gdb-command:run // gdb-command:whatis unit // gdb-check:type = () // gdb-command:whatis b // gdb-check:type = bool // gdb-command:whatis i // gdb-check:type = isize // gdb-comma...
() {()} fn _yyy() ->! {panic!()}
_zzz
identifier_name
basic-types-metadata.rs
// min-lldb-version: 310 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // gdb-command:run // gdb-command:whatis unit // gdb-check:type = () // gdb-command:whatis b // gdb-check:type = bool // gdb-command:whatis i // gdb-check:type = isize // gdb-comma...
fn _yyy() ->! {panic!()}
{()}
identifier_body
basic-types-metadata.rs
// min-lldb-version: 310 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // gdb-command:run // gdb-command:whatis unit // gdb-check:type = () // gdb-command:whatis b // gdb-check:type = bool // gdb-command:whatis i // gdb-check:type = isize // gdb-comma...
fn _yyy() ->! {panic!()}
} fn _zzz() {()}
random_line_split
commandbuffer.rs
// Copyright 2016 GFX developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to tho...
(&self) -> &ComputeCommandEncoderRef { unsafe { msg_send![self, computeCommandEncoder] } } pub fn new_render_command_encoder(&self, descriptor: &RenderPassDescriptorRef) -> &RenderCommandEncoderRef { unsafe { msg_send![self, renderCommandEncoderWithDescriptor:des...
new_compute_command_encoder
identifier_name
commandbuffer.rs
// Copyright 2016 GFX developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to tho...
} } pub fn set_label(&self, label: &str) { unsafe { let nslabel = NSString::from_str(label); msg_send![self, setLabel:nslabel]; } } pub fn enqueue(&self) { unsafe { msg_send![self, enqueue] } } pub fn commit(&self) { ...
let label: &NSString = msg_send![self, label]; label.as_str()
random_line_split
commandbuffer.rs
// Copyright 2016 GFX developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to tho...
pub fn enqueue(&self) { unsafe { msg_send![self, enqueue] } } pub fn commit(&self) { unsafe { msg_send![self, commit] } } pub fn status(&self) -> MTLCommandBufferStatus { unsafe { msg_send![self, status] } } ...
{ unsafe { let nslabel = NSString::from_str(label); msg_send![self, setLabel:nslabel]; } }
identifier_body
lib.rs
mod cannonball; use bbggez::ggez::{ event::EventHandler, graphics, nalgebra::{Point2, Vector2}, timer, Context, GameResult, }; use bbggez::traits::NatureOfCode; use bbggez::{rand, rand::prelude::*}; use cannonball::Cannonball; pub struct Game { cannonball: Cannonball, gravity_force: Vector2<f32>, drag_force: f...
(&mut self, context: &mut Context) -> GameResult<()> { let delta_time = timer::delta(context).as_secs_f32(); let arena_size = graphics::drawable_size(context); self.handle_window_size_change(context, arena_size)?; self.cannonball.apply_force(self.gravity_force); if self.cannonball.location.y > arena_size.1 {...
update
identifier_name
lib.rs
mod cannonball; use bbggez::ggez::{ event::EventHandler, graphics, nalgebra::{Point2, Vector2}, timer, Context, GameResult, }; use bbggez::traits::NatureOfCode; use bbggez::{rand, rand::prelude::*}; use cannonball::Cannonball; pub struct Game { cannonball: Cannonball, gravity_force: Vector2<f32>, drag_force: f...
} self.cannonball.update(delta_time); Ok(()) } fn draw(&mut self, context: &mut Context) -> GameResult<()> { graphics::clear(context, graphics::BLACK); graphics::draw( context, &self.cannonball.mesh, graphics::DrawParam::new() .dest(Point2::from(self.cannonball.location)) .rotation(self...
{ self.cannonball.apply_rotation_force(); self.cannonball.bounced = true; }
conditional_block
lib.rs
mod cannonball; use bbggez::ggez::{ event::EventHandler, graphics, nalgebra::{Point2, Vector2}, timer, Context, GameResult, }; use bbggez::traits::NatureOfCode; use bbggez::{rand, rand::prelude::*}; use cannonball::Cannonball; pub struct Game { cannonball: Cannonball, gravity_force: Vector2<f32>, drag_force: f...
self.cannonball.reverse_vertical_velocity(); let drag = (self.cannonball.velocity * -1.0) * self.drag_force; self.cannonball.apply_force(drag); if self.cannonball.bounced { let drag = (self.cannonball.rotation_velocity * -1.0) * self.drag_force; self.cannonball.apply_rotation_drag(drag); } else {...
self.handle_window_size_change(context, arena_size)?; self.cannonball.apply_force(self.gravity_force); if self.cannonball.location.y > arena_size.1 { self.cannonball.location.y = arena_size.1;
random_line_split
lib.rs
mod cannonball; use bbggez::ggez::{ event::EventHandler, graphics, nalgebra::{Point2, Vector2}, timer, Context, GameResult, }; use bbggez::traits::NatureOfCode; use bbggez::{rand, rand::prelude::*}; use cannonball::Cannonball; pub struct Game { cannonball: Cannonball, gravity_force: Vector2<f32>, drag_force: f...
fn handle_window_size_change( &self, context: &mut Context, (width, height): (f32, f32), ) -> GameResult<()> { graphics::set_screen_coordinates(context, graphics::Rect::new(0.0, 0.0, width, height)) } } impl EventHandler for Game { fn update(&mut self, context: &mut Context) -> GameResult<()> { let del...
{ let (_arena_width, arena_height) = graphics::drawable_size(context); let mass = 500.0; let mut cannonball = Cannonball::new(10.0, arena_height - 10.0, mass, context); cannonball.velocity = Vector2::new(500000.0, -500000.0) / mass; let gravity_force = Vector2::new(0.0, 1.0); let drag_force = 0.001; Gam...
identifier_body
threadmanager.rs
// rustyVM - Java VM written in pure Rust // Copyright (c) 2013 Alexander Gessler // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the r...
t.add_thread(16); assert_eq!(t.get_state(), TMS_Running); } #[test] #[should_fail] fn test_threadmanager_groups_cannot_remove_nonexistent_thread() { let mut t = ThreadManager::new(); t.remove_thread(1); } #[test] #[should_fail] fn test_threadmanager_groups_cannot_reuse_tid() { let mut t = Thread...
t.remove_thread(12); assert_eq!(t.get_state(), TMS_AllNonDaemonsDead);
random_line_split
threadmanager.rs
// rustyVM - Java VM written in pure Rust // Copyright (c) 2013 Alexander Gessler // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the r...
(&mut self, tid : uint) { assert!(!self.threads.contains_key(&tid)); self.threads.insert(tid, GlobThreadInfo { tid : tid, name : ~"", priority : 0, daemon : false, }); self.alive_nondaemon_count += 1; self.state = TMS_Running; } // ---------------------------------------------- // Unregiste...
add_thread
identifier_name
threadmanager.rs
// rustyVM - Java VM written in pure Rust // Copyright (c) 2013 Alexander Gessler // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the r...
// ---------------------------------------------- pub fn get_state(&self) -> ThreadManagerState { self.state } // ---------------------------------------------- // Register a thread with the ThreadManager pub fn add_thread(&mut self, tid : uint) { assert!(!self.threads.contains_key(&tid)); self.thread...
{ ThreadManager{ threads : HashMap::new(), alive_nondaemon_count : 0, state : TMS_NoThreadSeenYet, stopped_threads : ~[], } }
identifier_body
login.rs
use crate::core::prelude::*; //TODO: remove and use Credentials instead #[derive(Deserialize, Debug, Clone)] pub struct Login { username: String, password: String, } pub struct Credentials<'a> { pub email: &'a str, pub password: &'a str, } //TODO: remove and use email instead pub fn login_with_userna...
Err(err) => match err { RepoError::NotFound => Err(Error::Parameter(ParameterError::Credentials)), _ => Err(Error::Repo(RepoError::Other(Box::new(err)))), }, } } pub fn login_with_email<D: Db>(db: &D, login: &Credentials) -> Result<Role> { match db.get_users_by_email(&lo...
random_line_split
login.rs
use crate::core::prelude::*; //TODO: remove and use Credentials instead #[derive(Deserialize, Debug, Clone)] pub struct Login { username: String, password: String, } pub struct Credentials<'a> { pub email: &'a str, pub password: &'a str, } //TODO: remove and use email instead pub fn
<D: Db>(db: &D, login: &Login) -> Result<String> { match db.get_user(&login.username) { Ok(u) => { if u.password.verify(&login.password) { if u.email_confirmed { Ok(login.username.clone()) } else { Err(Error::Parameter(Param...
login_with_username
identifier_name
dynamic_lib.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} }; unsafe { if use_thread_mode { SetThreadErrorMode(prev_error_mode, ptr::null_mut()); } else { SetErrorMode(prev_error_mode); } } result } pub fn check_for_errors_in<T, F>(f: F) -> Result<T, St...
{ Ok(handle as *mut u8) }
conditional_block
dynamic_lib.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(filename: Option<&OsStr>) -> Result<*mut u8, String> { check_for_errors_in(|| { unsafe { match filename { Some(filename) => open_external(filename), None => open_internal(), } } }) } const LAZY: lib...
open
identifier_name
dynamic_lib.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
pub unsafe fn close(handle: *mut u8) { dlclose(handle as *mut libc::c_void); () } extern { fn dlopen(filename: *const libc::c_char, flag: libc::c_int) -> *mut libc::c_void; fn dlerror() -> *mut libc::c_char; fn dlsym(handle: *mut libc::c_void, ...
{ dlsym(handle as *mut libc::c_void, symbol) as *mut u8 }
identifier_body
dynamic_lib.rs
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// Windows >= 7 supports thread error mode. let result = SetThreadErrorMode(new_error_mode, &mut prev_error_mode); if result == 0 { let err = os::errno(); if err as libc::c_int == ERROR_CALL_NOT_IMPLEMENTED { use_thread_mode = false...
let new_error_mode = 1; let mut prev_error_mode = 0;
random_line_split
gradient.rs
// Copyright 2013 The Noise-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ...
#[inline(always)] pub fn get4<T: Float>(index: usize) -> math::Point4<T> { gradient(index) }
{ let value = gradient(index); [value[0], value[1], value[2]] }
identifier_body
gradient.rs
// Copyright 2013 The Noise-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ...
22 => [-one, -one, zero, one], 23 => [-one, -one, zero, -one], 24 => [ one, one, one, zero], 25 => [ one, one, -one, zero], 26 => [ one, -one, one, zero], 27 => [ one, -one, -one, zero], 28 => [-one, one, one, zero], 29 => ...
random_line_split
gradient.rs
// Copyright 2013 The Noise-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ...
<T: Float>(index: usize) -> math::Point2<T> { let value = gradient(index); [value[0], value[1]] } #[inline(always)] pub fn get3<T: Float>(index: usize) -> math::Point3<T> { let value = gradient(index); [value[0], value[1], value[2]] } #[inline(always)] pub fn get4<T: Float>(index: usize) -> math::Poin...
get2
identifier_name
qquote.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(unused_imports)] // ignore-cross-compile #![feature(quote, rustc_private)] ex...
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
qquote.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 ...
let item = quote_item!(cx, static x: $ty = 10;).unwrap(); check!(item_to_string, item, quote_item!(cx, $item).unwrap(); "static x: isize = 10;"); let twenty: u16 = 20; let stmt = quote_stmt!(cx, let x = $twenty;).unwrap(); check!(stmt_to_string, stmt, quote_stmt!(cx, $stmt).unwrap(); "let x = 20u1...
{ let ps = syntax::parse::ParseSess::new(FilePathMapping::empty()); let mut resolver = syntax::ext::base::DummyResolver; let mut cx = syntax::ext::base::ExtCtxt::new( &ps, syntax::ext::expand::ExpansionConfig::default("qquote".to_string()), &mut resolver); let cx = &mut cx; ...
identifier_body
qquote.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 ...
() { syntax::with_globals(|| run()); } fn run() { let ps = syntax::parse::ParseSess::new(FilePathMapping::empty()); let mut resolver = syntax::ext::base::DummyResolver; let mut cx = syntax::ext::base::ExtCtxt::new( &ps, syntax::ext::expand::ExpansionConfig::default("qquote".to_string())...
main
identifier_name
closure.rs
// rustfmt-normalize_comments: true // Closures fn main() { let square = ( |i: i32 | i * i ); let commented = |/* first */ a /*argument*/, /* second*/ b: WithType /* argument*/, /* ignored */ _ | (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb); let block_body = ...
() { {{{ let explicit_arg_decls = explicit_arguments.into_iter() .enumerate() .map(|(index, (ty, pattern))| { let lvalue = Lvalue::Arg(index as u32); block = this.pattern(block, argument_extent, ...
issue470
identifier_name
closure.rs
// rustfmt-normalize_comments: true // Closures fn main() { let square = ( |i: i32 | i * i ); let commented = |/* first */ a /*argument*/, /* second*/ b: WithType /* argument*/, /* ignored */ _ | (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb); let block_body = ...
fn issue1405() { open_raw_fd(fd, b'r') .and_then(|file| Capture::new_raw(None, |_, err| unsafe { raw::pcap_fopen_offline(file, err) })); } fn issue1466() { let vertex_buffer = frame.scope(|ctx| { let buffer = ctx.create_host_visible_buffer::<VertexBuffer<Vertex>...
{ lifetimes_iter___map(|lasdfasfd| { let hi = if l.bounds.is_empty() { l.lifetime.span.hi() }; }); }
identifier_body
closure.rs
// rustfmt-normalize_comments: true // Closures fn main() { let square = ( |i: i32 | i * i ); let commented = |/* first */ a /*argument*/, /* second*/ b: WithType /* argument*/, /* ignored */ _ | (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb); let block_body = ...
} fn issue1713() { rayon::join( || recurse(left, is_less, pred, limit), || recurse(right, is_less, Some(pivot), limit), ); rayon::join( 1, || recurse(left, is_less, pred, limit), 2, || recurse(right, is_less, Some(pivot), limit), ); } fn issue2063() { ...
foooooo(|_referencefffffffff: _, _target_reference: _, _oid: _, _target_oid: _| format!("refs/pull/{}/merge", pr_id))
random_line_split
closure.rs
// rustfmt-normalize_comments: true // Closures fn main() { let square = ( |i: i32 | i * i ); let commented = |/* first */ a /*argument*/, /* second*/ b: WithType /* argument*/, /* ignored */ _ | (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb); let block_body = ...
else { PERIPHERALS = true; } }) } fn issue2207() { a.map(|_| unsafe { a_very_very_very_very_very_very_very_long_function_name_or_anything_else() }.to_string()) } fn issue2262() { result.init(&mut result.slave.borrow_mut(), &mut (result.strategy)()).map_err(|factory| Error ...
{ loop {} }
conditional_block
main.rs
use std::io::BufReader; use std::io::BufWriter; use std::io::prelude::*; use std::fs::File; fn main()
if should_write(&line, &mut in_text, &vec) { writer.write(line.as_bytes()).unwrap(); writer.write(b"\n").unwrap(); } } } fn should_write(x: &str, in_text: &mut bool, list : &Vec<String>) -> bool { if x.contains("<text") { *in_text = true; } else if x.contains("</text>") { *in_text = false; } list....
{ let mut input_path: String = String::new(); let mut output_path = String::new(); let mut input = std::io::stdin(); let mut vec = vec![String::from("<page>"),String::from("</page>")]; println!("Enter the path of the input file: "); input.read_line(&mut input_path).unwrap(); let input_path = input_path.trim(); ...
identifier_body
main.rs
use std::io::BufReader; use std::io::BufWriter; use std::io::prelude::*; use std::fs::File; fn main() { let mut input_path: String = String::new(); let mut output_path = String::new(); let mut input = std::io::stdin(); let mut vec = vec![String::from("<page>"),String::from("</page>")]; println!("Enter the path of...
} option.clear(); println!("Capture timestamp? y/n?"); input.read_line(&mut option).unwrap(); if option.trim().eq("y") { vec.push(String::from("<timestamp>")); } option.clear(); println!("Capture username? y/n?"); input.read_line(&mut option).unwrap(); if option.trim().eq("y") { vec.push(String::from("<co...
random_line_split
main.rs
use std::io::BufReader; use std::io::BufWriter; use std::io::prelude::*; use std::fs::File; fn
() { let mut input_path: String = String::new(); let mut output_path = String::new(); let mut input = std::io::stdin(); let mut vec = vec![String::from("<page>"),String::from("</page>")]; println!("Enter the path of the input file: "); input.read_line(&mut input_path).unwrap(); let input_path = input_path.trim()...
main
identifier_name
main.rs
use std::io::BufReader; use std::io::BufWriter; use std::io::prelude::*; use std::fs::File; fn main() { let mut input_path: String = String::new(); let mut output_path = String::new(); let mut input = std::io::stdin(); let mut vec = vec![String::from("<page>"),String::from("</page>")]; println!("Enter the path of...
} } fn should_write(x: &str, in_text: &mut bool, list : &Vec<String>) -> bool { if x.contains("<text") { *in_text = true; } else if x.contains("</text>") { *in_text = false; } list.iter().any(|tag| x.contains(tag)) } fn get_options(input: &mut std::io::Stdin, vec : &mut Vec<String>) -> () { let mut option ...
{ writer.write(line.as_bytes()).unwrap(); writer.write(b"\n").unwrap(); }
conditional_block