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 |
|---|---|---|---|---|
ast.rs | // Copyright 2015 Pierre Talbot (IRCAM)
// 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... |
&AnySingleChar => {
visitor.visit_any_single_char(parent)
}
&NonTerminalSymbol(id) => {
visitor.visit_non_terminal_symbol(parent, id)
}
&Sequence(ref seq) => {
visitor.visit_sequence(parent, seq)
}
&Choice(ref choices) => {
visitor.visit_choice(parent, choices)
}... | {
visitor.visit_str_literal(parent, lit)
} | conditional_block |
ast.rs | // Copyright 2015 Pierre Talbot (IRCAM)
// 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... |
fn visit_syntactic_predicate(&mut self, _parent: &Box<Node>, expr: &Box<Node>) -> R {
walk_expr(self, expr)
}
fn visit_not_predicate(&mut self, parent: &Box<Node>, expr: &Box<Node>) -> R {
self.visit_syntactic_predicate(parent, expr)
}
fn visit_and_predicate(&mut self, parent: &Box<Node>, expr: &B... | {
walk_expr(self, expr)
} | identifier_body |
ast.rs | // Copyright 2015 Pierre Talbot (IRCAM)
// 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... | AnySingleChar, //.
CharacterClass(CharacterClassExpr), // [0-9]
NonTerminalSymbol(Ident), // a_rule
Sequence(Vec<Box<SubExpr>>), // a_rule next_rule
Choice(Vec<Box<SubExpr>>), // try_this / or_try_this_one
ZeroOrMore(Box<SubExpr>), // space*
OneOrMore(Box<SubExpr>), // space+
Optional(Box<SubExpr>), // ... | pub type RItem = rust::P<rust::Item>;
#[derive(Clone, Debug)]
pub enum Expression_<SubExpr: ?Sized>{
StrLiteral(String), // "match me" | random_line_split |
system.rs | use std::sync::{Arc, RwLock};
use crayon::application::prelude::{LifecycleListener, LifecycleListenerHandle};
use crayon::errors::Result;
use crayon::math::prelude::Vector3;
use crayon::res::utils::prelude::{ResourcePool, ResourceState};
use crayon::uuid::Uuid;
use super::assets::prelude::{AudioClipHandle, AudioClipL... | <T: AsRef<str>>(&self, url: T) -> Result<AudioClipHandle> {
self.clips.write().unwrap().create_from(url)
}
/// Creates a clip object from file asynchronously.
#[inline]
pub fn create_clip_from_uuid(&self, uuid: Uuid) -> Result<AudioClipHandle> {
self.clips.write().unwrap().create_from_u... | create_clip_from | identifier_name |
system.rs | use std::sync::{Arc, RwLock};
use crayon::application::prelude::{LifecycleListener, LifecycleListenerHandle};
use crayon::errors::Result;
use crayon::math::prelude::Vector3;
use crayon::res::utils::prelude::{ResourcePool, ResourceState};
use crayon::uuid::Uuid;
use super::assets::prelude::{AudioClipHandle, AudioClipL... | self.mixer.create_source(params.into())
}
/// Stops a played audio source.
#[inline]
pub fn stop(&self, handle: AudioSourceHandle) {
self.mixer.delete_source(handle);
}
/// Sets the emiiter position of playing sound.
#[inline]
pub fn set_position<T>(&self, handle: Audio... | pub fn play<T>(&self, params: T) -> Result<AudioSourceHandle>
where
T: Into<AudioSource>,
{ | random_line_split |
system.rs | use std::sync::{Arc, RwLock};
use crayon::application::prelude::{LifecycleListener, LifecycleListenerHandle};
use crayon::errors::Result;
use crayon::math::prelude::Vector3;
use crayon::res::utils::prelude::{ResourcePool, ResourceState};
use crayon::uuid::Uuid;
use super::assets::prelude::{AudioClipHandle, AudioClipL... | else {
Mixer::new(clips.clone())?
};
let state = AudioState {
clips: clips.clone(),
};
Ok(AudioSystem {
lis: crayon::application::attach(state),
clips: clips,
mixer: mixer,
})
}
/// Sets the position of liste... | {
Mixer::headless(clips.clone())?
} | conditional_block |
system.rs | use std::sync::{Arc, RwLock};
use crayon::application::prelude::{LifecycleListener, LifecycleListenerHandle};
use crayon::errors::Result;
use crayon::math::prelude::Vector3;
use crayon::res::utils::prelude::{ResourcePool, ResourceState};
use crayon::uuid::Uuid;
use super::assets::prelude::{AudioClipHandle, AudioClipL... |
/// Sets the position of listener.
#[inline]
pub fn set_listener<T>(&self, position: T)
where
T: Into<Vector3<f32>>,
{
self.mixer.set_listener(position.into());
}
/// Creates a clip object from file asynchronously.
#[inline]
pub fn create_clip_from<T: AsRef<str>>(&... | {
let clips = Arc::new(RwLock::new(ResourcePool::new(AudioClipLoader::new())));
let mixer = if crayon::application::headless() {
Mixer::headless(clips.clone())?
} else {
Mixer::new(clips.clone())?
};
let state = AudioState {
clips: clips.clone... | identifier_body |
sbwatchpoint.rs | use super::*;
cpp_class!(pub unsafe struct SBWatchpoint as "SBWatchpoint");
unsafe impl Send for SBWatchpoint {}
impl SBWatchpoint {
pub fn id(&self) -> WatchpointID {
cpp!(unsafe [self as "SBWatchpoint*"] -> WatchpointID as "watch_id_t" {
return self->GetID();
})
}
}
impl IsVali... |
}
impl fmt::Debug for SBWatchpoint {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let full = f.alternate();
debug_descr(f, |descr| {
cpp!(unsafe [self as "SBWatchpoint*", descr as "SBStream*", full as "bool"] -> bool as "bool" {
return self->GetDescription(*de... | {
cpp!(unsafe [self as "SBWatchpoint*"] -> bool as "bool" {
return self->IsValid();
})
} | identifier_body |
sbwatchpoint.rs | use super::*;
cpp_class!(pub unsafe struct SBWatchpoint as "SBWatchpoint");
unsafe impl Send for SBWatchpoint {}
impl SBWatchpoint {
pub fn id(&self) -> WatchpointID {
cpp!(unsafe [self as "SBWatchpoint*"] -> WatchpointID as "watch_id_t" {
return self->GetID();
})
}
}
impl IsVali... | (&self) -> bool {
cpp!(unsafe [self as "SBWatchpoint*"] -> bool as "bool" {
return self->IsValid();
})
}
}
impl fmt::Debug for SBWatchpoint {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let full = f.alternate();
debug_descr(f, |descr| {
cpp!(un... | is_valid | identifier_name |
sbwatchpoint.rs | use super::*;
cpp_class!(pub unsafe struct SBWatchpoint as "SBWatchpoint");
unsafe impl Send for SBWatchpoint {}
impl SBWatchpoint {
pub fn id(&self) -> WatchpointID {
cpp!(unsafe [self as "SBWatchpoint*"] -> WatchpointID as "watch_id_t" {
return self->GetID();
})
}
}
impl IsVali... | })
}
} | return self->GetDescription(*descr, full ? eDescriptionLevelFull : eDescriptionLevelBrief);
}) | random_line_split |
mod.rs | use std::collections::HashMap;
use std::error::Error;
use std::io::{self, Cursor};
use std::sync::Arc;
use rustc_serialize::{json, Encodable};
use rustc_serialize::json::Json;
use url;
use conduit::{Request, Response, Handler};
use conduit_router::{RouteBuilder, RequestParams};
use db::RequestTransaction;
use self::e... | fn redirect(&self, url: String) -> Response {
let mut headers = HashMap::new();
headers.insert("Location".to_string(), vec![url.to_string()]);
Response {
status: (302, "Found"),
headers: headers,
body: Box::new(io::empty()),
}
}
fn wants_j... | random_line_split | |
mod.rs | use std::collections::HashMap;
use std::error::Error;
use std::io::{self, Cursor};
use std::sync::Arc;
use rustc_serialize::{json, Encodable};
use rustc_serialize::json::Json;
use url;
use conduit::{Request, Response, Handler};
use conduit_router::{RouteBuilder, RequestParams};
use db::RequestTransaction;
use self::e... | <T: Encodable>(&self, t: &T) -> Response {
json_response(t)
}
fn query(&self) -> HashMap<String, String> {
url::form_urlencoded::parse(self.query_string().unwrap_or("")
.as_bytes())
.into_iter().collect()
}
fn redirect(&self, url: Strin... | json | identifier_name |
shannon.rs | use super::Entropy;
/// Implementation of Shannon entropy
pub struct Shannon {
frequency: Vec<f64>,
probabilities: Vec<f64>,
entropy: Option<f64>,
data_len: usize,
}
impl Shannon {
pub fn new() -> Self {
Self {
frequency: vec![0.0; 256],
probabilities: vec![0.0; 256... |
fn reset(&mut self) {
*self = Shannon::new();
}
}
#[cfg(test)]
mod tests {
#[test]
fn shannon_test_quick() {
use crate::Shannon;
assert_eq!(Shannon::quick(vec![0, 1, 2, 3, 4, 5]) as f32, 2.5849626_f32);
}
}
| {
if let Some(entropy) = self.entropy {
entropy
} else {
let mut entropy = 0.0;
for i in 0..256 {
if self.frequency[i] != 0.0 {
self.probabilities[i] = self.frequency[i] / self.data_len as f64;
entropy += self.pr... | identifier_body |
shannon.rs | use super::Entropy;
/// Implementation of Shannon entropy
pub struct Shannon {
frequency: Vec<f64>,
probabilities: Vec<f64>,
entropy: Option<f64>,
data_len: usize,
}
impl Shannon {
pub fn new() -> Self {
Self {
frequency: vec![0.0; 256],
probabilities: vec![0.0; 256... | () {
use crate::Shannon;
assert_eq!(Shannon::quick(vec![0, 1, 2, 3, 4, 5]) as f32, 2.5849626_f32);
}
}
| shannon_test_quick | identifier_name |
shannon.rs | use super::Entropy;
/// Implementation of Shannon entropy
pub struct Shannon {
frequency: Vec<f64>,
probabilities: Vec<f64>,
entropy: Option<f64>,
data_len: usize,
}
impl Shannon {
pub fn new() -> Self {
Self {
frequency: vec![0.0; 256],
probabilities: vec![0.0; 256... | /// let data = vec![0,1,2,3,4,5];
/// assert_eq!(2.584962500721156, Shannon::quick(&data));
///
/// ```
///
pub fn quick<T: AsRef<[u8]>>(data: T) -> f64 {
let mut quick = Self::new();
quick.input(data);
quick.calculate()
}
}
impl Entropy for Shannon {
fn input<T:... | /// use entropy_rs::Shannon; | random_line_split |
shannon.rs | use super::Entropy;
/// Implementation of Shannon entropy
pub struct Shannon {
frequency: Vec<f64>,
probabilities: Vec<f64>,
entropy: Option<f64>,
data_len: usize,
}
impl Shannon {
pub fn new() -> Self {
Self {
frequency: vec![0.0; 256],
probabilities: vec![0.0; 256... |
}
fn reset(&mut self) {
*self = Shannon::new();
}
}
#[cfg(test)]
mod tests {
#[test]
fn shannon_test_quick() {
use crate::Shannon;
assert_eq!(Shannon::quick(vec![0, 1, 2, 3, 4, 5]) as f32, 2.5849626_f32);
}
}
| {
let mut entropy = 0.0;
for i in 0..256 {
if self.frequency[i] != 0.0 {
self.probabilities[i] = self.frequency[i] / self.data_len as f64;
entropy += self.probabilities[i] * self.probabilities[i].log(2.0_f64);
}
... | conditional_block |
primes.rs | //! Functions involving primes without dependencies.
//!
//!
//! # Examples
//!
//! ```
//! use euler_library::primes as eu_primes;
//!
//! assert_eq!(eu_primes::prime_factors(84), [2, 2, 3, 7]);
//! assert_eq!(eu_primes::prime_factors_unique(84), [2, 3, 7]);
//!
//! ```
/// Returns a vector of the prime factors n.
/... | /// Returns a vector of the unique prime factors n.
///
/// ```
/// use euler_library::primes as eu_primes;
///
/// assert_eq!(eu_primes::prime_factors_unique(342), [2, 3, 19]);
/// assert_eq!(eu_primes::prime_factors_unique(123), [3, 41]);
/// ```
///
pub fn prime_factors_unique(n: usize) -> Vec<usize> {
let mut x... | random_line_split | |
primes.rs | //! Functions involving primes without dependencies.
//!
//!
//! # Examples
//!
//! ```
//! use euler_library::primes as eu_primes;
//!
//! assert_eq!(eu_primes::prime_factors(84), [2, 2, 3, 7]);
//! assert_eq!(eu_primes::prime_factors_unique(84), [2, 3, 7]);
//!
//! ```
/// Returns a vector of the prime factors n.
/... | (mut n: usize) -> Vec<usize> {
let mut xs: Vec<usize> = Vec::new();
let mut i = 2;
while n > 1 {
while n % i == 0 {
xs.push(i);
n /= i;
}
i += 1;
}
xs
}
/// Returns a vector of the unique prime factors n.
///
/// ```
/// use euler_library::primes as e... | prime_factors | identifier_name |
primes.rs | //! Functions involving primes without dependencies.
//!
//!
//! # Examples
//!
//! ```
//! use euler_library::primes as eu_primes;
//!
//! assert_eq!(eu_primes::prime_factors(84), [2, 2, 3, 7]);
//! assert_eq!(eu_primes::prime_factors_unique(84), [2, 3, 7]);
//!
//! ```
/// Returns a vector of the prime factors n.
/... |
}
s
}
| {
let mut j = i;
while j < n {
s[j] += 1;
j += i
}
} | conditional_block |
primes.rs | //! Functions involving primes without dependencies.
//!
//!
//! # Examples
//!
//! ```
//! use euler_library::primes as eu_primes;
//!
//! assert_eq!(eu_primes::prime_factors(84), [2, 2, 3, 7]);
//! assert_eq!(eu_primes::prime_factors_unique(84), [2, 3, 7]);
//!
//! ```
/// Returns a vector of the prime factors n.
/... |
/// Returns the sum of unique prime factors of n.
///
/// ```
/// use euler_library::primes as eu_primes;
///
/// assert_eq!(eu_primes::sopf(342), 24);
/// assert_eq!(eu_primes::sopf(123), 44);
/// ```
///
pub fn sopf(n: usize) -> usize {
prime_factors_unique(n).iter().fold(0, |acc, x| acc + x)
}
/// Return a ... | {
let mut xs = prime_factors(n);
xs.dedup();
xs
} | identifier_body |
borrowck-univariant-enum.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
// Test that borrowck treats enums with a single variant
// specially.
let x = @Cell::new(5);
let y = @Cell::new(newtype(3));
let z = match y.get() {
newtype(b) => {
x.set(x.get() + 1);
x.get() * b
}
};
assert_eq!(z, 18);
} | identifier_body | |
borrowck-univariant-enum.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
pub fn main() {
// Test that borrowck treats enums with a single variant
// specially.
let x = @Cell::new(5);
let y = @Cell::new(newtype(3));
let z = match y.get() {
newtype(b) => {
x.set(x.get() + 1);
x.get() * b
}
};
assert_eq!(z, 18);
} | random_line_split | |
borrowck-univariant-enum.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
// Test that borrowck treats enums with a single variant
// specially.
let x = @Cell::new(5);
let y = @Cell::new(newtype(3));
let z = match y.get() {
newtype(b) => {
x.set(x.get() + 1);
x.get() * b
}
};
assert_eq!(z, 18);
}
| main | identifier_name |
issue-6157.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 squarei<'a>(x: int, op: &'a OpInt) -> int { op.call(x, x) }
fn muli(x:int, y:int) -> int { x * y }
pub fn main() {
let f = |x,y| muli(x,y);
{
let g = &f;
let h = g as &OpInt;
squarei(3, h);
}
} | random_line_split | |
issue-6157.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 f = |x,y| muli(x,y);
{
let g = &f;
let h = g as &OpInt;
squarei(3, h);
}
}
| main | identifier_name |
issue-6157.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 squarei<'a>(x: int, op: &'a OpInt) -> int { op.call(x, x) }
fn muli(x:int, y:int) -> int { x * y }
pub fn main() {
let f = |x,y| muli(x,y);
{
let g = &f;
let h = g as &OpInt;
squarei(3, h);
}
}
| {
(*self)(a, b)
} | identifier_body |
domparser.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
use dom::bindings::codegen::Bindings::D... |
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<DOMParser>> {
Ok(DOMParser::new(global.as_window()))
}
}
impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
// http://domparsing.spec.whatwg.org/#the-domparser-interface
fn ParseFromString(self,
s: DOMString,
... | random_line_split | |
domparser.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
use dom::bindings::codegen::Bindings::D... | (window: JSRef<Window>) -> Temporary<DOMParser> {
reflect_dom_object(box DOMParser::new_inherited(window), GlobalRef::Window(window),
DOMParserBinding::Wrap)
}
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<DOMParser>> {
Ok(DOMParser::new(global.as_window... | new | identifier_name |
domparser.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
use dom::bindings::codegen::Bindings::D... |
pub fn new(window: JSRef<Window>) -> Temporary<DOMParser> {
reflect_dom_object(box DOMParser::new_inherited(window), GlobalRef::Window(window),
DOMParserBinding::Wrap)
}
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<DOMParser>> {
Ok(DOMParser::new(... | {
DOMParser {
reflector_: Reflector::new(),
window: JS::from_rooted(window),
}
} | identifier_body |
settings.rs | //! The configuration settings definitions.
| pub struct GithubSettings {
/// The OAuth app "client ID"
pub client_id: String,
/// The OAuth app "client secret"
pub client_secret: String,
/// A random string used to authenticate requests from github. Can be any
/// random secret value and can change.
pub state: String,
/// The githu... | use serde::Deserialize;
/// Settings for github login. To configure a github OAuth app must have been
/// provisioned.
#[derive(Debug, Deserialize)] | random_line_split |
settings.rs | //! The configuration settings definitions.
use serde::Deserialize;
/// Settings for github login. To configure a github OAuth app must have been
/// provisioned.
#[derive(Debug, Deserialize)]
pub struct GithubSettings {
/// The OAuth app "client ID"
pub client_id: String,
/// The OAuth app "client secret... | () -> String {
"/".to_string()
}
fn default_bind() -> String {
"127.0.0.1:8975".to_string()
}
| default_web_root | identifier_name |
presentation.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed... |
impl<'a, U: Drawable + 'a> ConcreteLayout<'a, Wrapper<'a, PresentationLayout, U>> for PresentationLayout {
fn layout(&'a self, _: &Context) -> Wrapper<'a, PresentationLayout, U> {
Wrapper::<'a, PresentationLayout, U>::new(
self,
math_background_reader
)
}
}
// TODO re... | {
&element.math_background
} | identifier_body |
presentation.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* 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... | pub(crate) script_size_multiplier: ScriptSizeMultiplier,
}
fn math_background_reader(element: &PresentationLayout) -> &Color {
&element.math_background
}
impl<'a, U: Drawable + 'a> ConcreteLayout<'a, Wrapper<'a, PresentationLayout, U>> for PresentationLayout {
fn layout(&'a self, _: &Context) -> Wrapper<'... | pub(crate) display_style: DisplayStyle,
pub(crate) script_level: ScriptLevel,
pub(crate) script_min_size: ScriptMinSize, | random_line_split |
presentation.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* 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... | (&'a self, _: &Context) -> Wrapper<'a, PresentationLayout, U> {
Wrapper::<'a, PresentationLayout, U>::new(
self,
math_background_reader
)
}
}
// TODO remove
impl PresentationLayout {
pub fn new(math_color: Color, math_background: Color) -> PresentationLayout {
P... | layout | identifier_name |
test.rs | use std::thread;
use std::time::Duration;
use std::sync::mpsc::channel;
/// Check if a function `f` terminates within a given timeframe.
///
/// It is used to check for deadlocks.
///
/// If the function does not terminate, it keeps a thread alive forever,
/// so don't run too many test (preferable just one) in sequen... |
pub fn terminates_async<F, F2>(duration_ms: u64, f: F, f2: F2) -> bool
where F: Send + FnOnce() -> () +'static,
F2: FnOnce() -> ()
{
async(duration_ms, f, f2).is_some()
}
pub fn async<T, F, F2>(duration_ms: u64, f: F, f2: F2) -> Option<T>
where F: Send + FnOnce() -> T +'static,
F2: FnOnce() -> (),
... | {
terminates_async(duration_ms, f, || {})
} | identifier_body |
test.rs | use std::thread;
use std::time::Duration;
use std::sync::mpsc::channel;
/// Check if a function `f` terminates within a given timeframe.
///
/// It is used to check for deadlocks.
///
/// If the function does not terminate, it keeps a thread alive forever,
/// so don't run too many test (preferable just one) in sequen... |
}
thread::sleep(Duration::from_millis(duration_ms % 50));
rx.try_recv().ok()
}
| {
return a;
} | conditional_block |
test.rs | use std::thread;
use std::time::Duration;
use std::sync::mpsc::channel;
/// Check if a function `f` terminates within a given timeframe.
///
/// It is used to check for deadlocks.
///
/// If the function does not terminate, it keeps a thread alive forever,
/// so don't run too many test (preferable just one) in sequen... |
thread::sleep(Duration::from_millis(duration_ms % 50));
rx.try_recv().ok()
} | } | random_line_split |
test.rs | use std::thread;
use std::time::Duration;
use std::sync::mpsc::channel;
/// Check if a function `f` terminates within a given timeframe.
///
/// It is used to check for deadlocks.
///
/// If the function does not terminate, it keeps a thread alive forever,
/// so don't run too many test (preferable just one) in sequen... | <T, F, F2>(duration_ms: u64, f: F, f2: F2) -> Option<T>
where F: Send + FnOnce() -> T +'static,
F2: FnOnce() -> (),
T: Send +'static,
{
let (tx, rx) = channel();
thread::spawn(move || {
let t = f();
// wakeup other thread
let _ = tx.send(t);
});
f2();
i... | async | identifier_name |
config.rs | // Copyright 2021 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... | // For forwards compatibility old config needs `Warning` log level changed to standard log::Level `WARN`
fn fix_warning_level(conf: String) -> String {
conf.replace("Warning", "WARN")
}
// For backwards compatibility only first letter of log level should be capitalised.
fn fix_log_level(conf: String) -> String ... | config_str
}
| random_line_split |
config.rs | // Copyright 2021 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
/// This migration does the following:
/// - Adds "config_file_version = 2"
/// - If server.pool_config.accept_fee_base is 1000000, change it to 500000
/// - Remove "#a setting to 1000000 will be overridden to 500000 to respect the fixfees RFC"
fn migrate_config_file_version_none_to_2(config_str: String) -> Stri... | {
let conf_out = self.ser_config()?;
let fixed_config = GlobalConfig::fix_log_level(conf_out);
let commented_config = insert_comments(fixed_config);
let mut file = File::create(name)?;
file.write_all(commented_config.as_bytes())?;
Ok(())
} | identifier_body |
config.rs | // Copyright 2021 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... | (conf: String) -> String {
conf.replace("TRACE", "Trace")
.replace("DEBUG", "Debug")
.replace("INFO", "Info")
.replace("WARN", "Warning")
.replace("ERROR", "Error")
}
}
#[test]
fn test_fix_log_level() {
let config = "TRACE DEBUG INFO WARN ERROR".to_string();
let fixed_config = GlobalConfig::fix_log_le... | fix_log_level | identifier_name |
encode.rs | extern crate criterion;
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use image::{ColorType, bmp::BmpEncoder, jpeg::JpegEncoder};
use std::fs::File;
use std::io::{BufWriter, Write, Seek, SeekFrom};
trait Encoder {
fn encode_raw(&self, into: &mut Vec<u8>, im: &[u8], dims: u32, color: C... |
}
| {
let mut x = JpegEncoder::new(&mut into);
x.encode(im, size, size, color).unwrap();
} | identifier_body |
encode.rs | extern crate criterion;
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use image::{ColorType, bmp::BmpEncoder, jpeg::JpegEncoder};
use std::fs::File;
use std::io::{BufWriter, Write, Seek, SeekFrom};
trait Encoder {
fn encode_raw(&self, into: &mut Vec<u8>, im: &[u8], dims: u32, color: C... | (&self, mut file: &File, im: &[u8], dims: u32, color: ColorType) {
file.seek(SeekFrom::Start(0)).unwrap();
let buf = BufWriter::new(file);
self.encode(buf, im, dims, color);
}
}
impl EncoderBase for Bmp {
fn encode(&self, mut into: impl Write, im: &[u8], size: u32, color: ColorType) {
... | encode_file | identifier_name |
encode.rs | extern crate criterion;
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use image::{ColorType, bmp::BmpEncoder, jpeg::JpegEncoder};
use std::fs::File;
use std::io::{BufWriter, Write, Seek, SeekFrom};
trait Encoder {
fn encode_raw(&self, into: &mut Vec<u8>, im: &[u8], dims: u32, color: C... | let mut x = JpegEncoder::new(&mut into);
x.encode(im, size, size, color).unwrap();
}
} | random_line_split | |
main.rs | extern crate gmp;
extern crate time;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::str::FromStr;
use asm::assembler::Assembler;
use asm::environment::Environment;
use std::env;
use std::collections::HashMap;
mod asm;
fn load_text(asm: &mut Assembler, code: &str) {
let mut linenum = 0;
fo... | }
let do_print_parsed = args.contains_key("print-parsed");
let do_stack_print = args.contains_key("print-stack");
let mut env = Environment::new();
let mut asm = Assembler::new(do_print_parsed);
let mut do_run = false;
if args.contains_key("help") {
println!("{}",
"Welcome to Bit Assembly!
For help on how t... | arg.push_str(element.as_ref());
} | random_line_split |
main.rs | extern crate gmp;
extern crate time;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::str::FromStr;
use asm::assembler::Assembler;
use asm::environment::Environment;
use std::env;
use std::collections::HashMap;
mod asm;
fn load_text(asm: &mut Assembler, code: &str) {
let mut linenum = 0;
fo... | else {
println!("{}", element);
let arg = args.get_mut(¤t_arg_name).expect("No argument");
arg.push_str(element.as_ref());
}
}
let do_print_parsed = args.contains_key("print-parsed");
let do_stack_print = args.contains_key("print-stack");
let mut env = Environment::new();
let mut asm = Assemble... | {
let element = &element[1..];
let mut arg_name = "".to_string();
for arg in &valid_args {
if arg.short == Some(element.to_string()) {
arg_name = arg.name.clone();
break;
}
}
if arg_name == "" {
panic!("No such argument of name '{}'!", element);
} else {
current_arg_name = a... | conditional_block |
main.rs | extern crate gmp;
extern crate time;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::str::FromStr;
use asm::assembler::Assembler;
use asm::environment::Environment;
use std::env;
use std::collections::HashMap;
mod asm;
fn | (asm: &mut Assembler, code: &str) {
let mut linenum = 0;
for line in code.lines() {
for s in line.split(';') {
linenum += 1;
asm.parse_line(&s.to_string(), linenum, None);
}
}
}
fn load_file(asm: &mut Assembler, file_name:&str) {
let file = File::open(file_name).unwrap();
let buffer = BufReader::new(&fi... | load_text | identifier_name |
args.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
pub fn put(_args: ~[~str]) {
fail2!()
}
pub fn clone() -> Option<~[~str]> {
fail2!()
}
}
| {
fail2!()
} | identifier_body |
args.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () -> Option<~[~str]> {
with_lock(|| unsafe {
let ptr = get_global_ptr();
(*ptr).as_ref().map(|s: &~~[~str]| (**s).clone())
})
}
fn with_lock<T>(f: &fn() -> T) -> T {
do (|| {
unsafe {
rust_take_global_args_lock();
f()
... | clone | identifier_name |
args.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | rust_drop_global_args_lock();
}
}
}
fn get_global_ptr() -> *mut Option<~~[~str]> {
unsafe { rust_get_global_args_ptr() }
}
// Copied from `os`.
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
do vec::from_fn(argc as uint) |i| {
... | rust_take_global_args_lock();
f()
}
}).finally {
unsafe { | random_line_split |
mod.rs | //! Encoding of portable pixmap Images
pub use self::encoder::PPMEncoder as PPMEncoder;
pub use self::decoder::PPMDecoder as PPMDecoder;
mod encoder;
mod decoder;
#[cfg(test)]
mod test {
use color::ColorType;
use image::{ImageDecoder, DecodingResult};
#[test]
fn test_roundtrip_ppm() | };
}
let mut decoder = match super::PPMDecoder::new(&stream[..]) {
Ok(img) => img,
Err(e) => panic!("PPM decoder failed with {}", e),
};
match decoder.read_image() {
Ok(DecodingResult::U8(vec)) => {
assert_eq!(&buf[..], &ve... | {
// 3x3 image that tries all the 0/255 RGB combinations
let buf: [u8; 27] = [
0, 0, 0,
0, 0, 255,
0, 255, 0,
0, 255, 255,
255, 0, 0,
255, 0, 255,
255, 255, 0,
255, 255, 255,
... | identifier_body |
mod.rs | //! Encoding of portable pixmap Images
pub use self::encoder::PPMEncoder as PPMEncoder;
pub use self::decoder::PPMDecoder as PPMDecoder;
mod encoder;
mod decoder;
#[cfg(test)]
mod test {
use color::ColorType;
use image::{ImageDecoder, DecodingResult};
#[test]
fn | () {
// 3x3 image that tries all the 0/255 RGB combinations
let buf: [u8; 27] = [
0, 0, 0,
0, 0, 255,
0, 255, 0,
0, 255, 255,
255, 0, 0,
255, 0, 255,
255, 255, 0,
255, 255, 255,
... | test_roundtrip_ppm | identifier_name |
mod.rs | //! Encoding of portable pixmap Images
pub use self::encoder::PPMEncoder as PPMEncoder;
pub use self::decoder::PPMDecoder as PPMDecoder;
mod encoder;
mod decoder;
#[cfg(test)]
mod test {
use color::ColorType;
use image::{ImageDecoder, DecodingResult};
#[test]
fn test_roundtrip_ppm() {
// 3x3... | o[0] = (i >> 8) as u8;
o[1] = (i & 0xff) as u8;
}
let mut stream = Vec::<u8>::new();
{
let mut encoder = super::PPMEncoder::new(&mut stream);
match encoder.encode(&bytebuf, 3, 3, ColorType::RGB(16)) {
Ok(_) => {},
Err(_... | ];
let mut bytebuf = [0 as u8; 54];
for (o, i) in bytebuf.chunks_mut(2).zip(buf.iter()) { | random_line_split |
namespaced-enum-glob-import-no-impls.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 ... | (&self) {}
}
}
mod m {
pub use m2::Foo::*;
}
pub fn main() {
use m2::Foo::*;
foo(); //~ ERROR cannot find function `foo` in this scope
m::foo(); //~ ERROR cannot find function `foo` in module `m`
bar(); //~ ERROR cannot find function `bar` in this scope
m::bar(); //~ ERROR cannot find fun... | bar | identifier_name |
namespaced-enum-glob-import-no-impls.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 m2::Foo::*;
foo(); //~ ERROR cannot find function `foo` in this scope
m::foo(); //~ ERROR cannot find function `foo` in module `m`
bar(); //~ ERROR cannot find function `bar` in this scope
m::bar(); //~ ERROR cannot find function `bar` in module `m`
} | identifier_body | |
namespaced-enum-glob-import-no-impls.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 ... | pub fn bar(&self) {}
}
}
mod m {
pub use m2::Foo::*;
}
pub fn main() {
use m2::Foo::*;
foo(); //~ ERROR cannot find function `foo` in this scope
m::foo(); //~ ERROR cannot find function `foo` in module `m`
bar(); //~ ERROR cannot find function `bar` in this scope
m::bar(); //~ ERR... | impl Foo {
pub fn foo() {} | random_line_split |
parser.rs | use std::num;
#[derive(Debug)]
pub enum ParseError {
UnexpectedChar(char),
UnexpectedEnd,
InvalidNumber(String, num::ParseIntError),
}
pub type ParseResult<T> = Result<T, ParseError>;
pub struct Parser<'src> {
source: &'src str,
position: usize,
}
#[derive(Debug)]
pub enum Expr {
Ident(Strin... | (&mut self) -> Option<ParseResult<Expr>> {
self.skip_whitespace();
if self.at_end() {
None
} else {
Some(self.parse_expr())
}
}
}
/// Returns `true` if the given character is whitespace.
fn is_whitespace(c: char) -> bool {
match c {
'' | '\t' | '\... | next | identifier_name |
parser.rs | use std::num;
#[derive(Debug)]
pub enum ParseError {
UnexpectedChar(char),
UnexpectedEnd,
InvalidNumber(String, num::ParseIntError),
}
pub type ParseResult<T> = Result<T, ParseError>;
pub struct Parser<'src> {
source: &'src str,
position: usize,
}
#[derive(Debug)]
pub enum Expr {
Ident(Strin... |
}
}
/// Returns `true` if the given character is whitespace.
fn is_whitespace(c: char) -> bool {
match c {
'' | '\t' | '\n' => true,
_ => false,
}
}
/// Returns `true` if the given character is a digit.
fn is_digit(c: char) -> bool {
match c {
'0'...'9' => true,... | {
Some(self.parse_expr())
} | conditional_block |
parser.rs | use std::num;
#[derive(Debug)]
pub enum ParseError {
UnexpectedChar(char),
UnexpectedEnd,
InvalidNumber(String, num::ParseIntError),
}
pub type ParseResult<T> = Result<T, ParseError>;
pub struct Parser<'src> {
source: &'src str,
position: usize,
}
#[derive(Debug)]
pub enum Expr {
Ident(Strin... | /// Step backwards one `char` in the input. Must not be called more times than `read_char` has
/// been called.
fn unread_char(&mut self) {
assert!(self.position!= 0);
let (prev_pos, _) = self.source[..self.position].char_indices().next_back().unwrap();
self.position = prev_pos;
... | }
opt_c
}
| random_line_split |
allapps.rs | #pragma version(1)
#pragma stateVertex(PV)
#pragma stateFragment(PFTexNearest)
#pragma stateStore(PSIcons)
#define PI 3.14159f
int g_SpecialHWWar;
// Attraction to center values from page edge to page center.
float g_AttractionTable[9];
float g_FrictionTable[9];
float g_PhysicsTableSize;
float g_PosPage;
float g_Po... |
return;
}
// If our velocity is low OR acceleration is opposing it, apply it.
if (fabsf(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
g_PosVelocity += accel;
}
//debugF("g_PosPage", g_PosPage);
//debugF(" g_PosVelocity", g_PosVelocity);
//debugF(" friction", fri... | {
g_MoveToTime = 0;
g_PosPage = state->targetPos;
} | conditional_block |
allapps.rs | #pragma version(1)
#pragma stateVertex(PV)
#pragma stateFragment(PFTexNearest)
#pragma stateStore(PSIcons)
#define PI 3.14159f
int g_SpecialHWWar;
// Attraction to center values from page edge to page center.
float g_AttractionTable[9];
float g_FrictionTable[9];
float g_PhysicsTableSize;
float g_PosPage;
float g_Po... | g_Rows = 4;
}
g_PosMax = ((iconCount + (g_Cols-1)) / g_Cols) - g_Rows;
if (g_PosMax < 0) g_PosMax = 0;
updatePos();
updateReadback();
//debugF(" draw g_PosPage", g_PosPage);
// Draw the icons ========================================
drawFrontGrid(g_PosPage, g_Animation);
... | g_Rows = 3;
} else {
g_Cols = 4; | random_line_split |
base16.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.
*/
//! Base16 iterator
//!
//! The main radix tree uses base16 to support hex string prefix lookups and
//! make the space usage more efficien... | <'a, T>(&'a T, usize, usize);
impl<'a, T: AsRef<[u8]>> Base16Iter<'a, T> {
/// Convert base256 binary sequence to a base16 iterator.
pub fn from_bin(binary: &'a T) -> Self {
let len = binary.as_ref().len() * 2;
Base16Iter(binary, 0, len)
}
}
/// Base16 iterator for [u8]
impl<'a, T: AsRef<[... | Base16Iter | identifier_name |
base16.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.
*/
//! Base16 iterator
//!
//! The main radix tree uses base16 to support hex string prefix lookups and
//! make the space usage more efficien... | else {
let i = self.2 - 1;
self.2 = i;
let v = self.0.as_ref()[i / 2];
if i & 1 == 0 { v >> 4 } else { v & 0xf }.into()
}
}
}
impl<'a, T: AsRef<[u8]>> ExactSizeIterator for Base16Iter<'a, T> {
#[inline]
fn len(&self) -> usize {
self.2 - self.... | {
None
} | conditional_block |
base16.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.
*/
//! Base16 iterator
//!
//! The main radix tree uses base16 to support hex string prefix lookups and
//! make the space usage more efficien... |
#[inline]
fn count(self) -> usize {
self.len()
}
}
impl<'a, T: AsRef<[u8]>> DoubleEndedIterator for Base16Iter<'a, T> {
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
if self.2 <= self.1 {
None
} else {
let i = self.2 - 1;
sel... | {
let len = self.len();
(len, Some(len))
} | identifier_body |
base16.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.
*/
//! Base16 iterator
//!
//! The main radix tree uses base16 to support hex string prefix lookups and
//! make the space usage more efficien... | fn check_skip_rev(src: Vec<u8>) -> bool {
let iter = Base16Iter::from_bin(&src);
let full: Vec<u8> = iter.clone().collect();
let rev: Vec<u8> = iter.clone().rev().collect();
(0..full.len()).all(|i| {
let v: Vec<u8> = iter.clone().skip(i).collect();... |
quickcheck! { | random_line_split |
game.rs | use rand::{thread_rng, Rng};
use sdl2::render;
use sdl2::rect::Rect;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use basic2d::Vec2;
use snake::{Snake, Move};
// Game structure
pub struct Game {
pub snakes: Vec<Snake>,
fruit: Vec2<i32>,
width: u32,
height: u32,
grid_size: u32
}
impl Ga... | (&mut self, renderer: &mut render::Renderer) {
// Draw fruit
renderer.set_draw_color(Color::RGB(0xAA, 0x30, 0x30));
renderer.fill_rect(self.point_to_rect(self.fruit)).unwrap();
// Draw snakes
renderer.set_draw_color(Color::RGB(0x60, 0xAA, 0x60));
for snake in &self.snake... | draw | identifier_name |
game.rs | use rand::{thread_rng, Rng};
use sdl2::render;
use sdl2::rect::Rect;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use basic2d::Vec2;
use snake::{Snake, Move};
// Game structure
pub struct Game {
pub snakes: Vec<Snake>,
fruit: Vec2<i32>,
width: u32,
height: u32,
grid_size: u32
}
impl Ga... |
let head = self.snakes[i].get_head();
if head == self.fruit {
self.snakes[i].score += 10;
self.snakes[i].add_segment();
self.new_fruit();
}
}
}
pub fn key_down(&mut self, keycode: Keycode) {
match keycode {
... | {
self.snakes[i].dead = true;
} | conditional_block |
game.rs | use rand::{thread_rng, Rng};
use sdl2::render;
use sdl2::rect::Rect;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use basic2d::Vec2;
use snake::{Snake, Move};
// Game structure
pub struct Game {
pub snakes: Vec<Snake>,
fruit: Vec2<i32>,
width: u32,
height: u32,
grid_size: u32
}
impl Ga... | (thread_rng().gen::<u32>() % self.width) as i32,
(thread_rng().gen::<u32>() % self.height) as i32
)
}
/// Randomizes the position of the fruit
pub fn new_fruit(&mut self) {
// FIXME: snakes should return iterators that iterate through their
// componen... | random_line_split | |
instr_aesdeclast.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn | () {
run_test(&Instruction { mnemonic: Mnemonic::AESDECLAST, operand1: Some(Direct(XMM1)), operand2: Some(Direct(XMM2)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 223, 202], OperandSize::Dword)
}
#[test]
fn aesdecla... | aesdeclast_1 | identifier_name |
instr_aesdeclast.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn aesdeclast_1() {
run_test(&Instruction { mnemonic: Mnemonic::AESDECLAST, operand1: Some(D... | {
run_test(&Instruction { mnemonic: Mnemonic::AESDECLAST, operand1: Some(Direct(XMM6)), operand2: Some(IndirectScaledIndexed(RBX, RSI, Two, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56... | identifier_body | |
instr_aesdeclast.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn aesdeclast_1() {
run_test(&Instruction { mnemonic: Mnemonic::AESDECLAST, operand1: Some(D... | run_test(&Instruction { mnemonic: Mnemonic::AESDECLAST, operand1: Some(Direct(XMM4)), operand2: Some(IndirectScaledDisplaced(EAX, Four, 1919230320, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102... | fn aesdeclast_2() { | random_line_split |
parsing.rs | //! Utility functions for Header implementations.
use language_tags::LanguageTag;
use std::str;
use std::str::FromStr;
use std::fmt::{self, Display};
use url::percent_encoding;
use header::shared::Charset;
/// Reads a single raw string when parsing a header.
pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) ... |
#[test]
fn test_parse_extended_value_partially_formatted_blank() {
let result = parse_extended_value("blank second part'");
assert!(result.is_err());
}
}
| {
let result = parse_extended_value("UTF-8'missing third part");
assert!(result.is_err());
} | identifier_body |
parsing.rs | //! Utility functions for Header implementations.
use language_tags::LanguageTag;
use std::str;
use std::str::FromStr;
use std::fmt::{self, Display};
use url::percent_encoding;
use header::shared::Charset;
/// Reads a single raw string when parsing a header.
pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) ... | charset: charset,
language_tag: lang,
value: value,
})
}
#[cfg(test)]
mod tests {
use header::shared::Charset;
use super::parse_extended_value;
#[test]
fn test_parse_extended_value_with_encoding_and_language_tag() {
let expected_language_tag = langtag!(en);
... | random_line_split | |
parsing.rs | //! Utility functions for Header implementations.
use language_tags::LanguageTag;
use std::str;
use std::str::FromStr;
use std::fmt::{self, Display};
use url::percent_encoding;
use header::shared::Charset;
/// Reads a single raw string when parsing a header.
pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) ... | (val: &str) -> ::Result<ExtendedValue> {
// Break into three pieces separated by the single-quote character
let mut parts = val.splitn(3,'\'');
// Interpret the first piece as a Charset
let charset: Charset = match parts.next() {
None => return Err(::Error::Header),
Some(n) => try!(Fro... | parse_extended_value | identifier_name |
lib.rs | extern crate regex;
extern crate fall_tree;
extern crate fall_parse;
mod rust;
pub use self::rust::language as lang_rust;
pub use self::rust::{
WHITESPACE,
LINE_COMMENT,
BLOCK_COMMENT,
UNION,
AS,
CRATE,
EXTERN,
FN,
LET,
PUB,
STRUCT,
USE,
MOD,
IF,
ELSE,
... | R_ANGLE,
L_BRACK,
R_BRACK,
SHL,
SHL_EQ,
SHR,
SHR_EQ,
AND,
OR,
THIN_ARROW,
FAT_ARROW,
EQ,
EQEQ,
BANGEQ,
GTET,
LTEQ,
SEMI,
COLON,
COLONCOLON,
COMMA,
DOT,
DOTDOT,
DOTDOTDOT,
HASH,
DOLLAR,
STAR,
STAR_EQ,
SLASH,
... | L_PAREN,
R_PAREN,
L_CURLY,
R_CURLY,
L_ANGLE, | random_line_split |
value.rs | use std::ffi::CString;
use std::{fmt, mem, ptr};
use std::ops::{Deref, Index};
use libc::{c_char, c_int, c_uint};
use ffi::core;
use ffi::prelude::LLVMValueRef;
use ffi::LLVMAttribute;
use ffi::core::{
LLVMConstStringInContext,
LLVMConstStructInContext,
LLVMConstVector,
LLVMGetValueName,
LLVMSetValueName,
LL... | deref!(GlobalValue, Value);
impl GlobalValue
{
/// Sets the initial value for this global.
pub fn set_initializer(&self, value: &Value)
{
unsafe { LLVMSetInitializer(self.into(), value.into()) }
}
/// Gets the initial value for this global.
pub fn get_initializer(&self) -> &Value
{
unsafe { LLVMGetIn... | native_ref!(&GlobalValue = LLVMValueRef); | random_line_split |
value.rs | use std::ffi::CString;
use std::{fmt, mem, ptr};
use std::ops::{Deref, Index};
use libc::{c_char, c_int, c_uint};
use ffi::core;
use ffi::prelude::LLVMValueRef;
use ffi::LLVMAttribute;
use ffi::core::{
LLVMConstStringInContext,
LLVMConstStructInContext,
LLVMConstVector,
LLVMGetValueName,
LLVMSetValueName,
LL... | else {
None
}
}
} | {
self.cur = unsafe { (self.step)(old) };
Some(old.into())
} | conditional_block |
value.rs | use std::ffi::CString;
use std::{fmt, mem, ptr};
use std::ops::{Deref, Index};
use libc::{c_char, c_int, c_uint};
use ffi::core;
use ffi::prelude::LLVMValueRef;
use ffi::LLVMAttribute;
use ffi::core::{
LLVMConstStringInContext,
LLVMConstStructInContext,
LLVMConstVector,
LLVMGetValueName,
LLVMSetValueName,
LL... | <'a>(context: &'a Context,
text: &str,
rust_style: bool) -> &'a Value
{
unsafe {
let ptr = text.as_ptr() as *const c_char;
let len = text.len() as c_uint;
LLVMConstStringInContext(context.into(), ptr, len, rust_style as c_int).into()
}
}
... | new_string | identifier_name |
value.rs | use std::ffi::CString;
use std::{fmt, mem, ptr};
use std::ops::{Deref, Index};
use libc::{c_char, c_int, c_uint};
use ffi::core;
use ffi::prelude::LLVMValueRef;
use ffi::LLVMAttribute;
use ffi::core::{
LLVMConstStringInContext,
LLVMConstStructInContext,
LLVMConstVector,
LLVMGetValueName,
LLVMSetValueName,
LL... |
}
pub struct GlobalValue;
native_ref!(&GlobalValue = LLVMValueRef);
deref!(GlobalValue, Value);
impl GlobalValue
{
/// Sets the initial value for this global.
pub fn set_initializer(&self, value: &Value)
{
unsafe { LLVMSetInitializer(self.into(), value.into()) }
}
/// Gets the initial value for this glo... | {
unsafe { LLVMTypeOf(self.into()) }.into()
} | identifier_body |
mod.rs | use gst::{glib, prelude::*};
pub(crate) mod bin;
glib::wrapper! {
pub struct RendererBin(ObjectSubclass<bin::RendererBin>) @extends gst::Bin, gst::Element, gst::Object;
}
impl RendererBin {
/// Asynchronoulsy call the provided function on the parent.
///
/// This is useful to set the state of the pip... | (&self, f: impl FnOnce(&RendererBin, &gst::Element) + Send +'static) {
match self.parent() {
Some(parent) => parent.downcast_ref::<gst::Element>().unwrap().call_async(
glib::clone!(@weak self as bin => @default-panic, move |parent| f(&bin, parent)),
),
None =>... | parent_call_async | identifier_name |
mod.rs | use gst::{glib, prelude::*};
pub(crate) mod bin;
glib::wrapper! {
pub struct RendererBin(ObjectSubclass<bin::RendererBin>) @extends gst::Bin, gst::Element, gst::Object;
}
impl RendererBin {
/// Asynchronoulsy call the provided function on the parent.
///
/// This is useful to set the state of the pip... |
}
unsafe impl Send for RendererBin {}
unsafe impl Sync for RendererBin {}
pub use bin::NAME as RENDERER_BIN_NAME;
glib::wrapper! {
pub struct Renderer(ObjectSubclass<renderer::Renderer>) @extends gst::Element, gst::Object;
}
unsafe impl Send for Renderer {}
unsafe impl Sync for Renderer {}
pub(crate) mod rend... | {
match self.parent() {
Some(parent) => parent.downcast_ref::<gst::Element>().unwrap().call_async(
glib::clone!(@weak self as bin => @default-panic, move |parent| f(&bin, parent)),
),
None => unreachable!("media-toc renderer bin has no parent"),
}
... | identifier_body |
mod.rs | use gst::{glib, prelude::*};
pub(crate) mod bin;
glib::wrapper! {
pub struct RendererBin(ObjectSubclass<bin::RendererBin>) @extends gst::Bin, gst::Element, gst::Object;
}
impl RendererBin {
/// Asynchronoulsy call the provided function on the parent.
///
/// This is useful to set the state of the pip... |
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register(
Some(plugin),
bin::NAME,
gst::Rank::None,
RendererBin::static_type(),
)?;
gst::Element::register(
Some(plugin),
renderer::NAME,
gst::Rank::None,
Rend... | gst::init().unwrap();
self::plugin_register_static().expect("media-toc rendering plugin init");
});
} | random_line_split |
sharedmem.rs | use crate::{OSHandle, OSMem, Result};
use core::mem;
use core::ops::{Deref, DerefMut};
use syscall;
fn align_down(value: usize, round: usize) -> usize {
value &!(round - 1)
}
fn align_up(value: usize, round: usize) -> usize {
align_down(value + round - 1, round)
}
pub struct SharedMem<T> {
handle: OSHand... |
pub fn resize(&mut self, new_len: usize) -> Result<()> {
let old_byte_len = self.mem.len() * mem::size_of::<T>();
let new_byte_len = new_len * mem::size_of::<T>();
if align_up(new_byte_len, 4096) == align_up(old_byte_len, 4096) {
return Ok(());
}
let ptr = sysca... | let handle = OSHandle::from_raw(syscall::create_shared_mem());
Self::from_raw(handle, len, writable)
} | random_line_split |
sharedmem.rs | use crate::{OSHandle, OSMem, Result};
use core::mem;
use core::ops::{Deref, DerefMut};
use syscall;
fn align_down(value: usize, round: usize) -> usize {
value &!(round - 1)
}
fn align_up(value: usize, round: usize) -> usize {
align_down(value + round - 1, round)
}
pub struct SharedMem<T> {
handle: OSHand... |
let ptr = syscall::map_shared_mem(self.handle.get(), new_byte_len, self.writable)? as *mut T;
self.mem = unsafe { OSMem::from_raw(ptr, new_len) };
Ok(())
}
}
impl<T> SharedMem<T> {
pub fn as_handle(&self) -> &OSHandle {
&self.handle
}
pub fn into_inner(self) -> (OSHan... | {
return Ok(());
} | conditional_block |
sharedmem.rs | use crate::{OSHandle, OSMem, Result};
use core::mem;
use core::ops::{Deref, DerefMut};
use syscall;
fn align_down(value: usize, round: usize) -> usize |
fn align_up(value: usize, round: usize) -> usize {
align_down(value + round - 1, round)
}
pub struct SharedMem<T> {
handle: OSHandle,
writable: bool,
mem: OSMem<T>,
}
impl<T> SharedMem<T>
where
T: Copy,
{
pub fn from_raw(handle: OSHandle, len: usize, writable: bool) -> Result<Self> {
... | {
value & !(round - 1)
} | identifier_body |
sharedmem.rs | use crate::{OSHandle, OSMem, Result};
use core::mem;
use core::ops::{Deref, DerefMut};
use syscall;
fn align_down(value: usize, round: usize) -> usize {
value &!(round - 1)
}
fn align_up(value: usize, round: usize) -> usize {
align_down(value + round - 1, round)
}
pub struct SharedMem<T> {
handle: OSHand... | (self) -> (OSHandle, OSMem<T>) {
(self.handle, self.mem)
}
}
impl<T> Deref for SharedMem<T> {
type Target = [T];
fn deref(&self) -> &[T] {
self.mem.as_ref()
}
}
impl<T> DerefMut for SharedMem<T> {
fn deref_mut(&mut self) -> &mut [T] {
self.mem.as_mut()
}
}
| into_inner | identifier_name |
connect.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... | },
ConnectState::Connected => panic!("poll Connect after it's done"),
};
self.state = next;
match result {
// by polling again, we register new future
Async::NotReady => self.poll(),
result => Ok(result)
}
}
}
| {
let (next, result) = match self.state {
ConnectState::TcpConnect(ref mut future) => {
let stream = try_ready!(future.poll());
let handshake = handshake(stream, self.self_key_pair.clone(), self.trusted_nodes.clone());
(ConnectState::Handshake(handshake), Async::NotReady)
},
ConnectState::Handsha... | identifier_body |
connect.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... | }
}
} | result => Ok(result) | random_line_split |
connect.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... | (address: &SocketAddr, handle: &Handle, self_key_pair: Arc<NodeKeyPair>, trusted_nodes: BTreeSet<NodeId>) -> Deadline<Connect> {
let connect = Connect {
state: ConnectState::TcpConnect(TcpStream::connect(address, handle)),
address: address.clone(),
self_key_pair: self_key_pair,
trusted_nodes: trusted_nodes,
}... | connect | identifier_name |
match-pipe-binding.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | match (1, 2, 3) {
(1, a, b) | (2, b, a) => {
assert_eq!(a, 2);
assert_eq!(b, 3);
},
_ => panic!(),
}
}
fn test3() {
match (1, 2, 3) {
(1, ref a, ref b) | (2, ref b, ref a) => {
assert_eq!(*a, 2);
assert_eq!(*b, 3);
},
... | _ => panic!(),
}
}
fn test2() { | random_line_split |
match-pipe-binding.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
test1();
test2();
test3();
test4();
test5();
} | identifier_body | |
match-pipe-binding.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
// from issue 6338
match ((1, "a".to_string()), (2, "b".to_string())) {
((1, a), (2, b)) | ((2, b), (1, a)) => {
assert_eq!(a, "a".to_string());
assert_eq!(b, "b".to_string());
},
_ => panic!(),
}
}
fn test2() {
match (1, 2, 3) {
... | test1 | identifier_name |
future.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
struct Bomb(Sender<bool>);
local_data_key!(LOCAL: Bomb)
impl Drop for Bomb {
fn drop(&mut self) {
let Bomb(ref tx) = *self;
tx.send(task::failing());
}
}
// Spawn a future, but drop it immediately. When we receive th... | test_dropped_future_doesnt_fail | identifier_name |
future.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (*(self.get_ref())).clone()
}
}
impl<A> Future<A> {
/// Gets the value from this future, forcing evaluation.
pub fn unwrap(mut self) -> A {
self.get_ref();
let state = replace(&mut self.state, Evaluating);
match state {
Forced(v) => v,
_ => fail!( "Lo... | impl<A:Clone> Future<A> {
pub fn get(&mut self) -> A {
//! Get the value of the future. | random_line_split |
local-drop-glue.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 mod mod1
{
use super::Struct;
//~ MONO_ITEM fn core::ptr[0]::real_drop_in_place[0]<local_drop_glue::mod1[0]::Struct2[0]> @@ local_drop_glue-mod1[Internal]
struct Struct2 {
_a: Struct,
//~ MONO_ITEM fn core::ptr[0]::real_drop_in_place[0]<(u32, local_drop_glue::Struct[0])> @@ local_drop... | {
let _ = Outer {
_a: Struct {
_a: 0
}
};
} | identifier_body |
local-drop-glue.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | ()
{
let _ = Outer {
_a: Struct {
_a: 0
}
};
}
pub mod mod1
{
use super::Struct;
//~ MONO_ITEM fn core::ptr[0]::real_drop_in_place[0]<local_drop_glue::mod1[0]::Struct2[0]> @@ local_drop_glue-mod1[Internal]
struct Struct2 {
_a: Struct,
//~ MONO_ITEM fn co... | user | identifier_name |
local-drop-glue.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | };
}
} | {
let _ = Struct2 {
_a: Struct { _a: 0 },
_b: (0, Struct { _a: 0 }), | random_line_split |
desc.rs | /// Used in `SQLColAttributeW`.
#[repr(u16)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum | {
/// `SQL_DESC_COUNT`. Returned in `NumericAttributePtr`. The number of columns available in the
/// result set. This returns 0 if there are no columns in the result set. The value in the
/// `column_number` argument is ignored.
Count = 1001,
/// `SQL_DESC_TYPE`. Retruned in `NumericAttributePtr`.... | Desc | identifier_name |
desc.rs | /// Used in `SQLColAttributeW`.
#[repr(u16)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Desc {
/// `SQL_DESC_COUNT`. Returned in `NumericAttributePtr`. The number of columns available in the
/// result set. This returns 0 if there are no columns in the result set. The value in the
/// `column_num... | /// `SQL_DESC_ROWS_PROCESSED_PTR`.
RowsProcessedPtr = 34,
#[cfg(feature = "odbc_version_3_50")]
/// `SQL_DESC_ROWVER`.
RowVer = 35,
/// `SQL_DESC_SCHEMA_NAME`. Returned in `CharacterAttributePtr`. The schema of the table that
/// contains the column. The returned value is implementation-defi... | ParameterType = 33, | random_line_split |
counter.rs | // 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::sync::atom... | fn add(&self, value: usize);
/// Take a snapshot of the current value for use with a `Reporter`.
fn snapshot(&self) -> CounterSnapshot;
}
impl Counter for StdCounter {
fn clear(&self) {
self.value.store(0, Ordering::Relaxed);
}
fn inc(&self) {
self.value.fetch_add(1, Ordering:... | /// Increment the counter by 1.
fn inc(&self);
/// Increment the counter by the given amount. MUST check that v >= 0. | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.