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
to_device.rs
use std::convert::TryFrom; use ruma_events::{ room_key::RoomKeyEventContent, Algorithm, AnyToDeviceEventContent, ToDeviceEvent, }; use ruma_identifiers::{RoomId, UserId}; use serde_json::{json, to_value as to_json_value}; #[test] fn
() { let ev = ToDeviceEvent { sender: UserId::try_from("@example:example.org").unwrap(), content: AnyToDeviceEventContent::RoomKey(RoomKeyEventContent { algorithm: Algorithm::MegolmV1AesSha2, room_id: RoomId::try_from("!testroomid:example.org").unwrap(), session_i...
serialization
identifier_name
to_device.rs
use std::convert::TryFrom; use ruma_events::{ room_key::RoomKeyEventContent, Algorithm, AnyToDeviceEventContent, ToDeviceEvent, }; use ruma_identifiers::{RoomId, UserId}; use serde_json::{json, to_value as to_json_value}; #[test] fn serialization()
"session_key": "SessKey", }, }) ); }
{ let ev = ToDeviceEvent { sender: UserId::try_from("@example:example.org").unwrap(), content: AnyToDeviceEventContent::RoomKey(RoomKeyEventContent { algorithm: Algorithm::MegolmV1AesSha2, room_id: RoomId::try_from("!testroomid:example.org").unwrap(), session_id: ...
identifier_body
to_device.rs
use std::convert::TryFrom; use ruma_events::{ room_key::RoomKeyEventContent, Algorithm, AnyToDeviceEventContent, ToDeviceEvent, }; use ruma_identifiers::{RoomId, UserId}; use serde_json::{json, to_value as to_json_value}; #[test] fn serialization() { let ev = ToDeviceEvent { sender: UserId::try_from("...
"content": { "algorithm": "m.megolm.v1.aes-sha2", "room_id": "!testroomid:example.org", "session_id": "SessId", "session_key": "SessKey", }, }) ); }
to_json_value(ev).unwrap(), json!({ "type": "m.room_key", "sender": "@example:example.org",
random_line_split
generate_block.rs
// Copyrighttape Technologies LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
impl BuildBlock { pub fn build_contract_address(sender: &Address, nonce: &U256) -> Address { use rlp::RlpStream; let mut stream = RlpStream::new_list(2); stream.append(sender); stream.append(nonce); From::from(stream.out().crypt_hash()) } pub fn build_tx( to...
random_line_split
generate_block.rs
// Copyrighttape Technologies LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
(sender: &Address, nonce: &U256) -> Address { use rlp::RlpStream; let mut stream = RlpStream::new_list(2); stream.append(sender); stream.append(nonce); From::from(stream.out().crypt_hash()) } pub fn build_tx( to_address: &str, data: &str, quota: ...
build_contract_address
identifier_name
buffer.rs
// Copyright 2017 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. use std::collections::{vec_deque, VecDeque}; use std::mem; use std::rc::Rc; use std::str; use crate::bam; use crate::ba...
&self) -> Option<u64> { self.inner.back().map(|rec| rec.pos() as u64) } fn tid(&self) -> Option<i32> { self.inner.back().map(|rec| rec.tid()) } /// Fill buffer at the given interval. If the start coordinate is left of /// the previous start coordinate, this will use an additional B...
nd(
identifier_name
buffer.rs
// Copyright 2017 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. use std::collections::{vec_deque, VecDeque}; use std::mem; use std::rc::Rc; use std::str; use crate::bam; use crate::ba...
match self .reader .read(Rc::get_mut(&mut self.buffer_record).unwrap()) { None => break, Some(res) => res?, } if self.buffer_record.is_unmapped() { continue;...
deleted = to_remove; } // extend to the right loop {
random_line_split
basic.rs
#![feature(plugin)] #![plugin(python_mixin)] #[test] fn smoke() { assert_eq!(python_mixin!("print(1 + 2)"), 3); assert_eq!(python_mixin!({version = "2.7"} "print 1 + 2"), 3); } #[test] fn can_use_macro()
python_mixin! {" for i in range(0, 3): print('fn f%d() -> i32 { %d }' % (i, i + 1)) "} #[test] fn items() { assert_eq!(f0(), 1); assert_eq!(f1(), 2); assert_eq!(f2(), 3); } struct Foo; impl Foo { python_mixin! {" for i in range(0, 3): print('fn f%d(&self) -> i32 { %d }' % (i, i + 1)) "}...
{ macro_rules! foo { () => { stringify!(1 + 2) } } let value = python_mixin! { concat!("x = ", foo!(), "\nprint(x)") }; assert_eq!(value, 3); }
identifier_body
basic.rs
#![feature(plugin)] #![plugin(python_mixin)]
} #[test] fn can_use_macro() { macro_rules! foo { () => { stringify!(1 + 2) } } let value = python_mixin! { concat!("x = ", foo!(), "\nprint(x)") }; assert_eq!(value, 3); } python_mixin! {" for i in range(0, 3): print('fn f%d() -> i32 { %d }' % (i, i + 1)) "...
#[test] fn smoke() { assert_eq!(python_mixin!("print(1 + 2)"), 3); assert_eq!(python_mixin!({version = "2.7"} "print 1 + 2"), 3);
random_line_split
basic.rs
#![feature(plugin)] #![plugin(python_mixin)] #[test] fn smoke() { assert_eq!(python_mixin!("print(1 + 2)"), 3); assert_eq!(python_mixin!({version = "2.7"} "print 1 + 2"), 3); } #[test] fn
() { macro_rules! foo { () => { stringify!(1 + 2) } } let value = python_mixin! { concat!("x = ", foo!(), "\nprint(x)") }; assert_eq!(value, 3); } python_mixin! {" for i in range(0, 3): print('fn f%d() -> i32 { %d }' % (i, i + 1)) "} #[test] fn items() { ...
can_use_macro
identifier_name
handle.rs
//! Handle interface to creating a verifier use std::sync::Arc; use itertools::Itertools; use log::debug; use pact_models::prelude::HttpAuth; use serde_json::Value; use pact_verifier::{ ConsumerVersionSelector, FilterInfo, NullRequestFilterExecutor, PactSource, ProviderInfo, PublishOptions, Verificatio...
path: String ) { self.provider = ProviderInfo { name, protocol: scheme, host, port: if port == 0 { None } else { Some(port) }, path } } /// Update the filter info pub fn update_filter_info( &mut self, filter_description: String, filter_state: String, fi...
port: u16,
random_line_split
handle.rs
//! Handle interface to creating a verifier use std::sync::Arc; use itertools::Itertools; use log::debug; use pact_models::prelude::HttpAuth; use serde_json::Value; use pact_verifier::{ ConsumerVersionSelector, FilterInfo, NullRequestFilterExecutor, PactSource, ProviderInfo, PublishOptions, Verificatio...
() -> Self { Self::new() } }
default
identifier_name
handle.rs
//! Handle interface to creating a verifier use std::sync::Arc; use itertools::Itertools; use log::debug; use pact_models::prelude::HttpAuth; use serde_json::Value; use pact_verifier::{ ConsumerVersionSelector, FilterInfo, NullRequestFilterExecutor, PactSource, ProviderInfo, PublishOptions, Verificatio...
else { FilterInfo::DescriptionAndState(filter_description, String::new()) } } else if!filter_description.is_empty() { FilterInfo::Description(filter_description) } else if!filter_state.is_empty() { FilterInfo::State(filter_state) } else if filter_no_state { Filte...
{ FilterInfo::DescriptionAndState(filter_description, filter_state) }
conditional_block
handle.rs
//! Handle interface to creating a verifier use std::sync::Arc; use itertools::Itertools; use log::debug; use pact_models::prelude::HttpAuth; use serde_json::Value; use pact_verifier::{ ConsumerVersionSelector, FilterInfo, NullRequestFilterExecutor, PactSource, ProviderInfo, PublishOptions, Verificatio...
/// Update the consumer filter pub fn update_consumers( &mut self, consumers: Vec<String> ) { self.consumers = consumers } /// Execute the verifier /// /// This will return an integer value based on the status of the verification: /// * 0 - verification was successful /// * 1 - verifica...
{ self.publish_options = Some(PublishOptions { provider_version: Some(provider_version.to_string()), build_url, provider_tags, provider_branch, }) }
identifier_body
thumbv7neon_unknown_linux_musleabihf.rs
use crate::spec::{Target, TargetOptions}; // This target is for musl Linux on ARMv7 with thumb mode enabled // (for consistency with Android and Debian-based distributions) // and with NEON unconditionally enabled and, therefore, with 32 FPU // registers enabled as well. See section A2.6.2 on page A2-56 in // https://...
}, } }
max_atomic_width: Some(64), mcount: "\u{1}mcount".to_string(), ..super::linux_musl_base::opts()
random_line_split
thumbv7neon_unknown_linux_musleabihf.rs
use crate::spec::{Target, TargetOptions}; // This target is for musl Linux on ARMv7 with thumb mode enabled // (for consistency with Android and Debian-based distributions) // and with NEON unconditionally enabled and, therefore, with 32 FPU // registers enabled as well. See section A2.6.2 on page A2-56 in // https://...
}
{ Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), pointer_width: 32, ...
identifier_body
thumbv7neon_unknown_linux_musleabihf.rs
use crate::spec::{Target, TargetOptions}; // This target is for musl Linux on ARMv7 with thumb mode enabled // (for consistency with Android and Debian-based distributions) // and with NEON unconditionally enabled and, therefore, with 32 FPU // registers enabled as well. See section A2.6.2 on page A2-56 in // https://...
() -> Target { Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), pointer_wid...
target
identifier_name
mod.rs
#![allow(unused)] use poisson::{algorithm, Builder, Float, Type, Vector}; use rand::distributions::{Distribution, Standard}; use rand::{rngs::SmallRng, SeedableRng}; use num_traits::NumCast; use alga::general::AbstractField; use alga::linear::{FiniteDimVectorSpace, NormedSpace}; use std::fmt::Debug; pub fn print_v...
<'r, T, F, I, A>( samples: usize, relative_radius: f64, seeds: u32, ptype: Type, prefiller: &mut F, valid: When, algo: A, ) where T: 'r + Debug + Vector<f64> + Copy, F: FnMut(f64) -> I, I: FnMut(Option<T>) -> Option<T>, A: algorithm::Creator<f64, T>, Standard: Distributio...
test_algo
identifier_name
mod.rs
#![allow(unused)] use poisson::{algorithm, Builder, Float, Type, Vector}; use rand::distributions::{Distribution, Standard}; use rand::{rngs::SmallRng, SeedableRng}; use num_traits::NumCast; use alga::general::AbstractField; use alga::linear::{FiniteDimVectorSpace, NormedSpace}; use std::fmt::Debug; pub fn print_v...
let len = hints.len(); for (n, (l, h)) in hints.into_iter().enumerate() { let remaining = len - (n + 1); assert!(l <= remaining, "For the '{:?}' algorithm the lower bound of hint should be smaller than or equal to actual: {} <= {}", algo, l, remaining); assert!(h >= remaining, "For the '...
{ use poisson::Type::*; let dim = T::dimension(); let mut vecs = vec![]; let mut hints = vec![]; { let mut iter = poisson.into_iter(); while let Some(v) = iter.next() { if let (low, Some(high)) = iter.size_hint() { hints.push((low, high)); } el...
identifier_body
mod.rs
#![allow(unused)] use poisson::{algorithm, Builder, Float, Type, Vector}; use rand::distributions::{Distribution, Standard}; use rand::{rngs::SmallRng, SeedableRng}; use num_traits::NumCast; use alga::general::AbstractField; use alga::linear::{FiniteDimVectorSpace, NormedSpace}; use std::fmt::Debug; pub fn print_v...
let dist = (v1 - v2).norm(); assert!(dist > radius * F::cast(2), "Poisson-disk distribution requirement not met while generating using the '{:?}' algorithm: There exists 2 vectors with \ distance to each other of {} which is smaller than smallest allowed...
{ continue; }
conditional_block
mod.rs
#![allow(unused)] use poisson::{algorithm, Builder, Float, Type, Vector}; use rand::distributions::{Distribution, Standard}; use rand::{rngs::SmallRng, SeedableRng}; use num_traits::NumCast; use alga::general::AbstractField; use alga::linear::{FiniteDimVectorSpace, NormedSpace}; use std::fmt::Debug; pub fn print_v...
T: Debug + Vector<f64> + Copy, Standard: Distribution<T>, { test_with_samples_prefilled( samples, relative_radius, seeds, ptype, |_| |_| None::<T>, When::Always, ); } pub fn test_with_samples_prefilled<'r, T, F, I>( samples: usize, relative_radius...
where
random_line_split
issue-2185.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 ...
// xfail-fast // This test had to do with an outdated version of the iterable trait. // However, the condition it was testing seemed complex enough to // warrant still having a test, so I inlined the old definitions. trait iterable<A> { fn iter(blk: &fn(A)); } impl<A> iterable<A> for @fn(&fn(A)) { fn iter(blk...
random_line_split
issue-2185.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn filter<A,IA:iterable<A>>(self: IA, prd: @fn(A) -> bool, blk: &fn(A)) { do self.iter |a| { if prd(a) { blk(a) } } } fn foldl<A,B,IA:iterable<A>>(self: IA, b0: B, blk: &fn(B, A) -> B) -> B { let mut b = b0; do self.iter |a| { b = blk(b, a); } b } fn range(lo: uint, hi: uin...
{ self( |i| blk(i) ) }
identifier_body
issue-2185.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<A,B,IA:iterable<A>>(self: IA, b0: B, blk: &fn(B, A) -> B) -> B { let mut b = b0; do self.iter |a| { b = blk(b, a); } b } fn range(lo: uint, hi: uint, it: &fn(uint)) { let mut i = lo; while i < hi { it(i); i += 1u; } } pub fn main() { let range: @fn(&fn(uint)) =...
foldl
identifier_name
issue-2185.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } fn foldl<A,B,IA:iterable<A>>(self: IA, b0: B, blk: &fn(B, A) -> B) -> B { let mut b = b0; do self.iter |a| { b = blk(b, a); } b } fn range(lo: uint, hi: uint, it: &fn(uint)) { let mut i = lo; while i < hi { it(i); i += 1u; } } pub fn main() { let range...
{ blk(a) }
conditional_block
disallowed_script_idents.rs
use clippy_utils::diagnostics::span_lint; use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_lint::{EarlyContext, EarlyLintPass, Level}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use unicode_script::{Script, UnicodeScript}; declare_clippy_lint! { /// ### What it does /// Chec...
} for c in symbol_str.chars() { // We want to iterate through all the scripts associated with this character // and check whether at least of one scripts is in the whitelist. let forbidden_script = c .script_extension() ...
lementation is heavily inspired by the implementation of [`non_ascii_idents`] lint: // https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint/src/non_ascii_idents.rs let check_disallowed_script_idents = cx.builder.lint_level(DISALLOWED_SCRIPT_IDENTS).0 != Level::Allow; if !check_disa...
identifier_body
disallowed_script_idents.rs
use clippy_utils::diagnostics::span_lint; use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_lint::{EarlyContext, EarlyLintPass, Level}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use unicode_script::{Script, UnicodeScript}; declare_clippy_lint! { /// ### What it does /// Chec...
: FxHashSet<Script>, } impl DisallowedScriptIdents { pub fn new(whitelist: &[String]) -> Self { let whitelist = whitelist .iter() .map(String::as_str) .filter_map(Script::from_full_name) .collect(); Self { whitelist } } } impl_lint_pass!(DisallowedSc...
Idents { whitelist
identifier_name
disallowed_script_idents.rs
use clippy_utils::diagnostics::span_lint; use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_lint::{EarlyContext, EarlyLintPass, Level}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use unicode_script::{Script, UnicodeScript}; declare_clippy_lint! { /// ### What it does /// Chec...
/// [the list of supported scripts][supported_scripts]. /// /// See also: [`non_ascii_idents`]. /// /// [aliases]: http://www.unicode.org/reports/tr24/tr24-31.html#Script_Value_Aliases /// [supported_scripts]: https://www.unicode.org/iso15924/iso15924-codes.html /// /// ### Why is this b...
/// It also ignores the `Common` script type. /// While configuring, be sure to use official script name [aliases] from
random_line_split
disallowed_script_idents.rs
use clippy_utils::diagnostics::span_lint; use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_lint::{EarlyContext, EarlyLintPass, Level}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use unicode_script::{Script, UnicodeScript}; declare_clippy_lint! { /// ### What it does /// Chec...
} } }
span_lint( cx, DISALLOWED_SCRIPT_IDENTS, span, &format!( "identifier `{}` has a Unicode script that is not allowed by configuration: {}", symbol_str, ...
conditional_block
option-unwrap.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 x = @Cell::new(1); { let b = Some(dtor { x:x }); let _c = unwrap(b); } assert_eq!(x.get(), 0); }
identifier_body
option-unwrap.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 ...
<T>(o: Option<T>) -> T { match o { Some(v) => v, None => fail!() } } pub fn main() { let x = @Cell::new(1); { let b = Some(dtor { x:x }); let _c = unwrap(b); } assert_eq!(x.get(), 0); }
unwrap
identifier_name
option-unwrap.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_eq!(x.get(), 0); }
random_line_split
dependency_format.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 calculate_type(sess: &session::Session, ty: config::CrateType) -> DependencyList { match ty { // If the global prefer_dynamic switch is turned off, first attempt // static linkage (this can fail). config::CrateTypeExecutable if!sess.opts.cg.prefer_dynamic => { ...
{ let mut fmts = tcx.dependency_formats.borrow_mut(); for &ty in tcx.sess.crate_types.borrow().iter() { fmts.insert(ty, calculate_type(&tcx.sess, ty)); } tcx.sess.abort_if_errors(); }
identifier_body
dependency_format.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 ...
sess.cstore.get_crate_data(depnum).name.clone()); add_library(sess, depnum, style, &mut formats); } } }); // Collect what we've got so far in the return vector. let mut ret = range(1, sess.cstore.next_crate_num()).map(|i| { match formats.ge...
for &(depnum, style) in deps.iter() { debug!("adding {}: {}", style,
random_line_split
dependency_format.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 ...
(tcx: &ty::ctxt) { let mut fmts = tcx.dependency_formats.borrow_mut(); for &ty in tcx.sess.crate_types.borrow().iter() { fmts.insert(ty, calculate_type(&tcx.sess, ty)); } tcx.sess.abort_if_errors(); } fn calculate_type(sess: &session::Session, ty: config::CrateType) -> Depende...
calculate
identifier_name
clone.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::BTreeMap; #[cfg(any(test, feature = "for-tests"))] use quickcheck::Arbitrary; use serde_derive::Deserialize; use ser...
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] pub struct WireIdMapEntry { #[serde(rename = "1")] pub dag_id: WireDagId, #[serde(rename = "2")] pub hg_id: WireHgId, } impl ToWire for CloneData<HgId> { type Wire = WireCloneData; fn to_wire(self) -> Self::Wire { let mut ...
#[serde(rename = "2")] pub high: WireDagId, #[serde(rename = "3")] pub parents: Vec<WireDagId>, }
random_line_split
clone.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::BTreeMap; #[cfg(any(test, feature = "for-tests"))] use quickcheck::Arbitrary; use serde_derive::Deserialize; use ser...
(self) -> Result<Self::Api, Self::Error> { let mut idmap = BTreeMap::new(); for wie in self.idmap { idmap.insert(wie.dag_id.to_api()?, wie.hg_id.to_api()?); } let flat_segments = PreparedFlatSegments { segments: self.flat_segments.to_api()?.into_iter().collect(), ...
to_api
identifier_name
clone.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::collections::BTreeMap; #[cfg(any(test, feature = "for-tests"))] use quickcheck::Arbitrary; use serde_derive::Deserialize; use ser...
} #[cfg(any(test, feature = "for-tests"))] impl Arbitrary for WireFlatSegment { fn arbitrary(g: &mut quickcheck::Gen) -> Self { FlatSegment::arbitrary(g).to_wire() } } #[cfg(any(test, feature = "for-tests"))] impl Arbitrary for WireCloneData { fn arbitrary(g: &mut quickcheck::Gen) -> Self { ...
{ Ok(FlatSegment { low: self.low.to_api()?, high: self.high.to_api()?, parents: self.parents.to_api()?, }) }
identifier_body
cci_class_cast.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 mod kitty { use std::fmt; pub struct cat { meows : uint, pub how_hungry : int, pub name : String, } impl fmt::String for cat { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.name) } } impl cat { fn meow(&mu...
random_line_split
cci_class_cast.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 ...
} impl cat { fn meow(&mut self) { println!("Meow"); self.meows += 1u; if self.meows % 5u == 0u { self.how_hungry += 1; } } } impl cat { pub fn speak(&mut self) { self.meow(); } pub fn eat(&mut self) -> b...
{ write!(f, "{}", self.name) }
identifier_body
cci_class_cast.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self) -> bool { if self.how_hungry > 0 { println!("OM NOM NOM"); self.how_hungry -= 2; return true; } else { println!("Not hungry!"); return false; } } } pub fn cat(in_x...
eat
identifier_name
cci_class_cast.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 ...
else { println!("Not hungry!"); return false; } } } pub fn cat(in_x : uint, in_y : int, in_name: String) -> cat { cat { meows: in_x, how_hungry: in_y, name: in_name } } }
{ println!("OM NOM NOM"); self.how_hungry -= 2; return true; }
conditional_block
static_handler.rs
use iron::{Request, Response, Url, Handler, Error, IronResult}; use iron::status; use mount::OriginalUrl; use super::errors::FileError; use super::requested_path::RequestedPath; /// The static file-serving `Handler`. /// /// This handler serves files from a single filesystem path, which may be absolute or relative. //...
} impl Handler for Static { fn call(&self, req: &mut Request) -> IronResult<Response> { let requested_path = RequestedPath::new(&self.root_path, req); // If the URL ends in a slash, serve the file directly. // Otherwise, redirect to the directory equivalent of the URL, ala Apache. ...
{ Static { root_path: root_path } }
identifier_body
static_handler.rs
use iron::{Request, Response, Url, Handler, Error, IronResult}; use iron::status; use mount::OriginalUrl; use super::errors::FileError; use super::requested_path::RequestedPath; /// The static file-serving `Handler`. /// /// This handler serves files from a single filesystem path, which may be absolute or relative. //...
(&self, req: &mut Request) -> IronResult<Response> { let requested_path = RequestedPath::new(&self.root_path, req); // If the URL ends in a slash, serve the file directly. // Otherwise, redirect to the directory equivalent of the URL, ala Apache. if requested_path.should_redirect(req) {...
call
identifier_name
static_handler.rs
use iron::{Request, Response, Url, Handler, Error, IronResult}; use iron::status; use mount::OriginalUrl; use super::errors::FileError; use super::requested_path::RequestedPath; /// The static file-serving `Handler`. /// /// This handler serves files from a single filesystem path, which may be absolute or relative. //...
}, None => // If no file is found, return a 404 response. return Ok(Response::with(status::NotFound, "File not found")), } } }
{ return Err(FileError(err).erase()); }
conditional_block
static_handler.rs
use iron::{Request, Response, Url, Handler, Error, IronResult}; use iron::status; use mount::OriginalUrl; use super::errors::FileError; use super::requested_path::RequestedPath; /// The static file-serving `Handler`. /// /// This handler serves files from a single filesystem path, which may be absolute or relative. //...
/// The path this handler is serving files from. pub root_path: Path } impl Static { /// Create a new instance of `Static` with a given root path. /// /// If `Path::new("")` is given, files will be served from the current directory. pub fn new(root_path: Path) -> Static { Static { root_...
#[deriving(Clone)] pub struct Static {
random_line_split
service.rs
// Copyright 2015, 2016 Ethcore (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 later version....
&spec, &client_db, Arc::new(::miner::Miner::with_spec(&spec)), IoChannel::disconnected(), &db_config, ).unwrap(); let service_params = ServiceParams { engine: spec.engine.clone(), genesis_block: spec.genesis_block(), db_config: db_config, pruning: ::util::journaldb::Algorithm::Archive, channel: I...
{ const NUM_BLOCKS: u32 = 400; const TX_PER: usize = 5; let gas_prices = vec![1.into(), 2.into(), 3.into(), 999.into()]; let client = generate_dummy_client_with_spec_and_data(Spec::new_null, NUM_BLOCKS, TX_PER, &gas_prices); let path = RandomTempPath::create_dir(); let mut path = path.as_path().clone(); let m...
identifier_body
service.rs
// Copyright 2015, 2016 Ethcore (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 later version....
use io::IoChannel; use util::kvdb::DatabaseConfig; struct NoopDBRestore; impl snapshot::DatabaseRestore for NoopDBRestore { fn restore_db(&self, _new_db: &str) -> Result<(), ::error::Error> { Ok(()) } } #[test] fn restored_is_equivalent() { const NUM_BLOCKS: u32 = 400; const TX_PER: usize = 5; let gas_prices...
use devtools::RandomTempPath;
random_line_split
service.rs
// Copyright 2015, 2016 Ethcore (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 later version....
() { let spec = Spec::new_null(); let path = RandomTempPath::create_dir(); let mut path = path.as_path().clone(); let service_params = ServiceParams { engine: spec.engine.clone(), genesis_block: spec.genesis_block(), db_config: DatabaseConfig::with_columns(::db::NUM_COLUMNS), pruning: ::util::journaldb::Alg...
guards_delete_folders
identifier_name
morestack4.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 ...
else { fail!(); } } struct and_then_get_big_again { x:int, } impl Drop for and_then_get_big_again { fn drop(&self) {} } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }...
{ getbig_and_fail(i - 1); }
conditional_block
morestack4.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { do task::spawn { getbig_and_fail(1); }; }
{ and_then_get_big_again { x: x } }
identifier_body
morestack4.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 ...
extern mod extra; use std::task; fn getbig_and_fail(i: int) { let r = and_then_get_big_again(5); if i!= 0 { getbig_and_fail(i - 1); } else { fail!(); } } struct and_then_get_big_again { x:int, } impl Drop for and_then_get_big_again { fn drop(&self) {} } fn and_then_get_big_ag...
// Just testing unwinding
random_line_split
morestack4.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 ...
(i: int) { let r = and_then_get_big_again(5); if i!= 0 { getbig_and_fail(i - 1); } else { fail!(); } } struct and_then_get_big_again { x:int, } impl Drop for and_then_get_big_again { fn drop(&self) {} } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_ge...
getbig_and_fail
identifier_name
mod.rs
use std::env; use std::io::{stderr, Write}; use std::path::{Path}; use std::process::exit; use std::fs::metadata; use std::os::unix::fs::MetadataExt; use libc::getuid; use unshare::Command; use options::build_mode::build_mode; use config::find_config; use config::read_settings::read_settings; use argparse::{ArgumentP...
() { let val = run(); exit(val); }
main
identifier_name
mod.rs
use std::env; use std::io::{stderr, Write}; use std::path::{Path}; use std::process::exit; use std::fs::metadata; use std::os::unix::fs::MetadataExt; use libc::getuid; use unshare::Command; use options::build_mode::build_mode; use config::find_config; use config::read_settings::read_settings; use argparse::{ArgumentP...
{ let val = run(); exit(val); }
identifier_body
mod.rs
use std::env; use std::io::{stderr, Write}; use std::path::{Path}; use std::process::exit; use std::fs::metadata; use std::os::unix::fs::MetadataExt; use libc::getuid; use unshare::Command; use options::build_mode::build_mode; use config::find_config; use config::read_settings::read_settings; use argparse::{ArgumentP...
} }; match result { Ok(rc) => { return rc; } Err(text) => { writeln!(&mut err, "{}", text).ok(); return 121; } } } pub fn main() { let val = run(); exit(val); }
} _ => { user::run_user_command(&config, &int_settings, &int_workdir, cname, args, bmode)
random_line_split
mod.rs
use std::env; use std::io::{stderr, Write}; use std::path::{Path}; use std::process::exit; use std::fs::metadata; use std::os::unix::fs::MetadataExt; use libc::getuid; use unshare::Command; use options::build_mode::build_mode; use config::find_config; use config::read_settings::read_settings; use argparse::{ArgumentP...
}; let int_workdir = workdir.rel_to(&cfg_dir) .unwrap_or(&Path::new(".")); for k in propagate_env.into_iter() { if k.chars().find(|&c| c == '=').is_some() { writeln!(&mut err, "Environment variable name \ (for option `-e`/`--use-env`) \ ...
{ writeln!(&mut err, "{}", e).ok(); return 126; }
conditional_block
foreach-external-iterators-hashmap.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 ...
for &(k,v) in &kvs { h.insert(k,v); } let mut x = 0; let mut y = 0; for (&k,&v) in &h { x += k; y += v; } assert_eq!(x, 6); assert_eq!(y, 60); }
use std::collections::HashMap; pub fn main() { let mut h = HashMap::new(); let kvs = [(1, 10), (2, 20), (3, 30)];
random_line_split
foreach-external-iterators-hashmap.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut h = HashMap::new(); let kvs = [(1, 10), (2, 20), (3, 30)]; for &(k,v) in &kvs { h.insert(k,v); } let mut x = 0; let mut y = 0; for (&k,&v) in &h { x += k; y += v; } assert_eq!(x, 6); assert_eq!(y, 60); }
main
identifier_name
foreach-external-iterators-hashmap.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut h = HashMap::new(); let kvs = [(1, 10), (2, 20), (3, 30)]; for &(k,v) in &kvs { h.insert(k,v); } let mut x = 0; let mut y = 0; for (&k,&v) in &h { x += k; y += v; } assert_eq!(x, 6); assert_eq!(y, 60); }
identifier_body
index.rs
use super::Value; use crate::map::Map; use alloc::borrow::ToOwned; use alloc::string::String; use core::fmt::{self, Display}; use core::ops; /// A type that can be used to index into a `serde_json::Value`. /// /// The [`get`] and [`get_mut`] methods of `Value` accept any type that /// implements `Index`, as does the [...
impl<'a> Display for Type<'a> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { match *self.0 { Value::Null => formatter.write_str("null"), Value::Bool(_) => formatter.write_str("boolean"), Value::Number(_) => formatter.write_str("number"), Valu...
/// Used in panic messages. struct Type<'a>(&'a Value);
random_line_split
index.rs
use super::Value; use crate::map::Map; use alloc::borrow::ToOwned; use alloc::string::String; use core::fmt::{self, Display}; use core::ops; /// A type that can be used to index into a `serde_json::Value`. /// /// The [`get`] and [`get_mut`] methods of `Value` accept any type that /// implements `Index`, as does the [...
<'a>(&'a Value); impl<'a> Display for Type<'a> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { match *self.0 { Value::Null => formatter.write_str("null"), Value::Bool(_) => formatter.write_str("boolean"), Value::Number(_) => formatter.write_str("number")...
Type
identifier_name
stdio.rs
use io::lazy::Lazy; use io::{Read, Write, Result}; use sync::Arc; use hal::Console; use hal::console; use sync::spin::{InterruptSpinLock, InterruptSpinGuard}; fn stdout_init() -> Arc<InterruptSpinLock<Console<'static>>> { Arc::new(InterruptSpinLock::new(console())) } pub fn stdout() -> Stdout { static STD...
} pub fn stdin() -> Stdin { static STDIN: Lazy<InterruptSpinLock<Console<'static>>> = Lazy::new(stdin_init); Stdin { inner: unsafe { STDIN.get() }, } } pub struct Stdin { inner: Arc<InterruptSpinLock<Console<'static>>>, } impl Stdin { pub fn lock(&self) -> StdinLock { StdinLock {...
Arc::new(InterruptSpinLock::new(console()))
random_line_split
stdio.rs
use io::lazy::Lazy; use io::{Read, Write, Result}; use sync::Arc; use hal::Console; use hal::console; use sync::spin::{InterruptSpinLock, InterruptSpinGuard}; fn stdout_init() -> Arc<InterruptSpinLock<Console<'static>>> { Arc::new(InterruptSpinLock::new(console())) } pub fn stdout() -> Stdout { static STD...
pub fn stdin() -> Stdin { static STDIN: Lazy<InterruptSpinLock<Console<'static>>> = Lazy::new(stdin_init); Stdin { inner: unsafe { STDIN.get() }, } } pub struct Stdin { inner: Arc<InterruptSpinLock<Console<'static>>>, } impl Stdin { pub fn lock(&self) -> StdinLock { StdinLock { ...
{ Arc::new(InterruptSpinLock::new(console())) }
identifier_body
stdio.rs
use io::lazy::Lazy; use io::{Read, Write, Result}; use sync::Arc; use hal::Console; use hal::console; use sync::spin::{InterruptSpinLock, InterruptSpinGuard}; fn stdout_init() -> Arc<InterruptSpinLock<Console<'static>>> { Arc::new(InterruptSpinLock::new(console())) } pub fn stdout() -> Stdout { static STD...
<'a> { lock: InterruptSpinGuard<'a, Console<'static>>, } impl<'a> Read for StdinLock<'a> { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { self.lock.read(buf) } }
StdinLock
identifier_name
deriving-hash.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::hash; use std::hash::Hash; #[deriving(Hash)] struct Person { id: uint, name: ~str, phone: uint, } fn main() { let person1 = Person { id: 5, name: "Janet".to_owned(), phone: 555_666_7777 }; let person2 = Person { id: 5, name: "Bob".to_owned(), phone: 555_666_7777 }; assert!(hash::hash(...
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
deriving-hash.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 person1 = Person { id: 5, name: "Janet".to_owned(), phone: 555_666_7777 }; let person2 = Person { id: 5, name: "Bob".to_owned(), phone: 555_666_7777 }; assert!(hash::hash(&person1) == hash::hash(&person1)); assert!(hash::hash(&person1)!= hash::hash(&person2)); }
main
identifier_name
prime.rs
#![feature(plugin)] #![plugin(fractran_macros)] fn main() { // Conway's prime enumeration program. The subsequence of perfect // powers of two (other than the initial 2) is 4 = 2^2, 8 = 2^3, // 32 = 2^5, etc. specifically, it enumerates the primes. let mut primes = fractran!(17/91, 78/85, 19/51, 23/3...
if primes.state()[1..].iter().all(|x| *x == 0) { println!("{} (step {})", primes.state()[0], count) } count += 1; } }
random_line_split
prime.rs
#![feature(plugin)] #![plugin(fractran_macros)] fn
() { // Conway's prime enumeration program. The subsequence of perfect // powers of two (other than the initial 2) is 4 = 2^2, 8 = 2^3, // 32 = 2^5, etc. specifically, it enumerates the primes. let mut primes = fractran!(17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17, ...
main
identifier_name
prime.rs
#![feature(plugin)] #![plugin(fractran_macros)] fn main()
} count += 1; } }
{ // Conway's prime enumeration program. The subsequence of perfect // powers of two (other than the initial 2) is 4 = 2^2, 8 = 2^3, // 32 = 2^5, etc. specifically, it enumerates the primes. let mut primes = fractran!(17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 77/19, 1/17, ...
identifier_body
lib.rs
#![crate_type="dylib"] #![feature(plugin_registrar, rustc_private)] extern crate syntax; extern crate rustc; extern crate rustc_plugin; extern crate rand; use rand::Rng; use std::ops::Deref; use std::rc::Rc; use syntax::ptr::P; use syntax::parse::token; use syntax::tokenstream::TokenTree; use syntax::ast::{Expr, L...
(text: &str) -> (Vec<u8>, Vec<u8>) { let text = String::from(text); let mut text = text.into_bytes(); // Generate a random key using the rand crate let mut random = rand::thread_rng(); let mut key = vec![0; text.len()]; random.fill_bytes(&mut key); // Encrypt the text using XOR for i i...
encrypt_str_with_rand_key
identifier_name
lib.rs
#![crate_type="dylib"] #![feature(plugin_registrar, rustc_private)] extern crate syntax; extern crate rustc; extern crate rustc_plugin; extern crate rand; use rand::Rng; use std::ops::Deref; use std::rc::Rc; use syntax::ptr::P; use syntax::parse::token; use syntax::tokenstream::TokenTree; use syntax::ast::{Expr, L...
fn encrypt_str(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult +'static> { let text = match args[0] { TokenTree::Token(_, token::Literal(token::Lit::Str_(s), _)) => s, _ => { cx.span_err(sp, "argument must be a string literal"); return DummyResult::any(sp); ...
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager}; use syntax::ext::build::AstBuilder; use rustc_plugin::Registry;
random_line_split
lib.rs
#![crate_type="dylib"] #![feature(plugin_registrar, rustc_private)] extern crate syntax; extern crate rustc; extern crate rustc_plugin; extern crate rand; use rand::Rng; use std::ops::Deref; use std::rc::Rc; use syntax::ptr::P; use syntax::parse::token; use syntax::tokenstream::TokenTree; use syntax::ast::{Expr, L...
fn get_expr_from_bytes(cx: &mut ExtCtxt, sp: Span, bytes: Vec<u8>) -> P<Expr> { cx.expr_lit(sp, LitKind::ByteStr(Rc::new(bytes))) } #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("e", encrypt_str); }
{ let text = String::from(text); let mut text = text.into_bytes(); // Generate a random key using the rand crate let mut random = rand::thread_rng(); let mut key = vec![0; text.len()]; random.fill_bytes(&mut key); // Encrypt the text using XOR for i in 0..text.len() { text[i] =...
identifier_body
build.rs
use gl_generator::{Api, Fallbacks, Profile, Registry}; use std::env; use std::fs::File; use std::path::PathBuf; fn main() { let target = env::var("TARGET").unwrap(); let dest = PathBuf::from(&env::var("OUT_DIR").unwrap()); println!("cargo:rerun-if-changed=build.rs"); if target.contains("windows") { ...
"WGL_ARB_multisample", "WGL_ARB_pixel_format", "WGL_ARB_pixel_format_float", "WGL_EXT_create_context_es2_profile", "WGL_EXT_extensions_string", "WGL_EXT_framebuffer_sRGB", "WGL_EXT_swap_control", ...
"WGL_ARB_context_flush_control", "WGL_ARB_extensions_string", "WGL_ARB_framebuffer_sRGB",
random_line_split
build.rs
use gl_generator::{Api, Fallbacks, Profile, Registry}; use std::env; use std::fs::File; use std::path::PathBuf; fn main() { let target = env::var("TARGET").unwrap(); let dest = PathBuf::from(&env::var("OUT_DIR").unwrap()); println!("cargo:rerun-if-changed=build.rs"); if target.contains("windows")
"WGL_ARB_pixel_format", "WGL_ARB_pixel_format_float", "WGL_EXT_create_context_es2_profile", "WGL_EXT_extensions_string", "WGL_EXT_framebuffer_sRGB", "WGL_EXT_swap_control", ], ) .write_bindings(gl_...
{ let mut file = File::create(&dest.join("wgl_bindings.rs")).unwrap(); Registry::new(Api::Wgl, (1, 0), Profile::Core, Fallbacks::All, []) .write_bindings(gl_generator::StaticGenerator, &mut file) .unwrap(); let mut file = File::create(&dest.join("wgl_extra_bindings.rs"))...
conditional_block
build.rs
use gl_generator::{Api, Fallbacks, Profile, Registry}; use std::env; use std::fs::File; use std::path::PathBuf; fn main()
"WGL_ARB_create_context_profile", "WGL_ARB_create_context_robustness", "WGL_ARB_context_flush_control", "WGL_ARB_extensions_string", "WGL_ARB_framebuffer_sRGB", "WGL_ARB_multisample", "WGL_ARB_pixel_format", ...
{ let target = env::var("TARGET").unwrap(); let dest = PathBuf::from(&env::var("OUT_DIR").unwrap()); println!("cargo:rerun-if-changed=build.rs"); if target.contains("windows") { let mut file = File::create(&dest.join("wgl_bindings.rs")).unwrap(); Registry::new(Api::Wgl, (1, 0), Profile...
identifier_body
build.rs
use gl_generator::{Api, Fallbacks, Profile, Registry}; use std::env; use std::fs::File; use std::path::PathBuf; fn
() { let target = env::var("TARGET").unwrap(); let dest = PathBuf::from(&env::var("OUT_DIR").unwrap()); println!("cargo:rerun-if-changed=build.rs"); if target.contains("windows") { let mut file = File::create(&dest.join("wgl_bindings.rs")).unwrap(); Registry::new(Api::Wgl, (1, 0), Prof...
main
identifier_name
mod.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} #[test] fn dwarf_reader() { let encoded: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 0xE5, 0x8E, 0x26, 0x9B, 0xF1, 0x59, 0xFF, 0xFF]; let mut reader = DwarfReader::new(encoded.as_ptr()); unsafe { assert!(reader.read::<u8>() == u8::to_be(1u8)); assert!(reader.read::<u16>() == u16::to_be(0x0203)); ...
{ let mut shift: usize = 0; let mut result: u64 = 0; let mut byte: u8; loop { byte = self.read::<u8>(); result |= ((byte & 0x7F) as u64) << shift; shift += 7; if byte & 0x80 == 0 { break; } } // s...
identifier_body
mod.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn new(ptr: *const u8) -> DwarfReader { DwarfReader { ptr } } // DWARF streams are packed, so e.g., a u32 would not necessarily be aligned // on a 4-byte boundary. This may cause problems on platforms with strict // alignment requirements. By wrapping data in a "packed" struct, we are ...
impl DwarfReader {
random_line_split
mod.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self) -> i64 { let mut shift: usize = 0; let mut result: u64 = 0; let mut byte: u8; loop { byte = self.read::<u8>(); result |= ((byte & 0x7F) as u64) << shift; shift += 7; if byte & 0x80 == 0 { break; } ...
read_sleb128
identifier_name
mod.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} result } pub unsafe fn read_sleb128(&mut self) -> i64 { let mut shift: usize = 0; let mut result: u64 = 0; let mut byte: u8; loop { byte = self.read::<u8>(); result |= ((byte & 0x7F) as u64) << shift; shift += 7; ...
{ break; }
conditional_block
cssstylevalue.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 cssparser::Parser; use cssparser::ParserInput; use dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSS...
} impl CSSStyleValueMethods for CSSStyleValue { /// https://drafts.css-houdini.org/css-typed-om-1/#CSSStyleValue-stringification-behavior fn Stringifier(&self) -> DOMString { DOMString::from(&*self.value) } /// This attribute is no longer part of the `CSSStyleValue` interface, /// but is ...
{ reflect_dom_object(box CSSStyleValue::new_inherited(value), global, Wrap) }
identifier_body
cssstylevalue.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 cssparser::Parser; use cssparser::ParserInput; use dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSS...
{ reflector: Reflector, value: String, } impl CSSStyleValue { fn new_inherited(value: String) -> CSSStyleValue { CSSStyleValue { reflector: Reflector::new(), value: value, } } pub fn new(global: &GlobalScope, value: String) -> Root<CSSStyleValue> { ...
CSSStyleValue
identifier_name
cssstylevalue.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 cssparser::Parser; use cssparser::ParserInput; use dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSS...
} impl CSSStyleValue { /// Parse the value as a `url()`. /// TODO: This should really always be an absolute URL, but we currently /// return relative URLs for computed values, so we pass in a base. /// https://github.com/servo/servo/issues/17625 pub fn get_url(&self, base_url: ServoUrl) -> Option<S...
/// https://github.com/GoogleChrome/houdini-samples/issues/16 // check-tidy: no specs after this line fn CssText(&self) -> DOMString { self.Stringifier() }
random_line_split
build.rs
use std::env;
use std::str::{self, FromStr}; fn main(){ let minor = match rustc_minor_version() { Some(minor) => minor, None => return, }; // const fn stabilized in Rust 1.31: if minor >= 31 { println!("cargo:rustc-cfg=bitflags_const_fn"); } } fn rustc_minor_version() -> Option<u32> { ...
use std::process::Command;
random_line_split
build.rs
use std::env; use std::process::Command; use std::str::{self, FromStr}; fn main(){ let minor = match rustc_minor_version() { Some(minor) => minor, None => return, }; // const fn stabilized in Rust 1.31: if minor >= 31 { println!("cargo:rustc-cfg=bitflags_const_fn"); } } fn...
let next = match pieces.next() { Some(next) => next, None => return None, }; u32::from_str(next).ok() }
{ let rustc = match env::var_os("RUSTC") { Some(rustc) => rustc, None => return None, }; let output = match Command::new(rustc).arg("--version").output() { Ok(output) => output, Err(_) => return None, }; let version = match str::from_utf8(&output.stdout) { O...
identifier_body
build.rs
use std::env; use std::process::Command; use std::str::{self, FromStr}; fn
(){ let minor = match rustc_minor_version() { Some(minor) => minor, None => return, }; // const fn stabilized in Rust 1.31: if minor >= 31 { println!("cargo:rustc-cfg=bitflags_const_fn"); } } fn rustc_minor_version() -> Option<u32> { let rustc = match env::var_os("RUSTC...
main
identifier_name
person.rs
// Copyright (C) 2015 Steven Allen // // This file is part of gazetta. // // 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 version 3 of the // License. // // This program is distributed in t...
name: match person.remove(&NAME) { Some(Yaml::String(name)) => name, None => return Err("missing name"), _ => return Err("name must be a string"), }, photo: match person.remove(&PHOTO) { Some(...
pub fn from_yaml(person: Yaml) -> Result<Self, &'static str> { Ok(match person { Yaml::Hash(mut person) => Person {
random_line_split
person.rs
// Copyright (C) 2015 Steven Allen // // This file is part of gazetta. // // 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 version 3 of the // License. // // This program is distributed in t...
{ pub url: String, pub fingerprint: String, } impl Key { pub fn from_yaml(key: Yaml) -> Result<Self, &'static str> { match key { Yaml::Hash(mut key) => Ok(Key { url: match key.remove(&URL) { Some(Yaml::String(url)) => url, Some(.....
Key
identifier_name
rollout.rs
//! Interface and implementations for the rollout phase of MCTS. use crate::game::Game; use crate::graph::{EdgeData, VertexData}; use crate::SearchSettings; use std::convert::From; use std::error::Error; use std::fmt; use std::result::Result; use rand::Rng; /// Error type for MCTS rollout. pub enum RolloutError<G: ...
<'a, 'id, G, S, R>( graph: &search_graph::view::View<'a, 'id, G::State, VertexData, EdgeData<G>>, mut node: search_graph::view::NodeRef<'id>, selector: S, rng: &mut R, ) -> Result<search_graph::view::NodeRef<'id>, RolloutError<G, S::Error>> where G: Game, S: RolloutSelector, R: Rng, { loop { if let ...
rollout
identifier_name
rollout.rs
//! Interface and implementations for the rollout phase of MCTS. use crate::game::Game; use crate::graph::{EdgeData, VertexData}; use crate::SearchSettings; use std::convert::From; use std::error::Error; use std::fmt; use std::result::Result; use rand::Rng; /// Error type for MCTS rollout. pub enum RolloutError<G: ...
impl<G: Game, E: Error> fmt::Display for RolloutError<G, E> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { RolloutError::Cycle { root: _, elements: _, } => write!(f, "Cycle in path"), RolloutError::Selector(ref e) => write!(f, "Selector error ({})", e), } } } impl<G: Ga...
} }
random_line_split
rollout.rs
//! Interface and implementations for the rollout phase of MCTS. use crate::game::Game; use crate::graph::{EdgeData, VertexData}; use crate::SearchSettings; use std::convert::From; use std::error::Error; use std::fmt; use std::result::Result; use rand::Rng; /// Error type for MCTS rollout. pub enum RolloutError<G: ...
} /// Provides a method for selecting an outgoing child edge to follow during /// the rollout phase of MCTS. pub trait RolloutSelector: for<'a> From<&'a SearchSettings> { type Error: Error; /// Returns the element of `children` that should be followed, or an error. fn select<'a, 'id, G: Game, R: Rng>( &sel...
{ RolloutError::Selector(e) }
identifier_body
imp.rs
// Copyright (C) 2016-2017 Sebastian Dröge <sebastian@centricular.com> // 2016 Luis de Bethencourt <luisbg@osg.samsung.com> // 2018 François Laignel <fengalin@free.fr> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or th...
if let State::Stopped = *state { return Err(gst_error_msg!( gst::ResourceError::Settings, ["FileSink not started"] )); } *state = State::Stopped; gst_info!(CAT, obj: element, "Stopped"); Ok(()) } // TODO: implemen...
Ok(()) } fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> { let mut state = self.state.lock().unwrap();
random_line_split
imp.rs
// Copyright (C) 2016-2017 Sebastian Dröge <sebastian@centricular.com> // 2016 Luis de Bethencourt <luisbg@osg.samsung.com> // 2018 François Laignel <fengalin@free.fr> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or th...
ype_: &mut subclass::InitializingType<Self>) { type_.add_interface::<gst::URIHandler>(); } fn class_init(klass: &mut Self::Class) { klass.set_metadata( "File Sink", "Sink/File", "Write stream to a file", "François Laignel <fengalin@free.fr>, Luis ...
pe_init(t
identifier_name
imp.rs
// Copyright (C) 2016-2017 Sebastian Dröge <sebastian@centricular.com> // 2016 Luis de Bethencourt <luisbg@osg.samsung.com> // 2018 François Laignel <fengalin@free.fr> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or th...
} Some(location) } None => { gst_info!(CAT, obj: element, "Resetting `location` to None",); None } }; Ok(()) } } impl ObjectSubclass for FileSink { const NAME: &'static str = "RsFileSink"; ty...
gst_info!(CAT, obj: element, "Setting `location` to {}", location,); }
conditional_block
iso_8859_7.rs
// AUTOGENERATED FROM index-iso-8859-7.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // https://creativecommons.org/publicdomain/zero/1.0/ // // For details on index index-iso-8859-7.txt see the Encoding Standard // https://encoding.spec.whatwg.org/ // // Identifier: f53d8aeba363...
(code: u32) -> u8 { let offset = (code >> 5) as usize; let offset = if offset < 262 {BACKWARD_TABLE_UPPER[offset] as usize} else {0}; BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] } #[cfg(test)] single_byte_tests!( mod = iso_8859_7 );
backward
identifier_name
iso_8859_7.rs
// AUTOGENERATED FROM index-iso-8859-7.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // https://creativecommons.org/publicdomain/zero/1.0/ // // For details on index index-iso-8859-7.txt see the Encoding Standard // https://encoding.spec.whatwg.org/ // // Identifier: f53d8aeba363...
; BACKWARD_TABLE_LOWER[offset + ((code & 31) as usize)] } #[cfg(test)] single_byte_tests!( mod = iso_8859_7 );
{0}
conditional_block
iso_8859_7.rs
// AUTOGENERATED FROM index-iso-8859-7.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // https://creativecommons.org/publicdomain/zero/1.0/ // // For details on index index-iso-8859-7.txt see the Encoding Standard // https://encoding.spec.whatwg.org/ // // Identifier: f53d8aeba363...
/// Returns the index code point for pointer `code` in this index. #[inline] pub fn forward(code: u8) -> u16 { FORWARD_TABLE[(code - 0x80) as usize] } static BACKWARD_TABLE_LOWER: &'static [u8] = &[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 13...
965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 65535, ];
random_line_split
iso_8859_7.rs
// AUTOGENERATED FROM index-iso-8859-7.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // https://creativecommons.org/publicdomain/zero/1.0/ // // For details on index index-iso-8859-7.txt see the Encoding Standard // https://encoding.spec.whatwg.org/ // // Identifier: f53d8aeba363...
static BACKWARD_TABLE_LOWER: &'static [u8] = &[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159...
{ FORWARD_TABLE[(code - 0x80) as usize] }
identifier_body
lib.rs
//! This crate provides a safe wrapper around the native `libusb` library. extern crate bit_set; extern crate libusb_sys as libusb; extern crate libc; pub use version::{LibraryVersion, version}; pub use error::{Result, Error}; pub use context::{Context, LogLevel}; pub use device_list::{DeviceList, Devices}; pub use ...
mod fields; mod device_descriptor; mod config_descriptor; mod interface_descriptor; mod endpoint_descriptor; mod language;
mod context; mod device_list; mod device; mod device_handle;
random_line_split