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 |
|---|---|---|---|---|
timer.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 ... |
#[test]
fn sleep() {
let mut timer = TimerWatcher::new(local_loop());
timer.sleep(1);
timer.sleep(1);
}
#[test] #[should_fail]
fn oneshot_fail() {
let mut timer = TimerWatcher::new(local_loop());
let _port = timer.oneshot(1);
fail!();
}
#[t... | {
let mut timer = TimerWatcher::new(local_loop());
let port = timer.period(1);
port.recv();
port.recv();
let port = timer.period(1);
port.recv();
port.recv();
} | identifier_body |
timer.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 ... | (loop_: &mut Loop) -> ~TimerWatcher {
let handle = UvHandle::alloc(None::<TimerWatcher>, uvll::UV_TIMER);
assert_eq!(unsafe {
uvll::uv_timer_init(loop_.handle, handle)
}, 0);
let me = ~TimerWatcher {
handle: handle,
action: None,
home: get_... | new | identifier_name |
timer.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 ... | self.action = Some(WakeTask(task));
self.start(msecs, 0);
});
self.stop();
}
fn oneshot(&mut self, msecs: u64) -> PortOne<()> {
let (port, chan) = oneshot();
// similarly to the destructor, we must drop the previous action outside
// of the homin... | random_line_split | |
lib.rs | //! # Mime
//!
//! Mime is now Media Type, technically, but `Mime` is more immediately
//! understandable, so the main type here is `Mime`.
//!
//! ## What is Mime?
//!
//! Example mime string: `text/plain;charset=utf-8`
//!
//! ```rust
//! # #[macro_use] extern crate mime;
//! # fn main() {
//! let plain_text: mime::M... | (c: char) -> bool {
match c {
'a'...'z' |
'0'...'9' => true,
_ => false
}
}
fn is_restricted_name_char(c: char) -> bool {
if is_restricted_name_first_char(c) {
true
} else {
match c {
'!' |
'#' |
'$' |
'&' |
... | is_restricted_name_first_char | identifier_name |
lib.rs | //! # Mime
//!
//! Mime is now Media Type, technically, but `Mime` is more immediately
//! understandable, so the main type here is `Mime`.
//!
//! ## What is Mime?
//!
//! Example mime string: `text/plain;charset=utf-8`
//!
//! ```rust
//! # #[macro_use] extern crate mime;
//! # fn main() {
//! let plain_text: mime::M... |
#[test]
fn test_mime_from_str() {
assert_eq!(Mime::from_str("text/plain").unwrap(), mime!(Text/Plain));
assert_eq!(Mime::from_str("TEXT/PLAIN").unwrap(), mime!(Text/Plain));
assert_eq!(Mime::from_str("text/plain; charset=utf-8").unwrap(), mime!(Text/Plain; Charset=Utf8));
asser... | {
let mime = mime!(Text/Plain);
assert_eq!(mime.to_string(), "text/plain".to_string());
let mime = mime!(Text/Plain; Charset=Utf8);
assert_eq!(mime.to_string(), "text/plain; charset=utf-8".to_string());
} | identifier_body |
lib.rs | //! # Mime
//!
//! Mime is now Media Type, technically, but `Mime` is more immediately
//! understandable, so the main type here is `Mime`.
//!
//! ## What is Mime?
//!
//! Example mime string: `text/plain;charset=utf-8`
//!
//! ```rust
//! # #[macro_use] extern crate mime;
//! # fn main() {
//! let plain_text: mime::M... | // >
// > type-name = restricted-name
// > subtype-name = restricted-name
// >
// > restricted-name = restricted-name-first *126restricted-name-chars
// > restricted-name-first = ALPHA / DIGIT
// > restricted-name-chars = ALPHA / DIGIT / "!" / "#" /
// > "$" / "&" / "-... | random_line_split | |
hash.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.... | }
impl serde::Serialize for $name {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer {
let mut hex = "0x".to_owned();
hex.push_str(&self.0.to_hex());
serializer.serialize_str(&hex)
}
}
impl serde::Deserialize for $name {
fn deserialize<D>(de... | } | random_line_split |
main.rs | use std::collections::HashMap;
use std::hash::Hash;
use std::thread;
use std::time::Duration;
// struct to cache results of expensive calculations
struct Cacher<T, U, V>
where
T: Fn(U) -> V,
U: Eq + Hash + Copy,
V: Copy,
{
calculation: T,
values: HashMap<U, V>,
}
impl<T, U, V> Cacher<T, U, V>
wher... |
#[test]
fn call_with_different_values() {
let mut c = Cacher::new(|a| a);
let v1 = c.value(1);
let v2 = c.value(2);
assert_ne!(v2, v1);
assert_eq!(v2, 2);
}
#[test]
fn call_with_different_types() {
let mut c1 = Cacher::new(|a| a);
let mut c2 = Cacher::new(|a| a);
let v1 = c1.value(... | {
let simulated_user_specified_value = 10;
let simulated_randon_number = 7;
generate_workout(simulated_user_specified_value, simulated_randon_number);
} | identifier_body |
main.rs | use std::collections::HashMap;
use std::hash::Hash;
use std::thread;
use std::time::Duration;
// struct to cache results of expensive calculations
struct Cacher<T, U, V>
where
T: Fn(U) -> V, | }
impl<T, U, V> Cacher<T, U, V>
where
T: Fn(U) -> V,
U: Eq + Hash + Copy,
V: Copy,
{
fn new(calculation: T) -> Cacher<T, U, V> {
Cacher {
calculation,
values: HashMap::new(),
}
}
fn value(&mut self, arg: U) -> V {
match self.values.get(&arg) {
... | U: Eq + Hash + Copy,
V: Copy,
{
calculation: T,
values: HashMap<U, V>, | random_line_split |
main.rs | use std::collections::HashMap;
use std::hash::Hash;
use std::thread;
use std::time::Duration;
// struct to cache results of expensive calculations
struct Cacher<T, U, V>
where
T: Fn(U) -> V,
U: Eq + Hash + Copy,
V: Copy,
{
calculation: T,
values: HashMap<U, V>,
}
impl<T, U, V> Cacher<T, U, V>
wher... | else {
if random_number == 3 {
println!("Take a break today! Remember to stay hydrated!");
} else {
println!(
"Today, run for {} minutes!",
expensive_result.value(intensity)
);
}
}
}
fn main() {
let simulated_user_spec... | {
println!("Today, do {} pushups!", expensive_result.value(intensity));
println!("Next, do {} situps!", expensive_result.value(intensity));
} | conditional_block |
main.rs | use std::collections::HashMap;
use std::hash::Hash;
use std::thread;
use std::time::Duration;
// struct to cache results of expensive calculations
struct Cacher<T, U, V>
where
T: Fn(U) -> V,
U: Eq + Hash + Copy,
V: Copy,
{
calculation: T,
values: HashMap<U, V>,
}
impl<T, U, V> Cacher<T, U, V>
wher... | () {
let mut c = Cacher::new(|a| a);
let v1 = c.value(1);
let v2 = c.value(2);
assert_ne!(v2, v1);
assert_eq!(v2, 2);
}
#[test]
fn call_with_different_types() {
let mut c1 = Cacher::new(|a| a);
let mut c2 = Cacher::new(|a| a);
let v1 = c1.value(1);
let v2 = c2.value("Test");
... | call_with_different_values | identifier_name |
custom_mesh.rs | extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::light::Light;
use kiss3d::resource::Mesh;
use kiss3d::window::Window;
use na::{Point3, UnitQuaternion, Vector3};
use std::cell::RefCell;
use std::rc::Rc;
fn | () {
let mut window = Window::new("Kiss3d: custom_mesh");
let a = Point3::new(-1.0, -1.0, 0.0);
let b = Point3::new(1.0, -1.0, 0.0);
let c = Point3::new(0.0, 1.0, 0.0);
let vertices = vec![a, b, c];
let indices = vec![Point3::new(0u16, 1, 2)];
let mesh = Rc::new(RefCell::new(Mesh::new(
... | main | identifier_name |
custom_mesh.rs | extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::light::Light;
use kiss3d::resource::Mesh;
use kiss3d::window::Window;
use na::{Point3, UnitQuaternion, Vector3};
use std::cell::RefCell;
use std::rc::Rc;
fn main() | let rot = UnitQuaternion::from_axis_angle(&Vector3::y_axis(), 0.014);
while window.render() {
c.prepend_to_local_rotation(&rot);
}
}
| {
let mut window = Window::new("Kiss3d: custom_mesh");
let a = Point3::new(-1.0, -1.0, 0.0);
let b = Point3::new(1.0, -1.0, 0.0);
let c = Point3::new(0.0, 1.0, 0.0);
let vertices = vec![a, b, c];
let indices = vec![Point3::new(0u16, 1, 2)];
let mesh = Rc::new(RefCell::new(Mesh::new(
... | identifier_body |
custom_mesh.rs | extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::light::Light;
use kiss3d::resource::Mesh; | use std::cell::RefCell;
use std::rc::Rc;
fn main() {
let mut window = Window::new("Kiss3d: custom_mesh");
let a = Point3::new(-1.0, -1.0, 0.0);
let b = Point3::new(1.0, -1.0, 0.0);
let c = Point3::new(0.0, 1.0, 0.0);
let vertices = vec![a, b, c];
let indices = vec![Point3::new(0u16, 1, 2)];
... | use kiss3d::window::Window;
use na::{Point3, UnitQuaternion, Vector3}; | random_line_split |
cull.rs | // Copyright (C) 2012 The Android Open Source Project
//
// 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 applic... | #pragma version(1)
#pragma rs java_package_name(com.android.scenegraph)
#include "scenegraph_objects.rsh"
static void getTransformedSphere(SgRenderable *obj) {
obj->worldBoundingSphere = obj->boundingSphere;
obj->worldBoundingSphere.w = 1.0f;
const SgTransform *objTransform = (const SgTransform *)rsGetEl... | // See the License for the specific language governing permissions and
// limitations under the License.
| random_line_split |
cull.rs | // Copyright (C) 2012 The Android Open Source Project
//
// 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 applic... | }
getTransformedSphere(obj);
return!rsIsSphereInFrustum(&obj->worldBoundingSphere,
&cam->frustumPlanes[0], &cam->frustumPlanes[1],
&cam->frustumPlanes[2], &cam->frustumPlanes[3],
&cam->frustumPlanes[4], &cam->... | {
float minX, minY, minZ, maxX, maxY, maxZ;
rsgMeshComputeBoundingBox(obj->mesh,
&minX, &minY, &minZ,
&maxX, &maxY, &maxZ);
//rsDebug("min", minX, minY, minZ);
//rsDebug("max", maxX, maxY, maxZ);
float4 sphere;
... | conditional_block |
ident.rs | use super::error::TomlHelper;
use log::error;
use regex::Regex;
use std::fmt;
use toml::Value;
#[derive(Clone, Debug)]
pub enum Ident {
Name(String),
Pattern(Box<Regex>),
}
impl fmt::Display for Ident {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Ident::Name... | s, what, object_name, e
);
e
})
.ok(),
None => match toml.lookup("name").and_then(Value::as_str) {
Some(name) => {
if name.contains(['.', '+', '*'].as_ref()) {
... | .map_err(|e| {
error!(
"Bad pattern `{}` in {} for `{}`: {}", | random_line_split |
ident.rs | use super::error::TomlHelper;
use log::error;
use regex::Regex;
use std::fmt;
use toml::Value;
#[derive(Clone, Debug)]
pub enum Ident {
Name(String),
Pattern(Box<Regex>),
}
impl fmt::Display for Ident {
fn | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Ident::Name(name) => f.write_str(name),
Ident::Pattern(regex) => write!(f, "Regex {}", regex),
}
}
}
impl PartialEq for Ident {
fn eq(&self, other: &Ident) -> bool {
pub use self::Ident::*;
... | fmt | identifier_name |
ident.rs | use super::error::TomlHelper;
use log::error;
use regex::Regex;
use std::fmt;
use toml::Value;
#[derive(Clone, Debug)]
pub enum Ident {
Name(String),
Pattern(Box<Regex>),
}
impl fmt::Display for Ident {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Ident::Name... |
}
| {
use self::Ident::*;
match self {
Name(n) => name == n,
Pattern(regex) => regex.is_match(name),
}
} | identifier_body |
lib.rs | #![feature(const_fn)]
#![feature(alloc, allocator_api)]
#![no_std]
#[cfg(test)]
#[macro_use]
extern crate std;
#[cfg(feature = "use_spin")]
extern crate spin;
extern crate alloc;
use alloc::alloc::{Alloc, AllocErr, Layout};
use core::alloc::{GlobalAlloc};
use core::mem;
#[cfg(feature = "use_spin")]
use core::ops::D... |
/// Initializes an empty heap
///
/// # Unsafety
///
/// This function must be called at most once and must only be used on an
/// empty heap.
pub unsafe fn init(&mut self, heap_bottom: usize, heap_size: usize) {
self.bottom = heap_bottom;
self.size = heap_size;
sel... | {
Heap {
bottom: 0,
size: 0,
holes: HoleList::empty(),
}
} | identifier_body |
lib.rs | #![feature(const_fn)]
#![feature(alloc, allocator_api)]
#![no_std]
#[cfg(test)]
#[macro_use]
extern crate std;
#[cfg(feature = "use_spin")]
extern crate spin;
extern crate alloc;
use alloc::alloc::{Alloc, AllocErr, Layout};
use core::alloc::{GlobalAlloc};
use core::mem;
#[cfg(feature = "use_spin")]
use core::ops::D... |
let size = align_up(size, mem::align_of::<Hole>());
let layout = Layout::from_size_align(size, layout.align()).unwrap();
self.holes.deallocate(ptr, layout);
}
/// Returns the bottom address of the heap.
pub fn bottom(&self) -> usize {
self.bottom
}
/// Returns the... | {
size = HoleList::min_size();
} | conditional_block |
lib.rs | #![feature(const_fn)]
#![feature(alloc, allocator_api)]
#![no_std]
#[cfg(test)]
#[macro_use]
extern crate std;
#[cfg(feature = "use_spin")]
extern crate spin;
extern crate alloc;
use alloc::alloc::{Alloc, AllocErr, Layout};
use core::alloc::{GlobalAlloc};
use core::mem;
#[cfg(feature = "use_spin")]
use core::ops::D... | (&mut self, ptr: NonNull<u8>, layout: Layout) {
let mut size = layout.size();
if size < HoleList::min_size() {
size = HoleList::min_size();
}
let size = align_up(size, mem::align_of::<Hole>());
let layout = Layout::from_size_align(size, layout.align()).unwrap();
... | deallocate | identifier_name |
lib.rs | #![feature(const_fn)]
#![feature(alloc, allocator_api)]
#![no_std]
#[cfg(test)]
#[macro_use]
extern crate std;
#[cfg(feature = "use_spin")]
extern crate spin;
extern crate alloc;
use alloc::alloc::{Alloc, AllocErr, Layout};
use core::alloc::{GlobalAlloc};
use core::mem;
#[cfg(feature = "use_spin")]
use core::ops::D... | }
}
/// Align upwards. Returns the smallest x with alignment `align`
/// so that x >= addr. The alignment must be a power of 2.
pub fn align_up(addr: usize, align: usize) -> usize {
align_down(addr + align - 1, align)
} | random_line_split | |
buffer.rs | //! A buffer is used for decoding raw bytes
//!
//! It is represented by a copyable slice
//!
//! This is normally imported as buffer::* such that the
//! pub's can be considered to be in the global namespace
use std::mem;
use std::marker;
#[derive(Debug)]
pub struct EndOfBufferError;
#[derive(Clone,Copy,Debug)]
pub... | }
/// Returns the buffer of what is contained in `original` that is no longer
/// in self. That is: returns whatever is consumed since original
pub fn consumed_since(self, original: Buffer) -> Buffer {
let len = original.inner.len() - self.inner.len();
Buffer {
inner: &origi... | }
pub fn len(self) -> usize {
self.inner.len() | random_line_split |
buffer.rs | //! A buffer is used for decoding raw bytes
//!
//! It is represented by a copyable slice
//!
//! This is normally imported as buffer::* such that the
//! pub's can be considered to be in the global namespace
use std::mem;
use std::marker;
#[derive(Debug)]
pub struct EndOfBufferError;
#[derive(Clone,Copy,Debug)]
pub... |
}
| {
let x = &[0xff_u8, 0x00_u8, 0x00_u8, 0x00_u8];
let mut buf = Buffer { inner: x };
let org_buf = buf;
assert_eq!(u32::parse(&mut buf).unwrap(), 0xff_u32);
assert_eq!(buf.len(), 0);
assert_eq!(buf.consumed_since(org_buf).len(), 4);
} | identifier_body |
buffer.rs | //! A buffer is used for decoding raw bytes
//!
//! It is represented by a copyable slice
//!
//! This is normally imported as buffer::* such that the
//! pub's can be considered to be in the global namespace
use std::mem;
use std::marker;
#[derive(Debug)]
pub struct EndOfBufferError;
#[derive(Clone,Copy,Debug)]
pub... | (buffer: &mut Buffer<'a>) -> Result<Vec<T>, EndOfBufferError> {
let count = try!(buffer.parse_compact_size());
let mut result: Vec<T> = Vec::with_capacity(count);
for _ in 0..count {
result.push(try!(T::parse(buffer)));
}
Ok(result)
}
}
macro_rules! impl_pars... | parse | identifier_name |
buffer.rs | //! A buffer is used for decoding raw bytes
//!
//! It is represented by a copyable slice
//!
//! This is normally imported as buffer::* such that the
//! pub's can be considered to be in the global namespace
use std::mem;
use std::marker;
#[derive(Debug)]
pub struct EndOfBufferError;
#[derive(Clone,Copy,Debug)]
pub... | ,
_ => byte1 as usize
})
}
/// Parses given amount of bytes
pub fn parse_bytes(&mut self, count: usize) -> Result<&'a[u8], EndOfBufferError> {
if self.inner.len() < count {
return Err(EndOfBufferError);
}
// split in result, and remaining
let... | { try!(u16::parse(self)) as usize } | conditional_block |
if-check.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (x: uint) {
if even(x) {
info2!("{}", x);
} else {
fail2!();
}
}
pub fn main() { foo(2u); }
| foo | identifier_name |
if-check.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() { foo(2u); }
| {
fail2!();
} | conditional_block |
if-check.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() { foo(2u); }
| {
if even(x) {
info2!("{}", x);
} else {
fail2!();
}
} | identifier_body |
if-check.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 | // option. This file may not be copied, modified, or distributed
// except according to those terms.
fn even(x: uint) -> bool {
if x < 2u {
return false;
} else if x == 2u { return true; } else { return even(x - 2u); }
}
fn foo(x: uint) {
if even(x) {
info2!("{}", x);
} else {
... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
proxyhandler.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/. */
//! Utilities for the implementation of JSAPI proxy handlers.
#![deny(missing_docs)]
use dom::bindings::conversi... |
/// Set the property descriptor's object to `obj` and set it to enumerable,
/// and writable if `readonly` is true.
pub fn fill_property_descriptor(desc: &mut JSPropertyDescriptor,
obj: *mut JSObject, readonly: bool) {
desc.obj = obj;
desc.attrs = if readonly { JSPROP_READONLY ... | {
unsafe {
assert!(is_dom_proxy(obj.get()));
let mut expando = get_expando_object(obj);
if expando.is_null() {
expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(), HandleObject::null());
assert!(!expando.is_null());
SetProxyExtra(obj.get(), JSPROXYSL... | identifier_body |
proxyhandler.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/. */
//! Utilities for the implementation of JSAPI proxy handlers.
#![deny(missing_docs)]
use dom::bindings::conversi... |
JS_GetPropertyDescriptorById(cx, proto.handle(), id, desc)
}
/// Defines an expando on the given `proxy`.
pub unsafe extern fn define_property(cx: *mut JSContext, proxy: HandleObject,
id: HandleId, desc: Handle<JSPropertyDescriptor>,
resul... | {
desc.get().obj = ptr::null_mut();
return true;
} | conditional_block |
proxyhandler.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/. */
//! Utilities for the implementation of JSAPI proxy handlers.
#![deny(missing_docs)]
use dom::bindings::conversi... | (cx: *mut JSContext, proxy: HandleObject,
id: HandleId, desc: Handle<JSPropertyDescriptor>,
result: *mut ObjectOpResult)
-> bool {
//FIXME: Workaround for https://github.com/mozilla/rust/issues/13385
l... | define_property | identifier_name |
issue-4252.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// |
#![feature(unsafe_destructor)]
trait X {
fn call<T: std::fmt::Debug>(&self, x: &T);
fn default_method<T: std::fmt::Debug>(&self, x: &T) {
println!("X::default_method {:?}", x);
}
}
#[derive(Debug)]
struct Y(int);
#[derive(Debug)]
struct Z<T> {
x: T
}
impl X for Y {
fn call<T: std::fmt::... | // 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. | random_line_split |
issue-4252.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
let _z = Z {x: Y(42)};
} | identifier_body | |
issue-4252.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
let _z = Z {x: Y(42)};
}
| main | identifier_name |
error.rs | use std::error;
use std::fmt;
use log::SetLoggerError;
use error::Error as NoritamaError;
// @TODO Implement ErrorKind
#[derive(Debug)]
pub enum Error {
InvalidArgError(String),
LibError(NoritamaError),
LoggerError(SetLoggerError),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter)... | Error::LoggerError(ref err) => err.description(),
}
}
}
impl From<NoritamaError> for Error {
fn from(err: NoritamaError) -> Error {
Error::LibError(err)
}
}
impl From<SetLoggerError> for Error {
fn from(err: SetLoggerError) -> Error {
Error::LoggerError(err)
}
} | Error::LibError(ref err) => err.description(), | random_line_split |
error.rs | use std::error;
use std::fmt;
use log::SetLoggerError;
use error::Error as NoritamaError;
// @TODO Implement ErrorKind
#[derive(Debug)]
pub enum Error {
InvalidArgError(String),
LibError(NoritamaError),
LoggerError(SetLoggerError),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter)... |
}
impl From<NoritamaError> for Error {
fn from(err: NoritamaError) -> Error {
Error::LibError(err)
}
}
impl From<SetLoggerError> for Error {
fn from(err: SetLoggerError) -> Error {
Error::LoggerError(err)
}
}
| {
match *self {
Error::InvalidArgError(ref err) => err,
Error::LibError(ref err) => err.description(),
Error::LoggerError(ref err) => err.description(),
}
} | identifier_body |
error.rs | use std::error;
use std::fmt;
use log::SetLoggerError;
use error::Error as NoritamaError;
// @TODO Implement ErrorKind
#[derive(Debug)]
pub enum Error {
InvalidArgError(String),
LibError(NoritamaError),
LoggerError(SetLoggerError),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter)... | (err: SetLoggerError) -> Error {
Error::LoggerError(err)
}
}
| from | identifier_name |
users.rs | use std::io::prelude::*;
use std::io::BufReader;
use std::io::Result;
use std::fs::File;
use std::option::Option;
#[derive(Debug, Clone)]
pub struct User {
pub username: String,
pub phone_number: Option<String>,
pub slack_username: Option<String>
}
pub fn read_users(path: String) -> Result<Vec<User>> {
... | (line: &str) -> Option<User> {
let parts: Vec<String> = line.split(",").map( |s| s.to_owned() ).collect();
let username = parts.get(0);
if username.is_none() || username.expect("Read invalid user").is_empty() {
return None;
}
let phone_number = match parts.get(1) {
Some(number) => ... | parse_user | identifier_name |
users.rs | use std::io::prelude::*;
use std::io::BufReader;
use std::io::Result;
use std::fs::File;
use std::option::Option;
#[derive(Debug, Clone)]
pub struct User {
pub username: String,
pub phone_number: Option<String>,
pub slack_username: Option<String>
}
pub fn read_users(path: String) -> Result<Vec<User>> {
... | phone_number: phone_number,
slack_username: slack_username
});
} else {
return None;
}
}
#[test]
fn test_parse_user() {
let line = "patrickod,+16507017829,patrickod";
let user = parse_user(line).unwrap();
assert_eq!(user.username, "patrickod".to_string());
... | {
let parts: Vec<String> = line.split(",").map( |s| s.to_owned() ).collect();
let username = parts.get(0);
if username.is_none() || username.expect("Read invalid user").is_empty() {
return None;
}
let phone_number = match parts.get(1) {
Some(number) => Some(number.to_owned()),
... | identifier_body |
users.rs | use std::io::prelude::*;
use std::io::BufReader;
use std::io::Result;
use std::fs::File;
use std::option::Option;
#[derive(Debug, Clone)]
pub struct User {
pub username: String,
pub phone_number: Option<String>,
pub slack_username: Option<String>
}
pub fn read_users(path: String) -> Result<Vec<User>> {
... | let phone_number = match parts.get(1) {
Some(number) => Some(number.to_owned()),
None => None
};
let slack_username = match parts.get(2) {
Some(number) => Some(number.to_owned()),
None => None
};
if phone_number.is_some() || slack_username.is_some() {
return ... | }
| random_line_split |
TestLog.rs | /*
* Copyright (C) 2014 The Android Open Source Project
*
* 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
* | */
#pragma version(1)
#pragma rs java_package_name(android.renderscript.cts)
// Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime.
float __attribute__((kernel)) testLogFloatFloat(float in) {
return log(in);
}
float2 __attribute__((kernel)) testLogFloat2Float2(float2 in) {
return... | * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. | random_line_split |
url.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/. */
//! Common handling for the specified value CSS url() values.
use cssparser::{CssStringWriter, Parser};
#[cfg(fea... |
/// Creates an already specified url value from an already resolved URL
/// for insertion in the cascade.
pub fn for_cascade(url: ServoUrl, extra_data: UrlExtraData) -> Self {
SpecifiedUrl {
original: None,
resolved: Some(url),
extra_data: extra_data,
}
... | {
self.resolved.is_some()
} | identifier_body |
url.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/. */
//! Common handling for the specified value CSS url() values.
use cssparser::{CssStringWriter, Parser};
#[cfg(fea... | (url: ServoUrl, extra_data: UrlExtraData) -> Self {
SpecifiedUrl {
original: None,
resolved: Some(url),
extra_data: extra_data,
}
}
/// Gets a new url from a string for unit tests.
#[cfg(feature = "servo")]
pub fn new_for_testing(url: &str) -> Self {
... | for_cascade | identifier_name |
url.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/. */
//! Common handling for the specified value CSS url() values.
use cssparser::{CssStringWriter, Parser};
#[cfg(fea... | }
impl Parse for SpecifiedUrl {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
let url = try!(input.expect_url());
Self::parse_from_string(url, context)
}
}
impl SpecifiedUrl {
/// Try to parse a URL from a string value that is a valid CSS token for a
/// U... | /// Extra data used for Stylo.
extra_data: UrlExtraData, | random_line_split |
mod.rs | use rustc_ast::{self as ast, MetaItem};
use rustc_middle::ty;
use rustc_session::Session;
use rustc_span::symbol::{sym, Symbol};
pub(crate) use self::drop_flag_effects::*;
pub use self::framework::{
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, BorrowckFlowState,
BorrowckResults, E... | {
for attr in attrs {
if attr.has_name(sym::rustc_mir) {
let items = attr.meta_item_list();
for item in items.iter().flat_map(|l| l.iter()) {
match item.meta_item() {
Some(mi) if mi.has_name(name) => return Some(mi.clone()),
_ =... | identifier_body | |
mod.rs | use rustc_ast::{self as ast, MetaItem};
use rustc_middle::ty;
use rustc_session::Session;
use rustc_span::symbol::{sym, Symbol};
pub(crate) use self::drop_flag_effects::*;
pub use self::framework::{
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, BorrowckFlowState,
BorrowckResults, E... | (
_sess: &Session,
attrs: &[ast::Attribute],
name: Symbol,
) -> Option<MetaItem> {
for attr in attrs {
if attr.has_name(sym::rustc_mir) {
let items = attr.meta_item_list();
for item in items.iter().flat_map(|l| l.iter()) {
match item.meta_item() {
... | has_rustc_mir_with | identifier_name |
mod.rs | use rustc_ast::{self as ast, MetaItem};
use rustc_middle::ty;
use rustc_session::Session; |
pub(crate) use self::drop_flag_effects::*;
pub use self::framework::{
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, BorrowckFlowState,
BorrowckResults, Engine, Forward, GenKill, GenKillAnalysis, JoinSemiLattice, Results,
ResultsCursor, ResultsRefCursor, ResultsVisitor, SwitchIn... | use rustc_span::symbol::{sym, Symbol}; | random_line_split |
aor-13.rs | use std::cmp::min;
use std::cmp::max;
use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::cell::RefCell;
const INFTY: i32 = 1 << 30;
struct Node {
adj: Vec<(String, i32)>
}
struct Graph {
names: HashMap<String, usize>,
nodes: Vec<RefCell<Node>>
}
impl... | ret = max(ret, dp[lim - 1][i]);
}
ret
}
}
fn main() {
let mut f = File::open(Path::new("/Users/PetarV/rust-proj/advent-of-rust/target/input.txt"))
.ok()
.expect("Failed to open the input file!");
let mut input = String::new();
f.read_to_string(&mut input)
.ok()
.exp... | random_line_split | |
aor-13.rs | use std::cmp::min;
use std::cmp::max;
use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::cell::RefCell;
const INFTY: i32 = 1 << 30;
struct Node {
adj: Vec<(String, i32)>
}
struct Graph {
names: HashMap<String, usize>,
nodes: Vec<RefCell<Node>>
}
impl... | b.pop();
let w = if g == "gain" {
d
} else if g == "lose" {
-d
} else {
panic!("Something is wrong, no gain/lose in line!");
};
let key = (min(a.clone(), b.clone()), max(a.clone(), b.clone()));
if edges.contains_key(&key) {
... | {
let mut f = File::open(Path::new("/Users/PetarV/rust-proj/advent-of-rust/target/input.txt"))
.ok()
.expect("Failed to open the input file!");
let mut input = String::new();
f.read_to_string(&mut input)
.ok()
.expect("Failed to read from the input file!");
let mut graph = Graph::new();
le... | identifier_body |
aor-13.rs | use std::cmp::min;
use std::cmp::max;
use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::cell::RefCell;
const INFTY: i32 = 1 << 30;
struct Node {
adj: Vec<(String, i32)>
}
struct Graph {
names: HashMap<String, usize>,
nodes: Vec<RefCell<Node>>
}
impl... | () -> Graph {
Graph {
names: HashMap::new(),
nodes: Vec::new()
}
}
fn spawn_if_missing(&mut self, name: String) {
if!self.names.contains_key(&name) {
let index = self.nodes.len();
self.nodes.push(RefCell::new(Node::new()));
sel... | new | identifier_name |
aor-13.rs | use std::cmp::min;
use std::cmp::max;
use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::cell::RefCell;
const INFTY: i32 = 1 << 30;
struct Node {
adj: Vec<(String, i32)>
}
struct Graph {
names: HashMap<String, usize>,
nodes: Vec<RefCell<Node>>
}
impl... | else {
panic!("Something is wrong, no gain/lose in line!");
};
let key = (min(a.clone(), b.clone()), max(a.clone(), b.clone()));
if edges.contains_key(&key) {
let val = edges[&key];
edges.insert(key, val + w);
} else {
edges.insert(key, w... | {
-d
} | conditional_block |
mod.rs | use std::cmp::{min, max};
use std::hash::{Hash, Hasher};
use std::collections::{HashSet, HashMap};
use std::ops::Add;
use std::str::FromStr;
extern crate itertools;
use self::itertools::Itertools;
extern crate permutohedron;
const DATA: &'static str = include_str!("input.txt");
pub fn main() -> Vec<String> {
le... | } | let d = map.find_longest_route();
assert_eq!(d, Some(982));
} | random_line_split |
mod.rs | use std::cmp::{min, max};
use std::hash::{Hash, Hasher};
use std::collections::{HashSet, HashMap};
use std::ops::Add;
use std::str::FromStr;
extern crate itertools;
use self::itertools::Itertools;
extern crate permutohedron;
const DATA: &'static str = include_str!("input.txt");
pub fn main() -> Vec<String> {
le... |
#[test]
fn examples_2() {
let map = RouteMap::build(&EXAMPLE_DATA.join("\n")).unwrap();
let d = map.find_longest_route();
assert_eq!(d, Some(982));
}
}
| {
let map = RouteMap::build(&EXAMPLE_DATA.join("\n")).unwrap();
let d = map.find_shortest_route();
assert_eq!(d, Some(605));
} | identifier_body |
mod.rs | use std::cmp::{min, max};
use std::hash::{Hash, Hasher};
use std::collections::{HashSet, HashMap};
use std::ops::Add;
use std::str::FromStr;
extern crate itertools;
use self::itertools::Itertools;
extern crate permutohedron;
const DATA: &'static str = include_str!("input.txt");
pub fn main() -> Vec<String> {
le... | (&self, other: &UnorderedPair<T>) -> bool {
((self.0 == other.0) && (self.1 == other.1)) || ((self.0 == other.1) && (self.1 == other.0))
}
}
impl<T: Hash + Ord> Hash for UnorderedPair<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
(min(&self.0, &self.1), max(&self.0, &self.1)).hash(state)
... | eq | identifier_name |
issue-17904.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 ... | <U> where U: Eq(U) -> R; // Notice this parses as well.
struct Baz<U>(U) where U: Eq; // This rightfully signals no error as well.
struct Foo<T> where T: Copy, (T); //~ ERROR unexpected token in `where` clause
struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where`
fn main() {}
| Baz | identifier_name |
issue-17904.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.
// | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax.
struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well.
... | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | random_line_split |
crate-method-reexport-grrrrrrr.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
use crate_method_reexport_grrrrrrr2::rust::add;
use crate_method_reexport_grrrrrrr2::rust::cx;
let x: Box<_> = box () ();
x.cx();
let y = ();
y.add("hi".to_string());
}
| main | identifier_name |
crate-method-reexport-grrrrrrr.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
use crate_method_reexport_grrrrrrr2::rust::add;
use crate_method_reexport_grrrrrrr2::rust::cx;
let x: Box<_> = box () ();
x.cx();
let y = ();
y.add("hi".to_string());
} | identifier_body | |
crate-method-reexport-grrrrrrr.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | use crate_method_reexport_grrrrrrr2::rust::add;
use crate_method_reexport_grrrrrrr2::rust::cx;
let x: Box<_> = box () ();
x.cx();
let y = ();
y.add("hi".to_string());
} | // aux-build:crate-method-reexport-grrrrrrr2.rs
extern crate crate_method_reexport_grrrrrrr2;
pub fn main() { | random_line_split |
interop.rs | use std::io::Read;
use std::io::Write;
use std::process;
/// Invoke `interop` binary, pass given data as stdin, return stdout.
pub fn interop_command(command: &str, stdin: &[u8]) -> Vec<u8> | .unwrap()
.read_to_end(&mut stdout)
.expect("read json");
let exit_status = interop.wait().expect("wait_with_output");
assert!(exit_status.success(), "{}", exit_status);
stdout
}
/// Decode binary protobuf, encode as JSON.
pub fn interop_json_encode(bytes: &[u8]) -> String {
let... | {
let mut interop = process::Command::new("../interop/cxx/interop")
.args(&[command])
.stdin(process::Stdio::piped())
.stdout(process::Stdio::piped())
.stderr(process::Stdio::inherit())
.spawn()
.expect("interop");
interop
.stdin
.take()
.... | identifier_body |
interop.rs | use std::io::Read;
use std::io::Write;
use std::process;
/// Invoke `interop` binary, pass given data as stdin, return stdout.
pub fn | (command: &str, stdin: &[u8]) -> Vec<u8> {
let mut interop = process::Command::new("../interop/cxx/interop")
.args(&[command])
.stdin(process::Stdio::piped())
.stdout(process::Stdio::piped())
.stderr(process::Stdio::inherit())
.spawn()
.expect("interop");
interop
... | interop_command | identifier_name |
interop.rs | use std::io::Read;
use std::io::Write;
use std::process; | pub fn interop_command(command: &str, stdin: &[u8]) -> Vec<u8> {
let mut interop = process::Command::new("../interop/cxx/interop")
.args(&[command])
.stdin(process::Stdio::piped())
.stdout(process::Stdio::piped())
.stderr(process::Stdio::inherit())
.spawn()
.expect("interop... |
/// Invoke `interop` binary, pass given data as stdin, return stdout. | random_line_split |
build.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "gecko")]
extern crate bindgen;
#[cfg(feature = "gecko")]
... | (engine: &str) {
for entry in WalkDir::new("properties") {
let entry = entry.unwrap();
match entry.path().extension().and_then(|e| e.to_str()) {
Some("mako") | Some("rs") | Some("py") | Some("zip") => {
println!("cargo:rerun-if-changed={}", entry.path().display());
... | generate_properties | identifier_name |
build.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "gecko")]
extern crate bindgen;
#[cfg(feature = "gecko")]
... | }
| {
let gecko = cfg!(feature = "gecko");
let servo = cfg!(feature = "servo");
let l2013 = cfg!(feature = "servo-layout-2013");
let l2020 = cfg!(feature = "servo-layout-2020");
let engine = match (gecko, servo, l2013, l2020) {
(true, false, false, false) => "gecko",
(false, true, true, ... | identifier_body |
build.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "gecko")]
extern crate bindgen;
#[cfg(feature = "gecko")]
... | ,
_ => {},
}
}
let script = Path::new(&env::var_os("CARGO_MANIFEST_DIR").unwrap())
.join("properties")
.join("build.py");
let status = Command::new(&*PYTHON)
.arg(&script)
.arg(engine)
.arg("style-crate")
.status()
.unwrap();
if!stat... | {
println!("cargo:rerun-if-changed={}", entry.path().display());
} | conditional_block |
build.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "gecko")]
extern crate bindgen;
#[cfg(feature = "gecko")]
... | if Command::new(name)
.arg("--version")
.output()
.ok()
.map_or(false, |out| out.status.success())
{
return name.to_owned();
}
}
panic!(
"Can't find python (tried {})! Try fixing P... | } else {
["python3"]
};
for &name in &candidates { | random_line_split |
checked_add_mul.rs | use num::arithmetic::traits::{CheckedAdd, CheckedAddMul, CheckedMul, UnsignedAbs, WrappingSub};
use num::basic::traits::Zero;
use num::conversion::traits::WrappingFrom;
fn checked_add_mul_unsigned<T: CheckedAdd<T, Output = T> + CheckedMul<T, Output = T>>(
x: T,
y: T,
z: T,
) -> Option<T> {
y.checked_mu... | else {
None
}
}
}
macro_rules! impl_checked_add_mul_signed {
($t:ident) => {
impl CheckedAddMul<$t> for $t {
type Output = $t;
/// Computes `self + y * z`, returning `None` if there is no valid result.
///
/// $$
/// f(x,... | {
Some(result)
} | conditional_block |
checked_add_mul.rs | use num::arithmetic::traits::{CheckedAdd, CheckedAddMul, CheckedMul, UnsignedAbs, WrappingSub};
use num::basic::traits::Zero;
use num::conversion::traits::WrappingFrom;
fn | <T: CheckedAdd<T, Output = T> + CheckedMul<T, Output = T>>(
x: T,
y: T,
z: T,
) -> Option<T> {
y.checked_mul(z).and_then(|yz| x.checked_add(yz))
}
macro_rules! impl_checked_add_mul_unsigned {
($t:ident) => {
impl CheckedAddMul<$t> for $t {
type Output = $t;
/// Comp... | checked_add_mul_unsigned | identifier_name |
checked_add_mul.rs | use num::arithmetic::traits::{CheckedAdd, CheckedAddMul, CheckedMul, UnsignedAbs, WrappingSub};
use num::basic::traits::Zero;
use num::conversion::traits::WrappingFrom;
fn checked_add_mul_unsigned<T: CheckedAdd<T, Output = T> + CheckedMul<T, Output = T>>(
x: T,
y: T,
z: T,
) -> Option<T> |
macro_rules! impl_checked_add_mul_unsigned {
($t:ident) => {
impl CheckedAddMul<$t> for $t {
type Output = $t;
/// Computes `self + y * z`, returning `None` if there is no valid result.
///
/// $$
/// f(x, y, z) = \\begin{cases}
/// ... | {
y.checked_mul(z).and_then(|yz| x.checked_add(yz))
} | identifier_body |
checked_add_mul.rs | use num::arithmetic::traits::{CheckedAdd, CheckedAddMul, CheckedMul, UnsignedAbs, WrappingSub};
use num::basic::traits::Zero;
use num::conversion::traits::WrappingFrom;
fn checked_add_mul_unsigned<T: CheckedAdd<T, Output = T> + CheckedMul<T, Output = T>>(
x: T,
y: T,
z: T,
) -> Option<T> {
y.checked_mu... | Some(result)
} else {
None
}
}
}
macro_rules! impl_checked_add_mul_signed {
($t:ident) => {
impl CheckedAddMul<$t> for $t {
type Output = $t;
/// Computes `self + y * z`, returning `None` if there is no valid result.
///
... | product.wrapping_sub(x)
});
if x >= product || (x_sign == (result < T::ZERO)) { | random_line_split |
texture.rs | extern crate gl;
extern crate image;
use self::gl::types::*;
use self::image::GenericImage;
use system::filesystem;
use std::path::Path;
use std::os::raw::c_void;
static VALID_IMG_EXT: [&'static str; 5] = [
"png", "jpeg", "jpg", "gif", "bmp"
];
pub enum TextureFmt {
R8U,
RG8U,
RGB8U,
RGBA8U
}
im... | (&mut self) {
unsafe { gl::DeleteTextures(1, &self.id); }
}
}
impl Texture {
pub fn from_image(path_str: &str) -> Texture {
let mut id = 0u32;
let path = Path::new(path_str);
//1. check extension
if!filesystem::check_extension(path, &VALID_IMG_EXT) {
panic!... | drop | identifier_name |
texture.rs | extern crate gl;
extern crate image;
use self::gl::types::*;
use self::image::GenericImage;
use system::filesystem;
use std::path::Path;
use std::os::raw::c_void;
static VALID_IMG_EXT: [&'static str; 5] = [
"png", "jpeg", "jpg", "gif", "bmp"
];
pub enum TextureFmt {
R8U,
RG8U,
RGB8U,
RGBA8U
}
im... |
pub struct Texture {
pub id: GLuint,
pub size: (u32, u32),
pub fmt: TextureFmt
}
impl Drop for Texture {
fn drop(&mut self) {
unsafe { gl::DeleteTextures(1, &self.id); }
}
}
impl Texture {
pub fn from_image(path_str: &str) -> Texture {
let mut id = 0u32;
let path = P... | {
use self::image::ColorType::*;
let ty = img.color();
match ty {
Gray(_) => (*img.as_luma8().unwrap()).as_ptr(),
RGB(_) => (*img.as_rgb8().unwrap()).as_ptr(),
GrayA(_) => (*img.as_luma_alpha8().unwrap()).as_ptr(),
RGBA(_) => (*img.as_rgba8().unwrap()).as_ptr(),
_ =>... | identifier_body |
texture.rs | extern crate gl;
extern crate image;
use self::gl::types::*;
use self::image::GenericImage;
use system::filesystem;
use std::path::Path;
use std::os::raw::c_void;
static VALID_IMG_EXT: [&'static str; 5] = [
"png", "jpeg", "jpg", "gif", "bmp" | RG8U,
RGB8U,
RGBA8U
}
impl TextureFmt {
pub fn gl_format(&self) -> GLenum {
match self {
&TextureFmt::R8U => gl::RED,
&TextureFmt::RG8U => gl::RG,
&TextureFmt::RGB8U => gl::RGB,
&TextureFmt::RGBA8U => gl::RGBA,
}
}
pub fn gl_type(... | ];
pub enum TextureFmt {
R8U, | random_line_split |
lexical-scope-in-parameterless-closure.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
let _ = ||();
let _ = range(1u,3).map(|_| 5i);
}
| main | identifier_name |
lexical-scope-in-parameterless-closure.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
let _ = ||();
let _ = range(1u,3).map(|_| 5i);
} | identifier_body | |
extras.rs | use std::fmt;
use std::sync::Arc;
#[cfg(feature = "cache")]
use std::time::Duration;
use super::{EventHandler, RawEventHandler};
use crate::client::bridge::gateway::GatewayIntents;
#[cfg(feature = "framework")]
use crate::framework::Framework;
/// A builder to extra things for altering the [`Client`].
///
/// [`Clien... | #[cfg(feature = "cache")]
ds.field("cache_update_timeout", &self.timeout);
ds.field("intents", &self.intents);
ds.finish()
}
} | let mut ds = f.debug_struct("Extras");
ds.field("event_handler", &EventHandler);
ds.field("raw_event_handler", &RawEventHandler); | random_line_split |
extras.rs | use std::fmt;
use std::sync::Arc;
#[cfg(feature = "cache")]
use std::time::Duration;
use super::{EventHandler, RawEventHandler};
use crate::client::bridge::gateway::GatewayIntents;
#[cfg(feature = "framework")]
use crate::framework::Framework;
/// A builder to extra things for altering the [`Client`].
///
/// [`Clien... | ;
#[derive(Debug)]
struct RawEventHandler;
let mut ds = f.debug_struct("Extras");
ds.field("event_handler", &EventHandler);
ds.field("raw_event_handler", &RawEventHandler);
#[cfg(feature = "cache")]
ds.field("cache_update_timeout", &self.timeout);
ds.fi... | EventHandler | identifier_name |
extras.rs | use std::fmt;
use std::sync::Arc;
#[cfg(feature = "cache")]
use std::time::Duration;
use super::{EventHandler, RawEventHandler};
use crate::client::bridge::gateway::GatewayIntents;
#[cfg(feature = "framework")]
use crate::framework::Framework;
/// A builder to extra things for altering the [`Client`].
///
/// [`Clien... |
/// Set the handler for raw events.
///
/// If you have set the specialised [`Self::event_handler`], all events
/// will be cloned for use to the raw event handler.
pub fn raw_event_handler<H>(&mut self, handler: H) -> &mut Self
where
H: RawEventHandler +'static,
{
self.raw... | {
self.event_handler = Some(Arc::new(handler));
self
} | identifier_body |
point.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 ... | (this: &Point) -> f32 {
#[cfg(cfail1)]
return this.x + this.y;
#[cfg(cfail2)]
return this.x * this.x + this.y * this.y;
}
impl Point {
pub fn distance_from_origin(&self) -> f32 {
distance_squared(self).sqrt()
}
}
impl Point {
pub fn translate(&mut self, x: f32, y: f32) {
s... | distance_squared | identifier_name |
point.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 translate(&mut self, x: f32, y: f32) {
self.x += x;
self.y += y;
} | random_line_split |
err.rs | use std::error::Error;
use std::fmt;
/// The enum `TermiosError` defines the possible errors from constructor Termios.
#[derive(Clone, Copy, Debug)]
pub enum TermiosError {
TcgGet,
TcgSet,
WriteMouseOn,
}
impl fmt::Display for TermiosError {
/// The function `fmt` formats the value using the given fo... |
/// The function `cause` returns the lower-level cause of this error, if any.
fn cause(&self) -> Option<&Error> {
None
}
}
| {
match *self {
TermiosError::TcgGet => "ioctl(2) TCGETS has occured an error.",
TermiosError::TcgSet => "ioctl(2) TCSETS has occured an error.",
TermiosError::WriteMouseOn => "Can't write the MouseOn term.",
}
} | identifier_body |
err.rs | use std::error::Error;
use std::fmt;
/// The enum `TermiosError` defines the possible errors from constructor Termios.
#[derive(Clone, Copy, Debug)]
pub enum TermiosError {
TcgGet,
TcgSet,
WriteMouseOn,
}
impl fmt::Display for TermiosError {
/// The function `fmt` formats the value using the given fo... |
/// The function `description` returns a short description of the error.
fn description(&self) -> &str {
match *self {
TermiosError::TcgGet => "ioctl(2) TCGETS has occured an error.",
TermiosError::TcgSet => "ioctl(2) TCSETS has occured an error.",
TermiosError::Writ... | random_line_split | |
err.rs | use std::error::Error;
use std::fmt;
/// The enum `TermiosError` defines the possible errors from constructor Termios.
#[derive(Clone, Copy, Debug)]
pub enum | {
TcgGet,
TcgSet,
WriteMouseOn,
}
impl fmt::Display for TermiosError {
/// The function `fmt` formats the value using the given formatter.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", ::errno::errno())
}
}
impl Error for TermiosError {
/// The function `des... | TermiosError | identifier_name |
mod.rs | #![recursion_limit = "128"]
#![no_std]
#[macro_use]
extern crate generic_array;
use core::cell::Cell;
use core::ops::{Add, Drop};
use generic_array::functional::*;
use generic_array::sequence::*;
use generic_array::typenum::{U0, U3, U4, U97};
use generic_array::GenericArray;
#[test]
fn test() {
let mut list97 = [0... | gen_arr[2] = 10;
}
assert_eq!(arr, [1, 2, 10, 4]);
let mut arr = [NoClone(1u32), NoClone(2), NoClone(3), NoClone(4)];
{
let gen_arr = GenericArray::<_, U3>::from_mut_slice(&mut arr[..3]);
gen_arr[2] = NoClone(10);
}
assert_eq!(arr, [NoClone(1), NoClone(2), NoClone(10), No... | random_line_split | |
mod.rs | #![recursion_limit = "128"]
#![no_std]
#[macro_use]
extern crate generic_array;
use core::cell::Cell;
use core::ops::{Add, Drop};
use generic_array::functional::*;
use generic_array::sequence::*;
use generic_array::typenum::{U0, U3, U4, U97};
use generic_array::GenericArray;
#[test]
fn test() {
let mut list97 = [0... | {
t: u16,
s: u32,
mm: bool,
r: u16,
f: u16,
p: (),
o: u32,
ff: *const extern "C" fn(*const char) -> *const core::ffi::c_void,
l: *const core::ffi::c_void,
w: bool,
q: bool,
v: E,
}
#[test]
fn test_sizes() {
use core::mem::{size_of, size_of_val};
assert_eq!(size... | Test | identifier_name |
mod.rs | // Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later ... | plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register(
Some(plugin),
"togglerecord",
gst::Rank::None,
ToggleRecord::static_type(),
)
}
| egister( | identifier_name |
mod.rs | // Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later ... | gst::Rank::None,
ToggleRecord::static_type(),
)
} | random_line_split | |
mod.rs | // Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later ... |
gst::Element::register(
Some(plugin),
"togglerecord",
gst::Rank::None,
ToggleRecord::static_type(),
)
}
| identifier_body | |
font.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="font" sub_properties="font-style ... |
if size.is_none() || (count(&style) + count(&weight) + count(&variant) + count(&stretch) + nb_normals) > 4 {
return Err(())
}
let line_height = if input.try(|input| input.expect_delim('/')).is_ok() {
Some(try!(line_height::parse(context, input)))
} else {
... | {
if opt.is_some() { 1 } else { 0 }
} | identifier_body |
font.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="font" sub_properties="font-style ... | // Leaves the values to None, 'normal' is the initial value for each of them.
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
nb_normals += 1;
continue;
}
if style.is_none() {
if let Ok(value) = input.t... | let size;
loop {
// Special-case 'normal' because it is valid in each of
// font-style, font-weight, font-variant and font-stretch. | random_line_split |
font.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="font" sub_properties="font-style ... |
if weight.is_none() {
if let Ok(value) = input.try(|input| font_weight::parse(context, input)) {
weight = Some(value);
continue
}
}
if variant.is_none() {
if let Ok(value) = input.try(|input| fon... | {
if let Ok(value) = input.try(|input| font_style::parse(context, input)) {
style = Some(value);
continue
}
} | conditional_block |
font.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<%helpers:shorthand name="font" sub_properties="font-style ... | <W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
if let DeclaredValue::Value(ref style) = *self.font_style {
try!(style.to_css(dest));
try!(write!(dest, " "));
}
if let DeclaredValue::Value(ref variant) = *self.font_variant {
... | to_css_declared | identifier_name |
sr_log.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later ver... | use std::thread;
use std::sync::mpsc::{channel, Sender, Receiver};
use std::io::{stderr, Write};
use std::fs::{create_dir_all, File};
use std::path::Path;
pub fn init(dir: String) -> (Sender<String>, thread::JoinHandle<()>) {
let tm = time::now();
let log_dir = dir + "/slave/log/" + &tm_cat(tm);
let _ = c... | random_line_split | |
sr_log.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later ver... |
};
size = 0;
}
}
}
}
| {
let _ = writeln!(&mut stderr(),
"Error:\nCan not create {}:\n{}",
fname, e);
unsafe { libc::exit(4); }
} | conditional_block |
sr_log.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later ver... | (dir: String) -> (Sender<String>, thread::JoinHandle<()>) {
let tm = time::now();
let log_dir = dir + "/slave/log/" + &tm_cat(tm);
let _ = create_dir_all(Path::new(&log_dir));
let (tx, rx) = channel();
let jh = thread::Builder::new().name("log".to_string()).spawn(|| {
log_task(log_dir, rx);... | init | identifier_name |
sr_log.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later ver... |
fn tm_format(tm: time::Tm) -> String {
format!("{}-{}-{} {}:{}:{}",
1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec)
}
fn log_task(log_dir: String, rx: Receiver<String>) {
let mut tm = time::now();
let mut fname = log_dir.to_string() + "/" + &tm_cat(... | {
format!("{}-{}-{}_{}-{}-{}",
1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec)
} | identifier_body |
htmlstyleelement.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::HTMLStyleElementBinding;
use dom::bindings::codegen::Bindings::NodeBinding::... | s.bind_to_tree(tree_in_doc);
}
if tree_in_doc {
self.parse_own_css();
}
}
} | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.