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 |
|---|---|---|---|---|
bench.rs | #![feature(test)]
extern crate robots;
extern crate test;
use std::any::Any;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender};
use robots::actors::{Actor, ActorSystem, ActorCell, ActorContext, Props};
use test::Bencher;
#[derive(Copy, Clone, PartialEq)]
enum BenchMessage {
Nothing,
Over,... |
let props = Props::new(Arc::new(Dummy::new), ());
b.iter(|| {
for i in 0..1_000 {
actor_system.actor_of(props.clone(), format!("{}", i));
}
});
actor_system.shutdown();
} | /// Since actor creation is synchronous this is ok to just call the function mutiple times.
/// The created actor is empty in order to just bench the overhead of creation.
fn create_1000_actors(b: &mut Bencher) {
let actor_system = ActorSystem::new("test".to_owned()); | random_line_split |
term_query.rs | use super::term_weight::TermWeight;
use crate::query::bm25::Bm25Weight;
use crate::query::Weight;
use crate::query::{Explanation, Query};
use crate::schema::IndexRecordOption;
use crate::Searcher;
use crate::Term;
use std::collections::BTreeMap;
use std::fmt;
/// A Term query matches all of the documents
/// containin... | /// );
/// let (top_docs, count) = searcher.search(&query, &(TopDocs::with_limit(2), Count))?;
/// assert_eq!(count, 2);
/// Ok(())
/// # }
/// # assert!(test().is_ok());
/// ```
#[derive(Clone)]
pub struct TermQuery {
term: Term,
index_record_option: IndexRecordOption,
}
impl fmt::Debug for TermQuery {
fn... | /// IndexRecordOption::Basic, | random_line_split |
term_query.rs | use super::term_weight::TermWeight;
use crate::query::bm25::Bm25Weight;
use crate::query::Weight;
use crate::query::{Explanation, Query};
use crate::schema::IndexRecordOption;
use crate::Searcher;
use crate::Term;
use std::collections::BTreeMap;
use std::fmt;
/// A Term query matches all of the documents
/// containin... | ;
Ok(TermWeight::new(
self.term.clone(),
index_record_option,
bm25_weight,
scoring_enabled,
))
}
}
impl Query for TermQuery {
fn weight(&self, searcher: &Searcher, scoring_enabled: bool) -> crate::Result<Box<dyn Weight>> {
Ok(Box::new(
... | {
IndexRecordOption::Basic
} | conditional_block |
term_query.rs | use super::term_weight::TermWeight;
use crate::query::bm25::Bm25Weight;
use crate::query::Weight;
use crate::query::{Explanation, Query};
use crate::schema::IndexRecordOption;
use crate::Searcher;
use crate::Term;
use std::collections::BTreeMap;
use std::fmt;
/// A Term query matches all of the documents
/// containin... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "TermQuery({:?})", self.term)
}
}
impl TermQuery {
/// Creates a new term query.
pub fn new(term: Term, segment_postings_options: IndexRecordOption) -> TermQuery {
TermQuery {
term,
index_record_option: segme... | fmt | identifier_name |
term_query.rs | use super::term_weight::TermWeight;
use crate::query::bm25::Bm25Weight;
use crate::query::Weight;
use crate::query::{Explanation, Query};
use crate::schema::IndexRecordOption;
use crate::Searcher;
use crate::Term;
use std::collections::BTreeMap;
use std::fmt;
/// A Term query matches all of the documents
/// containin... |
/// Returns a weight object.
///
/// While `.weight(...)` returns a boxed trait object,
/// this method return a specific implementation.
/// This is useful for optimization purpose.
pub fn specialized_weight(
&self,
searcher: &Searcher,
scoring_enabled: bool,
) -> ... | {
&self.term
} | identifier_body |
primitives.rs | use sdl2::render::Renderer;
use matrix::*;
pub struct Point2D {
pub x: f32,
pub y: f32,
}
impl Point2D {
pub fn new(x: f32, y: f32) -> Point2D {
Point2D {
x: x,
y: y,
}
}
}
pub trait Primitive2D {
fn to_matrix(&self) -> Matrix;
fn fro... | }
fn rotate(&mut self, angle: f32) {
let obj = self.to_matrix();
let (x, y) = (obj.matrix[2][0], obj.matrix[2][1]);
self.from_matrix(
&(obj *
translation_matrix(-x, -y) *
rotation_matrix(angle) *
translation_matrix(x, y))
... | translation_matrix(x, y))
);
| random_line_split |
primitives.rs | use sdl2::render::Renderer;
use matrix::*;
pub struct | {
pub x: f32,
pub y: f32,
}
impl Point2D {
pub fn new(x: f32, y: f32) -> Point2D {
Point2D {
x: x,
y: y,
}
}
}
pub trait Primitive2D {
fn to_matrix(&self) -> Matrix;
fn from_matrix(&mut self, m: &Matrix);
fn draw(&self, renderer: ... | Point2D | identifier_name |
primitives.rs | use sdl2::render::Renderer;
use matrix::*;
pub struct Point2D {
pub x: f32,
pub y: f32,
}
impl Point2D {
pub fn new(x: f32, y: f32) -> Point2D {
Point2D {
x: x,
y: y,
}
}
}
pub trait Primitive2D {
fn to_matrix(&self) -> Matrix;
fn fro... |
}
| {
let obj = self.to_matrix();
let (x, y) = (obj.matrix[2][0], obj.matrix[2][1]);
self.from_matrix(
&(obj *
translation_matrix(-x, -y) *
rotation_matrix(angle) *
translation_matrix(x, y))
);
} | identifier_body |
main.rs | #![feature(plugin)]
#![plugin(rocket_codegen)]
#![feature(custom_derive)]
extern crate chrono;
extern crate rocket;
extern crate postgres;
extern crate serde_json;
extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
mod webapp_config;
mod date_field;
use std::env;
use std::path::{Path, PathBuf};
... | (file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(file)).ok()
}
fn main() {
if webapp_config::use_local_static_handler() {
rocket::ignite().mount("/", routes![index, get_donation_data, get_donation_data_update, static_files]).launch()
} else {
rocket::ignite().mount("/", routes![... | static_files | identifier_name |
main.rs | #![feature(plugin)]
#![plugin(rocket_codegen)]
#![feature(custom_derive)]
extern crate chrono;
extern crate rocket;
extern crate postgres;
extern crate serde_json;
extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
mod webapp_config;
mod date_field;
use std::env;
use std::path::{Path, PathBuf};
... | use rocket::response::{content, NamedFile};
#[macro_use]
extern crate lazy_static;
lazy_static!{
static ref DATABASE_URI: String = env::var("GDQ_DATABASE_URI").unwrap();
static ref CURRENT_EVENT_ID: String = env::var("GDQ_LIVE_EVENT_ID").unwrap();
}
static DONATAION_DATA_QUERY: &'static str = "SELECT id, timestamp... | use rocket_contrib::JSON; | random_line_split |
main.rs | #![feature(plugin)]
#![plugin(rocket_codegen)]
#![feature(custom_derive)]
extern crate chrono;
extern crate rocket;
extern crate postgres;
extern crate serde_json;
extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
mod webapp_config;
mod date_field;
use std::env;
use std::path::{Path, PathBuf};
... | {
if webapp_config::use_local_static_handler() {
rocket::ignite().mount("/", routes![index, get_donation_data, get_donation_data_update, static_files]).launch()
} else {
rocket::ignite().mount("/", routes![index, get_donation_data, get_donation_data_update]).launch()
}
} | identifier_body | |
main.rs | #![feature(plugin)]
#![plugin(rocket_codegen)]
#![feature(custom_derive)]
extern crate chrono;
extern crate rocket;
extern crate postgres;
extern crate serde_json;
extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
mod webapp_config;
mod date_field;
use std::env;
use std::path::{Path, PathBuf};
... | else {
rocket::ignite().mount("/", routes![index, get_donation_data, get_donation_data_update]).launch()
}
} | {
rocket::ignite().mount("/", routes![index, get_donation_data, get_donation_data_update, static_files]).launch()
} | conditional_block |
plugin_crate_outlive_expansion_phase.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 ... |
use std::any::Any;
use std::cell::RefCell;
use rustc::plugin::Registry;
struct Foo {
foo: int
}
impl Drop for Foo {
fn drop(&mut self) {}
}
#[plugin_registrar]
pub fn registrar(_: &mut Registry) {
thread_local!(static FOO: RefCell<Option<Box<Any+Send>>> = RefCell::new(None));
FOO.with(|s| *s.borrow_... | random_line_split | |
plugin_crate_outlive_expansion_phase.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 ... | {
foo: int
}
impl Drop for Foo {
fn drop(&mut self) {}
}
#[plugin_registrar]
pub fn registrar(_: &mut Registry) {
thread_local!(static FOO: RefCell<Option<Box<Any+Send>>> = RefCell::new(None));
FOO.with(|s| *s.borrow_mut() = Some(box Foo { foo: 10 } as Box<Any+Send>));
}
| Foo | identifier_name |
imports.rs | use super::namespaces;
use crate::{library::Library, nameutil::crate_name, version::Version};
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::btree_map::BTreeMap;
use std::collections::HashSet;
use std::ops::{Deref, DerefMut};
use std::vec::IntoIter;
fn is_first_char_up(s: &str) -> bool {
s.cha... |
/// Declares that `name` is defined in scope
///
/// Removes existing imports from `self.map` and marks `name` as
/// available to counter future import "requests".
pub fn add_defined(&mut self, name: &str) {
if self.defined.insert(name.to_owned()) {
self.map.remove(name);
... | {
// The ffi namespace is used directly, including it is a programmer error.
assert_ne!(name, "crate::ffi");
if (!name.contains("::") && name != "xlib") || self.defined.contains(name) {
false
} else if let Some(name) = name.strip_prefix("crate::") {
!self.defined... | identifier_body |
imports.rs | use super::namespaces;
use crate::{library::Library, nameutil::crate_name, version::Version};
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::btree_map::BTreeMap;
use std::collections::HashSet;
use std::ops::{Deref, DerefMut};
use std::vec::IntoIter;
fn is_first_char_up(s: &str) -> bool {
s.cha... | (&mut self, name: &str) {
if!self.common_checks(name) {
return;
}
if let Some(mut name) = self.strip_crate_name(name) {
if name == "xlib" {
name = if self.crate_name == "gdk_x11" {
// Dirty little hack to allow to have correct import fo... | add | identifier_name |
imports.rs | use super::namespaces;
use crate::{library::Library, nameutil::crate_name, version::Version};
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::btree_map::BTreeMap;
use std::collections::HashSet;
use std::ops::{Deref, DerefMut};
use std::vec::IntoIter;
fn is_first_char_up(s: &str) -> bool {
s.cha... | entry
};
entry.update_version(version);
}
}
/// Declares that name should be available through its full path.
///
/// For example, if name is `X::Y` then it will be available as `X::Y`.
pub fn add_used_type(&mut self, used_type: &str) {
if let... | // Since there is no constraint on this import, if any constraint
// is present, we can just remove it.
entry.constraints.clear(); | random_line_split |
imports.rs | use super::namespaces;
use crate::{library::Library, nameutil::crate_name, version::Version};
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::btree_map::BTreeMap;
use std::collections::HashSet;
use std::ops::{Deref, DerefMut};
use std::vec::IntoIter;
fn is_first_char_up(s: &str) -> bool {
s.cha... | else {
// gtk has a module named "xlib" which is why this hack is needed too.
Cow::Borrowed("crate::xlib")
};
}
let defaults = &self.defaults;
let entry = self
.map
.entry(name.into_owned())
... | {
// Dirty little hack to allow to have correct import for GDKX11.
Cow::Borrowed("x11::xlib")
} | conditional_block |
text_run.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 app_units::Au;
use font::{Font, FontHandleMethods, FontMetrics, IS_WHITESPACE_SHAPING_FLAG, RunMetrics};
use f... | if text_run_ptr == (self as *const TextRun) {
index_of_first_glyph_run_cache.set(None);
}
}
})
}
}
/// A single series of glyphs within a text run.
#[derive(Clone, Deserialize, Serialize)]
pub struct GlyphRun {
/// The glyphs.
pub glyp... | random_line_split | |
text_run.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 app_units::Au;
use font::{Font, FontHandleMethods, FontMetrics, IS_WHITESPACE_SHAPING_FLAG, RunMetrics};
use f... | (&self, range: &Range<CharIndex>) -> Au {
debug!("iterating outer range {:?}", range);
self.natural_word_slices_in_range(range).fold(Au(0), |max_piece_width, slice| {
debug!("iterated on {:?}[{:?}]", slice.offset, slice.range);
max(max_piece_width, self.advance_for_range(&slice.r... | min_width_for_range | identifier_name |
text_run.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 app_units::Au;
use font::{Font, FontHandleMethods, FontMetrics, IS_WHITESPACE_SHAPING_FLAG, RunMetrics};
use f... | if!char_range.is_empty() {
Some(TextRunSlice {
glyphs: &*slice_glyphs.glyph_store,
offset: slice_range_begin,
range: char_range,
})
} else {
None
}
}
}
pub struct CharacterSliceIterator<'a> {
glyph_run:... | {
let slice_glyphs;
if self.reverse {
if self.index == 0 {
return None;
}
self.index -= 1;
slice_glyphs = &self.glyphs[self.index];
} else {
if self.index >= self.glyphs.len() {
return None;
}... | identifier_body |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::Duration;
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_raftstore::*... | stale_key,
®ion1000,
&leader1000,
®ion1,
&leader1,
apply_commit_merge,
);
}
#[test]
fn test_read_index_when_transfer_leader_2() {
let mut cluster = new_node_cluster(0, 3);
// Increase the election tick to make this test case running reliably.
confi... | // A key that is covered by region 1000 and region 1.
let stale_key = key2;
must_not_stale_read(
&mut cluster, | random_line_split |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::Duration;
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_raftstore::*... | assert!(
value1.as_ref().unwrap().get_header().has_error(),
"{:?}",
value1
);
}
#[test]
fn test_node_stale_read_during_splitting_left_derive() {
stale_read_during_splitting(false);
}
#[test]
fn test_node_stale_read_during_splitting_right_derive() {
stale_read_during_splitting(... | {
let value1 = read_on_peer(
cluster,
old_leader.clone(),
old_region.clone(),
key,
read_quorum,
Duration::from_secs(1),
);
let value2 = read_on_peer(
cluster,
new_leader.clone(),
new_region.clone(),
key,
read_quorum,
... | identifier_body |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::Duration;
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_raftstore::*... |
}
}
// Resume reserved messages in one batch to make sure the old leader can get read and role
// change in one `Ready`.
fail::cfg("pause_on_peer_collect_message", "pause").unwrap();
for raft_msg in reserved_msgs {
router.send_raft_message(raft_msg).unwrap();
}
fail::cfg("p... | {
reserved_msgs.push(raft_msg);
if msg_type == MessageType::MsgAppend {
break 'LOOP;
}
} | conditional_block |
test_stale_read.rs | // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::atomic::*;
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::Duration;
use kvproto::metapb::{Peer, Region};
use raft::eraftpb::MessageType;
use pd_client::PdClient;
use raftstore::store::Callback;
use test_raftstore::*... | (
cluster: &mut Cluster<NodeCluster>,
key: &[u8],
value: &[u8],
read_quorum: bool,
old_region: &Region,
old_leader: &Peer,
new_region: &Region,
new_leader: &Peer,
) {
let value1 = read_on_peer(
cluster,
old_leader.clone(),
old_region.clone(),
key,
... | must_not_eq_on_key | identifier_name |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... |
}
}
unsafe { JS_EndRequest(self.cx); }
}
}
| {
JS_RestoreFrameChain(self.cx);
} | conditional_block |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... |
/// Initialize the callback function with a value.
/// Should be called once this object is done moving.
pub fn init(&mut self, callback: *mut JSObject) {
self.object.callback.set(callback);
}
/// Returns the property with the given `name`, if it is a callable object,
/// or an error ... | {
CallbackInterface {
object: CallbackObject {
callback: Heap::default()
}
}
} | identifier_body |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... | (&self) -> *mut JSContext {
self.cx
}
}
impl Drop for CallSetup {
fn drop(&mut self) {
unsafe { JS_LeaveCompartment(self.cx, self.old_compartment); }
let need_to_deal_with_exception =
self.handling == ExceptionHandling::Report &&
unsafe { JS_IsExceptionPending(se... | get_context | identifier_name |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... | exception_compartment: RootedObject,
/// The `JSContext` used for the call.
cx: *mut JSContext,
/// The compartment we were in before the call.
old_compartment: *mut JSCompartment,
/// The exception handling used for the call.
handling: ExceptionHandling,
}
impl CallSetup {
/// Performs... | /// The compartment for reporting exceptions.
/// As a RootedObject, this must be the first field in order to
/// determine the final address on the stack correctly. | random_line_split |
klondike.rs | /*
* Copyright (c) 2018 Erik Nordstrøm <erik@nordstroem.no>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS... | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
use arrayvec::ArrayVec;
use std::ops::Deref;
use cards::Card;
impl_cardstack!(StockSlot, Stoc... | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | random_line_split |
klondike.rs | /*
* Copyright (c) 2018 Erik Nordstrøm <erik@nordstroem.no>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS... | {
pub stock: StockSlot,
pub waste_pile: WastePileSlot,
pub foundations: [FoundationSlot; 4],
pub tableau: [TableauSlot; 7],
}
| able
| identifier_name |
moves-based-on-type-exprs.rs | // Tests that references to move-by-default values trigger moves when
// they occur as part of various kinds of expressions.
struct Foo<A> { f: A }
fn guard(_s: ~str) -> bool {fail!()}
fn touch<A>(_a: &A) {}
fn f10() {
let x = ~"hi";
let _y = Foo { f:x };
touch(&x); //~ ERROR use of moved value: `x`
}
fn... | () {
let x = ~[~"hi"];
let _y = [x[0],..1];
touch(&x); //~ ERROR use of partially moved value: `x`
}
fn f120() {
let x = ~[~"hi", ~"ho"];
x[0] <-> x[1];
touch(&x[0]);
touch(&x[1]);
}
fn main() {}
| f110 | identifier_name |
moves-based-on-type-exprs.rs | // Tests that references to move-by-default values trigger moves when
// they occur as part of various kinds of expressions.
struct Foo<A> { f: A }
fn guard(_s: ~str) -> bool {fail!()}
fn touch<A>(_a: &A) {}
fn f10() {
let x = ~"hi";
let _y = Foo { f:x };
touch(&x); //~ ERROR use of moved value: `x`
}
fn... |
fn f100() {
let x = ~[~"hi"];
let _y = x[0];
touch(&x); //~ ERROR use of partially moved value: `x`
}
fn f110() {
let x = ~[~"hi"];
let _y = [x[0],..1];
touch(&x); //~ ERROR use of partially moved value: `x`
}
fn f120() {
let x = ~[~"hi", ~"ho"];
x[0] <-> x[1];
touch(&x[0]);
... | {
let x = ~"hi";
let _y = @[x];
touch(&x); //~ ERROR use of moved value: `x`
} | identifier_body |
moves-based-on-type-exprs.rs | // Tests that references to move-by-default values trigger moves when
// they occur as part of various kinds of expressions.
struct Foo<A> { f: A }
fn guard(_s: ~str) -> bool {fail!()}
fn touch<A>(_a: &A) {}
fn f10() {
let x = ~"hi";
let _y = Foo { f:x };
touch(&x); //~ ERROR use of moved value: `x`
}
fn... | touch(&y); //~ ERROR use of moved value: `y`
}
fn f40(cond: bool) {
let x = ~"hi", y = ~"ho";
let _y = match cond {
true => x,
false => y
};
touch(&x); //~ ERROR use of moved value: `x`
touch(&y); //~ ERROR use of moved value: `y`
}
fn f50(cond: bool) {
let x = ~"hi", y = ~... | y
};
touch(&x); //~ ERROR use of moved value: `x` | random_line_split |
feature-gate.rs | // Test that use of structural-match traits is only permitted with a feature gate,
// and that if a feature gate is supplied, it permits the type to be
// used in a match.
// revisions: with_gate no_gate
// gate-test-structural_match
#![allow(unused)]
#![feature(rustc_attrs)]
#![cfg_attr(with_gate, feature(structura... |
impl std::marker::StructuralPartialEq for Foo { }
//[no_gate]~^ ERROR use of unstable library feature'structural_match'
impl std::marker::StructuralEq for Foo { }
//[no_gate]~^ ERROR use of unstable library feature'structural_match'
impl PartialEq<Foo> for Foo {
fn eq(&self, other: &Self) -> bool {
self.... | { //[with_gate]~ ERROR fatal error triggered by #[rustc_error]
let y = Foo { x: 1 };
match y {
FOO => { }
_ => { }
}
} | identifier_body |
feature-gate.rs | // Test that use of structural-match traits is only permitted with a feature gate,
// and that if a feature gate is supplied, it permits the type to be
// used in a match.
// revisions: with_gate no_gate
// gate-test-structural_match
#![allow(unused)]
#![feature(rustc_attrs)]
#![cfg_attr(with_gate, feature(structura... | () { //[with_gate]~ ERROR fatal error triggered by #[rustc_error]
let y = Foo { x: 1 };
match y {
FOO => { }
_ => { }
}
}
impl std::marker::StructuralPartialEq for Foo { }
//[no_gate]~^ ERROR use of unstable library feature'structural_match'
impl std::marker::StructuralEq for Foo { }
//[no_... | main | identifier_name |
feature-gate.rs | // Test that use of structural-match traits is only permitted with a feature gate,
// and that if a feature gate is supplied, it permits the type to be
// used in a match.
// revisions: with_gate no_gate
// gate-test-structural_match
#![allow(unused)]
#![feature(rustc_attrs)]
#![cfg_attr(with_gate, feature(structura... | self.x == other.x
}
}
impl Eq for Foo { } | //[no_gate]~^ ERROR use of unstable library feature 'structural_match'
impl PartialEq<Foo> for Foo {
fn eq(&self, other: &Self) -> bool { | random_line_split |
feature-gate.rs | // Test that use of structural-match traits is only permitted with a feature gate,
// and that if a feature gate is supplied, it permits the type to be
// used in a match.
// revisions: with_gate no_gate
// gate-test-structural_match
#![allow(unused)]
#![feature(rustc_attrs)]
#![cfg_attr(with_gate, feature(structura... |
_ => { }
}
}
impl std::marker::StructuralPartialEq for Foo { }
//[no_gate]~^ ERROR use of unstable library feature'structural_match'
impl std::marker::StructuralEq for Foo { }
//[no_gate]~^ ERROR use of unstable library feature'structural_match'
impl PartialEq<Foo> for Foo {
fn eq(&self, other: &Self... | { } | conditional_block |
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 ... |
fn defer<'r>(b: &'r mut bool) -> defer<'r> {
defer {
b: b
}
}
pub fn main() {
let mut dtor_ran = false;
defer(&mut dtor_ran);
assert!((dtor_ran));
} | } | 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 ... | <'r>(b: &'r mut bool) -> defer<'r> {
defer {
b: b
}
}
pub fn main() {
let mut dtor_ran = false;
defer(&mut dtor_ran);
assert!((dtor_ran));
}
| 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 ... |
}
fn defer<'r>(b: &'r mut bool) -> defer<'r> {
defer {
b: b
}
}
pub fn main() {
let mut dtor_ran = false;
defer(&mut dtor_ran);
assert!((dtor_ran));
}
| {
unsafe {
*(self.b) = true;
}
} | identifier_body |
script_msg.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 AnimationState;
use DocumentState;
use IFrameLoadInfo;
use MouseButton;
use MouseEventType;
use MozBrowserEven... | {
/// Indicates whether this pipeline is currently running animations.
ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because
/// 2D canvases may use the GPU and we don't want to give untrusted content ac... | ScriptMsg | identifier_name |
script_msg.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 AnimationState;
use DocumentState;
use IFrameLoadInfo;
use MouseButton;
use MouseEventType;
use MozBrowserEven... | SetDocumentState(PipelineId, DocumentState),
/// Update the pipeline Url, which can change after redirections.
SetFinalUrl(PipelineId, Url),
} | /// Requests that the constellation set the contents of the clipboard
SetClipboardContents(String),
/// Mark a new document as active
ActivateDocument(PipelineId),
/// Set the document state for a pipeline (used by screenshot / reftests) | random_line_split |
issue-11267.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn next(&mut self) -> Option<U>;
}
impl T<int> for Empty {
fn next(&mut self) -> Option<int> { None }
}
fn do_something_with(a : &mut T<int>) {
println!("{:?}", a.next())
}
pub fn main() {
do_something_with(&mut Empty);
} | // Tests that unary structs can be mutably borrowed.
struct Empty;
trait T<U> { | random_line_split |
issue-11267.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 ... | (&mut self) -> Option<int> { None }
}
fn do_something_with(a : &mut T<int>) {
println!("{:?}", a.next())
}
pub fn main() {
do_something_with(&mut Empty);
}
| next | identifier_name |
misc.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 ... | } | assert_eq!(regex!(r"[a-z]+"), Regex::new("[a-z]+").unwrap()); | random_line_split |
misc.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 ... | () {
assert_eq!(regex!(r"[a-z]+"), Regex::new("[a-z]+").unwrap());
}
| eq | identifier_name |
misc.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 ... | {
assert_eq!(regex!(r"[a-z]+"), Regex::new("[a-z]+").unwrap());
} | identifier_body | |
eseful.rs | // Utility functions/data for EFL Rust bindings.
// Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of ... | (eb: eina::EinaBool) -> bool {
match eb {
eina::EINA_TRUE => true,
_ => false
}
}
| from_eina_to_bool | identifier_name |
eseful.rs | // Utility functions/data for EFL Rust bindings.
// Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of ... | use std::mem::forget;
use std::ffi::CString;
use eseful::libc::c_char;
use eina;
// Empty value handy to use in the 'data' field for callbacks.
pub static Empty: Option<()> = None;
// Callbacks event.
pub struct EventInfo;
pub fn to_c_args(argv: Vec<String>) -> *const *const c_char {
let mut vchars: Vec<*const c... | random_line_split | |
eseful.rs | // Utility functions/data for EFL Rust bindings.
// Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of ... | {
match eb {
eina::EINA_TRUE => true,
_ => false
}
} | identifier_body | |
scheduler.rs | //
// scheduler.rs
// Copyright (C) 2017 Szymon Urbaś <szymon.urbas@aol.com>
// Distributed under terms of the BSD (2-clause) license.
//
// Created on: 13 Mar 2017 21:03:41 +0100 (CET)
//
use process::*;
use tui::*; | fn schedule(&mut self);
fn has_processes(&self) -> bool;
fn add_process(&mut self, Process);
fn current_proc(&self) -> Option<&Process>;
fn current_proc_mut(&mut self) -> Option<&mut Process>;
fn kill_current_proc(&mut self);
fn list_processes(&self, &mut Tui);
fn increase_waiting_times(&mut self);
fn... |
pub trait Scheduler {
fn name(&self) -> String; | random_line_split |
htmlheadelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLHeadElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLEleme... |
fn bind_to_tree(&self, _tree_in_doc: bool) {
load_script(*self);
}
}
| {
let htmlelement: &&HTMLElement = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods)
} | identifier_body |
htmlheadelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLHeadElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLEleme... | pub struct HTMLHeadElement {
htmlelement: HTMLElement
}
impl HTMLHeadElementDerived for EventTarget {
fn is_htmlheadelement(&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHeadElement)))
}... | #[dom_struct]
#[derive(HeapSizeOf)] | random_line_split |
htmlheadelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLHeadElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLEleme... | (localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLHeadElement> {
let element = HTMLHeadElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLHeadElementBinding::Wrap)
}
}
impl<'a> VirtualMeth... | new | identifier_name |
match-arm-statics.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 ... | None => ()
}
}
fn unreachable_2() {
match Some(Some(North)) {
Some(NONE) => (),
Some(Some(North)) => (),
Some(Some(EAST)) => (),
Some(Some(South)) => (),
Some(Some(West)) => (),
Some(Some(East)) => (),
//~^ ERROR unreachable pattern
None =... | Some(Some(North)) => (),
Some(Some(EAST)) => (),
Some(Some(South)) => (), | random_line_split |
match-arm-statics.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 ... | () {
match (Foo { bar: Some(EAST), baz: NewBool(true) }) {
Foo { bar: None, baz: NewBool(true) } => (),
Foo { bar: _, baz: NEW_FALSE } => (),
Foo { bar: Some(West), baz: NewBool(true) } => (),
Foo { bar: Some(South),.. } => (),
Foo { bar: Some(EAST),.. } => (),
Foo { ... | unreachable_3 | identifier_name |
output.rs | //! Producing output from Value.
//!
//! This module defines how a Value is serialized as an output of the expression.
//! See also the `json` module.
#![allow(useless_format)]
use std::fmt;
use conv::TryFrom;
use conv::errors::GeneralError;
use rustc_serialize::json::ToJson;
use super::Value;
impl TryFrom<Value>... | (src: Value) -> Result<Self, Self::Err> {
String::try_from(&src)
}
}
impl<'a> TryFrom<&'a Value> for String {
type Err = <String as TryFrom<Value>>::Err;
/// Try to convert a Value to string that can be emitted
/// as a final result of a computation.
fn try_from(src: &'a Value) -> Result<S... | try_from | identifier_name |
output.rs | //! Producing output from Value.
//!
//! This module defines how a Value is serialized as an output of the expression.
//! See also the `json` module.
#![allow(useless_format)]
use std::fmt;
use conv::TryFrom;
use conv::errors::GeneralError;
use rustc_serialize::json::ToJson;
use super::Value;
impl TryFrom<Value>... | // when formatting constructs actually react to it constructively
.expect(&format!("can't display a value of type `{}`", self.typename()))
}
} | .map(|s| write!(fmt, "{}", s))
// TODO(xion): return an Err(fmt::Error) rather than panicking | random_line_split |
output.rs | //! Producing output from Value.
//!
//! This module defines how a Value is serialized as an output of the expression.
//! See also the `json` module.
#![allow(useless_format)]
use std::fmt;
use conv::TryFrom;
use conv::errors::GeneralError;
use rustc_serialize::json::ToJson;
use super::Value;
impl TryFrom<Value>... |
}
impl<'a> TryFrom<&'a Value> for String {
type Err = <String as TryFrom<Value>>::Err;
/// Try to convert a Value to string that can be emitted
/// as a final result of a computation.
fn try_from(src: &'a Value) -> Result<Self, Self::Err> {
match *src {
Value::Empty => Err(General... | {
String::try_from(&src)
} | identifier_body |
variadic-ffi.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | foo(1, 2, 1u16); //~ ERROR: can't pass u16 to variadic function, cast to c_uint
}
}
| {
unsafe {
foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
let x: unsafe extern "C" fn(f: int, x: u8) = foo;
//~^ ERROR: mismatched types: expected `u... | identifier_body |
variadic-ffi.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 ... | (f: int, x: u8) {}
fn main() {
unsafe {
foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
let x: unsafe extern "C" fn(f: int, x: u8) = foo;
//~^ ERROR:... | bar | identifier_name |
variadic-ffi.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | let y: unsafe extern "C" fn(f: int, x: u8,...) = bar;
//~^ ERROR: mismatched types: expected `unsafe extern "C" fn(int, u8,...)`
// but found `extern "C" extern fn(int, u8)`
// (expected variadic fn but found non-variadic function)
foo(1, 2, 3f32); //~ ERROR: c... | let x: unsafe extern "C" fn(f: int, x: u8) = foo;
//~^ ERROR: mismatched types: expected `unsafe extern "C" fn(int, u8)`
// but found `unsafe extern "C" fn(int, u8, ...)`
// (expected non-variadic fn but found variadic function)
| random_line_split |
tests.rs | use super::super::navigate;
use super::*;
use crate::fmt::Debug;
use crate::string::String;
impl<'a, K: 'a, V: 'a> NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal> {
// Asserts that the back pointer in each reachable node points to its parent.
pub fn assert_back_pointers(self) {
if let ForceRes... | }
}
#[test]
fn test_partial_eq() {
let mut root1 = NodeRef::new_leaf();
root1.borrow_mut().push(1, ());
let mut root1 = NodeRef::new_internal(root1.forget_type()).forget_type();
let root2 = Root::new();
root1.reborrow().assert_back_pointers();
root2.reborrow().assert_back_pointers();
... | {
for idx in 0..=CAPACITY {
let (middle_kv_idx, insertion) = splitpoint(idx);
// Simulate performing the split:
let mut left_len = middle_kv_idx;
let mut right_len = CAPACITY - middle_kv_idx - 1;
match insertion {
LeftOrRight::Left(edge_idx) => {
... | identifier_body |
tests.rs | use super::super::navigate;
use super::*;
use crate::fmt::Debug;
use crate::string::String;
impl<'a, K: 'a, V: 'a> NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal> {
// Asserts that the back pointer in each reachable node points to its parent.
pub fn assert_back_pointers(self) {
if let ForceRes... |
navigate::Position::Internal(_) => {}
navigate::Position::InternalKV(kv) => {
let depth = self.height() - kv.into_node().height();
let indent = " ".repeat(depth);
result += &format!("\n{}{:?}", indent, kv.into_kv().0);
}
});
... | {
let depth = self.height();
let indent = " ".repeat(depth);
result += &format!("\n{}{:?}", indent, leaf.keys());
} | conditional_block |
tests.rs | use super::super::navigate;
use super::*;
use crate::fmt::Debug;
use crate::string::String;
impl<'a, K: 'a, V: 'a> NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal> {
// Asserts that the back pointer in each reachable node points to its parent.
pub fn assert_back_pointers(self) {
if let ForceRes... | () {
assert_eq!(core::mem::size_of::<LeafNode<(), ()>>(), 16);
assert_eq!(core::mem::size_of::<LeafNode<i64, i64>>(), 16 + CAPACITY * 2 * 8);
assert_eq!(core::mem::size_of::<InternalNode<(), ()>>(), 16 + (CAPACITY + 1) * 8);
assert_eq!(core::mem::size_of::<InternalNode<i64, i64>>(), 16 + (CAPACITY * 3 +... | test_sizes | identifier_name |
tests.rs | use super::super::navigate;
use super::*;
use crate::fmt::Debug;
use crate::string::String;
impl<'a, K: 'a, V: 'a> NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal> {
// Asserts that the back pointer in each reachable node points to its parent.
pub fn assert_back_pointers(self) {
if let ForceRes... | }
// Renders a multi-line display of the keys in order and in tree hierarchy,
// picturing the tree growing sideways from its root on the left to its
// leaves on the right.
pub fn dump_keys(self) -> String
where
K: Debug,
{
let mut result = String::new();
self.visit... | random_line_split | |
primitive.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::lexer::TokenKind;
use common::{SourceLocationKey, Span, WithLocation};
use interner::StringKey;
use std::cmp::Ordering;
... | impl<T> List<T> {
pub fn generated(items: Vec<T>) -> Self {
Self {
span: Span::empty(),
start: Token {
span: Span::empty(),
kind: TokenKind::OpenBrace,
},
items,
end: Token {
span: Span::empty(),
... | pub start: Token,
pub items: Vec<T>,
pub end: Token,
}
| random_line_split |
primitive.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::lexer::TokenKind;
use common::{SourceLocationKey, Span, WithLocation};
use interner::StringKey;
use std::cmp::Ordering;
... |
}
| {
Self {
span: Span::empty(),
start: Token {
span: Span::empty(),
kind: TokenKind::OpenBrace,
},
items,
end: Token {
span: Span::empty(),
kind: TokenKind::CloseBrace,
},
... | identifier_body |
primitive.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::lexer::TokenKind;
use common::{SourceLocationKey, Span, WithLocation};
use interner::StringKey;
use std::cmp::Ordering;
... | <T> {
pub span: Span,
pub start: Token,
pub items: Vec<T>,
pub end: Token,
}
impl<T> List<T> {
pub fn generated(items: Vec<T>) -> Self {
Self {
span: Span::empty(),
start: Token {
span: Span::empty(),
kind: TokenKind::OpenBrace,
... | List | identifier_name |
syslog.rs | // Copyright 2015 click2stream, Inc.
//
// 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... | fn get_level(&self) -> Severity {
self.level
}
} | self.level = s;
}
| random_line_split |
syslog.rs | // Copyright 2015 click2stream, Inc.
//
// 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... |
}
impl Logger for Syslog {
fn log(&mut self, file: &str, line: u32, s: Severity, msg: Arguments) {
let msg = format!("[{}:{}] {}", file, line, msg);
let cstr_fmt = CString::new("%s").unwrap();
let cstr_msg = CString::new(msg).unwrap();
let fmt_ptr = cstr_fmt.as_ptr() as *const c_ch... | {
SYSLOG_INIT.call_once(|| unsafe {
openlog(ptr::null(), LOG_CONS | LOG_PID, LOG_USER);
});
Self {
level: Severity::INFO,
}
} | identifier_body |
syslog.rs | // Copyright 2015 click2stream, Inc.
//
// 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... | () -> Self {
Self::default()
}
}
impl Default for Syslog {
fn default() -> Self {
SYSLOG_INIT.call_once(|| unsafe {
openlog(ptr::null(), LOG_CONS | LOG_PID, LOG_USER);
});
Self {
level: Severity::INFO,
}
}
}
impl Logger for Syslog {
fn l... | new | identifier_name |
aesdec.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn aesdec_1() {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XM... |
fn aesdec_3() {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM0)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 222, 232], OperandSize::Qword)
}
fn aesdec_4... |
fn aesdec_2() {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM3)), operand2: Some(IndirectScaledDisplaced(ECX, Eight, 454573889, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: ... | random_line_split |
aesdec.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn aesdec_1() {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XM... |
fn aesdec_3() {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM0)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 222, 232], OperandSize::Qword)
}
fn aesdec_... | {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM3)), operand2: Some(IndirectScaledDisplaced(ECX, Eight, 454573889, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, ... | identifier_body |
aesdec.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn aesdec_1() {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XM... | () {
run_test(&Instruction { mnemonic: Mnemonic::AESDEC, operand1: Some(Direct(XMM5)), operand2: Some(Direct(XMM0)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 222, 232], OperandSize::Qword)
}
fn aesdec_4() {
run... | aesdec_3 | identifier_name |
lint-ctypes.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 ... | {
} | identifier_body | |
lint-ctypes.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 ... | #[repr(transparent)]
pub struct TransparentI128(i128);
#[repr(transparent)]
pub struct TransparentStr(&'static str);
#[repr(transparent)]
pub struct TransparentBadFn(RustBadRet);
#[repr(transparent)]
pub struct TransparentInt(u32);
#[repr(transparent)]
pub struct TransparentRef<'a>(&'a TransparentInt);
#[repr(transpare... | pub type RustBadRet = extern fn() -> Box<u32>;
pub type CVoidRet = ();
pub struct Foo; | random_line_split |
lint-ctypes.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 ... | <U>(f32, PhantomData<U>);
#[repr(transparent)]
pub struct TransparentCustomZst(i32, ZeroSize);
#[repr(C)]
pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData<i32>);
extern {
pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo`
pub fn ptr_type2(size: *const Foo); //~ ERROR: uses type `Foo`
... | TransparentUnit | identifier_name |
c_like.rs | // https://rustbyexample.com/custom_types/enum/c_like.html
// http://rust-lang-ja.org/rust-by-example/custom_types/enum/c_like.html
// An attribute to hide warnings for unused code.
#![allow(dead_code)]
// enum with implicit discriminator (starts at 0)
enum Number {
Zero,
One,
Two,
}
// enum with explici... | println!("roses are #{:06x}", Color::Red as i32);
println!("violets are #{:06x}", Color::Blue as i32);
} | // `enums` can be cast as integers.
println!("zero is {}", Number::Zero as i32);
println!("one is {}", Number::One as i32);
| random_line_split |
c_like.rs | // https://rustbyexample.com/custom_types/enum/c_like.html
// http://rust-lang-ja.org/rust-by-example/custom_types/enum/c_like.html
// An attribute to hide warnings for unused code.
#![allow(dead_code)]
// enum with implicit discriminator (starts at 0)
enum Number {
Zero,
One,
Two,
}
// enum with explici... | {
Red = 0xff0000,
Green = 0x00ff00,
Blue = 0x0000ff,
}
fn main() {
// `enums` can be cast as integers.
println!("zero is {}", Number::Zero as i32);
println!("one is {}", Number::One as i32);
println!("roses are #{:06x}", Color::Red as i32);
println!("violets are #{:06x}", Color::Blue ... | Color | identifier_name |
c_like.rs | // https://rustbyexample.com/custom_types/enum/c_like.html
// http://rust-lang-ja.org/rust-by-example/custom_types/enum/c_like.html
// An attribute to hide warnings for unused code.
#![allow(dead_code)]
// enum with implicit discriminator (starts at 0)
enum Number {
Zero,
One,
Two,
}
// enum with explici... | {
// `enums` can be cast as integers.
println!("zero is {}", Number::Zero as i32);
println!("one is {}", Number::One as i32);
println!("roses are #{:06x}", Color::Red as i32);
println!("violets are #{:06x}", Color::Blue as i32);
} | identifier_body | |
md4.rs | use std::cmp;
use rust_crypto::digest::Digest;
use util::{write_u64_le, write_u32v_le, read_u32v_le};
const DEFAULT_STATE: Md4State = Md4State {
state: [0x67452301_u32, 0xefcdab89, 0x98badcfe, 0x10325476]
};
#[derive(Copy, Clone)]
pub struct Md4 {
len: u64,
blocks: Blocks,
state: Md4State,
}
#[deri... |
}
impl Digest for Md4 {
fn input(&mut self, data: &[u8]) {
let len = &mut self.len;
let state = &mut self.state;
self.blocks.input(data, |chunk| {
*len += 64;
state.process(chunk);
});
}
fn result(&mut self, out: &mut [u8]) {
let mut state =... | {
Md4 {
len: len,
state: state,
blocks: Blocks {
len: 0,
block: [0; 64],
}
}
} | identifier_body |
md4.rs | use std::cmp;
use rust_crypto::digest::Digest;
use util::{write_u64_le, write_u32v_le, read_u32v_le};
const DEFAULT_STATE: Md4State = Md4State {
state: [0x67452301_u32, 0xefcdab89, 0x98badcfe, 0x10325476]
};
#[derive(Copy, Clone)]
pub struct Md4 {
len: u64,
blocks: Blocks,
state: Md4State,
}
#[deri... | (a: u32, b: u32, c: u32, d: u32, k: u32, s: u32) -> u32 {
a.wrapping_add(g(b, c, d))
.wrapping_add(k)
.wrapping_add(0x5a827999_u32)
.rotate_left(s)
}
fn op3(a: u32, b: u32, c: u32, d: u32, k: u32, s: u32) -> u32 {
a.wrapping_add(h(b, c... | op2 | identifier_name |
md4.rs | use std::cmp;
use rust_crypto::digest::Digest;
use util::{write_u64_le, write_u32v_le, read_u32v_le};
const DEFAULT_STATE: Md4State = Md4State {
state: [0x67452301_u32, 0xefcdab89, 0x98badcfe, 0x10325476]
};
#[derive(Copy, Clone)]
pub struct Md4 {
len: u64,
blocks: Blocks,
state: Md4State,
}
#[deri... | else {
self.block[..chunk.len()].copy_from_slice(chunk);
self.len = chunk.len() as u32;
}
}
}
}
impl Md4State {
fn process(&mut self, block: &[u8]) {
fn f(x: u32, y: u32, z: u32) -> u32 {
(x & y) | (!x & z)
}
fn g(x: u32, ... | {
f(chunk);
} | conditional_block |
md4.rs | use std::cmp;
use rust_crypto::digest::Digest;
use util::{write_u64_le, write_u32v_le, read_u32v_le};
const DEFAULT_STATE: Md4State = Md4State {
state: [0x67452301_u32, 0xefcdab89, 0x98badcfe, 0x10325476]
};
#[derive(Copy, Clone)]
pub struct Md4 {
len: u64,
blocks: Blocks,
state: Md4State,
}
#[deri... | let mut w = [0u32; 16];
read_u32v_le(&mut w, block);
let mut a = self.state[0];
let mut b = self.state[1];
let mut c = self.state[2];
let mut d = self.state[3];
for i in 0..4 {
let j = i * 4;
a = op1(a, b, c, d, w[j ], 3);
... | .rotate_left(s)
}
| random_line_split |
brightnessfilter.rs | rs_allocation gIn;
rs_allocation gOut;
rs_script gScript;
static int mImageWidth;
const uchar4 *gPixels;
void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) {
float4 apixel = rsUnpackColor8888(*v_in);
float3 pixel = apixel.rgb;
float factor = brightnessValue;
pixel... | #pragma version(1)
#pragma rs java_package_name(com.dss.renderscripttest)
float brightnessValue;
| random_line_split | |
alloc.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/.
//! Memory allocation
//!
//! = Description
//!
//! :allocator: link:lrs::alloc::Allocator[Allocator]
//!
//! This mo... | alloc_array, realloc_array, free_array, alloc, free, OncePool,
};
#[cfg(not(freestanding))] pub use lrs_alloc::{Bda, TlAlc};
#[cfg(not(no_libc))] pub use lrs_alloc::{Libc};
#[cfg(jemalloc)] pub use lrs_alloc::{JeMalloc}; | random_line_split | |
records.rs | //! Looking up raw records.
use futures::{Async, Future, Poll};
use ::bits::{DNameSlice, MessageBuf};
use ::iana::{Rtype, Class};
use super::super::{Query, Resolver};
use super::super::error::Error;
use super::search::SearchIter;
//------------ lookup_records ------------------------------------------------
/// Cre... | (&mut self) -> Poll<Self::Item, Self::Error> {
let err = match self.query.poll() {
Ok(Async::NotReady) => return Ok(Async::NotReady),
Ok(Async::Ready(item)) => return Ok(Async::Ready(item)),
Err(err) => err
};
let name = match self.search {
None =>... | poll | identifier_name |
records.rs | //! Looking up raw records.
use futures::{Async, Future, Poll};
use ::bits::{DNameSlice, MessageBuf};
use ::iana::{Rtype, Class};
use super::super::{Query, Resolver};
use super::super::error::Error;
use super::search::SearchIter;
//------------ lookup_records ------------------------------------------------
/// Cre... | None => return Err(err),
Some(name) => name,
}
}
};
self.query = self.resolver.clone()
.query((name, self.rtype, self.class));
self.poll()
}
} | Some(ref mut search) => {
match search.next() { | random_line_split |
globalsystems.rs | extern mod glfw;
extern mod std;
use components::{Components,texture_from_uint};
//GLOBAL SYSTEM DEFINITIONS
pub trait GlobalSystem {
fn process(&mut self, window: &glfw::Window) -> ();
}
pub struct ScoreUpdateSystem {
paddle: @Components,
counter: @Components,
score: uint,
port: Port<uint>
}
imp... |
}
pub struct KeyboardInputSystem {
paddle: @Components
}
impl GlobalSystem for KeyboardInputSystem {
fn process(&mut self, window: &glfw::Window) -> () {
let mut dir = 0.0;
if window.get_key(glfw::KeyA) == glfw::Press {
dir += 1.0;
}
if window.get_key(glfw::KeyZ) =... | {
let d = self.ball.position.unwrap().y - self.paddle.position.unwrap().y;
if std::num::abs(d) > 0.2 {
if d > 0.0 {
self.paddle.vert_velocity.unwrap().y = 1.5/60.0;
} else {
self.paddle.vert_velocity.unwrap().y = -1.5/60.0;
}
} ... | identifier_body |
globalsystems.rs | extern mod glfw;
extern mod std;
use components::{Components,texture_from_uint};
//GLOBAL SYSTEM DEFINITIONS
pub trait GlobalSystem {
fn process(&mut self, window: &glfw::Window) -> ();
}
pub struct ScoreUpdateSystem {
paddle: @Components,
counter: @Components,
score: uint,
port: Port<uint>
}
imp... | (&mut self, _: &glfw::Window) -> () {
loop {
match self.port.try_recv() {
Some(i) => {
self.score += i;
}
None => break
}
}
self.counter.sprite.unwrap().texture = Some(texture_from_uint(self.score));
... | process | identifier_name |
globalsystems.rs | extern mod glfw;
extern mod std;
use components::{Components,texture_from_uint};
//GLOBAL SYSTEM DEFINITIONS
pub trait GlobalSystem {
fn process(&mut self, window: &glfw::Window) -> ();
}
pub struct ScoreUpdateSystem {
paddle: @Components,
counter: @Components,
score: uint,
port: Port<uint>
}
imp... | }
}
}
pub struct KeyboardInputSystem {
paddle: @Components
}
impl GlobalSystem for KeyboardInputSystem {
fn process(&mut self, window: &glfw::Window) -> () {
let mut dir = 0.0;
if window.get_key(glfw::KeyA) == glfw::Press {
dir += 1.0;
}
if window.get_ke... | } else {
self.paddle.vert_velocity.unwrap().y = 0.0; | random_line_split |
sync.rs | #[macro_use]
extern crate indep;
#[macro_use]
extern crate log;
//`sync` mod contains DI set for single-threaded environments (uses Rc<RefCell<>> as an abstraction).
//We pretend that all the DI module traits and implementations are separated into different mods.
//Base trait for all depencencies. May contain no func... | (&self) -> String {
format!("Impl1 says 'Trait2'")
}
}
impl Base for Box<Impl1> {
fn init(&mut self) {
self.foo();
}
}
//Here comes `indep`.
//This macro defines requirements of the DI module implementation.
//The syntax is {Impl_Name, [... | do2 | identifier_name |
sync.rs | #[macro_use]
extern crate indep;
#[macro_use]
extern crate log;
//`sync` mod contains DI set for single-threaded environments (uses Rc<RefCell<>> as an abstraction).
//We pretend that all the DI module traits and implementations are separated into different mods.
//Base trait for all depencencies. May contain no func... |
//Here comes `indep`.
//This macro defines requirements of the DI module implementation.
//The syntax is {Impl_Name, [requirement_name_1: requirement_trait_1, requirement_name_2: requirement_trait_2],... }.
//Here `Impl1` does not have dependecies, so its requirement array is empty.
indep_reqs... | }
} | random_line_split |
sync.rs | #[macro_use]
extern crate indep;
#[macro_use]
extern crate log;
//`sync` mod contains DI set for single-threaded environments (uses Rc<RefCell<>> as an abstraction).
//We pretend that all the DI module traits and implementations are separated into different mods.
//Base trait for all depencencies. May contain no func... | {
//`Pool` is a structure created by `indep_pool_sync` macro.
let mut pool = Pool::new();
let t1 = i1::new_dep();
let t2 = i2::new_dep();
let t3 = i3::new_dep();
//Here we mark this struct with a special tag so it will be injected only to similarly named member of a dependent struct.
... | identifier_body | |
direction.rs | use specs::{ReadStorage, System, WriteStorage};
use crate::combat::components::intent::XAxis;
use crate::combat::components::movement::get_distance;
use crate::combat::components::{Action, AiState, Command, Facing, Intent, Position, State};
pub struct PlayerDirection;
impl<'a> System<'a> for PlayerDirection {
ty... | }
_ => (),
}
}
}
}
| {
use specs::Join;
for (intent, ai_state, position, state) in
(&intent, &ai_state, &position_storage, &mut state).join()
{
match state.action {
Action::Idle | Action::Move { .. } => {
if let Command::Move { .. } = intent.command {
... | identifier_body |
direction.rs | use specs::{ReadStorage, System, WriteStorage};
use crate::combat::components::intent::XAxis;
use crate::combat::components::movement::get_distance;
use crate::combat::components::{Action, AiState, Command, Facing, Intent, Position, State};
pub struct PlayerDirection;
impl<'a> System<'a> for PlayerDirection {
ty... |
impl<'a> System<'a> for AiDirection {
type SystemData = (
ReadStorage<'a, Intent>,
ReadStorage<'a, AiState>,
ReadStorage<'a, Position>,
WriteStorage<'a, State>,
);
fn run(&mut self, (intent, ai_state, position_storage, mut state): Self::SystemData) {
use specs::Join... | }
}
}
pub struct AiDirection; | random_line_split |
direction.rs | use specs::{ReadStorage, System, WriteStorage};
use crate::combat::components::intent::XAxis;
use crate::combat::components::movement::get_distance;
use crate::combat::components::{Action, AiState, Command, Facing, Intent, Position, State};
pub struct PlayerDirection;
impl<'a> System<'a> for PlayerDirection {
ty... | ;
impl<'a> System<'a> for AiDirection {
type SystemData = (
ReadStorage<'a, Intent>,
ReadStorage<'a, AiState>,
ReadStorage<'a, Position>,
WriteStorage<'a, State>,
);
fn run(&mut self, (intent, ai_state, position_storage, mut state): Self::SystemData) {
use specs::Jo... | AiDirection | identifier_name |
formatter.rs | use ansi_term::Colour::Green;
use ansi_term::Colour::Yellow;
use app::machine::Machine;
fn get_empty_line() -> String {
String::from("")
}
fn get_header() -> String {
let o = format!("{0: ^10} | {1: ^10} | {2: ^10} | {3: ^10}",
"Number",
"Name",
"St... |
fn get_separator() -> String {
let s = format!("{0: ^10} | {1: ^10} | {2: ^10} | {3: ^10}",
"----------",
"----------",
"----------",
"----------");
format!("{}", Yellow.paint(s))
}
pub fn format(machines: &[Machine]) -> String {... | {
let line = format!("{0: ^10} | {1: ^10} | {2: ^10} | {3: ^10}",
machine.get_number(),
machine.get_name(),
machine.get_state(),
machine.get_path());
format!("{}", Green.paint(line))
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.