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
dom_html_head_element.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::DOMElement; use crate::DOMEventTarget; use crate::DOMHTMLElement; use crate::DOMNode; use crate::DOMObject; use glib::object::Cast; use glib::object::IsA; use glib::si...
} impl<O: IsA<DOMHTMLHeadElement>> DOMHTMLHeadElementExt for O { fn profile(&self) -> Option<glib::GString> { unsafe { from_glib_full(ffi::webkit_dom_html_head_element_get_profile( self.as_ref().to_glib_none().0, )) } } fn set_profile(&self, value: &...
fn set_profile(&self, value: &str); fn connect_property_profile_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
random_line_split
dom_html_head_element.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::DOMElement; use crate::DOMEventTarget; use crate::DOMHTMLElement; use crate::DOMNode; use crate::DOMObject; use glib::object::Cast; use glib::object::IsA; use glib::si...
(&self) -> Option<glib::GString> { unsafe { from_glib_full(ffi::webkit_dom_html_head_element_get_profile( self.as_ref().to_glib_none().0, )) } } fn set_profile(&self, value: &str) { unsafe { ffi::webkit_dom_html_head_element_set_profil...
profile
identifier_name
clean.rs
// Copyright 2016 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 f(path) { Ok(()) => {} // On windows we can't remove a readonly file, and git will often clone files as readonly. // As a result, we have some special logic to remove readonly files on windows. // This is also the reason that we can't use things like fs::remove_dir_all(). ...
identifier_body
clean.rs
// Copyright 2016 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 path = t!(entry.path().canonicalize()); rm_rf(&path); } } } fn rm_rf(path: &Path) { match path.symlink_metadata() { Err(e) => { if e.kind() == ErrorKind::NotFound { return; } panic!("failed to get metadata for file ...
}
random_line_split
clean.rs
// Copyright 2016 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 ...
(build: &Build) { rm_rf("tmp".as_ref()); rm_rf(&build.out.join("tmp")); rm_rf(&build.out.join("dist")); for host in build.config.host.iter() { let entries = match build.out.join(host).read_dir() { Ok(iter) => iter, Err(_) => continue, }; for entry in ent...
clean
identifier_name
etcd_node.rs
use rustc_serialize::json; //use chrono::datetime::DateTime; //use chrono::offset::fixed::FixedOffset; #[derive(Debug)] pub struct EtcdNode { /// key: the HTTP path to which the request was made. etcd uses a file-system-like structure to represent the /// key-value pairs, therefore all keys start with /. pub k...
, dir: if let Some(j) = obj.get("dir") { j.as_boolean().unwrap() } else { false }, nodes: if let Some(j) = obj.get("nodes") { let arr: &Vec<json::Json> = j.as_array().unwrap(); let mut list: Vec<EtcdNode> = Vec::with_capacity(arr.len()); for n in arr { // these should ...
{ None }
conditional_block
etcd_node.rs
use rustc_serialize::json; //use chrono::datetime::DateTime; //use chrono::offset::fixed::FixedOffset; #[derive(Debug)] pub struct
{ /// key: the HTTP path to which the request was made. etcd uses a file-system-like structure to represent the /// key-value pairs, therefore all keys start with /. pub key: String, /// createdIndex: an index is a unique, monotonically-incrementing integer created for each change to etcd. This /// spec...
EtcdNode
identifier_name
etcd_node.rs
use rustc_serialize::json; //use chrono::datetime::DateTime; //use chrono::offset::fixed::FixedOffset; #[derive(Debug)] pub struct EtcdNode { /// key: the HTTP path to which the request was made. etcd uses a file-system-like structure to represent the /// key-value pairs, therefore all keys start with /. pub k...
} } //// "20133-12-04T12:01:21.874888581-08:00" /*fn decode_tm_from_str<D: Decoder>(d: &mut D) -> Result<DateTime<FixedOffset>, D::Error> { let time_str = try!(d.read_str()); let parse_result = DateTime::parse_from_rfc3339(&time_str); println!("parse_result {:?}", parse_result); match parse_result { Ok(t) ...
{ return EtcdNode { key: obj.get("key").unwrap().as_string().unwrap().to_string(), created_index: obj.get("createdIndex").unwrap().as_i64().unwrap(), modified_index: obj.get("modifiedIndex").unwrap().as_i64().unwrap(), value: if let Some(j) = obj.get("value") { Some(j.as_string().unwrap().to_string()) } el...
identifier_body
etcd_node.rs
use rustc_serialize::json; //use chrono::datetime::DateTime; //use chrono::offset::fixed::FixedOffset; #[derive(Debug)] pub struct EtcdNode { /// key: the HTTP path to which the request was made. etcd uses a file-system-like structure to represent the
/// specific index reflects the point in the etcd state member at which a given key was created.There are internal /// commands that also change the state behind the scenes, like adding and syncing servers. pub created_index: i64, /// modifiedIndex: like node.createdIndex, this attribute is also an etcd in...
/// key-value pairs, therefore all keys start with /. pub key: String, /// createdIndex: an index is a unique, monotonically-incrementing integer created for each change to etcd. This
random_line_split
historystore.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::{ops::Deref, path::PathBuf}; use anyhow::Result; use edenapi_types::HistoryEntry; use types::{Key, NodeInfo}; use crate::{localst...
(&self, key: &Key) -> Result<Option<NodeInfo>> { T::get_node_info(self, key) } fn refresh(&self) -> Result<()> { T::refresh(self) } } impl<T: HgIdMutableHistoryStore +?Sized, U: Deref<Target = T> + Send + Sync> HgIdMutableHistoryStore for U { fn add(&self, key: &Key, info: &NodeInf...
get_node_info
identifier_name
historystore.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::{ops::Deref, path::PathBuf}; use anyhow::Result; use edenapi_types::HistoryEntry; use types::{Key, NodeInfo}; use crate::{localst...
/// /// When implemented on a pure remote store, like the `EdenApi`, the method will always fetch /// everything that was asked. On a higher level store, such as the `MetadataStore`, this will /// avoid fetching data that is already present locally. fn prefetch(&self, keys: &[StoreKey]) -> Result<()...
/// `prefetch` API. pub trait RemoteHistoryStore: HgIdHistoryStore + Send + Sync { /// Attempt to bring the data corresponding to the passed in keys to a local store.
random_line_split
historystore.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::{ops::Deref, path::PathBuf}; use anyhow::Result; use edenapi_types::HistoryEntry; use types::{Key, NodeInfo}; use crate::{localst...
} impl<T: RemoteHistoryStore +?Sized, U: Deref<Target = T> + Send + Sync> RemoteHistoryStore for U { fn prefetch(&self, keys: &[StoreKey]) -> Result<()> { T::prefetch(self, keys) } }
{ T::flush(self) }
identifier_body
node_style.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/. */ //! Style retrieval from DOM elements. use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; use std::mem; use...
}
{ let mut layout_data_ref = self.mutate_layout_data(); let layout_data = layout_data_ref.as_mut().expect("no layout data"); let style = match self.get_pseudo_element_type() { PseudoElementType::Before(_) => &mut layout_data.data.before_style, PseudoEl...
identifier_body
node_style.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/. */ //! Style retrieval from DOM elements. use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; use std::mem; use...
PseudoElementType::Normal => { mem::transmute(layout_data_ref.as_ref() .unwrap() .shared_data .style ...
{ mem::transmute(layout_data_ref.as_ref() .unwrap() .data .after_style .as_ref() ...
conditional_block
node_style.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/. */ //! Style retrieval from DOM elements. use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; use std::mem; use...
<'a>(&'a self) -> &'a Arc<ComputedValues> { unsafe { let layout_data_ref = self.borrow_layout_data(); match self.get_pseudo_element_type() { PseudoElementType::Before(_) => { mem::transmute(layout_data_ref.as_ref() ...
style
identifier_name
node_style.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::mem; use style::properties::ComputedValues; use std::sync::Arc; /// Node mixin providing `style` method that returns a `NodeStyle` pub trait StyledNode { /// Returns the style results for the given node. If CSS selector matching has not yet been /// performed, fails. fn style<'a>(&'a self) -> &'a...
//! Style retrieval from DOM elements. use wrapper::{PseudoElementType, ThreadSafeLayoutNode};
random_line_split
errors.rs
/* * Copyright (C) 2021, Wafelack <wafelack@protonmail.com> * * ------------------------------------------------------ * * This file is part of Orion. * * Orion is free software: you can redistribute it and/or modify
* Orion 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 the GNU General Public License * ...
* 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 later version. *
random_line_split
errors.rs
/* * Copyright (C) 2021, Wafelack <wafelack@protonmail.com> * * ------------------------------------------------------ * * This file is part of Orion. * * Orion 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 Sof...
(pub String); pub type Result<T> = std::result::Result<T, OrionError>; #[macro_export] macro_rules! error { ($($arg:tt)*) => { Err(OrionError(format_args!($($arg)*).to_string())) } }
OrionError
identifier_name
circos_plot.rs
use crate::plot::colorizers::Colorizer; use crate::plot::*; use crate::utils::slugify; use std::fs::File; use std::io::prelude::*; pub struct CircosPlotter { result: RunResult, settings: Settings, } impl Plotter for CircosPlotter { fn plot(&self) -> Result<()> { let prefix = self.settings.out_f...
fn plot_links(&self) -> String { let links : String = self.result.families .iter() .map(|family| family .iter() .map( |sd| format!("{chr_left} {chr_left_start} {chr_left_end} {chr_right} {chr_r...
{ fn encode_chromosome(chr: &Start) -> String { format!( "chr - {id} {label} {start} {end} {color}", id = slugify(&chr.name), label = slugify(&chr.name), start = 0, end = chr.length, color = "grey" ...
identifier_body
circos_plot.rs
use crate::plot::colorizers::Colorizer; use crate::plot::*; use crate::utils::slugify; use std::fs::File; use std::io::prelude::*; pub struct CircosPlotter { result: RunResult, settings: Settings, } impl Plotter for CircosPlotter { fn plot(&self) -> Result<()> { let prefix = self.settings.out_f...
(&self) -> String { fn encode_chromosome(chr: &Start) -> String { format!( "chr - {id} {label} {start} {end} {color}", id = slugify(&chr.name), label = slugify(&chr.name), start = 0, end = chr.length, col...
plot_karyotype
identifier_name
circos_plot.rs
use crate::plot::colorizers::Colorizer; use crate::plot::*; use crate::utils::slugify; use std::fs::File; use std::io::prelude::*; pub struct CircosPlotter { result: RunResult, settings: Settings, } impl Plotter for CircosPlotter { fn plot(&self) -> Result<()> { let prefix = self.settings.out_f...
<links> <link> file = {links_filename} radius = 0.95r bezier_radius = 0r ribbon = yes </link> </links> <image> <<include {circos_root}/etc/image.conf>> </image> <<include {circos_root}/etc/colors_fonts_patterns.conf>> <<include {circos_root}/etc/housekeeping.conf>>...
</ticks> ### END TICKS SECTION
random_line_split
stub.rs
#[derive(Clone, Copy, Default, Debug)] #[repr(C, align(2))] pub struct
(pub u16); #[derive(Clone, Copy, Default, Debug)] #[repr(C, align(4))] pub struct f16x2_stub(pub u16, pub u16); pub trait FloatStub: Sized { type Inner; fn from_parts(negative: bool, exponent: Self::Inner, fraction: Self::Inner) -> Self; } impl FloatStub for f16_stub { type Inner = u16; #[inline] fn from...
f16_stub
identifier_name
stub.rs
#[derive(Clone, Copy, Default, Debug)] #[repr(C, align(2))] pub struct f16_stub(pub u16); #[derive(Clone, Copy, Default, Debug)] #[repr(C, align(4))] pub struct f16x2_stub(pub u16, pub u16); pub trait FloatStub: Sized { type Inner; fn from_parts(negative: bool, exponent: Self::Inner, fraction: Self::Inner) -> Se...
; let biased_exp = ((exponent + 15) & 0x1f) << 10; let fraction = fraction & 0x3ff; f16_stub(sign | biased_exp | fraction) } } impl f16_stub { #[inline] fn _zero() -> f16_stub { f16_stub(0) } #[inline] fn _one() -> f16_stub { f16_stub::from_parts(false, 0, 0) } }
{ 0 }
conditional_block
stub.rs
#[derive(Clone, Copy, Default, Debug)] #[repr(C, align(2))] pub struct f16_stub(pub u16); #[derive(Clone, Copy, Default, Debug)] #[repr(C, align(4))] pub struct f16x2_stub(pub u16, pub u16); pub trait FloatStub: Sized { type Inner; fn from_parts(negative: bool, exponent: Self::Inner, fraction: Self::Inner) -> Se...
} #[inline] fn _one() -> f16_stub { f16_stub::from_parts(false, 0, 0) } }
fn _zero() -> f16_stub { f16_stub(0)
random_line_split
stub.rs
#[derive(Clone, Copy, Default, Debug)] #[repr(C, align(2))] pub struct f16_stub(pub u16); #[derive(Clone, Copy, Default, Debug)] #[repr(C, align(4))] pub struct f16x2_stub(pub u16, pub u16); pub trait FloatStub: Sized { type Inner; fn from_parts(negative: bool, exponent: Self::Inner, fraction: Self::Inner) -> Se...
#[inline] fn _one() -> f16_stub { f16_stub::from_parts(false, 0, 0) } }
{ f16_stub(0) }
identifier_body
macros.rs
#[macro_export] macro_rules! derive_Component { ($type_name: ty) => { impl $crate::ecs::Component for $type_name { type Manager = $crate::component::DefaultManager<$type_name>; type Message = $crate::component::DefaultMessage<$type_name>; } } } #[macro_export] macro_rule...
} }
random_line_split
create_join_event.rs
//! `PUT /_matrix/federation/*/send_join/{roomId}/{eventId}` //! //! Endpoint to send join events to remote homeservers. pub mod v1; pub mod v2; use serde::{Deserialize, Serialize}; use serde_json::value::RawValue as RawJsonValue; /// Full state of the room. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr...
/// The resident server's DNS name. pub origin: String, /// The full set of authorization events that make up the state of the room, /// and their authorization events, recursively. pub auth_chain: Vec<Box<RawJsonValue>>, /// The room state. pub state: Vec<Box<RawJsonValue>>, } #[cfg(feat...
pub struct RoomState { #[cfg(not(feature = "unstable-pre-spec"))]
random_line_split
create_join_event.rs
//! `PUT /_matrix/federation/*/send_join/{roomId}/{eventId}` //! //! Endpoint to send join events to remote homeservers. pub mod v1; pub mod v2; use serde::{Deserialize, Serialize}; use serde_json::value::RawValue as RawJsonValue; /// Full state of the room. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr...
#[cfg(feature = "unstable-pre-spec")] /// Creates an empty `RoomState` with the given `origin`. /// /// Without the `unstable-pre-spec` feature, this method takes a parameter for the origin /// See [matrix-spec#374](https://github.com/matrix-org/matrix-spec/issues/374). pub fn new() -> Self { ...
{ Self { origin, auth_chain: Vec::new(), state: Vec::new() } }
identifier_body
create_join_event.rs
//! `PUT /_matrix/federation/*/send_join/{roomId}/{eventId}` //! //! Endpoint to send join events to remote homeservers. pub mod v1; pub mod v2; use serde::{Deserialize, Serialize}; use serde_json::value::RawValue as RawJsonValue; /// Full state of the room. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr...
() -> Self { Self { auth_chain: Vec::new(), state: Vec::new() } } }
new
identifier_name
u32.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 ...
#![doc(primitive = "u32")] use from_str::FromStr; use num::{ToStrRadix, FromStrRadix}; use num::strconv; use option::Option; use slice::ImmutableVector; use string::String; pub use core::u32::{BITS, BYTES, MIN, MAX}; uint_module!(u32)
//! Operations and constants for unsigned 32-bits integers (`u32` type)
random_line_split
lib.rs
#![doc(html_logo_url = "https://raw.githubusercontent.com/rusoto/rusoto/master/assets/logo-square.png")] #![cfg_attr(feature = "unstable", feature(proc_macro))] #![cfg_attr(feature = "nightly-testing", feature(plugin))] #![cfg_attr(feature = "nightly-testing", plugin(clippy))] #![cfg_attr(feature = "nightly-testing", a...
pub mod signature; #[doc(hidden)] pub use client::Client; #[doc(hidden)] pub mod serialization; #[doc(hidden)] pub mod xmlerror; #[doc(hidden)] pub mod xmlutil; pub use credential::{ProvideAwsCredentials, DefaultCredentialsProvider, CredentialsError}; pub use request::{DispatchSignedRequest, HttpClient, HttpDispatchE...
pub mod request;
random_line_split
domtokenlist.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::attr::Attr; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
}, } } // https://dom.spec.whatwg.org/#stringification-behavior fn Stringifier(&self) -> DOMString { let tokenlist = self.element.get_tokenlist_attribute(&self.local_name); DOMString::from(str_join(&tokenlist, "\x20")) } // check-tidy: no specs after this line ...
{ atoms.push(token); self.element.set_atomic_tokenlist_attribute(&self.local_name, atoms); Ok(true) }
conditional_block
domtokenlist.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::attr::Attr; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
(&self, index: u32, found: &mut bool) -> Option<DOMString> { let item = self.Item(index); *found = item.is_some(); item } }
IndexedGetter
identifier_name
domtokenlist.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::attr::Attr; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
element: JS<Element>, local_name: Atom, } impl DOMTokenList { pub fn new_inherited(element: &Element, local_name: Atom) -> DOMTokenList { DOMTokenList { reflector_: Reflector::new(), element: JS::from_ref(element), local_name: local_name, } } pub...
pub struct DOMTokenList { reflector_: Reflector,
random_line_split
domtokenlist.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::attr::Attr; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindin...
// https://dom.spec.whatwg.org/#dom-domtokenlist-add fn Add(&self, tokens: Vec<DOMString>) -> ErrorResult { let mut atoms = self.element.get_tokenlist_attribute(&self.local_name); for token in &tokens { let token = try!(self.check_token_exceptions(&token)); if!atoms.ite...
{ self.check_token_exceptions(&token).map(|token| { self.attribute().map(|attr| { let attr = attr.r(); attr.value() .as_tokens() .iter() .any(|atom: &Atom| *atom == token) }).unwrap_or(false) ...
identifier_body
cmd_resp.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0. use std::error; use crate::Error; use kvproto::raft_cmdpb::RaftCmdResponse; pub fn bind_term(resp: &mut RaftCmdResponse, term: u64)
pub fn bind_error(resp: &mut RaftCmdResponse, err: Error) { resp.mut_header().set_error(err.into()); } pub fn new_error(err: Error) -> RaftCmdResponse { let mut resp = RaftCmdResponse::default(); bind_error(&mut resp, err); resp } pub fn err_resp(e: Error, term: u64) -> RaftCmdResponse { let mut...
{ if term == 0 { return; } resp.mut_header().set_current_term(term); }
identifier_body
cmd_resp.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0. use std::error; use crate::Error; use kvproto::raft_cmdpb::RaftCmdResponse; pub fn bind_term(resp: &mut RaftCmdResponse, term: u64) { if term == 0 { return; } resp.mut_header().set_current_term(term); } pub fn bind_error(resp: &...
E: Into<Box<dyn error::Error + Send + Sync>>, { new_error(Error::Other(err.into())) }
} pub fn message_error<E>(err: E) -> RaftCmdResponse where
random_line_split
cmd_resp.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0. use std::error; use crate::Error; use kvproto::raft_cmdpb::RaftCmdResponse; pub fn bind_term(resp: &mut RaftCmdResponse, term: u64) { if term == 0
resp.mut_header().set_current_term(term); } pub fn bind_error(resp: &mut RaftCmdResponse, err: Error) { resp.mut_header().set_error(err.into()); } pub fn new_error(err: Error) -> RaftCmdResponse { let mut resp = RaftCmdResponse::default(); bind_error(&mut resp, err); resp } pub fn err_resp(e: E...
{ return; }
conditional_block
cmd_resp.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0. use std::error; use crate::Error; use kvproto::raft_cmdpb::RaftCmdResponse; pub fn
(resp: &mut RaftCmdResponse, term: u64) { if term == 0 { return; } resp.mut_header().set_current_term(term); } pub fn bind_error(resp: &mut RaftCmdResponse, err: Error) { resp.mut_header().set_error(err.into()); } pub fn new_error(err: Error) -> RaftCmdResponse { let mut resp = RaftCmdRes...
bind_term
identifier_name
archive.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
members: vec![], should_update_symbols: false, } } /// Create a new static archive, ready for adding files. pub fn create(config: ArchiveConfig<'a>) -> ArchiveBuilder<'a> { let archive = Archive::new(config); ArchiveBuilder::new(archive) } /// Adds a...
fn new(archive: Archive<'a>) -> ArchiveBuilder<'a> { ArchiveBuilder { archive: archive, work_dir: TempDir::new("rsar").unwrap(),
random_line_split
archive.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(self) -> ArchiveBuilder<'a> { ArchiveBuilder::new(self) } fn run(&self, cwd: Option<&Path>, action: Action) -> Output { let abs_dst = env::current_dir().unwrap().join(&self.config.dst); let ar = &self.config.ar_prog; let mut cmd = Command::new(ar); cmd.stdout(Stdio::pip...
extend
identifier_name
constants.rs
// Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation
// Copyright (C) 2020 Stacks Open Internet Foundation // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This ...
random_line_split
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use msg::constel...
(resource_task: Arc<ResourceTask>, data: Option<NotifierData>, initial_load: Option<Url>) -> DocumentLoader { let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect(); DocumentLoader { resourc...
new_with_task
identifier_name
document_loader.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/. */ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end use msg::constel...
if!self.is_blocked() { script_chan.send(MainThreadScriptMsg::DocumentLoadsComplete(pipeline)).unwrap(); } } } pub fn is_blocked(&self) -> bool { //TODO: Ensure that we report blocked if parsing is still ongoing. !self.blocking_loads.is_empty() ...
random_line_split
abstractworkerglobalscope.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 https://mozilla.org/MPL/2.0/. */ use crate::dom::abstractworker::WorkerScriptMsg; use crate::dom::bindings::conversions::DerivedFrom; use crate::d...
} /// A ScriptChan that can be cloned freely and will silently send a TrustedWorkerAddress with /// worker event loop messages. While this SendableWorkerScriptChan is alive, the associated /// Worker object will remain alive. #[derive(Clone, JSTraceable)] pub struct WorkerThreadWorkerChan { pub sender: Sender<Ded...
{ Box::new(SendableWorkerScriptChan { sender: self.sender.clone(), worker: self.worker.clone(), }) }
identifier_body
abstractworkerglobalscope.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 https://mozilla.org/MPL/2.0/. */ use crate::dom::abstractworker::WorkerScriptMsg; use crate::dom::bindings::conversions::DerivedFrom; use crate::d...
{ pub sender: Sender<DedicatedWorkerScriptMsg>, pub worker: TrustedWorkerAddress, } impl ScriptChan for WorkerThreadWorkerChan { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { let msg = DedicatedWorkerScriptMsg::CommonWorker( self.worker.clone(), WorkerScriptMsg::...
WorkerThreadWorkerChan
identifier_name
abstractworkerglobalscope.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 https://mozilla.org/MPL/2.0/. */ use crate::dom::abstractworker::WorkerScriptMsg; use crate::dom::bindings::conversions::DerivedFrom; use crate::d...
}) } } /// A ScriptChan that can be cloned freely and will silently send a TrustedWorkerAddress with /// worker event loop messages. While this SendableWorkerScriptChan is alive, the associated /// Worker object will remain alive. #[derive(Clone, JSTraceable)] pub struct WorkerThreadWorkerChan { pub se...
sender: self.sender.clone(), worker: self.worker.clone(),
random_line_split
mod.rs
// Copyright 2016 The Cartographer Authors // // 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...
{ gl: Rc<Gl>, id: GLuint, buffer_type: GLuint, } impl GlBuffer { pub fn new_array_buffer(gl: Rc<opengl::Gl>) -> Self { let mut id = 0; unsafe { gl.GenBuffers(1, &mut id); } GlBuffer { gl, id, buffer_type: opengl::ARRAY_BUF...
GlBuffer
identifier_name
mod.rs
// Copyright 2016 The Cartographer Authors // // 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...
pub use moving_window_texture::GlMovingWindowTexture; pub use program::{GlProgram, GlProgramBuilder}; pub use uniform::GlUniform; pub struct GlBuffer { gl: Rc<Gl>, id: GLuint, buffer_type: GLuint, } impl GlBuffer { pub fn new_array_buffer(gl: Rc<opengl::Gl>) -> Self { let mut id = 0; ...
random_line_split
issue-10392.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 ...
() { if false { test() } }
main
identifier_name
issue-10392.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } pub fn main() { if false { test() } }
{}
conditional_block
issue-10392.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 test() { let A { foo, } = mka(); let A { foo, } = mka(); let B { a, b, c, } = mkb(); match mka() { A { foo: _foo, } => {} } match Some(mka()) { Some(A { foo: _foo, }) => {} None => {} } } pub fn main() { if false { test() } }
random_line_split
lints_in_proc_macros.rs
// Copyright 2016 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 foobar = 42; bang_proc_macro2!(); //~^ ERROR cannot find value `foobar2` in this scope //~^^ did you mean `foobar`? println!("{}", x); }
identifier_body
lints_in_proc_macros.rs
// Copyright 2016 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 ...
// aux-build:bang_proc_macro2.rs #![feature(proc_macro_hygiene)] #![allow(unused_macros)] extern crate bang_proc_macro2; use bang_proc_macro2::bang_proc_macro2; fn main() { let foobar = 42; bang_proc_macro2!(); //~^ ERROR cannot find value `foobar2` in this scope //~^^ did you mean `foobar`? pri...
random_line_split
lints_in_proc_macros.rs
// Copyright 2016 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 foobar = 42; bang_proc_macro2!(); //~^ ERROR cannot find value `foobar2` in this scope //~^^ did you mean `foobar`? println!("{}", x); }
main
identifier_name
indexer_entries.rs
// Copyright 2020 The Kythe Authors. All rights reserved. // // 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 appli...
assert_eq!(entry.get_fact_value(), b"file".to_vec()); Ok(()) } // This test checks that the emit_edge function works properly #[test] fn edges_properly_emitted() -> Result<(), KytheError> { // Create an emitter that writes to the ArrayWriter. This makes it easier to // look at the emitted Entry proto...
{ // Create an emitter that writes to the ArrayWriter. This makes it easier to // look at the emitted Entry protobufs. let mut array_writer = ArrayWriter::new(); let mut emitter = EntryEmitter::new(&mut array_writer); // Create a test VName let mut vname = VName::new(); vname.set_signature(...
identifier_body
indexer_entries.rs
// Copyright 2020 The Kythe Authors. All rights reserved. // // 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 appli...
let mut vname = VName::new(); vname.set_signature("test_signature".to_string()); emitter.emit_fact(&vname, "/kythe/node/kind", b"file".to_vec())?; // Ensure that there is one emitted Entry and that the values match what we // expect let entries = array_writer.as_ref(); assert_eq!(entries.l...
random_line_split
indexer_entries.rs
// Copyright 2020 The Kythe Authors. All rights reserved. // // 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 appli...
() -> Result<(), KytheError> { // Create an emitter that writes to the ArrayWriter. This makes it easier to // look at the emitted Entry protobufs. let mut array_writer = ArrayWriter::new(); let mut emitter = EntryEmitter::new(&mut array_writer); // Create anchor and target VNames for the test ...
anchors_properly_emitted
identifier_name
issue-980.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub fn main() { let m = box(GC) RefCell::new(Pointy { x : no_pointy }); *m.borrow_mut() = Pointy { x: yes_pointy(m) }; }
x: maybe_pointy
random_line_split
issue-980.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 m = box(GC) RefCell::new(Pointy { x : no_pointy }); *m.borrow_mut() = Pointy { x: yes_pointy(m) }; }
identifier_body
issue-980.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ x: maybe_pointy } pub fn main() { let m = box(GC) RefCell::new(Pointy { x : no_pointy }); *m.borrow_mut() = Pointy { x: yes_pointy(m) }; }
Pointy
identifier_name
coupon.rs
// entity #[allow(dead_code)] use chrono::prelude::*; use rust_decimal::prelude::*; #[derive(Clone)] pub struct Coupon { pub code: String, pub percentage: Decimal, pub expiration_date: Date<Utc>, } impl Coupon { pub fn expired(&self, today: Date<Utc>) -> bool { return today > self.expiration_...
fn valid_coupons() { let coupon1 = Coupon { code: "code".to_string(), percentage: dec!(10), expiration_date: Utc.ymd(2019, 1, 1), }; assert_eq!(coupon1.expired(Utc.ymd(2019, 1, 1)), false); let coupon2 = Coupon { code: "code".to_string(...
#[test]
random_line_split
coupon.rs
// entity #[allow(dead_code)] use chrono::prelude::*; use rust_decimal::prelude::*; #[derive(Clone)] pub struct Coupon { pub code: String, pub percentage: Decimal, pub expiration_date: Date<Utc>, } impl Coupon { pub fn expired(&self, today: Date<Utc>) -> bool
} #[cfg(test)] mod tests { use super::*; use rust_decimal_macros::dec; #[test] fn expired_coupons() { let coupon1 = Coupon { code: "code".to_string(), percentage: dec!(10), expiration_date: Utc.ymd(2019, 1, 1), }; assert_eq!(coupon1.expired(...
{ return today > self.expiration_date; }
identifier_body
coupon.rs
// entity #[allow(dead_code)] use chrono::prelude::*; use rust_decimal::prelude::*; #[derive(Clone)] pub struct Coupon { pub code: String, pub percentage: Decimal, pub expiration_date: Date<Utc>, } impl Coupon { pub fn
(&self, today: Date<Utc>) -> bool { return today > self.expiration_date; } } #[cfg(test)] mod tests { use super::*; use rust_decimal_macros::dec; #[test] fn expired_coupons() { let coupon1 = Coupon { code: "code".to_string(), percentage: dec!(10), ...
expired
identifier_name
constants.rs
use crate::{config, env::Env, library, nameutil, traits::*, version::Version}; use std::borrow::Borrow; #[derive(Debug)] pub struct Info { pub name: String, pub glib_name: String, pub typ: library::TypeId, pub version: Option<Version>, pub deprecated_version: Option<Version>, pub cfg_condition:...
let constant = constant.borrow(); let configured_constants = obj.constants.matched(&constant.name); if!configured_constants .iter() .all(|c| c.status.need_generate()) { continue; } if env.is_totally_deprecated(None, constant.deprecated_...
random_line_split
constants.rs
use crate::{config, env::Env, library, nameutil, traits::*, version::Version}; use std::borrow::Borrow; #[derive(Debug)] pub struct Info { pub name: String, pub glib_name: String, pub typ: library::TypeId, pub version: Option<Version>, pub deprecated_version: Option<Version>, pub cfg_condition:...
_ => continue, } let version = configured_constants .iter() .filter_map(|c| c.version) .min() .or(constant.version); let version = env.config.filter_version(version); let deprecated_version = constant.deprecated_version; le...
{ let mut consts = Vec::new(); for constant in constants { let constant = constant.borrow(); let configured_constants = obj.constants.matched(&constant.name); if !configured_constants .iter() .all(|c| c.status.need_generate()) { continue; ...
identifier_body
constants.rs
use crate::{config, env::Env, library, nameutil, traits::*, version::Version}; use std::borrow::Borrow; #[derive(Debug)] pub struct
{ pub name: String, pub glib_name: String, pub typ: library::TypeId, pub version: Option<Version>, pub deprecated_version: Option<Version>, pub cfg_condition: Option<String>, } pub fn analyze<F: Borrow<library::Constant>>( env: &Env, constants: &[F], obj: &config::gobjects::GObject...
Info
identifier_name
mod.rs
#[macro_use] pub mod ccallback; #[macro_use] pub mod cstring; #[macro_use] pub mod version_constants; #[macro_use] pub mod devsetup; pub mod error; pub mod httpclient; pub mod constants; pub mod timeout; pub mod openssl; pub mod json; pub mod libindy; pub mod threadpool; pub mod uuid; use std::sync::atomic::{Atomi...
(filename: Option<&str>) -> PathBuf { let mut path = env::temp_dir(); path.push(filename.unwrap_or("")); path } #[macro_use] pub mod logger;
get_temp_dir_path
identifier_name
mod.rs
#[macro_use] pub mod ccallback; #[macro_use] pub mod cstring; #[macro_use] pub mod version_constants; #[macro_use] pub mod devsetup; pub mod error; pub mod httpclient; pub mod constants; pub mod timeout; pub mod openssl; pub mod json; pub mod libindy; pub mod threadpool; pub mod uuid; use std::sync::atomic::{Atomi...
pub fn get_temp_dir_path(filename: Option<&str>) -> PathBuf { let mut path = env::temp_dir(); path.push(filename.unwrap_or("")); path } #[macro_use] pub mod logger;
{ let command_handle = (COMMAND_HANDLE_COUNTER.fetch_add(1, Ordering::SeqCst) + 1) as i32; command_handle }
identifier_body
mod.rs
#[macro_use] pub mod ccallback; #[macro_use] pub mod cstring; #[macro_use] pub mod version_constants; #[macro_use] pub mod devsetup; pub mod error; pub mod httpclient;
pub mod threadpool; pub mod uuid; use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; use std::path::PathBuf; use std::env; lazy_static! { static ref COMMAND_HANDLE_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; } // allows all threads to atomically get a unique command handle pub fn generate_command_ha...
pub mod constants; pub mod timeout; pub mod openssl; pub mod json; pub mod libindy;
random_line_split
parse.rs
use regex; pub fn parse_testfn_list(files: &Vec<String>) -> Vec<String> { let parser = Parser::new(); files.iter() .map(|file| parser.parse_labels(file)) .fold(Vec::new(), |mut a, b| { a.extend(b); a }) } struct Parser { fn_label_regex: regex::Regex } impl Parser { pub fn new() -> Pars...
() { assert_correct_labels_generated( vec![ "test_function", "inner_scope", "brace_style", "no_close_delim", "void_arg" ], vec![" void some_function(void) { } ...
good_fn
identifier_name
parse.rs
use regex; pub fn parse_testfn_list(files: &Vec<String>) -> Vec<String> { let parser = Parser::new(); files.iter() .map(|file| parser.parse_labels(file)) .fold(Vec::new(), |mut a, b| { a.extend(b); a }) } struct Parser { fn_label_regex: regex::Regex } impl Parser { pub fn new() -> Pars...
#[test] fn bad_fn() { assert_correct_labels_generated( vec![], vec![" void normal_fn() { } ///[test] int non_void() { } ///[test] void parameters(thing) { ...
{ let actual_labels = super::parse_testfn_list(&actual.to_owned_vec()); let expected_labels = expected.to_owned_vec(); assert_eq!(expected_labels.len(), actual_labels.len()); for label in expected_labels { assert!(actual_labels.contains(&label)); } }
identifier_body
parse.rs
use regex; pub fn parse_testfn_list(files: &Vec<String>) -> Vec<String> { let parser = Parser::new(); files.iter() .map(|file| parser.parse_labels(file)) .fold(Vec::new(), |mut a, b| { a.extend(b); a }) } struct Parser { fn_label_regex: regex::Regex } impl Parser { pub fn new() -> Pars...
regex!(r"(?x) #set ignore-whitespace mode /// #c-style comment with extra slash .* #any number of non-newlines \[test\].* #test tag \s*void\s+ #require void return type (\w+) #capture function identifier ...
fn label_regex() -> regex::Regex {
random_line_split
borrowck-unary-move-2.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 x1 = wrapper(noncopyable()); let _x2 = *x1; }
main
identifier_name
borrowck-unary-move-2.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 ...
}
struct wrapper(noncopyable); fn main() { let x1 = wrapper(noncopyable()); let _x2 = *x1;
random_line_split
moves-based-on-type-block-bad.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 ...
{ x: Box<E> } enum E { Foo(Box<S>), Bar(Box<int>), Baz } fn f(s: &S, g: |&S|) { g(s) } fn main() { let s = S { x: box Bar(box 42) }; loop { f(&s, |hellothere| { match hellothere.x { //~ ERROR cannot move out box Foo(_) => {} box Bar(x) ...
S
identifier_name
moves-based-on-type-block-bad.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 main() { let s = S { x: box Bar(box 42) }; loop { f(&s, |hellothere| { match hellothere.x { //~ ERROR cannot move out box Foo(_) => {} box Bar(x) => println!("{}", x.to_str()), //~ NOTE attempting to move value to here box Baz => {} ...
{ g(s) }
identifier_body
moves-based-on-type-block-bad.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 ...
} }) } }
{}
conditional_block
moves-based-on-type-block-bad.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct S { x: Box<E> } enum E { Foo(Box<S>), Bar(Box<int>), Baz } fn f(s: &S, g: |&S|) { g(s) } fn main() { let s = S { x: box...
// 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
random_line_split
declmagic.rs
#![feature(macro_rules)] #![feature(globs)] #![allow(non_camel_case_types)] extern crate collections; extern crate gl; extern crate libc;
extern crate lua = "rust-hl-lua"; extern crate serialize; extern crate stb_image; extern crate sync; use std::sync::Arc; use display::Drawable; pub mod entities; pub mod log; pub mod resources; mod config; mod display; mod input; mod mechanics; mod physics; mod script; mod threaded_executer; pub trait GameSystem { ...
extern crate stdlog = "log"; extern crate glob; extern crate nalgebra; extern crate ncollide = "ncollide2df32"; extern crate nphysics = "nphysics2df32";
random_line_split
declmagic.rs
#![feature(macro_rules)] #![feature(globs)] #![allow(non_camel_case_types)] extern crate collections; extern crate gl; extern crate libc; extern crate stdlog = "log"; extern crate glob; extern crate nalgebra; extern crate ncollide = "ncollide2df32"; extern crate nphysics = "nphysics2df32"; extern crate lua = "rust-hl-...
pub fn exec(mut self) { let mut timer = ::std::io::timer::Timer::new().unwrap(); let period: f64 = 1.0 / 60.0; let timerPeriod = timer.periodic((period * 1000.0) as u64); 'mainLoop: loop { let mut inputMessages = Vec::new(); loop { match sel...
{ self.thirdPartySystems.push(box system as Box<GameSystem>) }
identifier_body
declmagic.rs
#![feature(macro_rules)] #![feature(globs)] #![allow(non_camel_case_types)] extern crate collections; extern crate gl; extern crate libc; extern crate stdlog = "log"; extern crate glob; extern crate nalgebra; extern crate ncollide = "ncollide2df32"; extern crate nphysics = "nphysics2df32"; extern crate lua = "rust-hl-...
<RL: resources::ResourcesLoader+Send+Share>(resources: RL) { let game = Game::new(resources); game.exec(); }
exec_game
identifier_name
threaded.rs
/// Threaded IO model: A pool of threads is used so that syscall latencies /// due to (nonexhaustive list) Network file systems, virus scanners, and /// operating system design, do not cause rustup to be significantly slower /// than desired. In particular the docs workload with 20K files requires /// very low latency ...
else { None } } Task::Request(item) => Some(item), }, } } } struct SubmitIterator<'a, 'b> { executor: &'a mut Threaded<'b>, item: Cell<Task>, } impl<'a, 'b> Iterator for SubmitIterator<'a, 'b> { type Item ...
{ self.next() }
conditional_block
threaded.rs
/// Threaded IO model: A pool of threads is used so that syscall latencies /// due to (nonexhaustive list) Network file systems, virus scanners, and /// operating system design, do not cause rustup to be significantly slower /// than desired. In particular the docs workload with 20K files requires /// very low latency ...
(&mut self) { // We are not permitted to fail - consume but do not handle the items. self.join().for_each(drop); } } struct JoinIterator<T: Iterator<Item = Task>> { iter: T, consume_sentinel: bool, } impl<T: Iterator<Item = Task>> Iterator for JoinIterator<T> { type Item = Item; f...
drop
identifier_name
threaded.rs
/// Threaded IO model: A pool of threads is used so that syscall latencies /// due to (nonexhaustive list) Network file systems, virus scanners, and /// operating system design, do not cause rustup to be significantly slower /// than desired. In particular the docs workload with 20K files requires /// very low latency ...
prev_files as u64, )); } if prev_files > 50 { println!("{} deferred IO operations", prev_files); } let buf: Vec<u8> = vec![0; prev_files]; // Cheap wrap-around correctness check - we have 20k files, more than // 32K means we subtrac...
{ // Some explanation is in order. Even though the tar we are reading from (if // any) will have had its FileWithProgress download tracking // completed before we hit drop, that is not true if we are unwinding due to a // failure, where the logical ownership of the progress bar is ...
identifier_body
threaded.rs
/// Threaded IO model: A pool of threads is used so that syscall latencies /// due to (nonexhaustive list) Network file systems, virus scanners, and /// operating system design, do not cause rustup to be significantly slower /// than desired. In particular the docs workload with 20K files requires /// very low latency ...
pool, notify_handler, rx, tx, } } fn submit(&mut self, mut item: Item) { let tx = self.tx.clone(); self.n_files.fetch_add(1, Ordering::Relaxed); let n_files = self.n_files.clone(); self.pool.execute(move || { pe...
random_line_split
camera_input_system.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // 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 wi...
impl System for CameraInputSystem { fn update(&mut self, arg: specs::RunArg, _time_step: Fixed) { fetch_components!(arg, _entities, [ components(cameras: CameraComponent), mut components(velocities: VelocityComponent), resource(keyboard_key_states: KeyboardKeyStates), ...
}
random_line_split
camera_input_system.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // 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 wi...
() -> CameraInputSystem { CameraInputSystem } } impl System for CameraInputSystem { fn update(&mut self, arg: specs::RunArg, _time_step: Fixed) { fetch_components!(arg, _entities, [ components(cameras: CameraComponent), mut components(velocities: VelocityComponent), ...
new
identifier_name
camera_input_system.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // 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 wi...
} if new_velocity.length_squared() > ZERO_THRESHOLD { new_velocity.normalize(); } velocity.velocity = new_velocity * CAMERA_SPEED; } } }
{ fetch_components!(arg, _entities, [ components(cameras: CameraComponent), mut components(velocities: VelocityComponent), resource(keyboard_key_states: KeyboardKeyStates), ]); for (velocity, _camera) in (&mut velocities, &cameras).iter() { let mu...
identifier_body
camera_input_system.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // 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 wi...
if new_velocity.length_squared() > ZERO_THRESHOLD { new_velocity.normalize(); } velocity.velocity = new_velocity * CAMERA_SPEED; } } }
{ new_velocity.x = 1.into(); }
conditional_block
mcs_player.rs
extern crate time; extern crate rand; use {Player, MoveResult}; use game_manager::{Game, State}; use gdl::{Move, Score, Role}; use std::cmp::{max, min}; /// A Monte Carlo search player. This player should only be used for 2 player, constant sum, /// turn based games. pub struct
{ depth_limit: u32, best_move: Option<Move>, charge_count: u32, } impl McsPlayer { /// Returns an McsPlayer that begins the random terminal state searches at depth `depth` pub fn new(depth: u32, charge_count: u32) -> McsPlayer { McsPlayer { depth_limit: depth, best_move: None, charge_count...
McsPlayer
identifier_name
mcs_player.rs
extern crate time; extern crate rand; use {Player, MoveResult}; use game_manager::{Game, State}; use gdl::{Move, Score, Role}; use std::cmp::{max, min}; /// A Monte Carlo search player. This player should only be used for 2 player, constant sum, /// turn based games. pub struct McsPlayer { depth_limit: u32, ...
new_state = game.next_state(&new_state, &moves); check_time_result!(self, game); } return Ok(game.goal(state, role)); } } fn opponent<'a>(game: &'a Game, role: &'a Role) -> &'a Role { let roles = game.roles(); assert!(roles.len() == 2, "Must be a two player game"); ...
moves.push(legals.swap_remove(r)); }
random_line_split
mcs_player.rs
extern crate time; extern crate rand; use {Player, MoveResult}; use game_manager::{Game, State}; use gdl::{Move, Score, Role}; use std::cmp::{max, min}; /// A Monte Carlo search player. This player should only be used for 2 player, constant sum, /// turn based games. pub struct McsPlayer { depth_limit: u32, ...
if game.is_terminal(state) { return Ok(game.goal(state, game.role())); } let moves = game.legal_moves(state, role); assert!(!moves.is_empty(), "No legal moves"); let opponent = opponent(game, role); let mut alpha = alpha; for m in moves { ...
{ return self.monte_carlo(role, game, state); }
conditional_block
grad.rs
//! Helper functions to compute gradients-dot-residual vectors (1D to 4D). use utils::if_else; /// Compute 1D gradient-dot-residual vector. pub fn grad1(hash: u8, x: f64) -> f64 { let h: u8 = hash & 15; let mut grad: f64 = 1.0 + (h & 7) as f64; // Gradient value 1.0, 2.0,..., 8.0 if (h & 8)!= 0
grad * x // Multiply the gradient with the distance } /// Compute 2D gradient-dot-residual vector. pub fn grad2(hash: u8, x: f64, y: f64) -> f64 { // Convert low 3 bits of hash code into 8 simple gradient directions, // and compute the dot product with (x,y). let h: u8 = hash & 7; let u: f64 = if...
{ grad = -grad; // Set a random sign for the gradient }
conditional_block
grad.rs
//! Helper functions to compute gradients-dot-residual vectors (1D to 4D). use utils::if_else; /// Compute 1D gradient-dot-residual vector. pub fn grad1(hash: u8, x: f64) -> f64 { let h: u8 = hash & 15; let mut grad: f64 = 1.0 + (h & 7) as f64; // Gradient value 1.0, 2.0,..., 8.0 if (h & 8)!= 0 { ...
(hash: u8, x: f64, y: f64) -> f64 { // Convert low 3 bits of hash code into 8 simple gradient directions, // and compute the dot product with (x,y). let h: u8 = hash & 7; let u: f64 = if_else(h < 4, x, y); let v: f64 = if_else(h < 4, y, x); if_else(h & 1!= 0, -u, u) + if_else(h & 2!= 0, -2.0 * ...
grad2
identifier_name
grad.rs
//! Helper functions to compute gradients-dot-residual vectors (1D to 4D). use utils::if_else; /// Compute 1D gradient-dot-residual vector. pub fn grad1(hash: u8, x: f64) -> f64 { let h: u8 = hash & 15; let mut grad: f64 = 1.0 + (h & 7) as f64; // Gradient value 1.0, 2.0,..., 8.0 if (h & 8)!= 0 { ...
grad * x // Multiply the gradient with the distance } /// Compute 2D gradient-dot-residual vector. pub fn grad2(hash: u8, x: f64, y: f64) -> f64 { // Convert low 3 bits of hash code into 8 simple gradient directions, // and compute the dot product with (x,y). let h: u8 = hash & 7; let u: f64 = if_e...
random_line_split
grad.rs
//! Helper functions to compute gradients-dot-residual vectors (1D to 4D). use utils::if_else; /// Compute 1D gradient-dot-residual vector. pub fn grad1(hash: u8, x: f64) -> f64 { let h: u8 = hash & 15; let mut grad: f64 = 1.0 + (h & 7) as f64; // Gradient value 1.0, 2.0,..., 8.0 if (h & 8)!= 0 { ...
{ // Convert low 4 bits of hash code into 12 simple gradient directions, // and compute dot product. let h: u8 = hash & 15; let u: f64 = if_else(h < 8, x, y); // Fix repeats at h = 12 to 15 let v: f64 = if_else(h < 4, y, if_else(h == 12 || h == 14, x, z)); if_else(h & 1 != 0, -u, u) + if_el...
identifier_body
run.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { flag_bin: Option<String>, flag_example: Option<String>, flag_jobs: Option<u32>, flag_features: Vec<String>, flag_no_default_feat...
(options: Options, config: &Config) -> CliResult<Option<()>> { try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); let ...
execute
identifier_name
run.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { flag_bin: Option<String>, flag_example: Option<String>, flag_jobs: Option<u32>, flag_features: Vec<String>, flag_no_default_feat...
bin target it will be run. Otherwise `--bin` specifies the bin target to run, and `--example` specifies the example target to run. At most one of `--bin` or `--example` can be provided. All of the trailing arguments are passed to the binary to run. If you're passing arguments to both Cargo and the binary, the ones aft...
random_line_split
run.rs
use cargo::ops; use cargo::util::{CliResult, CliError, Config}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { flag_bin: Option<String>, flag_example: Option<String>, flag_jobs: Option<u32>, flag_features: Vec<String>, flag_no_default_feat...
spec: &[], exec_engine: None, release: options.flag_release, mode: ops::CompileMode::Build, filter: if examples.is_empty() && bins.is_empty() { ops::CompileFilter::Everything } else { ops::CompileFilter::Only { lib: false, tests: &[...
{ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); let (mut examples, mut bins) = (Vec::new(), Vec::new()); if l...
identifier_body