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 |
|---|---|---|---|---|
gen_table.rs | /*
* This file is part of the uutils coreutils package.
*
* (c) Arcterus <arcterus@mail.com>
* (c) Michael Gehring <mg@ebfe.org>
* | use std::io;
static CRC_TABLE_LEN: uint = 256;
fn main() {
let mut table = Vec::with_capacity(CRC_TABLE_LEN);
for num in range(0, CRC_TABLE_LEN) {
table.push(crc_entry(num as u8) as u32);
}
let mut file = io::File::open_mode(&Path::new("crc_table.rs"), io::Truncate, io::Write).unwrap();
le... | * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
| random_line_split |
gen_table.rs | /*
* This file is part of the uutils coreutils package.
*
* (c) Arcterus <arcterus@mail.com>
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use std::io;
static CRC_TABLE_LEN: uint = 256;
fn main() {... | else {
crc <<= 1;
}
}
crc
}
| {
crc <<= 1;
crc ^= 0x04c11db7;
} | conditional_block |
gen_table.rs | /*
* This file is part of the uutils coreutils package.
*
* (c) Arcterus <arcterus@mail.com>
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use std::io;
static CRC_TABLE_LEN: uint = 256;
fn | () {
let mut table = Vec::with_capacity(CRC_TABLE_LEN);
for num in range(0, CRC_TABLE_LEN) {
table.push(crc_entry(num as u8) as u32);
}
let mut file = io::File::open_mode(&Path::new("crc_table.rs"), io::Truncate, io::Write).unwrap();
let output = format!("/* auto-generated (DO NOT EDIT) */
... | main | identifier_name |
gen_table.rs | /*
* This file is part of the uutils coreutils package.
*
* (c) Arcterus <arcterus@mail.com>
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use std::io;
static CRC_TABLE_LEN: uint = 256;
fn main() {... | {
let mut crc = input as u32 << 24;
for _ in range(0u, 8) {
if crc & 0x80000000 != 0 {
crc <<= 1;
crc ^= 0x04c11db7;
} else {
crc <<= 1;
}
}
crc
} | identifier_body | |
lockfile.rs | use std::{fs, result};
use std::path::Path;
use serde::Deserialize;
use crate::errors::*;
#[derive(Debug)]
pub struct Dependency {
raw: String,
}
impl Dependency {
pub fn crate_id(&self) -> String {
self.raw.split_whitespace().next().unwrap_or("").to_owned()
}
pub fn is_registry(&self) -> bool {
self... | {
Ok(toml::from_str(&fs::read_to_string(&path)?)?)
} | identifier_body | |
lockfile.rs | use std::{fs, result};
use std::path::Path;
use serde::Deserialize;
use crate::errors::*;
#[derive(Debug)]
pub struct Dependency {
raw: String,
}
impl Dependency {
pub fn | (&self) -> String {
self.raw.split_whitespace().next().unwrap_or("").to_owned()
}
pub fn is_registry(&self) -> bool {
self.raw.ends_with("(registry+https://github.com/rust-lang/crates.io-index)")
}
}
impl<'de> serde::Deserialize<'de> for Dependency {
fn deserialize<D: serde::Deserializer<'de>>(deseria... | crate_id | identifier_name |
lockfile.rs | use std::{fs, result};
use std::path::Path;
use serde::Deserialize;
use crate::errors::*;
#[derive(Debug)]
pub struct Dependency {
raw: String,
}
impl Dependency {
pub fn crate_id(&self) -> String {
self.raw.split_whitespace().next().unwrap_or("").to_owned()
}
pub fn is_registry(&self) -> bool {
self... | pub packages: Vec<Package>,
}
pub fn read(path: &Path) -> Result<Lockfile> {
Ok(toml::from_str(&fs::read_to_string(&path)?)?)
} | random_line_split | |
font_context.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 font::{Font, FontDescriptor, FontGroup, FontHandleMethods, FontStyle,
SelectorPlatformIdentifier};
... |
}
}
fn transform_family(&self, family: &str) -> ~str {
// FIXME: Need a find_like() in HashMap.
let family = family.to_str();
debug!("(transform family) searching for `%s`", family);
match self.generic_fonts.find(&family) {
None => family,
Some(m... | {
debug!("font cache miss");
let result = self.create_font_instance(desc);
match result {
Ok(font) => {
self.instance_cache.insert(desc.clone(), font);
}, _ => {}
};
result
... | conditional_block |
font_context.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 font::{Font, FontDescriptor, FontGroup, FontHandleMethods, FontStyle,
SelectorPlatformIdentifier};
... |
let font_id =
SelectorPlatformIdentifier(font_entry.handle.face_identifier());
let font_desc = FontDescriptor::new((*style).clone(), font_id);
let instance = self.get_font_by_descriptor(&font_desc);
for font in instance.iter() { fonts.... | found = true; | random_line_split |
font_context.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 font::{Font, FontDescriptor, FontGroup, FontHandleMethods, FontStyle,
SelectorPlatformIdentifier};
... |
pub fn get_font_by_descriptor(&mut self, desc: &FontDescriptor) -> Result<@mut Font, ()> {
match self.instance_cache.find(desc) {
Some(f) => {
debug!("font cache hit");
Ok(f)
},
None => {
debug!("font cache miss");
... | {
match self.group_cache.find(style) {
Some(fg) => {
debug!("font group cache hit");
fg
},
None => {
debug!("font group cache miss");
let fg = self.create_font_group(style);
self.group_cache.inser... | identifier_body |
font_context.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 font::{Font, FontDescriptor, FontGroup, FontHandleMethods, FontStyle,
SelectorPlatformIdentifier};
... | (&mut self, style: &SpecifiedFontStyle) -> @FontGroup {
let mut fonts = ~[];
debug!("(create font group) --- starting ---");
// TODO(Issue #193): make iteration over 'font-family' more robust.
for family in style.families.split_iter(',') {
let family_name = family.trim();
... | create_font_group | identifier_name |
armebv7r_none_eabihf.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 ... | () -> TargetResult {
Ok(Target {
llvm_target: "armebv7r-unknown-none-eabihf".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string()... | target | identifier_name |
armebv7r_none_eabihf.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 ... | abi_blacklist: super::arm_base::abi_blacklist(),
emit_debug_gdb_scripts: false,
.. Default::default()
},
})
}
| {
Ok(Target {
llvm_target: "armebv7r-unknown-none-eabihf".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "ar... | identifier_body |
armebv7r_none_eabihf.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 ... |
pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "armebv7r-unknown-none-eabihf".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S6... | use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult}; | random_line_split |
rc.rs | // "Tifflin" Userland
// - By John Hodge (thePowersGang)
//
// liballoc/rc.rs
//! Reference-counted shared allocation
use core::{ops,fmt,cmp};
use super::grc::Grc;
/// Non-atomic reference counted type
pub struct Rc<T:?Sized> {
_inner: Grc<::core::cell::Cell<usize>, T>,
}
// Rc is not Send or Sync
impl<T:?Sized>!Se... |
}
impl<T:?Sized> Rc<T>
{
/// Compares this Rc with another, checking if they point to the same object
pub fn is_same(&self, other: &Rc<T>) -> bool {
self._inner.is_same( &other._inner )
}
}
impl<T:?Sized> Clone for Rc<T> {
fn clone(&self) -> Rc<T> {
Rc { _inner: self._inner.clone() }
}
}
impl<T:?Sized + fmt... | {
Rc { _inner: Grc::new(value) }
} | identifier_body |
rc.rs | // "Tifflin" Userland
// - By John Hodge (thePowersGang)
//
// liballoc/rc.rs
//! Reference-counted shared allocation
use core::{ops,fmt,cmp};
use super::grc::Grc;
/// Non-atomic reference counted type
pub struct Rc<T:?Sized> {
_inner: Grc<::core::cell::Cell<usize>, T>,
}
// Rc is not Send or Sync
impl<T:?Sized>!Se... | /// Compares this Rc with another, checking if they point to the same object
pub fn is_same(&self, other: &Rc<T>) -> bool {
self._inner.is_same( &other._inner )
}
}
impl<T:?Sized> Clone for Rc<T> {
fn clone(&self) -> Rc<T> {
Rc { _inner: self._inner.clone() }
}
}
impl<T:?Sized + fmt::Display> fmt::Display fo... | Rc { _inner: Grc::new(value) }
}
}
impl<T: ?Sized> Rc<T>
{ | random_line_split |
rc.rs | // "Tifflin" Userland
// - By John Hodge (thePowersGang)
//
// liballoc/rc.rs
//! Reference-counted shared allocation
use core::{ops,fmt,cmp};
use super::grc::Grc;
/// Non-atomic reference counted type
pub struct Rc<T:?Sized> {
_inner: Grc<::core::cell::Cell<usize>, T>,
}
// Rc is not Send or Sync
impl<T:?Sized>!Se... | <I>(iterator: I) -> Self
where
I: IntoIterator<Item=U>,
I::IntoIter: ExactSizeIterator,
{
Rc { _inner: Grc::from_iter(iterator) }
}
}
//impl<U> Default for Rc<[U]> {
// fn default() -> Self {
// Rc { _inner: Grc::default() }
// }
//}
// vim: ft=rust
| from_iter | identifier_name |
unique-cmp.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 ... | assert!(i <= box 100i);
assert!(i > box 99i);
assert!(i >= box 99i);
} | random_line_split | |
unique-cmp.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 i = box 100i;
assert!(i == box 100i);
assert!(i < box 101i);
assert!(i <= box 100i);
assert!(i > box 99i);
assert!(i >= box 99i);
}
| main | identifier_name |
unique-cmp.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 i = box 100i;
assert!(i == box 100i);
assert!(i < box 101i);
assert!(i <= box 100i);
assert!(i > box 99i);
assert!(i >= box 99i);
} | identifier_body | |
mod.rs | // encrypter.rs
//
// Copyright 2019 Jordan Petridis <jordan@centricular.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// ri... | (plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register(
Some(plugin),
"sodiumencrypter",
gst::Rank::None,
Encrypter::static_type(),
)
}
| register | identifier_name |
mod.rs | // encrypter.rs
//
// Copyright 2019 Jordan Petridis <jordan@centricular.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// ri... | )
} | random_line_split | |
mod.rs | // encrypter.rs
//
// Copyright 2019 Jordan Petridis <jordan@centricular.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// ri... | {
gst::Element::register(
Some(plugin),
"sodiumencrypter",
gst::Rank::None,
Encrypter::static_type(),
)
} | identifier_body | |
mod.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/. */
//! Animated values.
//!
//! Some values, notably colors, cannot be interpolated directly with their
//! computed ... | animated: Self::AnimatedValue) -> Self {
animated.into_iter().map(T::from_animated_value).collect()
}
}
/// Marker trait for computed values with the same representation during animations.
pub trait AnimatedValueAsComputed {}
impl AnimatedValueAsComputed for Au {}
impl AnimatedValueAsComputed for Computed... | rom_animated_value( | identifier_name |
mod.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/. */
//! Animated values.
//!
//! Some values, notably colors, cannot be interpolated directly with their
//! computed ... | }
impl ToAnimatedZero for i32 {
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> { Ok(0) }
}
| Ok(0.) }
| identifier_body |
mod.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/. */
//! Animated values.
//!
//! Some values, notably colors, cannot be interpolated directly with their
//! computed ... | #[inline]
fn to_animated_zero(&self) -> Result<Self, ()> { Ok(0) }
} | random_line_split | |
arrange.rs | Unary;
use timely::dataflow::channels::pact::{Pipeline, Exchange};
use timely::progress::frontier::MutableAntichain;
use timely::progress::Timestamp;
use timely::dataflow::operators::Capability;
use timely_sort::Unsigned;
use hashable::{HashableWrapper, OrdWrapper};
use ::{Data, Diff, Collection, AsCollection, Hasha... |
// Extract updates not in advance of `upper`.
let batch = batcher.seal(&upper[..]);
// If the source is still active, commit the extracted batch.
// The source may become inactive if all downsteam users of the trace drop t... | if !upper.iter().any(|t| t.less_equal(&time)) {
upper.retain(|t| !time.less_equal(t));
upper.push(time);
}
} | random_line_split |
arrange.rs | ;
use timely::dataflow::channels::pact::{Pipeline, Exchange};
use timely::progress::frontier::MutableAntichain;
use timely::progress::Timestamp;
use timely::dataflow::operators::Capability;
use timely_sort::Unsigned;
use hashable::{HashableWrapper, OrdWrapper};
use ::{Data, Diff, Collection, AsCollection, Hashable};... | });
})
.as_collection()
}
}
/// Arranges something as `(Key,Val)` pairs according to a type `T` of trace.
pub trait Arrange<G: Scope, K, V, R: Diff> where G::Timestamp: Lattice {
/// Arranges a stream of `(Key, Val)` updates by `Key`. Accepts an empty instance of the trace type.
... | {
self.stream.unary_stream(Pipeline, "AsCollection", move |input, output| {
input.for_each(|time, data| {
let mut session = output.session(&time);
for wrapper in data.drain(..) {
let batch = wrapper.item;
let mut cursor = batch... | identifier_body |
arrange.rs | ;
use timely::dataflow::channels::pact::{Pipeline, Exchange};
use timely::progress::frontier::MutableAntichain;
use timely::progress::Timestamp;
use timely::dataflow::operators::Capability;
use timely_sort::Unsigned;
use hashable::{HashableWrapper, OrdWrapper};
use ::{Data, Diff, Collection, AsCollection, Hashable};... | <T>(&self, empty_trace: T) -> Arranged<G, K, V, R, T>
where
T: Trace<K, V, G::Timestamp, R>+'static {
// create a trace to share with downstream consumers.
let handle = TraceHandle::new(empty_trace, &[<G::Timestamp as Lattice>::min()], &[<G::Timestamp as Lattice>::min()]);
... | arrange | identifier_name |
arrange.rs | ;
use timely::dataflow::channels::pact::{Pipeline, Exchange};
use timely::progress::frontier::MutableAntichain;
use timely::progress::Timestamp;
use timely::dataflow::operators::Capability;
use timely_sort::Unsigned;
use hashable::{HashableWrapper, OrdWrapper};
use ::{Data, Diff, Collection, AsCollection, Hashable};... |
}
// Extract updates not in advance of `upper`.
let batch = batcher.seal(&upper[..]);
// If the source is still active, commit the extracted batch.
// The source may become inactive if all downstea... | {
upper.retain(|t| !time.less_equal(t));
upper.push(time);
} | conditional_block |
elastic_import.rs | // Copyright (C) 2020-2021 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish... | client.disable_certificate_validation(disable_certificate_validation);
if let Some(username) = &username {
client.with_username(username);
}
if let Some(password) = &password {
client.with_password(password);
}
debug!(
"Elasticsearch index: {}, no-index-suffix={}",
... | let username: Option<String> = settings.get_string("username")?;
let password: Option<String> = settings.get_string("password")?;
let mut client = crate::elastic::ClientBuilder::new(&elastic_url); | random_line_split |
elastic_import.rs | // Copyright (C) 2020-2021 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish... | crate::eve::filters::EveBoxMetadataFilter {
filename: Some(filename.to_string()),
},
));
let filters = Arc::new(filters);
let mut processor = Processor::new(reader, importer);
if config.use_bookmark {
processor.bookmark_filename = Some(bookmark_path.clone());
}
... | {
info!("Starting reader on {}", filename);
let reader = eve::EveReader::new(filename);
let bookmark_path = PathBuf::from(&config.bookmark_filename);
let mut filters = vec![EveFilter::Filters(root_filters)];
if config.disable_geoip {
debug!("GeoIP disabled");
} else {
match crat... | identifier_body |
elastic_import.rs | // Copyright (C) 2020-2021 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish... |
} else if bookmark_dir!= "." {
let bookmark_filename = bookmark::bookmark_filename(&input, &bookmark_dir);
config.bookmark_filename = bookmark_filename;
}
}
let done_tx = done_tx.clone();
let filters = filters.clone();
let t = tok... | {
config.bookmark_filename = new_bookmark_filename;
} | conditional_block |
elastic_import.rs | // Copyright (C) 2020-2021 Jason Ish
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish... | (args: &clap::ArgMatches<'static>) -> Result<(), Box<dyn std::error::Error>> {
let mut config = ElasticImportConfig::default();
let settings = Config::from_args(args.clone(), Some("config"))?;
let elastic_url: String = settings.get_string("elasticsearch")?.unwrap();
let index: String = settings.get_str... | main | identifier_name |
htmlanchorelement.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::activation::Activatable;
use dom::attr::AttrValue;
use dom::bindings::codegen::Bindings::AttrBinding::At... | let window = document.window();
window.load_url(url);
} | // Step 7.
debug!("following hyperlink to {}", url.serialize()); | random_line_split |
htmlanchorelement.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::activation::Activatable;
use dom::attr::AttrValue;
use dom::bindings::codegen::Bindings::AttrBinding::At... |
//TODO:https://html.spec.whatwg.org/multipage/#the-a-element
// https://html.spec.whatwg.org/multipage/#run-canceled-activation-steps
fn canceled_activation(&self) {
}
//https://html.spec.whatwg.org/multipage/#the-a-element:activation-behaviour
fn activation_behavior(&self, event: &Event, tar... | {
} | identifier_body |
htmlanchorelement.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::activation::Activatable;
use dom::attr::AttrValue;
use dom::bindings::codegen::Bindings::AttrBinding::At... | (&self, event: &Event, target: &EventTarget) {
//Step 1. If the node document is not fully active, abort.
let doc = document_from_node(self);
if!doc.is_fully_active() {
return;
}
//TODO: Step 2. Check if browsing context is specified and act accordingly.
//Ste... | activation_behavior | identifier_name |
iq.rs | // rust-xmpp
// Copyright (c) 2014-2015 Florian Zeitz
//
// This project is MIT licensed.
// Please see the COPYING file for more information.
use xml;
use ns;
use super::{Stanza, StanzaType};
#[derive(Copy, Clone, Debug)]
pub enum IqType {
Set,
Get,
Result,
Error
}
impl StanzaType for IqType {
... | { elem: xml::Element }
impl_Stanza!("iq", Iq, IqType,
|ty: &str| {
match ty {
"get" => Some(IqType::Get),
"set" => Some(IqType::Set),
"result" => Some(IqType::Result),
"error" => Some(IqType::Error),
_ => None
}
}
, None);
impl Iq {
... | Iq | identifier_name |
iq.rs | // rust-xmpp
// Copyright (c) 2014-2015 Florian Zeitz
//
// This project is MIT licensed.
// Please see the COPYING file for more information.
use xml;
use ns;
use super::{Stanza, StanzaType};
#[derive(Copy, Clone, Debug)]
pub enum IqType {
Set,
Get,
Result,
Error
}
impl StanzaType for IqType {
... | }
}
} | ("id".into(), None, id)]) | random_line_split |
ncg.rs | //! Implementation of a nonlinear conjugate gradient method.
use num_traits::Float;
use secant2::{Secant2, Secant2Error};
use ndarray::Array1;
use ndarray::ArrayView;
use std::fmt;
use std::error::Error as StdError;
use std::mem::swap;
/// Implementation of a nonlinear conjugate gradient method.
#[derive(Debug, Clone... | <Func>(&self, x0: &[S], f: Func) -> Result<Vec<S>, Error<S>>
where
Func: FnMut(&[S], &mut [S]) -> S,
{
self.minimize_with_trace(x0, f, |_, _| {})
}
/// The same as `minimize`, but allows to pass in a callback function that
/// is called after every iteration.
/// It is provided ... | minimize | identifier_name |
ncg.rs | //! Implementation of a nonlinear conjugate gradient method.
use num_traits::Float;
use secant2::{Secant2, Secant2Error};
use ndarray::Array1;
use ndarray::ArrayView; | use std::mem::swap;
/// Implementation of a nonlinear conjugate gradient method.
#[derive(Debug, Clone)]
pub struct NonlinearCG<S: Float> {
/// Nonlinear CG method
pub method: NonlinearCGMethod<S>,
/// Parameters for the line minimization `secant2` method
pub line_method: Secant2<S>,
/// Initial li... | use std::fmt;
use std::error::Error as StdError; | random_line_split |
f32.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | pub const LN_2: f32 = 0.693147180559945309417232121458176568_f32;
/// ln(10.0)
#[stable(feature = "rust1", since = "1.0.0")]
pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32;
}
impl Float for f32 {
#[inline]
fn nan() -> f32 { NAN }
#[inline]
fn infinity() -> f32 { INFI... | /// ln(2.0)
#[stable(feature = "rust1", since = "1.0.0")] | random_line_split |
f32.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | else {
unsafe { intrinsics::sqrtf32(self) }
}
}
#[inline]
fn rsqrt(self) -> f32 { self.sqrt().recip() }
/// Returns the exponential of the number.
#[inline]
fn exp(self) -> f32 {
return expf(self);
// see notes above in `floor`
#[cfg(target_env = "... | {
NAN
} | conditional_block |
f32.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () -> f32 { NEG_INFINITY }
#[inline]
fn zero() -> f32 { 0.0 }
#[inline]
fn neg_zero() -> f32 { -0.0 }
#[inline]
fn one() -> f32 { 1.0 }
from_str_radix_float_impl! { f32 }
/// Returns `true` if the number is NaN.
#[inline]
fn is_nan(self) -> bool { self!= self }
/// Retu... | neg_infinity | identifier_name |
f32.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
/// Returns the logarithm of the number with respect to an arbitrary base.
#[inline]
fn log(self, base: f32) -> f32 { self.ln() / base.ln() }
/// Returns the base 2 logarithm of the number.
#[inline]
fn log2(self) -> f32 {
unsafe { intrinsics::log2f32(self) }
}
/// Retu... | { unsafe { intrinsics::logf32(f) } } | identifier_body |
sessions_queue.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... |
if let Some(unknown_session) = self.unknown_sessions.pop_front() {
return Some(Ok(unknown_session));
}
None
}
}
| {
return Some(Ok(known_session));
} | conditional_block |
sessions_queue.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | (&mut self) -> Option<Self::Item> {
if let Some(known_session) = self.known_sessions.pop_front() {
return Some(Ok(known_session));
}
if let Some(unknown_session) = self.unknown_sessions.pop_front() {
return Some(Ok(unknown_session));
}
None
}
}
| next | identifier_name |
sessions_queue.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... |
None
}
} | } | random_line_split |
sessions_queue.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... |
}
| {
if let Some(known_session) = self.known_sessions.pop_front() {
return Some(Ok(known_session));
}
if let Some(unknown_session) = self.unknown_sessions.pop_front() {
return Some(Ok(unknown_session));
}
None
} | identifier_body |
client.rs | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// 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 r... | msg.set_svc_group_id(gid);
}
// This is only for Windows
if let Some(password) = password {
msg.set_svc_password(password.to_string());
}
msg.set_env(env);
msg.set_id(id.to_string());
Self::send(&self.tx, &msg)?;
let reply = Self::... | {
let mut msg = protocol::Spawn::new();
msg.set_binary(bin.as_ref().to_path_buf().to_string_lossy().into_owned());
// On Windows, we only expect user to be Some.
//
// On Linux, we expect user_id and group_id to be Some, while
// user and group may be either Some or None... | identifier_body |
client.rs | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// 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 r... | // used; names are only for backward compatibility with older
// Launchers.
if let Some(name) = user {
msg.set_svc_user(name.to_string());
}
if let Some(name) = group {
msg.set_svc_group(name.to_string());
}
if let Some(uid) = user_id {
... | // On Linux, we expect user_id and group_id to be Some, while
// user and group may be either Some or None. Only the IDs are | random_line_split |
client.rs | // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// 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 r... | <T>(bytes: &[u8]) -> Result<T>
where
T: protobuf::MessageStatic,
{
let txn = protocol::NetTxn::from_bytes(bytes).map_err(Error::Deserialize)?;
if txn.message_id() == "NetErr" {
let err = txn.decode::<protocol::NetErr>()
.map_err(Error::Deserialize)?;
... | read | identifier_name |
main.rs | #[macro_use]
extern crate clap;
extern crate futures;
extern crate linkerd_tcp;
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
extern crate tokio_core;
extern crate tokio_timer;
use clap::{Arg, App as ClapApp};
use linkerd_tcp::app::{self, AppConfig, App, AdminRunner, RouterSpawner};
use std::collectio... |
fn run_routers(routers: VecDeque<RouterSpawner>, closed: app::Closed, timer: &Timer) {
// Schedule all routers on the main thread.
let mut core = Core::new().expect("failed to initialize server reactor");
spawn_routers(routers, &core.handle(), timer);
// Run until the admin thread closes the applicat... | {
let timer = timer.clone();
thread::Builder::new()
.name("admin".into())
.spawn(move || {
debug!("running admin server");
let mut core = Core::new().expect("failed to initialize admin reactor");
admin.run(closer, &mut core, &timer).expect(
"fa... | identifier_body |
main.rs | #[macro_use]
extern crate clap;
extern crate futures;
extern crate linkerd_tcp;
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
extern crate tokio_core;
extern crate tokio_timer;
use clap::{Arg, App as ClapApp};
use linkerd_tcp::app::{self, AppConfig, App, AdminRunner, RouterSpawner};
use std::collectio... | () {
// Configure the logger from the RUST_LOG environment variable.
drop(pretty_env_logger::init());
// Load command-line options.
let opts = ClapApp::new(crate_name!())
.version(crate_version!())
.about(crate_description!())
.arg(
Arg::with_name(CONFIG_PATH_ARG)
... | main | identifier_name |
main.rs | #[macro_use]
extern crate clap;
extern crate futures;
extern crate linkerd_tcp;
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
extern crate tokio_core;
extern crate tokio_timer;
use clap::{Arg, App as ClapApp};
use linkerd_tcp::app::{self, AppConfig, App, AdminRunner, RouterSpawner};
use std::collectio... | while let Some(r) = routers.pop_front() {
debug!("spawning router");
r.spawn(reactor, timer).expect("failed to spawn router");
}
} | debug!("running until admin server closes");
core.run(closed).expect("failed to run");
}
fn spawn_routers(mut routers: VecDeque<RouterSpawner>, reactor: &Handle, timer: &Timer) { | random_line_split |
unit_selection_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 mouse_state.key_states.key_state(MouseButton::Right) == KeyState::TransitionUp {
let mouse_ray = calculate_mouse_ray(&viewport, &mouse_state, &view_projector, &terrain);
let mut moving_unit = false;
for (entity, transform, unit, _selected_unit) in... | {
let unit_box = unit::selection_box(unit_info, transform);
// Cast a ray from the mouse position through to the terrain and select any unit
// whose axis-aligned box intersects the ray.
if unit_box.intersects_ray(&mouse_ray.origin, &mouse... | conditional_block |
unit_selection_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 UnitSelectionSystem {
fn update(&mut self, arg: specs::RunArg, _time_step: Fixed) {
fetch_components!(arg, entities, [
components(on_screen: OnScreenComponent),
components(units: UnitComponent),
mut components(decals: DecalComponent),
mut c... | {
UnitSelectionSystem { empires: empires }
} | identifier_body |
unit_selection_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 UnitSelectionSystem {
fn update(&mut self, arg: specs::RunArg, _time_step: Fixed) {
fetch_components!(arg, entities, [
components(on_screen: OnScreenComponent),
components(units: UnitComponent),
mut components(decals: DecalComponent),
mut co... |
impl UnitSelectionSystem {
pub fn new(empires: dat::EmpiresDbRef) -> UnitSelectionSystem {
UnitSelectionSystem { empires: empires }
} | random_line_split |
unit_selection_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... | {
world_coord: Vector3,
origin: Vector3,
direction: Vector3,
}
fn calculate_mouse_ray(viewport: &Viewport,
mouse_state: &MouseState,
view_projector: &ViewProjector,
terrain: &Terrain)
-> MouseRay {
let viewport... | MouseRay | identifier_name |
layout.rs | //! Management of the directory layout of a build
//!
//! The directory layout is a little tricky at times, hence a separate file to
//! house this logic. The current layout looks like this:
//!
//! ```ignore
//! # This is the root directory for all output, the top-level package
//! # places all of its output here.
//!... |
}
pub fn deps(&self) -> &'a Path {
self.root.deps()
}
pub fn examples(&self) -> &'a Path {
self.root.examples()
}
pub fn build(&self, pkg: &Package) -> PathBuf {
self.root.build(pkg)
}
pub fn build_out(&self, pkg: &Package) -> PathBuf {
self.root.build... | {
self.root.deps()
} | conditional_block |
layout.rs | //! Management of the directory layout of a build
//!
//! The directory layout is a little tricky at times, hence a separate file to
//! house this logic. The current layout looks like this:
//!
//! ```ignore
//! # This is the root directory for all output, the top-level package
//! # places all of its output here.
//!... | (&self, package: &Package) -> PathBuf {
self.fingerprint.join(&self.pkg_dir(package))
}
pub fn build(&self, package: &Package) -> PathBuf {
self.build.join(&self.pkg_dir(package))
}
pub fn build_out(&self, package: &Package) -> PathBuf {
self.build(package).join("out")
}
... | fingerprint | identifier_name |
layout.rs | //! Management of the directory layout of a build
//!
//! The directory layout is a little tricky at times, hence a separate file to
//! house this logic. The current layout looks like this:
//!
//! ```ignore
//! # This is the root directory for all output, the top-level package
//! # places all of its output here.
//!... |
pub fn examples(&self) -> &'a Path {
self.root.examples()
}
pub fn build(&self, pkg: &Package) -> PathBuf {
self.root.build(pkg)
}
pub fn build_out(&self, pkg: &Package) -> PathBuf {
self.root.build_out(pkg)
}
pub fn proxy(&self) -> &'a Layout {
self.root... | {
self.root.deps()
} | identifier_body |
layout.rs | //! Management of the directory layout of a build
//!
//! The directory layout is a little tricky at times, hence a separate file to
//! house this logic. The current layout looks like this:
//!
//! ```ignore
//! # This is the root directory for all output, the top-level package
//! # places all of its output here.
//!... | //! $pkg3/
//!
//! # Each directory package has a `out` directory where output
//! # is placed.
//! out/
//!
//! # This is the location at which the output of all old custom build
//! # commands are rooted
//! native/
//!
//! # Each package gets its own di... | //! $pkg2/ | random_line_split |
sha2.rs | st item is the
/// high-order value and the 2nd item is the low order value.
fn to_bits(self) -> (Self, Self);
}
impl ToBits for u64 {
fn to_bits(self) -> (u64, u64) {
return (self >> 61, self << 3);
}
}
/// Adds the specified number of bytes to the bit count. fail!() if this would cause numer... | (x: u32) -> u32 {
((x >> 17) | (x << 15)) ^ ((x >> 19) | (x << 13)) ^ (x >> 10)
}
let mut a = self.h0;
let mut b = self.h1;
let mut c = self.h2;
let mut d = self.h3;
let mut e = self.h4;
let mut f = self.h5;
let mut g = self.h6;
let mu... | sigma1 | identifier_name |
sha2.rs | methods do not and require the caller to process the buffer. Any
/// method that modifies the buffer directory or provides the caller with bytes that can be modified
/// results in those bytes being marked as used by the buffer.
trait FixedBuffer {
/// Input a vector of bytes. If the buffer becomes full, process i... |
test_hash(sh, tests.as_slice());
}
/// Feed 1,000,000 'a's into the digest with varying input sizes and check that the result is | random_line_split | |
sha2.rs | return;
}
}
// While we have at least a full buffer size chunk's worth of data, process that data
// without copying it into the buffer
while input.len() - i >= size {
func(input.slice(i, i + size));
i += size;
}
// Copy any input d... | {
let mut sh = Sha256::new();
let bytes = [1u8, ..1024];
b.iter(|| {
sh.input(bytes);
});
b.bytes = bytes.len() as u64;
} | identifier_body | |
weighted.rs | //! "Weighted" graph types
use std;
use std::ops::{Deref,DerefMut};
use smallvec::SmallVec;
use super::interface::{self, Id};
// ----------------------------------------------------------------
// Edge
/// Weighted edge type.
#[derive(Debug)]
pub struct Edge<T, I: Id> {
source: I,
target: I,
data: T
}
... | (&mut self) {
::std::mem::swap(&mut self.source, &mut self.target);
}
}
impl<T, I: Id> Edge<T, I> {
/// Create an edge with the given source & target node indices and
/// weight data.
pub fn new(source: I, target: I, data: T) -> Self {
Edge{source: source, target: target, data: data}
... | rev | identifier_name |
weighted.rs | //! "Weighted" graph types
use std;
use std::ops::{Deref,DerefMut};
use smallvec::SmallVec;
use super::interface::{self, Id};
// ----------------------------------------------------------------
// Edge
/// Weighted edge type.
#[derive(Debug)]
pub struct Edge<T, I: Id> {
source: I,
target: I,
data: T
}
... |
}
impl<T, I: Id> interface::DirectedEdgeMut for Edge<T, I> {
fn rev(&mut self) {
::std::mem::swap(&mut self.source, &mut self.target);
}
}
impl<T, I: Id> Edge<T, I> {
/// Create an edge with the given source & target node indices and
/// weight data.
pub fn new(source: I, target: I, data... | { self.target } | identifier_body |
weighted.rs | //! "Weighted" graph types
use std;
use std::ops::{Deref,DerefMut};
use smallvec::SmallVec;
use super::interface::{self, Id};
// ----------------------------------------------------------------
// Edge
/// Weighted edge type.
#[derive(Debug)]
pub struct Edge<T, I: Id> {
source: I,
target: I,
data: T
}
... | fn deref(&self) -> &Self::Target {
&self.data
}
}
impl<T, I: Id> DerefMut for Edge<T, I> {
fn deref_mut(&mut self) -> &mut <Self as Deref>::Target {
&mut self.data
}
}
impl<T, I: Id, I2: Copy> From<(I2, I2)> for Edge<T, I>
where T: Default, I: From<I2> {
fn from(u: (I2, I2)) -... | }
impl<T, I: Id> Deref for Edge<T, I> {
type Target = T; | random_line_split |
plane.rs | use cgmath::{Quaternion, Rad, Rotation3};
use mint;
use three::{self, Object};
use {COLOR_BROWN, COLOR_BROWN_DARK, COLOR_RED, COLOR_WHITE};
pub struct | {
pub group: three::Group,
_cockpit: three::Mesh,
_engine: three::Mesh,
_tail: three::Mesh,
_wing: three::Mesh,
propeller_group: three::Group,
_propeller: three::Mesh,
_blade: three::Mesh,
}
impl AirPlane {
pub fn new(factory: &mut three::Factory) -> Self {
let group = fact... | AirPlane | identifier_name |
plane.rs | use cgmath::{Quaternion, Rad, Rotation3};
use mint;
use three::{self, Object};
use {COLOR_BROWN, COLOR_BROWN_DARK, COLOR_RED, COLOR_WHITE};
pub struct AirPlane {
pub group: three::Group,
_cockpit: three::Mesh,
_engine: three::Mesh,
_tail: three::Mesh,
_wing: three::Mesh,
propeller_group: three... | ;
v.y += if v.y > 0.0 { -10.0 } else { 30.0 };
}
}
factory.mesh(
geo,
three::material::Lambert {
color: COLOR_RED,
flat: false,
},
)
};
group.ad... | { 20.0 } | conditional_block |
plane.rs | use cgmath::{Quaternion, Rad, Rotation3};
use mint;
use three::{self, Object};
use {COLOR_BROWN, COLOR_BROWN_DARK, COLOR_RED, COLOR_WHITE};
pub struct AirPlane {
pub group: three::Group,
_cockpit: three::Mesh,
_engine: three::Mesh,
_tail: three::Mesh,
_wing: three::Mesh,
propeller_group: three... | self.propeller_group.set_orientation(q);
self.group
.set_position([0.0 + target.x * 100.0, 100.0 + target.y * 75.0, 0.0]);
}
} | random_line_split | |
plane.rs | use cgmath::{Quaternion, Rad, Rotation3};
use mint;
use three::{self, Object};
use {COLOR_BROWN, COLOR_BROWN_DARK, COLOR_RED, COLOR_WHITE};
pub struct AirPlane {
pub group: three::Group,
_cockpit: three::Mesh,
_engine: three::Mesh,
_tail: three::Mesh,
_wing: three::Mesh,
propeller_group: three... |
let engine = factory.mesh(
three::Geometry::cuboid(20.0, 50.0, 50.0),
three::material::Lambert {
color: COLOR_WHITE,
flat: false,
},
);
engine.set_position([40.0, 0.0, 0.0]);
group.add(&engine);
let tail = fact... | {
let group = factory.group();
let cockpit = {
let mut geo = three::Geometry::cuboid(80.0, 50.0, 50.0);
for v in geo.base.vertices.iter_mut() {
if v.x < 0.0 {
v.z += if v.y > 0.0 { -20.0 } else { 20.0 };
v.y += if v.y > 0.0... | identifier_body |
stream.rs | use crate::internal::streamname::{
self, DIGITAL_SIGNATURE_STREAM_NAME, MSI_DIGITAL_SIGNATURE_EX_STREAM_NAME,
SUMMARY_INFO_STREAM_NAME,
};
use cfb;
use std::io::{self, Read, Seek, SeekFrom, Write};
// ========================================================================= //
/// An IO reader for an embedded... | fn seek(&mut self, from: SeekFrom) -> io::Result<u64> {
self.stream.seek(from)
}
}
// ========================================================================= //
/// An IO writer for an embedded binary stream in a package.
pub struct StreamWriter<'a, F: 'a> {
stream: cfb::Stream<'a, F>,
}
impl<'... | random_line_split | |
stream.rs | use crate::internal::streamname::{
self, DIGITAL_SIGNATURE_STREAM_NAME, MSI_DIGITAL_SIGNATURE_EX_STREAM_NAME,
SUMMARY_INFO_STREAM_NAME,
};
use cfb;
use std::io::{self, Read, Seek, SeekFrom, Write};
// ========================================================================= //
/// An IO reader for an embedded... | (stream: cfb::Stream<'a, F>) -> StreamWriter<'a, F> {
StreamWriter { stream }
}
}
impl<'a, F: Read + Seek + Write> Write for StreamWriter<'a, F> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.stream.write(buf)
}
fn flush(&mut self) -> io::Result<()> {
self.stream... | new | identifier_name |
stream.rs | use crate::internal::streamname::{
self, DIGITAL_SIGNATURE_STREAM_NAME, MSI_DIGITAL_SIGNATURE_EX_STREAM_NAME,
SUMMARY_INFO_STREAM_NAME,
};
use cfb;
use std::io::{self, Read, Seek, SeekFrom, Write};
// ========================================================================= //
/// An IO reader for an embedded... |
}
// ========================================================================= //
/// An iterator over the names of the binary streams in a package.
///
/// No guarantees are made about the order in which items are returned.
pub struct Streams<'a> {
entries: cfb::Entries<'a>,
}
impl<'a> Streams<'a> {
pub(cr... | {
self.stream.seek(from)
} | identifier_body |
qmodelindex.rs |
use types::*;
extern "C" {
fn dos_qmodelindex_create() -> DosQModelIndex;
// DOS_API DosQModelIndex *DOS_CALL dos_qmodelindex_create_qmodelindex(DosQModelIndex *index);
// DOS_API void DOS_CALL dos_qmodelindex_delete (DosQModelIndex *vptr);
fn dos_qmodelindex_row(vptr: DosQModelIndex) -> i32;
fn ... | (i: DosQModelIndex) -> Self {
QModelIndex(i)
}
}
| from | identifier_name |
qmodelindex.rs | use types::*;
extern "C" {
fn dos_qmodelindex_create() -> DosQModelIndex;
// DOS_API DosQModelIndex *DOS_CALL dos_qmodelindex_create_qmodelindex(DosQModelIndex *index); | // DOS_API void DOS_CALL dos_qmodelindex_delete (DosQModelIndex *vptr);
fn dos_qmodelindex_row(vptr: DosQModelIndex) -> i32;
fn dos_qmodelindex_column(vptr: DosQModelIndex) -> i32;
// DOS_API bool DOS_CALL dos_qmodelindex_isValid(const DosQModelIndex *vptr);
// DOS_API DosQVariant *DOS_CALL dos_qmodelindex_... | random_line_split | |
qmodelindex.rs |
use types::*;
extern "C" {
fn dos_qmodelindex_create() -> DosQModelIndex;
// DOS_API DosQModelIndex *DOS_CALL dos_qmodelindex_create_qmodelindex(DosQModelIndex *index);
// DOS_API void DOS_CALL dos_qmodelindex_delete (DosQModelIndex *vptr);
fn dos_qmodelindex_row(vptr: DosQModelIndex) -> i32;
fn ... |
}
| {
QModelIndex(i)
} | identifier_body |
error.rs | use solicit::client::ClientConnectError;
use solicit::http::client::tls::TlsConnectError;
use openssl::ssl::error::SslError;
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub enum ProviderError {
ClientConnectError(String),
SslError(String)
}
impl From<SslError> for ProviderError {
fn from(e: SslE... | }
fn cause(&self) -> Option<&Error> {
None
}
}
impl fmt::Display for ProviderError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
} | random_line_split | |
error.rs | use solicit::client::ClientConnectError;
use solicit::http::client::tls::TlsConnectError;
use openssl::ssl::error::SslError;
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub enum ProviderError {
ClientConnectError(String),
SslError(String)
}
impl From<SslError> for ProviderError {
fn from(e: SslE... |
fn cause(&self) -> Option<&Error> {
None
}
}
impl fmt::Display for ProviderError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
| {
"APNs connection failed"
} | identifier_body |
error.rs | use solicit::client::ClientConnectError;
use solicit::http::client::tls::TlsConnectError;
use openssl::ssl::error::SslError;
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub enum ProviderError {
ClientConnectError(String),
SslError(String)
}
impl From<SslError> for ProviderError {
fn | (e: SslError) -> ProviderError {
ProviderError::SslError(format!("Error generating an SSL context: {}", e.description()))
}
}
impl From<ClientConnectError<TlsConnectError>> for ProviderError {
fn from(e: ClientConnectError<TlsConnectError>) -> ProviderError {
ProviderError::ClientConnectError(f... | from | identifier_name |
pagination.rs |
pub trait PaginatedRequestor {
type Item:'static + Clone;
type Error:'static;
fn next_page(&mut self) -> Result<Option<Vec<Self::Item>>, Self::Error>;
}
pub struct | <'a, TR: PaginatedRequestor> {
requestor: TR,
current_page: Option<Vec<TR::Item>>,
error: &'a mut Option<TR::Error>
}
impl<'a, TR: PaginatedRequestor> PaginatedIterator<'a, TR> {
pub fn new(requestor: TR, error: &'a mut Option<TR::Error>) -> Self {
PaginatedIterator {
requestor: req... | PaginatedIterator | identifier_name |
pagination.rs |
pub trait PaginatedRequestor {
type Item:'static + Clone;
type Error:'static;
fn next_page(&mut self) -> Result<Option<Vec<Self::Item>>, Self::Error>;
}
pub struct PaginatedIterator<'a, TR: PaginatedRequestor> {
requestor: TR,
current_page: Option<Vec<TR::Item>>,
error: &'a mut Option<TR::Erro... |
fn advance_page(&mut self) {
self.current_page = match self.requestor.next_page() {
Ok(Some(p)) => Some(p.iter().cloned().rev().collect()),
Ok(None) => None,
Err(e) => { *self.error = Some(e); None }
}
}
}
impl<'a, TR: PaginatedRequestor> Iterator for Pagin... | {
PaginatedIterator {
requestor: requestor,
current_page: None,
error: error
}
} | identifier_body |
pagination.rs | pub trait PaginatedRequestor {
type Item:'static + Clone;
type Error:'static;
fn next_page(&mut self) -> Result<Option<Vec<Self::Item>>, Self::Error>;
}
pub struct PaginatedIterator<'a, TR: PaginatedRequestor> {
requestor: TR,
current_page: Option<Vec<TR::Item>>,
error: &'a mut Option<TR::Error... | }
}
fn advance_page(&mut self) {
self.current_page = match self.requestor.next_page() {
Ok(Some(p)) => Some(p.iter().cloned().rev().collect()),
Ok(None) => None,
Err(e) => { *self.error = Some(e); None }
}
}
}
impl<'a, TR: PaginatedRequestor> Ite... | PaginatedIterator {
requestor: requestor,
current_page: None,
error: error | random_line_split |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! How and where to record the Serde format of interesting Diem types.
//! See API documentation with `cargo doc -p serde-reflection --open`
use serde_reflection::Registry;
use std::str::FromStr;
use structopt::{clap::arg_enum, Struct... | (self) -> Option<&'static str> {
match self {
Corpus::Diem => diem::output_file(),
Corpus::Consensus => consensus::output_file(),
Corpus::Network => network::output_file(),
Corpus::MoveABI => move_abi::output_file(),
}
}
}
| output_file | identifier_name |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! How and where to record the Serde format of interesting Diem types.
//! See API documentation with `cargo doc -p serde-reflection --open`
use serde_reflection::Registry;
use std::str::FromStr;
use structopt::{clap::arg_enum, Struct... |
}
| {
match self {
Corpus::Diem => diem::output_file(),
Corpus::Consensus => consensus::output_file(),
Corpus::Network => network::output_file(),
Corpus::MoveABI => move_abi::output_file(),
}
} | identifier_body |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! How and where to record the Serde format of interesting Diem types.
//! See API documentation with `cargo doc -p serde-reflection --open`
use serde_reflection::Registry;
use std::str::FromStr;
use structopt::{clap::arg_enum, Struct... | }
impl Corpus {
/// All corpuses.
pub fn values() -> Vec<Corpus> {
Corpus::variants()
.iter()
.filter_map(|s| Corpus::from_str(s).ok())
.collect()
}
/// Compute the registry of formats.
pub fn get_registry(self) -> Registry {
let result = match self... | Consensus,
Network,
MoveABI,
} | random_line_split |
interval.rs | use std::char;
use std::cmp;
use std::fmt::Debug;
use std::slice;
use std::u8;
use unicode;
// This module contains an *internal* implementation of interval sets.
//
// The primary invariant that interval sets guards is canonical ordering. That
// is, every interval set contains an ordered sequence of intervals where... | (&mut self) -> Result<(), unicode::CaseFoldError> {
let len = self.ranges.len();
for i in 0..len {
let range = self.ranges[i];
if let Err(err) = range.case_fold_simple(&mut self.ranges) {
self.canonicalize();
return Err(err);
}
... | case_fold_simple | identifier_name |
interval.rs | use std::char;
use std::cmp;
use std::fmt::Debug;
use std::slice;
use std::u8;
use unicode;
// This module contains an *internal* implementation of interval sets.
//
// The primary invariant that interval sets guards is canonical ordering. That
// is, every interval set contains an ordered sequence of intervals where... |
if self.is_intersection_empty(other) {
return (Some(self.clone()), None);
}
let add_lower = other.lower() > self.lower();
let add_upper = other.upper() < self.upper();
// We know this because!self.is_subset(other) and the ranges have
// a non-empty intersecti... | {
return (None, None);
} | conditional_block |
interval.rs | use std::char;
use std::cmp;
use std::fmt::Debug;
use std::slice;
use std::u8;
use unicode;
// This module contains an *internal* implementation of interval sets.
//
// The primary invariant that interval sets guards is canonical ordering. That
// is, every interval set contains an ordered sequence of intervals where... | fn increment(self) -> Self {
match self {
'\u{D7FF}' => '\u{E000}',
c => char::from_u32((c as u32).checked_add(1).unwrap()).unwrap(),
}
}
fn decrement(self) -> Self {
match self {
'\u{E000}' => '\u{D7FF}',
c => char::from_u32((c as u32... | random_line_split | |
interval.rs | use std::char;
use std::cmp;
use std::fmt::Debug;
use std::slice;
use std::u8;
use unicode;
// This module contains an *internal* implementation of interval sets.
//
// The primary invariant that interval sets guards is canonical ordering. That
// is, every interval set contains an ordered sequence of intervals where... |
fn max_value() -> Self {
'\u{10FFFF}'
}
fn as_u32(self) -> u32 {
self as u32
}
fn increment(self) -> Self {
match self {
'\u{D7FF}' => '\u{E000}',
c => char::from_u32((c as u32).checked_add(1).unwrap()).unwrap(),
}
}
fn decrement(sel... | {
'\x00'
} | identifier_body |
h2handshake.rs | // Copyright 2017 ThetaSinner
//
// This file is part of Osmium.
// Osmium 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.
// Osmi... |
{
DidNotUpgrade(SslStream<tokio_net::TcpStream>, Vec<u8>)
}
| HandshakeError | identifier_name |
h2handshake.rs | // Copyright 2017 ThetaSinner
//
// This file is part of Osmium.
// Osmium 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.
// Osmi... | #[derive(Debug)]
pub enum HandshakeError
{
DidNotUpgrade(SslStream<tokio_net::TcpStream>, Vec<u8>)
} | pub settings_frame: framing::settings::SettingsFrame
}
| random_line_split |
signal-exit-status.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let args: Vec<String> = env::args().collect();
if args.len() >= 2 && args[1] == "signal" {
// Raise a segfault.
unsafe { *(0 as *mut isize) = 0; }
} else {
let status = Command::new(&args[0]).arg("signal").status().unwrap();
// Windows does not have signal, so we get exit s... | identifier_body | |
signal-exit-status.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 ... | else {
let status = Command::new(&args[0]).arg("signal").status().unwrap();
// Windows does not have signal, so we get exit status 0xC0000028 (STATUS_BAD_STACK).
match status {
ExitSignal(_) if cfg!(unix) => {},
ExitStatus(0xC0000028) if cfg!(windows) => {},
... | {
// Raise a segfault.
unsafe { *(0 as *mut isize) = 0; }
} | conditional_block |
signal-exit-status.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let args: Vec<String> = env::args().collect();
if args.len() >= 2 && args[1] == "signal" {
// Raise a segfault.
unsafe { *(0 as *mut isize) = 0; }
} else {
let status = Command::new(&args[0]).arg("signal").status().unwrap();
// Windows does not have signal, so we get exi... | main | identifier_name |
signal-exit-status.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::env;
use std::old_io::process::{Command, ExitSignal, ExitStatus};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() >= 2 && args[1] == "signal" {
// Raise a segfault.
unsafe { *(0 as *mut isize) = 0; }
} else {
let status = Command::new(&args[0])... | #![feature(os)] | random_line_split |
mod.rs | extern crate rustc_serialize;
mod impl_rustc_serialize;
use rustc_serialize::{ Encodable, Decodable };
use byteorder::{ ByteOrder, BigEndian, WriteBytesExt };
use self::impl_rustc_serialize::{ encode as enc, decode as dec };
pub use super::*;
pub type EncodingResult<T> = impl_rustc_serialize::EncodingResult<T>;
pub ... |
pub fn decode<T: Decodable>(bytes: Vec<u8>) -> DecodingResult<T> {
dec::<T>(&bytes[..])
}
pub fn usize_as_u32(u: usize) -> u32 {
u as u32
}
//Preppends the length of a message
pub fn wrap_msg_len(msg: Vec<u8>) -> Vec<u8> {
let mut msg = msg;
let mut len_bytes = Vec::with_capacity(4);
len_bytes.write_u32::<B... | {
enc(data)
} | identifier_body |
mod.rs | extern crate rustc_serialize;
mod impl_rustc_serialize;
use rustc_serialize::{ Encodable, Decodable };
use byteorder::{ ByteOrder, BigEndian, WriteBytesExt };
use self::impl_rustc_serialize::{ encode as enc, decode as dec };
pub use super::*;
pub type EncodingResult<T> = impl_rustc_serialize::EncodingResult<T>;
pub ... | <T: Encodable>(data: &T) -> EncodingResult<Vec<u8>> {
enc(data)
}
pub fn decode<T: Decodable>(bytes: Vec<u8>) -> DecodingResult<T> {
dec::<T>(&bytes[..])
}
pub fn usize_as_u32(u: usize) -> u32 {
u as u32
}
//Preppends the length of a message
pub fn wrap_msg_len(msg: Vec<u8>) -> Vec<u8> {
let mut msg = msg;
l... | encode | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.